ia64/xen-unstable

changeset 10238:b27139d8c1e1

[IA64] paravirtualize vdso

paravirtualize vdso area.
introduce hyperprivop HYPERPRIVOP_RSM_BE and HYPERPRIVOP_GET_PSR.
and paravirtualize vdso area using them.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author awilliam@xenbuild.aw
date Sat Jun 03 11:16:47 2006 -0600 (2006-06-03)
parents f8ab23b4f704
children 34455164dd33
files linux-2.6-xen-sparse/arch/ia64/kernel/gate.S linux-2.6-xen-sparse/arch/ia64/kernel/gate.lds.S linux-2.6-xen-sparse/arch/ia64/kernel/patch.c linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h xen/arch/ia64/xen/privop.c xen/include/public/arch-ia64.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/ia64/kernel/gate.S	Sat Jun 03 11:16:41 2006 -0600
     1.2 +++ b/linux-2.6-xen-sparse/arch/ia64/kernel/gate.S	Sat Jun 03 11:16:47 2006 -0600
     1.3 @@ -14,6 +14,9 @@
     1.4  #include <asm/sigcontext.h>
     1.5  #include <asm/system.h>
     1.6  #include <asm/unistd.h>
     1.7 +#ifdef CONFIG_XEN
     1.8 +# include <asm/privop.h>
     1.9 +#endif
    1.10  
    1.11  /*
    1.12   * We can't easily refer to symbols inside the kernel.  To avoid full runtime relocation,
    1.13 @@ -33,6 +36,15 @@
    1.14  [1:](pr)brl.cond.sptk 0;				\
    1.15  	.xdata4 ".data.patch.brl_fsys_bubble_down", 1b-.
    1.16  
    1.17 +	// Currently is_running_on_xen() is defined as running_on_xen.
    1.18 +	// If is_running_on_xen() is a real function, we must update 
    1.19 +	// according to it.
    1.20 +.section ".data.patch.running_on_xen", "a"
    1.21 +	.previous
    1.22 +#define LOAD_RUNNING_ON_XEN(reg)			\
    1.23 +[1:]	movl reg=0;					\
    1.24 +	.xdata4 ".data.patch.running_on_xen", 1b-.
    1.25 +
    1.26  GLOBAL_ENTRY(__kernel_syscall_via_break)
    1.27  	.prologue
    1.28  	.altrp b6
    1.29 @@ -77,7 +89,42 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
    1.30  	epc					// B	causes split-issue
    1.31  }
    1.32  	;;
    1.33 +#ifdef CONFIG_XEN
    1.34 +	// r20 = 1
    1.35 +	// r22 = &vcpu->evtchn_mask
    1.36 +	// r23 = &vpsr.ic
    1.37 +	// r24 = vcpu->pending_interruption
    1.38 +	// r25 = tmp
    1.39 +	// r28 = &running_on_xen
    1.40 +	// r30 = running_on_xen
    1.41 +	// r31 = tmp
    1.42 +	// p11 = tmp
    1.43 +	// p12 = running_on_xen
    1.44 +	// p13 = !running_on_xen
    1.45 +	// p14 = tmp
    1.46 +	// p15 = tmp
    1.47 +#define isXen	p12
    1.48 +#define isRaw	p13	
    1.49 +	LOAD_RUNNING_ON_XEN(r28)
    1.50 +	movl r22=XSI_PSR_I_ADDR
    1.51 +	movl r23=XSI_PSR_IC
    1.52 +	movl r24=XSI_PEND
    1.53 +	mov r20=1
    1.54 +	;;
    1.55 +	ld4 r30=[r28]
    1.56 +	;; 
    1.57 +	cmp.ne p12,p13=r0,r30
    1.58 +	;; 
    1.59 +(isXen)	ld8 r22=[r22]
    1.60 +(isRaw)	rsm psr.be | psr.i
    1.61 +	;; 
    1.62 +(isXen)	st1 [r22]=r20
    1.63 +(isXen)	st4 [r23]=r0
    1.64 +(isXen)	XEN_HYPER_RSM_BE
    1.65 +(isXen)	st4 [r23]=r20
    1.66 +#else	
    1.67  	rsm psr.be | psr.i			// M2 (5 cyc to srlz.d)
    1.68 +#endif
    1.69  	LOAD_FSYSCALL_TABLE(r14)		// X
    1.70  	;;
    1.71  	mov r16=IA64_KR(CURRENT)		// M2 (12 cyc)
    1.72 @@ -85,7 +132,19 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
    1.73  	mov r19=NR_syscalls-1			// A
    1.74  	;;
    1.75  	lfetch [r18]				// M0|1
    1.76 +#ifdef CONFIG_XEN
    1.77 +(isXen)	mov r31=r8
    1.78 +(isXen)	mov r25=IA64_PSR_IC
    1.79 +(isXen)	st4 [r23]=r0
    1.80 +(isXen)	XEN_HYPER_GET_PSR
    1.81 +(isRaw)	mov r29=psr
    1.82 +	;; 
    1.83 +(isXen)	st4 [r23]=r20
    1.84 +(isXen)	or r29=r8,r25 // vpsr.ic was cleared for hyperprivop
    1.85 +(isXen)	mov r8=r31
    1.86 +#else
    1.87  	mov r29=psr				// M2 (12 cyc)
    1.88 +#endif
    1.89  	// If r17 is a NaT, p6 will be zero
    1.90  	cmp.geu p6,p7=r19,r17			// A    (sysnr > 0 && sysnr < 1024+NR_syscalls)?
    1.91  	;;
    1.92 @@ -99,9 +158,26 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
    1.93  	;;
    1.94  	nop.m 0
    1.95  (p6)	tbit.z.unc p8,p0=r18,0			// I0 (dual-issues with "mov b7=r18"!)
    1.96 +#ifdef CONFIG_XEN
    1.97 +	;; 
    1.98 +	// p14 = running_on_xen && p8
    1.99 +	// p15 = !running_on_xen && p8
   1.100 +(p8)	cmp.ne.unc p14,p15=r0,r30
   1.101 +	;; 
   1.102 +(p14)	st4 [r22]=r20
   1.103 +(p14)	ld4 r25=[r24]
   1.104 +(p15)	ssm psr.i
   1.105 +	;;
   1.106 +(p14)   cmp.ne.unc p11,p0=r0, r25
   1.107 +	;; 
   1.108 +(p11)	st4 [r22]=r0
   1.109 +(p11)	st4 [r23]=r0
   1.110 +(p11)	XEN_HYPER_SSM_I
   1.111 +#else
   1.112  	nop.i 0
   1.113  	;;
   1.114  (p8)	ssm psr.i
   1.115 +#endif
   1.116  (p6)	mov b7=r18				// I0
   1.117  (p8)	br.dptk.many b7				// B
   1.118  
   1.119 @@ -122,7 +198,20 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
   1.120  #else
   1.121  	BRL_COND_FSYS_BUBBLE_DOWN(p6)
   1.122  #endif
   1.123 +#ifdef CONFIG_XEN
   1.124 +(isXen)	st4 [r22]=r20
   1.125 +(isXen)	ld4 r25=[r24]
   1.126 +(isRaw)	ssm psr.i
   1.127 +	;; 
   1.128 +(isXen)	cmp.ne.unc p11,p0=r0, r25
   1.129 +	;; 
   1.130 +(p11)	st4 [r22]=r0
   1.131 +(p11)	st4 [r23]=r0
   1.132 +(p11)	XEN_HYPER_SSM_I
   1.133 +	;; 
   1.134 +#else
   1.135  	ssm psr.i
   1.136 +#endif	
   1.137  	mov r10=-1
   1.138  (p10)	mov r8=EINVAL
   1.139  (p9)	mov r8=ENOSYS
     2.1 --- a/linux-2.6-xen-sparse/arch/ia64/kernel/gate.lds.S	Sat Jun 03 11:16:41 2006 -0600
     2.2 +++ b/linux-2.6-xen-sparse/arch/ia64/kernel/gate.lds.S	Sat Jun 03 11:16:47 2006 -0600
     2.3 @@ -43,6 +43,10 @@ SECTIONS
     2.4  				    __start_gate_brl_fsys_bubble_down_patchlist = .;
     2.5  				    *(.data.patch.brl_fsys_bubble_down)
     2.6  				    __end_gate_brl_fsys_bubble_down_patchlist = .;
     2.7 +
     2.8 +				    __start_gate_running_on_xen_patchlist = .;
     2.9 +				    *(.data.patch.running_on_xen)
    2.10 +				    __end_gate_running_on_xen_patchlist = .;
    2.11    }									:readable
    2.12    .IA_64.unwind_info		: { *(.IA_64.unwind_info*) }
    2.13    .IA_64.unwind			: { *(.IA_64.unwind*) }			:readable :unwind
     3.1 --- a/linux-2.6-xen-sparse/arch/ia64/kernel/patch.c	Sat Jun 03 11:16:41 2006 -0600
     3.2 +++ b/linux-2.6-xen-sparse/arch/ia64/kernel/patch.c	Sat Jun 03 11:16:47 2006 -0600
     3.3 @@ -184,6 +184,29 @@ patch_brl_fsys_bubble_down (unsigned lon
     3.4  	ia64_srlz_i();
     3.5  }
     3.6  
     3.7 +#ifdef CONFIG_XEN
     3.8 +extern char __start_gate_running_on_xen_patchlist[];
     3.9 +extern char __end_gate_running_on_xen_patchlist[];
    3.10 +void
    3.11 +patch_running_on_xen(unsigned long start, unsigned long end)
    3.12 +{
    3.13 +	extern int running_on_xen;
    3.14 +	s32 *offp = (s32 *) start;
    3.15 +	u64 ip;
    3.16 +
    3.17 +	while (offp < (s32 *) end) {
    3.18 +		ip = (u64) ia64_imva((char *) offp + *offp);
    3.19 +		ia64_patch_imm64(ip, (u64) &running_on_xen);
    3.20 +		ia64_fc((void *) ip);
    3.21 +		++offp;
    3.22 +	}
    3.23 +	ia64_sync_i();
    3.24 +	ia64_srlz_i();
    3.25 +}
    3.26 +#else
    3.27 +#define patch_running_on_xen(start, end)	do { } while (0)
    3.28 +#endif
    3.29 +
    3.30  void
    3.31  ia64_patch_gate (void)
    3.32  {
    3.33 @@ -192,6 +215,7 @@ ia64_patch_gate (void)
    3.34  
    3.35  	patch_fsyscall_table(START(fsyscall), END(fsyscall));
    3.36  	patch_brl_fsys_bubble_down(START(brl_fsys_bubble_down), END(brl_fsys_bubble_down));
    3.37 +	patch_running_on_xen(START(running_on_xen), END(running_on_xen));
    3.38  	ia64_patch_vtop(START(vtop), END(vtop));
    3.39  	ia64_patch_mckinley_e9(START(mckinley_e9), END(mckinley_e9));
    3.40  }
     4.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h	Sat Jun 03 11:16:41 2006 -0600
     4.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h	Sat Jun 03 11:16:47 2006 -0600
     4.3 @@ -39,6 +39,8 @@
     4.4  #define	XEN_HYPER_GET_PMD		break HYPERPRIVOP_GET_PMD
     4.5  #define	XEN_HYPER_GET_EFLAG		break HYPERPRIVOP_GET_EFLAG
     4.6  #define	XEN_HYPER_SET_EFLAG		break HYPERPRIVOP_SET_EFLAG
     4.7 +#define	XEN_HYPER_RSM_BE		break HYPERPRIVOP_RSM_BE
     4.8 +#define	XEN_HYPER_GET_PSR		break HYPERPRIVOP_GET_PSR
     4.9  #endif
    4.10  
    4.11  #ifndef __ASSEMBLY__
     5.1 --- a/xen/arch/ia64/xen/privop.c	Sat Jun 03 11:16:41 2006 -0600
     5.2 +++ b/xen/arch/ia64/xen/privop.c	Sat Jun 03 11:16:47 2006 -0600
     5.3 @@ -897,6 +897,13 @@ ia64_hyperprivop(unsigned long iim, REGS
     5.4  	    case HYPERPRIVOP_SET_EFLAG:
     5.5  		(void)vcpu_set_ar(v,24,regs->r8);
     5.6  		return 1;
     5.7 +	    case HYPERPRIVOP_RSM_BE:
     5.8 +		(void)vcpu_reset_psr_sm(v, IA64_PSR_BE);
     5.9 +		return 1;
    5.10 +	    case HYPERPRIVOP_GET_PSR:
    5.11 +		(void)vcpu_get_psr(v, &val);
    5.12 +		regs->r8 = val;
    5.13 +		return 1;
    5.14  	}
    5.15  	return 0;
    5.16  }
     6.1 --- a/xen/include/public/arch-ia64.h	Sat Jun 03 11:16:41 2006 -0600
     6.2 +++ b/xen/include/public/arch-ia64.h	Sat Jun 03 11:16:47 2006 -0600
     6.3 @@ -400,7 +400,9 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_conte
     6.4  #define HYPERPRIVOP_GET_PMD		0x15
     6.5  #define HYPERPRIVOP_GET_EFLAG		0x16
     6.6  #define HYPERPRIVOP_SET_EFLAG		0x17
     6.7 -#define HYPERPRIVOP_MAX			0x17
     6.8 +#define HYPERPRIVOP_RSM_BE		0x18
     6.9 +#define HYPERPRIVOP_GET_PSR		0x19
    6.10 +#define HYPERPRIVOP_MAX			0x19
    6.11  
    6.12  #endif /* __HYPERVISOR_IF_IA64_H__ */
    6.13