ia64/xen-unstable

changeset 9816:3ffb6cc6b8d2

Xen support for sysenter/exit on x86_32 when supervisor_mode_kernel is
enabled.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian.Campbell@xensource.com
date Fri Apr 21 17:19:29 2006 +0100 (2006-04-21)
parents d73eeceeae69
children 42a398e1daf1
files xen/arch/x86/cpu/common.c xen/arch/x86/traps.c xen/arch/x86/x86_32/traps.c xen/include/asm-x86/cpufeature.h xen/include/public/callback.h
line diff
     1.1 --- a/xen/arch/x86/cpu/common.c	Fri Apr 21 17:19:26 2006 +0100
     1.2 +++ b/xen/arch/x86/cpu/common.c	Fri Apr 21 17:19:29 2006 +0100
     1.3 @@ -575,6 +575,8 @@ void __devinit cpu_init(void)
     1.4  #if defined(CONFIG_X86_32)
     1.5  	t->ss0  = __HYPERVISOR_DS;
     1.6  	t->esp0 = get_stack_bottom();
     1.7 +	if ( supervisor_mode_kernel && cpu_has_sep )
     1.8 +		wrmsr(MSR_IA32_SYSENTER_ESP, &t->esp1, 0);
     1.9  #elif defined(CONFIG_X86_64)
    1.10  	/* Bottom-of-stack must be 16-byte aligned! */
    1.11  	BUG_ON((get_stack_bottom() & 15) != 0);
     2.1 --- a/xen/arch/x86/traps.c	Fri Apr 21 17:19:26 2006 +0100
     2.2 +++ b/xen/arch/x86/traps.c	Fri Apr 21 17:19:29 2006 +0100
     2.3 @@ -425,7 +425,8 @@ static int emulate_forced_invalid_op(str
     2.4          clear_bit(X86_FEATURE_DE,  &d);
     2.5          clear_bit(X86_FEATURE_PSE, &d);
     2.6          clear_bit(X86_FEATURE_PGE, &d);
     2.7 -        clear_bit(X86_FEATURE_SEP, &d);
     2.8 +        if ( !supervisor_mode_kernel )
     2.9 +            clear_bit(X86_FEATURE_SEP, &d);
    2.10          if ( !IS_PRIV(current->domain) )
    2.11              clear_bit(X86_FEATURE_MTRR, &d);
    2.12      }
     3.1 --- a/xen/arch/x86/x86_32/traps.c	Fri Apr 21 17:19:26 2006 +0100
     3.2 +++ b/xen/arch/x86/x86_32/traps.c	Fri Apr 21 17:19:29 2006 +0100
     3.3 @@ -318,6 +318,16 @@ void init_int80_direct_trap(struct vcpu 
     3.4          set_int80_direct_trap(v);
     3.5  }
     3.6  
     3.7 +#ifdef CONFIG_X86_SUPERVISOR_MODE_KERNEL
     3.8 +static void do_update_sysenter(void *info)
     3.9 +{
    3.10 +    xen_callback_t *address = info;
    3.11 +
    3.12 +    wrmsr(MSR_IA32_SYSENTER_CS, address->cs, 0);
    3.13 +    wrmsr(MSR_IA32_SYSENTER_EIP, address->eip, 0);
    3.14 +}
    3.15 +#endif
    3.16 +
    3.17  static long register_guest_callback(struct callback_register *reg)
    3.18  {
    3.19      long ret = 0;
    3.20 @@ -337,6 +347,15 @@ static long register_guest_callback(stru
    3.21          v->arch.guest_context.failsafe_callback_eip = reg->address.eip;
    3.22          break;
    3.23  
    3.24 +#ifdef CONFIG_X86_SUPERVISOR_MODE_KERNEL
    3.25 +    case CALLBACKTYPE_sysenter:
    3.26 +        if ( ! cpu_has_sep )
    3.27 +            ret = -EINVAL;
    3.28 +        else if ( on_each_cpu(do_update_sysenter, &reg->address, 1, 1) != 0 )
    3.29 +            ret = -EIO;
    3.30 +        break;
    3.31 +#endif
    3.32 +
    3.33      case CALLBACKTYPE_nmi:
    3.34          ret = register_guest_nmi_callback(reg->address.eip);
    3.35          break;
     4.1 --- a/xen/include/asm-x86/cpufeature.h	Fri Apr 21 17:19:26 2006 +0100
     4.2 +++ b/xen/include/asm-x86/cpufeature.h	Fri Apr 21 17:19:29 2006 +0100
     4.3 @@ -104,6 +104,7 @@
     4.4  #define cpu_has_pae		boot_cpu_has(X86_FEATURE_PAE)
     4.5  #define cpu_has_pge		boot_cpu_has(X86_FEATURE_PGE)
     4.6  #define cpu_has_apic		boot_cpu_has(X86_FEATURE_APIC)
     4.7 +#define cpu_has_sep		boot_cpu_has(X86_FEATURE_SEP)
     4.8  #define cpu_has_mtrr		boot_cpu_has(X86_FEATURE_MTRR)
     4.9  #define cpu_has_mmx		boot_cpu_has(X86_FEATURE_MMX)
    4.10  #define cpu_has_fxsr		boot_cpu_has(X86_FEATURE_FXSR)
    4.11 @@ -125,6 +126,7 @@
    4.12  #define cpu_has_pae		1
    4.13  #define cpu_has_pge		1
    4.14  #define cpu_has_apic		boot_cpu_has(X86_FEATURE_APIC)
    4.15 +#define cpu_has_sep		0
    4.16  #define cpu_has_mtrr		1
    4.17  #define cpu_has_mmx		1
    4.18  #define cpu_has_fxsr		1
     5.1 --- a/xen/include/public/callback.h	Fri Apr 21 17:19:26 2006 +0100
     5.2 +++ b/xen/include/public/callback.h	Fri Apr 21 17:19:29 2006 +0100
     5.3 @@ -21,6 +21,11 @@
     5.4  #define CALLBACKTYPE_event                 0
     5.5  #define CALLBACKTYPE_failsafe              1
     5.6  #define CALLBACKTYPE_syscall               2 /* x86_64 only */
     5.7 +/*
     5.8 + * sysenter is only available on x86_32 with the
     5.9 + * supervisor_mode_kernel option enabled.
    5.10 + */
    5.11 +#define CALLBACKTYPE_sysenter              3
    5.12  #define CALLBACKTYPE_nmi                   4
    5.13  
    5.14  /*