ia64/xen-unstable

changeset 17775:a4775034ef83

vmx: Better diagnostic messages when VMXON might have failed due to
bad setting of the IA32_FEATURE_CONTROL MSR.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jun 02 10:55:55 2008 +0100 (2008-06-02)
parents 0216f0d07efe
children b9879d710825
files xen/arch/x86/hvm/vmx/vmcs.c xen/include/asm-x86/hvm/vmx/vmx.h
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vmcs.c	Mon Jun 02 10:04:19 2008 +0100
     1.2 +++ b/xen/arch/x86/hvm/vmx/vmcs.c	Mon Jun 02 10:55:55 2008 +0100
     1.3 @@ -267,7 +267,7 @@ static void vmx_load_vmcs(struct vcpu *v
     1.4  int vmx_cpu_up(void)
     1.5  {
     1.6      u32 eax, edx;
     1.7 -    int cpu = smp_processor_id();
     1.8 +    int bios_locked, cpu = smp_processor_id();
     1.9      u64 cr0, vmx_cr0_fixed0, vmx_cr0_fixed1;
    1.10  
    1.11      BUG_ON(!(read_cr4() & X86_CR4_VMXE));
    1.12 @@ -288,7 +288,8 @@ int vmx_cpu_up(void)
    1.13  
    1.14      rdmsr(IA32_FEATURE_CONTROL_MSR, eax, edx);
    1.15  
    1.16 -    if ( eax & IA32_FEATURE_CONTROL_MSR_LOCK )
    1.17 +    bios_locked = !!(eax & IA32_FEATURE_CONTROL_MSR_LOCK);
    1.18 +    if ( bios_locked )
    1.19      {
    1.20          if ( !(eax & (IA32_FEATURE_CONTROL_MSR_ENABLE_VMXON_OUTSIDE_SMX |
    1.21                        IA32_FEATURE_CONTROL_MSR_ENABLE_VMXON_INSIDE_SMX)) )
    1.22 @@ -320,10 +321,28 @@ int vmx_cpu_up(void)
    1.23          }
    1.24      }
    1.25  
    1.26 -    if ( __vmxon(virt_to_maddr(this_cpu(host_vmcs))) )
    1.27 +    switch ( __vmxon(virt_to_maddr(this_cpu(host_vmcs))) )
    1.28      {
    1.29 -        printk("CPU%d: VMXON failed\n", cpu);
    1.30 +    case -2: /* #UD or #GP */
    1.31 +        if ( bios_locked &&
    1.32 +             test_bit(X86_FEATURE_SMXE, &boot_cpu_data.x86_capability) &&
    1.33 +             (!(eax & IA32_FEATURE_CONTROL_MSR_ENABLE_VMXON_OUTSIDE_SMX) ||
    1.34 +              !(eax & IA32_FEATURE_CONTROL_MSR_ENABLE_VMXON_INSIDE_SMX)) )
    1.35 +        {
    1.36 +            printk("CPU%d: VMXON failed: perhaps because of TXT settings "
    1.37 +                   "in your BIOS configuration?\n", cpu);
    1.38 +            printk(" --> Disable TXT in your BIOS unless using a secure "
    1.39 +                   "bootloader.\n");
    1.40 +            return 0;
    1.41 +        }
    1.42 +        /* fall through */
    1.43 +    case -1: /* CF==1 or ZF==1 */
    1.44 +        printk("CPU%d: unexpected VMXON failure\n", cpu);
    1.45          return 0;
    1.46 +    case 0: /* success */
    1.47 +        break;
    1.48 +    default:
    1.49 +        BUG();
    1.50      }
    1.51  
    1.52      ept_sync_all();
     2.1 --- a/xen/include/asm-x86/hvm/vmx/vmx.h	Mon Jun 02 10:04:19 2008 +0100
     2.2 +++ b/xen/include/asm-x86/hvm/vmx/vmx.h	Mon Jun 02 10:55:55 2008 +0100
     2.3 @@ -334,7 +334,7 @@ static inline int __vmxon(u64 addr)
     2.4          "   setna %b0 ; neg %0\n" /* CF==1 or ZF==1 --> rc = -1 */
     2.5          "2:\n"
     2.6          ".section .fixup,\"ax\"\n"
     2.7 -        "3: not %0 ; jmp 2b\n"    /* #UD --> rc = -1 */
     2.8 +        "3: sub $2,%0 ; jmp 2b\n"    /* #UD or #GP --> rc = -2 */
     2.9          ".previous\n"
    2.10          ".section __ex_table,\"a\"\n"
    2.11          "   "__FIXUP_ALIGN"\n"