ia64/xen-unstable

changeset 18092:fb5cfb8b122e

[IA64] kexec: Use a separate RID for EFI

This activates the use of the EFI RID.

The basic idea is to switch to this RID, which is in the range reserved
for the hypervisor, before making EFI, PAL or SAL calls. The page fault
handler where the identity mapping checks for this RID, if present it
does the identity mapping, else it just follows the normal mapping
rules. In this way, VMX domains should not be able to access this
memory, and they should be able to use the virtual addresses that are
used by EFI for their own purposes.

Subsequent patches move EFI memory such that faults to it will
be protected by the EFI RID.

Cc: Tristan Gingold <tgingold@free.fr>
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 18a933a52874
children 54060aec0dc1
files xen/arch/ia64/linux-xen/efi.c xen/include/asm-ia64/linux-xen/asm/pal.h xen/include/asm-ia64/linux-xen/asm/sal.h
line diff
     1.1 --- a/xen/arch/ia64/linux-xen/efi.c	Tue Jul 22 12:15:02 2008 +0900
     1.2 +++ b/xen/arch/ia64/linux-xen/efi.c	Tue Jul 22 12:15:02 2008 +0900
     1.3 @@ -65,11 +65,14 @@ prefix##_get_time (efi_time_t *tm, efi_t
     1.4  	struct ia64_fpreg fr[6];								  \
     1.5  	efi_time_cap_t *atc = NULL;								  \
     1.6  	efi_status_t ret;									  \
     1.7 +	XEN_EFI_RR_DECLARE(rr6, rr7);								  \
     1.8  												  \
     1.9  	if (tc)											  \
    1.10  		atc = adjust_arg(tc);								  \
    1.11  	ia64_save_scratch_fpregs(fr);								  \
    1.12 +	XEN_EFI_RR_ENTER(rr6, rr7);								  \
    1.13  	ret = efi_call_##prefix((efi_get_time_t *) __va(runtime->get_time), adjust_arg(tm), atc); \
    1.14 +	XEN_EFI_RR_LEAVE(rr6, rr7);								  \
    1.15  	ia64_load_scratch_fpregs(fr);								  \
    1.16  	return ret;										  \
    1.17  }
    1.18 @@ -80,9 +83,12 @@ prefix##_set_time (efi_time_t *tm)						
    1.19  {												\
    1.20  	struct ia64_fpreg fr[6];								\
    1.21  	efi_status_t ret;									\
    1.22 +	XEN_EFI_RR_DECLARE(rr6, rr7);								  \
    1.23  												\
    1.24  	ia64_save_scratch_fpregs(fr);								\
    1.25 +	XEN_EFI_RR_ENTER(rr6, rr7);								  \
    1.26  	ret = efi_call_##prefix((efi_set_time_t *) __va(runtime->set_time), adjust_arg(tm));	\
    1.27 +	XEN_EFI_RR_LEAVE(rr6, rr7);								  \
    1.28  	ia64_load_scratch_fpregs(fr);								\
    1.29  	return ret;										\
    1.30  }
    1.31 @@ -93,10 +99,13 @@ prefix##_get_wakeup_time (efi_bool_t *en
    1.32  {												\
    1.33  	struct ia64_fpreg fr[6];								\
    1.34  	efi_status_t ret;									\
    1.35 +	XEN_EFI_RR_DECLARE(rr6, rr7);								  \
    1.36  												\
    1.37  	ia64_save_scratch_fpregs(fr);								\
    1.38 +	XEN_EFI_RR_ENTER(rr6, rr7);								  \
    1.39  	ret = efi_call_##prefix((efi_get_wakeup_time_t *) __va(runtime->get_wakeup_time),	\
    1.40  				adjust_arg(enabled), adjust_arg(pending), adjust_arg(tm));	\
    1.41 +	XEN_EFI_RR_LEAVE(rr6, rr7);								  \
    1.42  	ia64_load_scratch_fpregs(fr);								\
    1.43  	return ret;										\
    1.44  }
    1.45 @@ -108,12 +117,15 @@ prefix##_set_wakeup_time (efi_bool_t ena
    1.46  	struct ia64_fpreg fr[6];								\
    1.47  	efi_time_t *atm = NULL;									\
    1.48  	efi_status_t ret;									\
    1.49 +	XEN_EFI_RR_DECLARE(rr6, rr7);								  \
    1.50  												\
    1.51  	if (tm)											\
    1.52  		atm = adjust_arg(tm);								\
    1.53  	ia64_save_scratch_fpregs(fr);								\
    1.54 +	XEN_EFI_RR_ENTER(rr6, rr7);								  \
    1.55  	ret = efi_call_##prefix((efi_set_wakeup_time_t *) __va(runtime->set_wakeup_time),	\
    1.56  				enabled, atm);							\
    1.57 +	XEN_EFI_RR_LEAVE(rr6, rr7);								  \
    1.58  	ia64_load_scratch_fpregs(fr);								\
    1.59  	return ret;										\
    1.60  }
    1.61 @@ -126,13 +138,16 @@ prefix##_get_variable (efi_char16_t *nam
    1.62  	struct ia64_fpreg fr[6];							\
    1.63  	u32 *aattr = NULL;									\
    1.64  	efi_status_t ret;								\
    1.65 +	XEN_EFI_RR_DECLARE(rr6, rr7);								  \
    1.66  											\
    1.67  	if (attr)									\
    1.68  		aattr = adjust_arg(attr);						\
    1.69  	ia64_save_scratch_fpregs(fr);							\
    1.70 +	XEN_EFI_RR_ENTER(rr6, rr7);								  \
    1.71  	ret = efi_call_##prefix((efi_get_variable_t *) __va(runtime->get_variable),	\
    1.72  				adjust_arg(name), adjust_arg(vendor), aattr,		\
    1.73  				adjust_arg(data_size), adjust_arg(data));		\
    1.74 +	XEN_EFI_RR_LEAVE(rr6, rr7);								  \
    1.75  	ia64_load_scratch_fpregs(fr);							\
    1.76  	return ret;									\
    1.77  }
    1.78 @@ -143,10 +158,13 @@ prefix##_get_next_variable (unsigned lon
    1.79  {												\
    1.80  	struct ia64_fpreg fr[6];								\
    1.81  	efi_status_t ret;									\
    1.82 +	XEN_EFI_RR_DECLARE(rr6, rr7);								  \
    1.83  												\
    1.84  	ia64_save_scratch_fpregs(fr);								\
    1.85 +	XEN_EFI_RR_ENTER(rr6, rr7);								  \
    1.86  	ret = efi_call_##prefix((efi_get_next_variable_t *) __va(runtime->get_next_variable),	\
    1.87  				adjust_arg(name_size), adjust_arg(name), adjust_arg(vendor));	\
    1.88 +	XEN_EFI_RR_LEAVE(rr6, rr7);								  \
    1.89  	ia64_load_scratch_fpregs(fr);								\
    1.90  	return ret;										\
    1.91  }
    1.92 @@ -158,11 +176,14 @@ prefix##_set_variable (efi_char16_t *nam
    1.93  {											\
    1.94  	struct ia64_fpreg fr[6];							\
    1.95  	efi_status_t ret;								\
    1.96 +	XEN_EFI_RR_DECLARE(rr6, rr7);								  \
    1.97  											\
    1.98  	ia64_save_scratch_fpregs(fr);							\
    1.99 +	XEN_EFI_RR_ENTER(rr6, rr7);								  \
   1.100  	ret = efi_call_##prefix((efi_set_variable_t *) __va(runtime->set_variable),	\
   1.101  				adjust_arg(name), adjust_arg(vendor), attr, data_size,	\
   1.102  				adjust_arg(data));					\
   1.103 +	XEN_EFI_RR_LEAVE(rr6, rr7);								  \
   1.104  	ia64_load_scratch_fpregs(fr);							\
   1.105  	return ret;									\
   1.106  }
   1.107 @@ -173,10 +194,13 @@ prefix##_get_next_high_mono_count (u32 *
   1.108  {												\
   1.109  	struct ia64_fpreg fr[6];								\
   1.110  	efi_status_t ret;									\
   1.111 +	XEN_EFI_RR_DECLARE(rr6, rr7);								  \
   1.112  												\
   1.113  	ia64_save_scratch_fpregs(fr);								\
   1.114 +	XEN_EFI_RR_ENTER(rr6, rr7);								  \
   1.115  	ret = efi_call_##prefix((efi_get_next_high_mono_count_t *)				\
   1.116  				__va(runtime->get_next_high_mono_count), adjust_arg(count));	\
   1.117 +	XEN_EFI_RR_LEAVE(rr6, rr7);								  \
   1.118  	ia64_load_scratch_fpregs(fr);								\
   1.119  	return ret;										\
   1.120  }
   1.121 @@ -188,14 +212,17 @@ prefix##_reset_system (int reset_type, e
   1.122  {										\
   1.123  	struct ia64_fpreg fr[6];						\
   1.124  	efi_char16_t *adata = NULL;						\
   1.125 +	XEN_EFI_RR_DECLARE(rr6, rr7);								  \
   1.126  										\
   1.127  	if (data)								\
   1.128  		adata = adjust_arg(data);					\
   1.129  										\
   1.130  	ia64_save_scratch_fpregs(fr);						\
   1.131 +	XEN_EFI_RR_ENTER(rr6, rr7);						\
   1.132  	efi_call_##prefix((efi_reset_system_t *) __va(runtime->reset_system),	\
   1.133  			  reset_type, status, data_size, adata);		\
   1.134  	/* should not return, but just in case... */				\
   1.135 +	XEN_EFI_RR_LEAVE(rr6, rr7);								  \
   1.136  	ia64_load_scratch_fpregs(fr);						\
   1.137  }
   1.138  
     2.1 --- a/xen/include/asm-ia64/linux-xen/asm/pal.h	Tue Jul 22 12:15:02 2008 +0900
     2.2 +++ b/xen/include/asm-ia64/linux-xen/asm/pal.h	Tue Jul 22 12:15:02 2008 +0900
     2.3 @@ -93,6 +93,9 @@
     2.4  
     2.5  #include <linux/types.h>
     2.6  #include <asm/fpu.h>
     2.7 +#ifdef XEN
     2.8 +#include <linux/efi.h>
     2.9 +#endif
    2.10  
    2.11  /*
    2.12   * Data types needed to pass information into PAL procedures and
    2.13 @@ -791,29 +794,41 @@ extern void ia64_load_scratch_fpregs (st
    2.14  
    2.15  #define PAL_CALL(iprv,a0,a1,a2,a3) do {			\
    2.16  	struct ia64_fpreg fr[6];			\
    2.17 +	XEN_EFI_RR_DECLARE(rr6, rr7);			\
    2.18  	ia64_save_scratch_fpregs(fr);			\
    2.19 +	XEN_EFI_RR_ENTER(rr6, rr7);			\
    2.20  	iprv = ia64_pal_call_static(a0, a1, a2, a3);	\
    2.21 +	XEN_EFI_RR_LEAVE(rr6, rr7);			\
    2.22  	ia64_load_scratch_fpregs(fr);			\
    2.23  } while (0)
    2.24  
    2.25  #define PAL_CALL_STK(iprv,a0,a1,a2,a3) do {		\
    2.26  	struct ia64_fpreg fr[6];			\
    2.27 +	XEN_EFI_RR_DECLARE(rr6, rr7);			\
    2.28  	ia64_save_scratch_fpregs(fr);			\
    2.29 +	XEN_EFI_RR_ENTER(rr6, rr7);			\
    2.30  	iprv = ia64_pal_call_stacked(a0, a1, a2, a3);	\
    2.31 +	XEN_EFI_RR_LEAVE(rr6, rr7);			\
    2.32  	ia64_load_scratch_fpregs(fr);			\
    2.33  } while (0)
    2.34  
    2.35  #define PAL_CALL_PHYS(iprv,a0,a1,a2,a3) do {			\
    2.36  	struct ia64_fpreg fr[6];				\
    2.37 +	XEN_EFI_RR_DECLARE(rr6, rr7);				\
    2.38  	ia64_save_scratch_fpregs(fr);				\
    2.39 +	XEN_EFI_RR_ENTER(rr6, rr7);				\
    2.40  	iprv = ia64_pal_call_phys_static(a0, a1, a2, a3);	\
    2.41 +	XEN_EFI_RR_LEAVE(rr6, rr7);				\
    2.42  	ia64_load_scratch_fpregs(fr);				\
    2.43  } while (0)
    2.44  
    2.45  #define PAL_CALL_PHYS_STK(iprv,a0,a1,a2,a3) do {		\
    2.46  	struct ia64_fpreg fr[6];				\
    2.47 +	XEN_EFI_RR_DECLARE(rr6, rr7);				\
    2.48  	ia64_save_scratch_fpregs(fr);				\
    2.49 +	XEN_EFI_RR_ENTER(rr6, rr7);				\
    2.50  	iprv = ia64_pal_call_phys_stacked(a0, a1, a2, a3);	\
    2.51 +	XEN_EFI_RR_LEAVE(rr6, rr7);				\
    2.52  	ia64_load_scratch_fpregs(fr);				\
    2.53  } while (0)
    2.54  
     3.1 --- a/xen/include/asm-ia64/linux-xen/asm/sal.h	Tue Jul 22 12:15:02 2008 +0900
     3.2 +++ b/xen/include/asm-ia64/linux-xen/asm/sal.h	Tue Jul 22 12:15:02 2008 +0900
     3.3 @@ -52,9 +52,12 @@ extern spinlock_t sal_lock;
     3.4  # define SAL_CALL(result,args...) do {				\
     3.5  	unsigned long __ia64_sc_flags;				\
     3.6  	struct ia64_fpreg __ia64_sc_fr[6];			\
     3.7 +	XEN_EFI_RR_DECLARE(rr6, rr7);				\
     3.8  	ia64_save_scratch_fpregs(__ia64_sc_fr);			\
     3.9  	spin_lock_irqsave(&sal_lock, __ia64_sc_flags);		\
    3.10 +	XEN_EFI_RR_ENTER(rr6, rr7);				\
    3.11  	__SAL_CALL(result, args);				\
    3.12 +	XEN_EFI_RR_LEAVE(rr6, rr7);				\
    3.13  	spin_unlock_irqrestore(&sal_lock, __ia64_sc_flags);	\
    3.14  	ia64_load_scratch_fpregs(__ia64_sc_fr);			\
    3.15  } while (0)
    3.16 @@ -62,18 +65,24 @@ extern spinlock_t sal_lock;
    3.17  # define SAL_CALL_NOLOCK(result,args...) do {		\
    3.18  	unsigned long __ia64_scn_flags;			\
    3.19  	struct ia64_fpreg __ia64_scn_fr[6];		\
    3.20 +	XEN_EFI_RR_DECLARE(rr6, rr7);			\
    3.21  	ia64_save_scratch_fpregs(__ia64_scn_fr);	\
    3.22  	local_irq_save(__ia64_scn_flags);		\
    3.23 +	XEN_EFI_RR_ENTER(rr6, rr7);			\
    3.24  	__SAL_CALL(result, args);			\
    3.25 +	XEN_EFI_RR_LEAVE(rr6, rr7);			\
    3.26  	local_irq_restore(__ia64_scn_flags);		\
    3.27  	ia64_load_scratch_fpregs(__ia64_scn_fr);	\
    3.28  } while (0)
    3.29  
    3.30  # define SAL_CALL_REENTRANT(result,args...) do {	\
    3.31  	struct ia64_fpreg __ia64_scs_fr[6];		\
    3.32 +	XEN_EFI_RR_DECLARE(rr6, rr7);			\
    3.33  	ia64_save_scratch_fpregs(__ia64_scs_fr);	\
    3.34  	preempt_disable();				\
    3.35 +	XEN_EFI_RR_ENTER(rr6, rr7);			\
    3.36  	__SAL_CALL(result, args);			\
    3.37 +	XEN_EFI_RR_LEAVE(rr6, rr7);			\
    3.38  	preempt_enable();				\
    3.39  	ia64_load_scratch_fpregs(__ia64_scs_fr);	\
    3.40  } while (0)