ia64/xen-unstable

changeset 16768:fb47d7f0d84b

[IA64] Fix ia64_switch_to() so that it checks overlap with xenheap.

- Remove unncessary movl if possible
- Fix overlapping check
- re-add #ifdef XEN.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Thu Jan 17 12:05:43 2008 -0700 (2008-01-17)
parents ed7d55e8cd34
children d4abdf169a00
files xen/arch/ia64/linux-xen/entry.S
line diff
     1.1 --- a/xen/arch/ia64/linux-xen/entry.S	Thu Jan 17 12:05:43 2008 -0700
     1.2 +++ b/xen/arch/ia64/linux-xen/entry.S	Thu Jan 17 12:05:43 2008 -0700
     1.3 @@ -195,8 +195,8 @@ GLOBAL_ENTRY(ia64_switch_to)
     1.4  
     1.5  	adds r22=IA64_TASK_THREAD_KSP_OFFSET,r13
     1.6  #ifdef XEN
     1.7 -	movl r27=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_STACK_OFFSET;;
     1.8 -	ld8 r27=[r27]
     1.9 +	movl r24=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_STACK_OFFSET;;
    1.10 +	ld8 r27=[r24]
    1.11  	adds r21=IA64_TASK_THREAD_KSP_OFFSET,in0
    1.12  	dep r20=0,in0,60,4		// physical address of "next"
    1.13  #else
    1.14 @@ -231,12 +231,9 @@ GLOBAL_ENTRY(ia64_switch_to)
    1.15  (p6)	srlz.d
    1.16  	ld8 sp=[r21]			// load kernel stack pointer of new task
    1.17  #ifdef XEN
    1.18 -	movl r8=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
    1.19 -	st8 [r8]=in0
    1.20 -#else
    1.21 -	mov IA64_KR(CURRENT)=in0	// update "current" application register
    1.22 -#endif
    1.23 -#ifdef XEN          //for VTI domain current is save to 21 of bank0
    1.24 +	add r25=IA64_KR_CURRENT_OFFSET-IA64_KR_CURRENT_STACK_OFFSET,r24
    1.25 +	;;
    1.26 +	st8 [r25]=in0			// update "current" application register
    1.27  	;;
    1.28  	bsw.0
    1.29  	;;
    1.30 @@ -247,6 +244,7 @@ GLOBAL_ENTRY(ia64_switch_to)
    1.31  	bsw.1
    1.32  	;;
    1.33  #else
    1.34 +	mov IA64_KR(CURRENT)=in0	// update "current" application register
    1.35  	mov r8=r13          // return pointer to previously running task
    1.36  	mov r13=in0         // set "current" pointer
    1.37  #endif
    1.38 @@ -259,33 +257,55 @@ GLOBAL_ENTRY(ia64_switch_to)
    1.39  
    1.40  .map:
    1.41  #ifdef XEN
    1.42 -	// avoid overlapping with kernel TR
    1.43 -	movl r25=KERNEL_START
    1.44 -	dep  r23=0,in0,0,KERNEL_TR_PAGE_SHIFT
    1.45 +	// in0:	next in virtual address which must be in 
    1.46 +	//      the xen identity mapping area.
    1.47 +	// r20:	physical address of next
    1.48 +	// r22:	ksp offset: used: don't overwrite. will be used later
    1.49 +	// r24:	= THIS_CPU(cpu_kr)+IA64_KR_CURRENT_STACK_OFFSET
    1.50 +	// r26:	(physical address of next) >> IA64_GRANULE_SHIFT
    1.51 +	//
    1.52 +	// r8: return value
    1.53 +	// r13:	 thread pointer
    1.54 +	// r21:	 thread pointer for VTi domain ??? can be removed?
    1.55 +	
    1.56 +	// avoid overlapping with xenheap TR
    1.57 +	mov r28=ip			// get kernel tr area
    1.58  	;;
    1.59 -	cmp.eq p7,p0=r25,r23
    1.60 +	tpa r27=r28			// convert to physical address
    1.61  	;;
    1.62 -(p7)	movl r8=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_STACK_OFFSET;;
    1.63 -(p7)	st8 [r8]=r26
    1.64 +	dep r25=0,r27,0,KERNEL_TR_PAGE_SHIFT
    1.65 +	dep r23=0,r20,0,KERNEL_TR_PAGE_SHIFT
    1.66 +	;;
    1.67 +	cmp.eq p7,p6=r25,r23
    1.68 +	mov r28=-1
    1.69 +	;;
    1.70 +(p7)	st8 [r24]=r28			// remember we don't map stack.
    1.71  (p7)	br.cond.sptk .done
    1.72 +	;;
    1.73  #endif
    1.74  	rsm psr.ic			// interrupts (psr.i) are already disabled here
    1.75  	movl r25=PAGE_KERNEL
    1.76 -	movl r26 = IA64_GRANULE_SHIFT << 2
    1.77 +#ifdef XEN	
    1.78 +	movl r27=IA64_GRANULE_SHIFT << 2
    1.79 +#endif
    1.80  	;;
    1.81  	srlz.d
    1.82  	or r23=r25,r20			// construct PA | page properties
    1.83 -	ptr.d in0, r26			// to purge dtr[IA64_TR_VHPT]
    1.84 +#ifdef XEN
    1.85 +	ptr.d in0,r27			// to purge dtr[IA64_TR_VHPT]
    1.86 +#else
    1.87 +	movl r27=IA64_GRANULE_SHIFT << 2	
    1.88 +#endif
    1.89  	;;
    1.90 -	mov cr.itir=r26
    1.91 +	mov cr.itir=r27
    1.92  	mov cr.ifa=in0			// VA of next task...
    1.93 +#ifdef XEN
    1.94  	srlz.d
    1.95 +#endif
    1.96  	;;
    1.97  	mov r25=IA64_TR_CURRENT_STACK
    1.98  #ifdef XEN
    1.99 -	movl r8=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_STACK_OFFSET;;
   1.100 -	st8 [r8]=r26
   1.101 -	
   1.102 +	st8 [r24]=r26			// remember last page we mapped...
   1.103  #else
   1.104  	mov IA64_KR(CURRENT_STACK)=r26	// remember last page we mapped...
   1.105  #endif