ia64/xen-unstable

changeset 18087:34a84a5306f7

[IA64] kexec: Repining for EFI RID

A cut down version of set_one_rr (and ia64_new_rr7) for
use when switching to the EFI RID for SAL, PAL and EFI calls.

There seems to be no need to repin: palcode, mapped_regs or vhpt in this
case. If it turns they do need to be repinned then special care needs to
betaken to track the correct value to repin. That is generally the values
that were most recently pinned by ia64_new_rr7.

ia64_new_rr7_efi can probably be merged with ia64_new_rr7,
as they are quite similar, but for testing purposes it seems
easier to keep them separate.

Cc: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: Alex Williamson <alex.williamson@hp.com>
Cc: Aron Griffis <aron@hp.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Tue Jul 22 12:15:02 2008 +0900 (2008-07-22)
parents 246a179ebb6d
children 91332bc4abd4
files xen/arch/ia64/xen/mm_init.c xen/arch/ia64/xen/regionreg.c xen/arch/ia64/xen/xenasm.S xen/include/asm-ia64/regionreg.h
line diff
     1.1 --- a/xen/arch/ia64/xen/mm_init.c	Tue Jul 22 12:15:02 2008 +0900
     1.2 +++ b/xen/arch/ia64/xen/mm_init.c	Tue Jul 22 12:15:02 2008 +0900
     1.3 @@ -18,12 +18,16 @@ struct ia64_mca_tlb_info ia64_mca_tlb_li
     1.4  
     1.5  extern void ia64_tlb_init (void);
     1.6  
     1.7 +#ifdef XEN
     1.8 +cpumask_t percpu_set;
     1.9 +#endif
    1.10 +
    1.11  void __devinit
    1.12  ia64_mmu_init (void *my_cpu_data)
    1.13  {
    1.14  	unsigned long psr, impl_va_bits;
    1.15  	extern void __devinit tlb_init (void);
    1.16 -	int cpu;
    1.17 +	int cpu = smp_processor_id();
    1.18  
    1.19  	/* Pin mapping for percpu area into TLB */
    1.20  	psr = ia64_clear_ic();
    1.21 @@ -33,6 +37,9 @@ ia64_mmu_init (void *my_cpu_data)
    1.22  
    1.23  	ia64_set_psr(psr);
    1.24  	ia64_srlz_i();
    1.25 +#ifdef XEN
    1.26 +	cpu_set(cpu, percpu_set);
    1.27 +#endif
    1.28  
    1.29  	/*
    1.30  	 * Check if the virtually mapped linear page table (VMLPT) overlaps with a mapped
    1.31 @@ -72,8 +79,6 @@ ia64_mmu_init (void *my_cpu_data)
    1.32  	ia64_srlz_d();
    1.33  #endif
    1.34  
    1.35 -	cpu = smp_processor_id();
    1.36 -
    1.37  	/* mca handler uses cr.lid as key to pick the right entry */
    1.38  	ia64_mca_tlb_list[cpu].cr_lid = ia64_getreg(_IA64_REG_CR_LID);
    1.39  
     2.1 --- a/xen/arch/ia64/xen/regionreg.c	Tue Jul 22 12:15:02 2008 +0900
     2.2 +++ b/xen/arch/ia64/xen/regionreg.c	Tue Jul 22 12:15:02 2008 +0900
     2.3 @@ -11,6 +11,7 @@
     2.4  #include <linux/config.h>
     2.5  #include <linux/types.h>
     2.6  #include <linux/sched.h>
     2.7 +#include <linux/percpu.h>
     2.8  #include <asm/page.h>
     2.9  #include <asm/regionreg.h>
    2.10  #include <asm/vhpt.h>
    2.11 @@ -20,6 +21,8 @@
    2.12  
    2.13  /* Defined in xemasm.S  */
    2.14  extern void ia64_new_rr7(unsigned long rid, void *shared_info, void *shared_arch_info, unsigned long shared_info_va, unsigned long va_vhpt);
    2.15 +extern void ia64_new_rr7_efi(unsigned long rid, unsigned long repin_percpu,
    2.16 +			     unsigned long vpd);
    2.17  
    2.18  /* RID virtualization mechanism is really simple:  domains have less rid bits
    2.19     than the host and the host rid space is shared among the domains.  (Values
    2.20 @@ -284,6 +287,27 @@ int set_one_rr(unsigned long rr, unsigne
    2.21  	return 1;
    2.22  }
    2.23  
    2.24 +int set_one_rr_efi(unsigned long rr, unsigned long val)
    2.25 +{
    2.26 +	unsigned long rreg = REGION_NUMBER(rr);
    2.27 +	unsigned long vpd = 0UL;
    2.28 +
    2.29 +	BUG_ON(rreg != 6 && rreg != 7);
    2.30 +
    2.31 +	if (rreg == 6) {
    2.32 +		ia64_set_rr(rr, val);
    2.33 +		ia64_srlz_d();
    2.34 +	}
    2.35 +	else {
    2.36 +		if (current && VMX_DOMAIN(current))
    2.37 +			vpd = __get_cpu_var(inserted_vpd);
    2.38 +		ia64_new_rr7_efi(val, cpu_isset(smp_processor_id(),
    2.39 +				 percpu_set), vpd);
    2.40 +	}
    2.41 +
    2.42 +	return 1;
    2.43 +}
    2.44 +
    2.45  void set_virtual_rr0(void)
    2.46  {
    2.47  	struct vcpu *v = current;
     3.1 --- a/xen/arch/ia64/xen/xenasm.S	Tue Jul 22 12:15:02 2008 +0900
     3.2 +++ b/xen/arch/ia64/xen/xenasm.S	Tue Jul 22 12:15:02 2008 +0900
     3.3 @@ -195,6 +195,187 @@ 1:
     3.4  	br.ret.sptk.many rp
     3.5  END(ia64_new_rr7)
     3.6  
     3.7 +
     3.8 + /* ia64_new_rr7_efi:
     3.9 +  *   in0 = rid
    3.10 +  *   in1 = repin_percpu
    3.11 +  *   in2 = VPD vaddr
    3.12 +  *
    3.13 +  * There seems to be no need to repin: palcode, mapped_regs
    3.14 +  * or vhpt. If they do need to be repinned then special care
    3.15 +  * needs to betaken to track the correct value to repin.
    3.16 +  * That is generally the values that were most recently pinned by
    3.17 +  * ia64_new_rr7.
    3.18 +  *
    3.19 +  * This code function could probably be merged with ia64_new_rr7
    3.20 +  * as it is just a trimmed down version of that function.
    3.21 +  * However, current can change without repinning occuring,
    3.22 +  * so simply getting the values from current does not work correctly.
    3.23 +  */
    3.24 +
    3.25 +GLOBAL_ENTRY(ia64_new_rr7_efi)
    3.26 +	// FIXME? not sure this unwind statement is correct...
    3.27 +	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(1)
    3.28 +	alloc loc1 = ar.pfs, 3, 8, 0, 0
    3.29 +	movl loc2=PERCPU_ADDR
    3.30 +1:	{
    3.31 +	  mov loc3 = psr		// save psr
    3.32 +	  mov loc0 = rp			// save rp
    3.33 +	  mov r8   = ip			// save ip to compute branch
    3.34 +	};;
    3.35 +	.body
    3.36 +	tpa loc2=loc2			// grab this BEFORE changing rr7
    3.37 +	adds r8 = 1f-1b,r8		// calculate return address for call
    3.38 +	;;
    3.39 +	movl r17=PSR_BITS_TO_SET
    3.40 +	mov loc4=ar.rsc			// save RSE configuration
    3.41 +	movl r16=PSR_BITS_TO_CLEAR
    3.42 +	;;
    3.43 +	tpa r8=r8			// convert rp to physical
    3.44 +	mov ar.rsc=0			// put RSE in enforced lazy, LE mode
    3.45 +	or loc3=loc3,r17		// add in psr the bits to set
    3.46 +	;;
    3.47 +        movl loc5=pal_vaddr             // get pal_vaddr
    3.48 +	;;
    3.49 +	ld8 loc5=[loc5]                 // read pal_vaddr
    3.50 +	;;
    3.51 +	dep loc7 = 0,in2,60,4		// get physical address of VPD
    3.52 +	;;
    3.53 +	dep loc7 = 0,loc7,0,IA64_GRANULE_SHIFT
    3.54 +					// mask granule shift
    3.55 +	;;
    3.56 +	andcm r16=loc3,r16		// removes bits to clear from psr
    3.57 +	dep loc6=0,r8,0,KERNEL_TR_PAGE_SHIFT // Xen code paddr
    3.58 +	br.call.sptk.many rp=ia64_switch_mode_phys
    3.59 +1:
    3.60 +	movl	r26=PAGE_KERNEL
    3.61 +	// now in physical mode with psr.i/ic off so do rr7 switch
    3.62 +	dep r16=-1,r0,61,3
    3.63 +	;;
    3.64 +	mov	rr[r16]=in0
    3.65 +	;;
    3.66 +	srlz.d
    3.67 +
    3.68 +	// re-pin mappings for kernel text and data
    3.69 +	mov r24=KERNEL_TR_PAGE_SHIFT<<2
    3.70 +	movl r17=KERNEL_START
    3.71 +	;;
    3.72 +	ptr.i	r17,r24
    3.73 +	;;
    3.74 +	ptr.d	r17,r24
    3.75 +	;;
    3.76 +	srlz.i
    3.77 +	;;
    3.78 +	srlz.d
    3.79 +	;;
    3.80 +	mov r16=IA64_TR_KERNEL
    3.81 +	mov cr.itir=r24
    3.82 +	mov cr.ifa=r17
    3.83 +	or r18=loc6,r26
    3.84 +	;;
    3.85 +	itr.i itr[r16]=r18
    3.86 +	;;
    3.87 +	itr.d dtr[r16]=r18
    3.88 +	;;
    3.89 +	srlz.i
    3.90 +	;;
    3.91 +	srlz.d
    3.92 +	;;
    3.93 +
    3.94 +	// re-pin mappings for stack (current)
    3.95 +	mov r25=IA64_GRANULE_SHIFT<<2
    3.96 +	dep r21=0,r13,60,4		// physical address of "current"
    3.97 +	;;
    3.98 +	ptr.d	r13,r25
    3.99 +	;;
   3.100 +	srlz.d
   3.101 +	;;
   3.102 +	or r23=r21,r26			// construct PA | page properties
   3.103 +	mov cr.itir=r25
   3.104 +	mov cr.ifa=r13			// VA of next task...
   3.105 +	mov r21=IA64_TR_CURRENT_STACK
   3.106 +	;;
   3.107 +	itr.d dtr[r21]=r23		// wire in new mapping...
   3.108 +	;;
   3.109 +	srlz.d
   3.110 +	;;
   3.111 +
   3.112 +	//  Per-cpu
   3.113 +	cmp.eq p7,p0=r0,in1
   3.114 +(p7)	br.cond.sptk ia64_new_rr7_efi_percpu_not_mapped
   3.115 +	mov r24=PERCPU_PAGE_SHIFT<<2
   3.116 +	movl r22=PERCPU_ADDR
   3.117 +	;;
   3.118 +	ptr.d	r22,r24
   3.119 +	;;
   3.120 +	srlz.d
   3.121 +	;;
   3.122 +	or r23=loc2,r26
   3.123 +	mov cr.itir=r24
   3.124 +	mov cr.ifa=r22
   3.125 +	mov r25=IA64_TR_PERCPU_DATA
   3.126 +	;;
   3.127 +	itr.d dtr[r25]=r23		// wire in new mapping...
   3.128 +	;;
   3.129 +	srlz.d
   3.130 +	;;
   3.131 +ia64_new_rr7_efi_percpu_not_mapped:
   3.132 +
   3.133 +	// VPD
   3.134 +	cmp.eq p7,p0=r0,in2
   3.135 +(p7)	br.cond.sptk ia64_new_rr7_efi_vpd_not_mapped
   3.136 +	or loc7 = r26,loc7		// construct PA | page properties
   3.137 +	mov r22=IA64_TR_VPD
   3.138 +	mov r24=IA64_TR_MAPPED_REGS
   3.139 +	mov r23=IA64_GRANULE_SHIFT<<2
   3.140 +	;;
   3.141 +	ptr.i   in2,r23
   3.142 +	;;
   3.143 +	ptr.d	in2,r24
   3.144 +	;;
   3.145 +	srlz.i
   3.146 +	;;
   3.147 +	srlz.d
   3.148 +	;;
   3.149 +	mov cr.itir=r23
   3.150 +	mov cr.ifa=in2
   3.151 +	;;
   3.152 +	itr.i itr[r22]=loc7
   3.153 +	;;
   3.154 +	itr.d dtr[r24]=loc7
   3.155 +	;;
   3.156 +	srlz.i
   3.157 +	;;
   3.158 +	srlz.d
   3.159 +	;;
   3.160 +ia64_new_rr7_efi_vpd_not_mapped:
   3.161 +
   3.162 +	// Purge/insert PAL TR
   3.163 +	mov r24=IA64_TR_PALCODE
   3.164 +	mov r23=IA64_GRANULE_SHIFT<<2
   3.165 +	dep r25=0,loc5,60,4		// convert pal vaddr to paddr
   3.166 +	;;
   3.167 +	ptr.i	loc5,r23
   3.168 +	or r25=r25,r26			// construct PA | page properties
   3.169 +	mov cr.itir=r23
   3.170 +	mov cr.ifa=loc5
   3.171 +	;;
   3.172 +	itr.i itr[r24]=r25
   3.173 +
   3.174 +	// done, switch back to virtual and return
   3.175 +	mov r16=loc3			// r16= original psr
   3.176 +	br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
   3.177 +	mov psr.l = loc3		// restore init PSR
   3.178 +	;;
   3.179 +
   3.180 +	mov ar.pfs = loc1
   3.181 +	mov rp = loc0
   3.182 +	;;
   3.183 +	mov ar.rsc=loc4			// restore RSE configuration
   3.184 +	srlz.d				// seralize restoration of psr.l
   3.185 +	br.ret.sptk.many rp
   3.186 +END(ia64_new_rr7_efi)
   3.187 +
   3.188  #if 0 /* Not used */
   3.189  #include "minstate.h"
   3.190  
     4.1 --- a/xen/include/asm-ia64/regionreg.h	Tue Jul 22 12:15:02 2008 +0900
     4.2 +++ b/xen/include/asm-ia64/regionreg.h	Tue Jul 22 12:15:02 2008 +0900
     4.3 @@ -41,7 +41,10 @@ DECLARE_PER_CPU(unsigned long, inserted_
     4.4  DECLARE_PER_CPU(unsigned long, inserted_mapped_regs);
     4.5  DECLARE_PER_CPU(unsigned long, inserted_vpd);
     4.6  
     4.7 +extern cpumask_t percpu_set;
     4.8 +
     4.9  int set_one_rr(unsigned long rr, unsigned long val);
    4.10 +int set_one_rr_efi(unsigned long rr, unsigned long val);
    4.11  
    4.12  // This function is purely for performance... apparently scrambling
    4.13  //  bits in the region id makes for better hashing, which means better