[xen-3.2-testing] vmx: Better diagnostic messages when VMXON might have failed due to

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen-3.2-testing] vmx: Better diagnostic messages when VMXON might have failed due to

Xen patchbot-3.2-testing
# HG changeset patch
# User Keir Fraser <[hidden email]>
# Date 1212400747 -3600
# Node ID 5aff4284c43cfea52a95059d8287274019afccce
# Parent  0b5bd01884070054e12817a36b5fc071009011e4
vmx: Better diagnostic messages when VMXON might have failed due to
bad setting of the IA32_FEATURE_CONTROL MSR.
Signed-off-by: Keir Fraser <[hidden email]>
xen-unstable changeset:   17769:a4775034ef83946803eb6a61e0af33fb6971123f
xen-unstable date:        Mon Jun 02 10:55:55 2008 +0100
---
 xen/arch/x86/hvm/vmx/vmcs.c       |   29 ++++++++++++++++++++++++-----
 xen/include/asm-x86/hvm/vmx/vmx.h |    2 +-
 2 files changed, 25 insertions(+), 6 deletions(-)

diff -r 0b5bd0188407 -r 5aff4284c43c xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c Sun Jun 01 09:29:24 2008 +0100
+++ b/xen/arch/x86/hvm/vmx/vmcs.c Mon Jun 02 10:59:07 2008 +0100
@@ -244,7 +244,7 @@ int vmx_cpu_up(void)
 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));
@@ -265,7 +265,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)) )
@@ -297,10 +298,28 @@ int vmx_cpu_up(void)
         }
     }
 
-    if ( __vmxon(virt_to_maddr(this_cpu(host_vmcs))) )
-    {
-        printk("CPU%d: VMXON failed\n", cpu);
+    switch ( __vmxon(virt_to_maddr(this_cpu(host_vmcs))) )
+    {
+    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();
     }
 
     return 1;
diff -r 0b5bd0188407 -r 5aff4284c43c xen/include/asm-x86/hvm/vmx/vmx.h
--- a/xen/include/asm-x86/hvm/vmx/vmx.h Sun Jun 01 09:29:24 2008 +0100
+++ b/xen/include/asm-x86/hvm/vmx/vmx.h Mon Jun 02 10:59:07 2008 +0100
@@ -259,7 +259,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"

_______________________________________________
Xen-changelog mailing list
[hidden email]
http://lists.xensource.com/xen-changelog