ia64/xen-unstable

changeset 15665:d69a57b29e3f

[IA64][MINIOS] PKR support

- adds optimization feature for region 7 identity mapping
- adds protection keys to region 5 and region 7 addresses,
may be used for testing the hypervisor protection key support

Signed-off-by: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
author Alex Williamson <alex.williamson@hp.com>
date Mon Jul 30 18:14:29 2007 -0600 (2007-07-30)
parents 57f519c41534
children 039f2ccb1e38
files extras/mini-os/arch/ia64/common.c extras/mini-os/arch/ia64/ia64.S extras/mini-os/arch/ia64/ivt.S extras/mini-os/include/ia64/hypercall-ia64.h extras/mini-os/include/ia64/ia64_cpu.h extras/mini-os/include/ia64/page.h
line diff
     1.1 --- a/extras/mini-os/arch/ia64/common.c	Mon Jul 30 16:51:52 2007 -0600
     1.2 +++ b/extras/mini-os/arch/ia64/common.c	Mon Jul 30 18:14:29 2007 -0600
     1.3 @@ -103,7 +103,8 @@ map_pal_code(void)
     1.4  	 */
     1.5  	ia64_ptc_l(machineFwG.ia64_pal_base, PTE_PS_16K);
     1.6  	ia64_write_itr_i(&pte, IA64_TR_PAL,
     1.7 -			 (uint64_t) machineFwG.ia64_pal_base, PTE_PS_16K, 0);
     1.8 +			 (uint64_t)machineFwG.ia64_pal_base,
     1.9 +			 PTE_PS_16K, IA64_KEY_REG7);
    1.10  	xen_set_virtual_psr_ic(1);
    1.11  }
    1.12  
    1.13 @@ -180,6 +181,21 @@ init_boot_params(void)
    1.14  		bootverbose = 1;
    1.15  }
    1.16  
    1.17 +static void
    1.18 +set_opt_feature(void)
    1.19 +{
    1.20 +	struct xen_ia64_opt_feature optf;
    1.21 +
    1.22 +	optf.cmd = XEN_IA64_OPTF_IDENT_MAP_REG7;
    1.23 +	optf.on = XEN_IA64_OPTF_ON;
    1.24 +	optf.pgprot = ((1 << PTE_OFF_P) | (1 << PTE_OFF_A) | (1 << PTE_OFF_D) |
    1.25 +		       (PTE_MA_WB << PTE_OFF_MA) |
    1.26 +		       (PTE_PL_KERN << PTE_OFF_PL) |
    1.27 +		       (PTE_AR_RW << PTE_OFF_AR));
    1.28 +	optf.key = IA64_KEY_REG7;
    1.29 +	HYPERVISOR_opt_feature(&optf);
    1.30 +}
    1.31 +
    1.32  void
    1.33  arch_init(start_info_t *si)
    1.34  {
    1.35 @@ -213,6 +229,9 @@ arch_init(start_info_t *si)
    1.36  		printk("efi_get_time() failed\n");
    1.37  
    1.38  	registerCallback();
    1.39 +
    1.40 +	set_opt_feature();
    1.41 +
    1.42  	initialized = 1;
    1.43  }
    1.44  
     2.1 --- a/extras/mini-os/arch/ia64/ia64.S	Mon Jul 30 16:51:52 2007 -0600
     2.2 +++ b/extras/mini-os/arch/ia64/ia64.S	Mon Jul 30 18:14:29 2007 -0600
     2.3 @@ -101,11 +101,21 @@ ENTRY(_start)
     2.4  	;;
     2.5  	mov	rr[r3]=r2
     2.6  	;;
     2.7 -
     2.8 +	/*
     2.9 +	 * Setup protection keys for region 5 and 7.
    2.10 +	 */
    2.11 +	mov	r2=(IA64_KEY_REG5 << IA64_PKR_KEY) | IA64_PKR_VALID
    2.12 +	mov	r3=(IA64_KEY_REG7 << IA64_PKR_KEY) | IA64_PKR_VALID
    2.13 +	mov	r14=0x1
    2.14 +	;;
    2.15 +	mov	pkr[r0]=r2	/* Region 5 */
    2.16 +	mov	pkr[r14]=r3	/* Region 7 */
    2.17 +	;;
    2.18  	/*
    2.19  	 * Now pin mappings into the TLB for kernel text and data
    2.20  	 */
    2.21 -	mov	r18=KERNEL_TR_PAGE_SIZE<<IA64_ITIR_PS
    2.22 +	mov	r18=(KERNEL_TR_PAGE_SIZE<<IA64_ITIR_PS)| \
    2.23 +			(IA64_KEY_REG5<<IA64_ITIR_KEY)
    2.24  	movl	r17=KERNEL_START
    2.25  	;;
    2.26  	mov	cr.itir=r18
     3.1 --- a/extras/mini-os/arch/ia64/ivt.S	Mon Jul 30 16:51:52 2007 -0600
     3.2 +++ b/extras/mini-os/arch/ia64/ivt.S	Mon Jul 30 18:14:29 2007 -0600
     3.3 @@ -249,7 +249,7 @@ ENTRY(save_tf_rse_switch)
     3.4  		/* xen special handling for possibly lazy cover */
     3.5  	movl	r8=XSI_PRECOVER_IFS;
     3.6  	;;
     3.7 -	ld8	r21=[r8];
     3.8 +	ld8	r21=[r8]
     3.9  	;;
    3.10  #if defined(BIG_ENDIAN)			// swap because mini-os is in BE
    3.11  	mux1	r21=r21,@rev
    3.12 @@ -771,7 +771,7 @@ adt_reg7_addr:
    3.13  	 * addresses. Currently I don't do a check.
    3.14  	 */
    3.15  	movl	r20=~((7 << IA64_RR_IDX_POS) | 0xfff)
    3.16 -	movl	r18=((PTE_PS_16K<<IA64_ITIR_PS)|(0<<IA64_ITIR_KEY))
    3.17 +	movl	r18=((PTE_PS_16K<<IA64_ITIR_PS)|(IA64_KEY_REG7<<IA64_ITIR_KEY))
    3.18  	;;
    3.19  	movl	r19=	((1<<PTE_OFF_P) | (PTE_MA_WB<<PTE_OFF_MA) | \
    3.20  			 (1<<PTE_OFF_A) | (1<<PTE_OFF_D) | \
     4.1 --- a/extras/mini-os/include/ia64/hypercall-ia64.h	Mon Jul 30 16:51:52 2007 -0600
     4.2 +++ b/extras/mini-os/include/ia64/hypercall-ia64.h	Mon Jul 30 18:14:29 2007 -0600
     4.3 @@ -223,4 +223,14 @@ xencomm_arch_hypercall_grant_table_op(un
     4.4  
     4.5  int HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count);
     4.6  
     4.7 +static inline int
     4.8 +HYPERVISOR_opt_feature(void *arg)
     4.9 +{
    4.10 +	struct xencomm_handle *new_arg;
    4.11 +
    4.12 +	new_arg = xencomm_create_inline(arg);
    4.13 +
    4.14 +	return _hypercall1(int, opt_feature, new_arg);
    4.15 +}
    4.16 +
    4.17  #endif /* __HYPERCALL_H__ */
     5.1 --- a/extras/mini-os/include/ia64/ia64_cpu.h	Mon Jul 30 16:51:52 2007 -0600
     5.2 +++ b/extras/mini-os/include/ia64/ia64_cpu.h	Mon Jul 30 18:14:29 2007 -0600
     5.3 @@ -141,7 +141,7 @@
     5.4  #define MOS_IA64_PSR_BE	0
     5.5  #endif
     5.6  
     5.7 -#define STARTUP_PSR (IA64_PSR_IT | \
     5.8 +#define STARTUP_PSR (IA64_PSR_IT | IA64_PSR_PK | \
     5.9              	     IA64_PSR_DT | IA64_PSR_RT | MOS_IA64_PSR_BE | \
    5.10  		     IA64_PSR_BN | IA64_PSR_CPL_KERN | IA64_PSR_AC)
    5.11  
     6.1 --- a/extras/mini-os/include/ia64/page.h	Mon Jul 30 16:51:52 2007 -0600
     6.2 +++ b/extras/mini-os/include/ia64/page.h	Mon Jul 30 18:14:29 2007 -0600
     6.3 @@ -99,6 +99,10 @@ extern paddr_t phys_avail[];
     6.4  #define KERN_VIRT_2_PHYS(x) (((x) - KERNEL_START) + \
     6.5  				(1 << KERNEL_PHYS_START_SHIFT))
     6.6  
     6.7 +/* Some protection keys for region 5 and 7 addresses. */
     6.8 +#define IA64_KEY_REG7	0x234	/* Region 7 - identity mapped addresses */
     6.9 +#define IA64_KEY_REG5	0x89a	/* Region 5 - kernel addresses */
    6.10 +
    6.11  // This is xen specific !
    6.12  #define PAGE_SHIFT_XEN_16K	14	// For 16KB page size
    6.13  #define mfn_to_virt(mfn)	((void*)__va((mfn) << PAGE_SHIFT_XEN_16K))