ia64/linux-2.6.18-xen.hg

changeset 444:ee7015727bd1

[IA64] kexec: Unpin TLB in the hypervisor

In the case where kexec is being run for a xen dom0 or hypervisor,
this code, present in dom0, will be called from the hypervisor
after ia64_machine_kexec and before going into purgatory.

This code makes a large number of assumptions about various compile
time constants, and thus assumes that these constants are the
same for the hypervisor and dom0. Despite extensive #ifdef work this
has proved to be both fragile and incomplete.

This patch changes things around so that the unpinning work is done
by code provided by the hypervisor, reusing existing code there.
Apart from being a solution that works, its also likely
a much more maintainable solution, as as TLB changes in the hypervisor
code are made, the code paths in the hypervisor are much more likely
to be checked than this one which lies in a completely different tree.

With this change, and the corresponding change to the hypervisor,
the CPU will be running in "physical mode" when it enters this
relocate_new_kernel code. Previously the code was called with the
CPU in "virtual mode". This is still the case when the code is
called from a regular Linux kernel.

Code that switches the CPU into "physical mode" is still called.
This is primarily left in tact to ensure that the register stack
(bspstore) and stack (sp) are updated correctly. It could probably
be trimmed down a bit, but there seems little point.

When called from the hypervisor, in3 is ignored. The number
of parameters could hence be shrunk from 4 to 3, but again,
there seems little point.

This code still assumes that PAGE_SIZE and PAGE_MASK are the
same in the hypervisor and dom0. I am reluctant to fix this
as I think that it is unlikely this will change. But if it does,
the fix should be as easy as passing PAGE_SIZE as in3. I am quite
happy to create a patch if/when it is needed.

As noted above, there is a hypervisor portion of this patch
supplied separately.

Signed-off-by: Simon Horman <horms@verge.net.au>
author Alex Williamson <alex.williamson@hp.com>
date Fri Feb 29 09:14:21 2008 -0700 (2008-02-29)
parents 423662c82283
children 68e78169679e
files arch/ia64/kernel/relocate_kernel.S
line diff
     1.1 --- a/arch/ia64/kernel/relocate_kernel.S	Fri Feb 29 09:06:15 2008 -0700
     1.2 +++ b/arch/ia64/kernel/relocate_kernel.S	Fri Feb 29 09:14:21 2008 -0700
     1.3 @@ -20,11 +20,7 @@
     1.4          */
     1.5  GLOBAL_ENTRY(relocate_new_kernel)
     1.6  	.prologue
     1.7 -#ifdef CONFIG_XEN
     1.8 -	alloc r31=ar.pfs,8,0,0,0
     1.9 -#else
    1.10  	alloc r31=ar.pfs,4,0,0,0
    1.11 -#endif
    1.12          .body
    1.13  .reloc_entry:
    1.14  {
    1.15 @@ -37,11 +33,7 @@ GLOBAL_ENTRY(relocate_new_kernel)
    1.16          srlz.i
    1.17  }
    1.18  	;;
    1.19 -#ifdef CONFIG_XEN
    1.20 -	dep r2=0,r2,60,4		//to physical address
    1.21 -#else
    1.22  	dep r2=0,r2,61,3		//to physical address
    1.23 -#endif
    1.24  	;;
    1.25  	//first switch to physical mode
    1.26  	add r3=1f-.reloc_entry, r2
    1.27 @@ -66,18 +58,13 @@ 1:
    1.28  	//physical mode code begin
    1.29  	mov b6=in1
    1.30  #ifdef CONFIG_XEN
    1.31 -	dep r28=0,in2,60,4	//to physical address
    1.32 +	mov r28=in2		//already a physical address
    1.33  #else
    1.34  	dep r28=0,in2,61,3	//to physical address
    1.35 -#endif
    1.36  
    1.37  	// purge all TC entries
    1.38  #define O(member)       IA64_CPUINFO_##member##_OFFSET
    1.39 -#ifdef CONFIG_XEN
    1.40 -	mov r2=in4			// load phys addr of cpu_info into r2
    1.41 -#else
    1.42          GET_THIS_PADDR(r2, cpu_info)    // load phys addr of cpu_info into r2
    1.43 -#endif
    1.44          ;;
    1.45          addl r17=O(PTCE_STRIDE),r2
    1.46          addl r2=O(PTCE_BASE),r2
    1.47 @@ -111,11 +98,7 @@ 4:
    1.48          srlz.i
    1.49          ;;
    1.50  	//purge TR entry for kernel text and data
    1.51 -#ifdef CONFIG_XEN
    1.52 -	mov r16=in5
    1.53 -#else
    1.54          movl r16=KERNEL_START
    1.55 -#endif
    1.56          mov r18=KERNEL_TR_PAGE_SHIFT<<2
    1.57          ;;
    1.58          ptr.i r16, r18
    1.59 @@ -146,11 +129,7 @@ 4:
    1.60          mov r16=IA64_KR(CURRENT_STACK)
    1.61          ;;
    1.62          shl r16=r16,IA64_GRANULE_SHIFT
    1.63 -#ifdef CONFIG_XEN
    1.64 -	mov r19=in6
    1.65 -#else
    1.66          movl r19=PAGE_OFFSET
    1.67 -#endif
    1.68          ;;
    1.69          add r16=r19,r16
    1.70          mov r18=IA64_GRANULE_SHIFT<<2
    1.71 @@ -159,20 +138,7 @@ 4:
    1.72          ;;
    1.73          srlz.i
    1.74  	;;
    1.75 -
    1.76 -#ifdef XEN
    1.77 -	/* XXX: Is this neccessary ??? */
    1.78 -	// purge TR entry for VHPT
    1.79 -	mov r16=in7
    1.80 -	;;
    1.81 -	dep r16=0,r16,0,IA64_GRANULE_SHIFT
    1.82 -	mov r18=IA64_GRANULE_SHIFT<<2
    1.83 -        ;;
    1.84 -        ptr.d r16,r18
    1.85 -        ;;
    1.86 -        srlz.i
    1.87 -	;;
    1.88 -#endif
    1.89 +#endif /* ! CONFIG_XEN */
    1.90  
    1.91  	//copy segments
    1.92  	movl r16=PAGE_MASK