From d44e3c1d2ece044f6a8613624678ef19f647cbeb Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 2 Jun 2008 10:55:55 +0100 Subject: [PATCH] vmx: Better diagnostic messages when VMXON might have failed due to bad setting of the IA32_FEATURE_CONTROL MSR. Signed-off-by: Keir Fraser --- xen/arch/x86/hvm/vmx/vmcs.c | 27 +++++++++++++++++++++++---- xen/include/asm-x86/hvm/vmx/vmx.h | 2 +- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index 97e65c54a3..7056251c9e 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -267,7 +267,7 @@ static void vmx_load_vmcs(struct vcpu *v) int vmx_cpu_up(void) { u32 eax, edx; - int cpu = smp_processor_id(); + int bios_locked, cpu = smp_processor_id(); u64 cr0, vmx_cr0_fixed0, vmx_cr0_fixed1; BUG_ON(!(read_cr4() & X86_CR4_VMXE)); @@ -288,7 +288,8 @@ int vmx_cpu_up(void) rdmsr(IA32_FEATURE_CONTROL_MSR, eax, edx); - if ( eax & IA32_FEATURE_CONTROL_MSR_LOCK ) + bios_locked = !!(eax & IA32_FEATURE_CONTROL_MSR_LOCK); + if ( bios_locked ) { if ( !(eax & (IA32_FEATURE_CONTROL_MSR_ENABLE_VMXON_OUTSIDE_SMX | IA32_FEATURE_CONTROL_MSR_ENABLE_VMXON_INSIDE_SMX)) ) @@ -320,10 +321,28 @@ int vmx_cpu_up(void) } } - if ( __vmxon(virt_to_maddr(this_cpu(host_vmcs))) ) + switch ( __vmxon(virt_to_maddr(this_cpu(host_vmcs))) ) { - printk("CPU%d: VMXON failed\n", cpu); + case -2: /* #UD or #GP */ + if ( bios_locked && + test_bit(X86_FEATURE_SMXE, &boot_cpu_data.x86_capability) && + (!(eax & IA32_FEATURE_CONTROL_MSR_ENABLE_VMXON_OUTSIDE_SMX) || + !(eax & IA32_FEATURE_CONTROL_MSR_ENABLE_VMXON_INSIDE_SMX)) ) + { + printk("CPU%d: VMXON failed: perhaps because of TXT settings " + "in your BIOS configuration?\n", cpu); + printk(" --> Disable TXT in your BIOS unless using a secure " + "bootloader.\n"); + return 0; + } + /* fall through */ + case -1: /* CF==1 or ZF==1 */ + printk("CPU%d: unexpected VMXON failure\n", cpu); return 0; + case 0: /* success */ + break; + default: + BUG(); } ept_sync_all(); diff --git a/xen/include/asm-x86/hvm/vmx/vmx.h b/xen/include/asm-x86/hvm/vmx/vmx.h index 0e381f7e1d..35f7aa76fc 100644 --- a/xen/include/asm-x86/hvm/vmx/vmx.h +++ b/xen/include/asm-x86/hvm/vmx/vmx.h @@ -334,7 +334,7 @@ static inline int __vmxon(u64 addr) " setna %b0 ; neg %0\n" /* CF==1 or ZF==1 --> rc = -1 */ "2:\n" ".section .fixup,\"ax\"\n" - "3: not %0 ; jmp 2b\n" /* #UD --> rc = -1 */ + "3: sub $2,%0 ; jmp 2b\n" /* #UD or #GP --> rc = -2 */ ".previous\n" ".section __ex_table,\"a\"\n" " "__FIXUP_ALIGN"\n" -- 2.30.2