ia64/xen-unstable

changeset 16643:35ab2bb25e09

vmx: Do not set bit 1 of FEATURE_CONTROL MSR if SMX is not supported
by the CPU. Also generally beef up robustness of VMXON instruction.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Dec 19 15:51:01 2007 +0000 (2007-12-19)
parents 643ab64d12d5
children ea809f12c813
files xen/arch/x86/hvm/vmx/vmcs.c xen/arch/x86/traps.c xen/include/asm-x86/hvm/vmx/vmx.h
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vmcs.c	Wed Dec 19 15:05:15 2007 +0000
     1.2 +++ b/xen/arch/x86/hvm/vmx/vmcs.c	Wed Dec 19 15:51:01 2007 +0000
     1.3 @@ -274,19 +274,13 @@ int vmx_cpu_up(void)
     1.4      }
     1.5      else
     1.6      {
     1.7 -        eax = (IA32_FEATURE_CONTROL_MSR_LOCK |
     1.8 -               IA32_FEATURE_CONTROL_MSR_ENABLE_VMXON_OUTSIDE_SMX |
     1.9 -               IA32_FEATURE_CONTROL_MSR_ENABLE_VMXON_INSIDE_SMX);
    1.10 +        eax  = IA32_FEATURE_CONTROL_MSR_LOCK;
    1.11 +        eax |= IA32_FEATURE_CONTROL_MSR_ENABLE_VMXON_OUTSIDE_SMX;
    1.12 +        if ( test_bit(X86_FEATURE_SMXE, &boot_cpu_data.x86_capability) )
    1.13 +            eax |= IA32_FEATURE_CONTROL_MSR_ENABLE_VMXON_INSIDE_SMX;
    1.14          wrmsr(IA32_FEATURE_CONTROL_MSR, eax, 0);
    1.15      }
    1.16  
    1.17 -    if ( !tboot_in_measured_env() &&
    1.18 -         !(eax & IA32_FEATURE_CONTROL_MSR_ENABLE_VMXON_OUTSIDE_SMX) )
    1.19 -    {
    1.20 -        printk("VMX only allowed in SMX but SMX not active.\n");
    1.21 -        return 0;
    1.22 -    }
    1.23 -
    1.24      vmx_init_vmcs_config();
    1.25  
    1.26      INIT_LIST_HEAD(&this_cpu(active_vmcs_list));
     2.1 --- a/xen/arch/x86/traps.c	Wed Dec 19 15:05:15 2007 +0000
     2.2 +++ b/xen/arch/x86/traps.c	Wed Dec 19 15:51:01 2007 +0000
     2.3 @@ -719,6 +719,7 @@ asmlinkage void do_invalid_op(struct cpu
     2.4      struct bug_frame bug;
     2.5      struct bug_frame_str bug_str;
     2.6      char *filename, *predicate, *eip = (char *)regs->eip;
     2.7 +    unsigned long fixup;
     2.8      int id, lineno;
     2.9  
    2.10      DEBUGGER_trap_entry(TRAP_invalid_op, regs);
    2.11 @@ -789,6 +790,11 @@ asmlinkage void do_invalid_op(struct cpu
    2.12            predicate, filename, lineno);
    2.13  
    2.14   die:
    2.15 +    if ( (fixup = search_exception_table(regs->eip)) != 0 )
    2.16 +    {
    2.17 +        regs->eip = fixup;
    2.18 +        return;
    2.19 +    }
    2.20      DEBUGGER_trap_fatal(TRAP_invalid_op, regs);
    2.21      show_execution_state(regs);
    2.22      panic("FATAL TRAP: vector = %d (invalid opcode)\n", TRAP_invalid_op);
     3.1 --- a/xen/include/asm-x86/hvm/vmx/vmx.h	Wed Dec 19 15:05:15 2007 +0000
     3.2 +++ b/xen/include/asm-x86/hvm/vmx/vmx.h	Wed Dec 19 15:51:01 2007 +0000
     3.3 @@ -240,23 +240,31 @@ static inline void __vm_clear_bit(unsign
     3.4      __vmwrite(field, __vmread(field) & ~(1UL << bit));
     3.5  }
     3.6  
     3.7 -static inline void __vmxoff (void)
     3.8 +static inline void __vmxoff(void)
     3.9  {
    3.10 -    __asm__ __volatile__ ( VMXOFF_OPCODE
    3.11 -                           ::: "memory");
    3.12 +    asm volatile (
    3.13 +        VMXOFF_OPCODE
    3.14 +        : : : "memory" );
    3.15  }
    3.16  
    3.17 -static inline int __vmxon (u64 addr)
    3.18 +static inline int __vmxon(u64 addr)
    3.19  {
    3.20      int rc;
    3.21  
    3.22 -    __asm__ __volatile__ ( VMXON_OPCODE
    3.23 -                           MODRM_EAX_06
    3.24 -                           /* CF==1 or ZF==1 --> rc = -1 */
    3.25 -                           "setna %b0 ; neg %0"
    3.26 -                           : "=q" (rc)
    3.27 -                           : "0" (0), "a" (&addr)
    3.28 -                           : "memory");
    3.29 +    asm volatile ( 
    3.30 +        "1: " VMXON_OPCODE MODRM_EAX_06 "\n"
    3.31 +        "   setna %b0 ; neg %0\n" /* CF==1 or ZF==1 --> rc = -1 */
    3.32 +        "2:\n"
    3.33 +        ".section .fixup,\"ax\"\n"
    3.34 +        "3: not %0 ; jmp 2b\n"    /* #UD --> rc = -1 */
    3.35 +        ".previous\n"
    3.36 +        ".section __ex_table,\"a\"\n"
    3.37 +        "   "__FIXUP_ALIGN"\n"
    3.38 +        "   "__FIXUP_WORD" 1b,3b\n"
    3.39 +        ".previous\n"
    3.40 +        : "=q" (rc)
    3.41 +        : "0" (0), "a" (&addr)
    3.42 +        : "memory");
    3.43  
    3.44      return rc;
    3.45  }