Fix VM Guest CPUID emulation to hide VMX
authorGan Shun <ganshun@gmail.com>
Thu, 4 Aug 2016 17:45:14 +0000 (10:45 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 4 Aug 2016 18:00:39 +0000 (11:00 -0700)
We report no VMX capabilities to the VM guest we're running as we don't
currently support nested VMs.

Signed-off-by: Gan Shun <ganshun@gmail.com>
Change-Id: Ie90bea3c255a95df0dad6c9f5b58055431029b02
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/arch/x86/trap.c

index 94fe699..949d3a1 100644 (file)
@@ -896,6 +896,9 @@ static bool handle_vmexit_cpuid(struct vm_trapframe *tf)
                if (tf->tf_rax == 1) {
                        /* Set the hypervisor bit to let the guest know it is virtualized */
                        ecx |= 1 << 31;
+                       /* Unset the vmx capability bit so that the guest does not try
+                        * to turn it on. */
+                       ecx &= ~(1 << 5);
                }
        }
        tf->tf_rax = eax;