ia64/xen-unstable

changeset 6865:0e548ff36960

Re-enable improved PAL code (time and perfmon work again). PAL code remapped
_lazily_ only when PAL called after rr7 changes. Old PAL emulator can
be re-enabled with #define USE_PAL_EMULATOR in config.h.
Signed-off by: Dan Magenheimer <dan.magenheimer@hp.com>
author djm@kirby.fc.hp.com
date Sun Sep 18 10:30:57 2005 -0600 (2005-09-18)
parents aecdccb1a350
children 8d133d172bfd
files xen/arch/ia64/linux-xen/efi.c xen/arch/ia64/xen/dom_fw.c xen/include/asm-ia64/config.h
line diff
     1.1 --- a/xen/arch/ia64/linux-xen/efi.c	Fri Sep 16 16:54:53 2005 -0600
     1.2 +++ b/xen/arch/ia64/linux-xen/efi.c	Sun Sep 18 10:30:57 2005 -0600
     1.3 @@ -525,7 +525,7 @@ efi_get_pal_addr (void)
     1.4  
     1.5  
     1.6  #ifdef XEN
     1.7 -void *pal_vaddr;
     1.8 +void *pal_vaddr = 0;
     1.9  #endif
    1.10  
    1.11  void
    1.12 @@ -533,14 +533,39 @@ efi_map_pal_code (void)
    1.13  {
    1.14  #ifdef XEN
    1.15  	u64 psr;
    1.16 -	pal_vaddr = efi_get_pal_addr ();
    1.17 +	static unsigned long last_rr7 = 0;
    1.18 +	unsigned long current_rr7 = ia64_get_rr(7L<<61);
    1.19 +
    1.20 +	// this routine is called only once in Linux but may be called
    1.21 +	// multiple times in Xen.  However, we only need to flush and
    1.22 +	// reset itr[IA64_TR_PALCODE] if rr7 changes
    1.23 +	if (!pal_vaddr) {
    1.24 +		pal_vaddr = efi_get_pal_addr ();
    1.25 +		last_rr7 = current_rr7;
    1.26 +	}
    1.27 +	else if (last_rr7 == current_rr7) return;
    1.28 +	else {
    1.29 +		last_rr7 = current_rr7;
    1.30 +		printk("efi_map_pal_code,remapping pal w/rr7=%lx\n",last_rr7);
    1.31 +	}
    1.32 +
    1.33 +	printf("efi_map_pal_code: about to ia64_ptr(%d,%p,%p)\n",
    1.34 +		0x1, GRANULEROUNDDOWN((unsigned long) pal_vaddr),
    1.35 +		 IA64_GRANULE_SHIFT);
    1.36 +	ia64_ptr(0x1, GRANULEROUNDDOWN((unsigned long) pal_vaddr),
    1.37 +		 IA64_GRANULE_SHIFT);
    1.38 +	ia64_srlz_i();
    1.39 +	printf("efi_map_pal_code: about to ia64_itr(%p,%p,%p,%p,%p)\n",
    1.40 +		0x1, IA64_TR_PALCODE, GRANULEROUNDDOWN((unsigned long) pal_vaddr),
    1.41 +		 pte_val(pfn_pte(__pa(pal_vaddr) >> PAGE_SHIFT, PAGE_KERNEL)),
    1.42 +		 IA64_GRANULE_SHIFT);
    1.43  #else
    1.44  	void *pal_vaddr = efi_get_pal_addr ();
    1.45  	u64 psr;
    1.46 -#endif
    1.47  
    1.48  	if (!pal_vaddr)
    1.49  		return;
    1.50 +#endif
    1.51  
    1.52  	/*
    1.53  	 * Cannot write to CRx with PSR.ic=1
     2.1 --- a/xen/arch/ia64/xen/dom_fw.c	Fri Sep 16 16:54:53 2005 -0600
     2.2 +++ b/xen/arch/ia64/xen/dom_fw.c	Sun Sep 18 10:30:57 2005 -0600
     2.3 @@ -291,16 +291,18 @@ xen_pal_emulator(unsigned long index, un
     2.4  	long r11 = 0;
     2.5  	long status = -1;
     2.6  
     2.7 -#define USE_PAL_EMULATOR
     2.8 -#ifdef USE_PAL_EMULATOR
     2.9 -	return pal_emulator_static(index);
    2.10 -#endif
    2.11  	if (running_on_sim) return pal_emulator_static(index);
    2.12  	if (index >= PAL_COPY_PAL) {
    2.13 -		printk("xen_pal_emulator: UNIMPLEMENTED PAL CALL %d!!!!\n",
    2.14 -				index);
    2.15 +		// build_hypercall_bundle needs to be modified to generate
    2.16 +		// a second bundle that conditionally does a br.ret
    2.17 +		panic("xen_pal_emulator: stacked calls not supported!!\n");
    2.18  	}
    2.19 -	else switch (index) {
    2.20 +	printk("xen_pal_emulator: index=%d\n",index);
    2.21 +	// pal code must be mapped by a TR when pal is called, however
    2.22 +	// calls are rare enough that we will map it lazily rather than
    2.23 +	// at every context switch
    2.24 +	efi_map_pal_code();
    2.25 +	switch (index) {
    2.26  	    case PAL_MEM_ATTRIB:
    2.27  		status = ia64_pal_mem_attrib(&r9);
    2.28  		break;
    2.29 @@ -514,11 +516,12 @@ dom_fw_init (struct domain *d, char *arg
    2.30  */
    2.31  	memset(fw_mem, 0, fw_mem_size);
    2.32  
    2.33 -#ifdef XEN
    2.34 -#else
    2.35 +#ifdef USE_PAL_EMULATOR
    2.36  	pal_desc = (unsigned long *) &pal_emulator_static;
    2.37 +#else
    2.38 +	pal_desc = (unsigned long *) &xen_pal_emulator;
    2.39 +#endif
    2.40  	sal_desc = (unsigned long *) &sal_emulator;
    2.41 -#endif
    2.42  
    2.43  	cp = fw_mem;
    2.44  	efi_systab  = (void *) cp; cp += sizeof(*efi_systab);
     3.1 --- a/xen/include/asm-ia64/config.h	Fri Sep 16 16:54:53 2005 -0600
     3.2 +++ b/xen/include/asm-ia64/config.h	Sun Sep 18 10:30:57 2005 -0600
     3.3 @@ -1,6 +1,7 @@
     3.4  #ifndef	_IA64_CONFIG_H_
     3.5  #define _IA64_CONFIG_H_
     3.6  
     3.7 +#undef USE_PAL_EMULATOR
     3.8  // control flags for turning on/off features under test
     3.9  #undef CLONE_DOMAIN0
    3.10  //#define CLONE_DOMAIN0 1