Re: [PATCH kvm-unit-test] x86: vmx: Check #UD triggering of vmmcall

2015-03-13 Thread Marcelo Tosatti
On Mon, Mar 09, 2015 at 09:00:11PM +0100, Jan Kiszka wrote:
 KVM tends to patch and emulated vmmcall on Intel. But that must not
 happen for L2.
 
 Signed-off-by: Jan Kiszka jan.kis...@siemens.com

Applied, thanks.

--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH kvm-unit-test] x86: vmx: Check #UD triggering of vmmcall

2015-03-09 Thread Jan Kiszka
KVM tends to patch and emulated vmmcall on Intel. But that must not
happen for L2.

Signed-off-by: Jan Kiszka jan.kis...@siemens.com
---

If the recently posted fixed for KVM are applied, this test passes.

 x86/vmx_tests.c | 40 
 1 file changed, 40 insertions(+)

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 41a9a82..4f8ace1 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -11,6 +11,7 @@
 #include fwcfg.h
 #include isr.h
 #include apic.h
+#include types.h
 
 u64 ia32_pat;
 u64 ia32_efer;
@@ -1493,6 +1494,44 @@ static int msr_switch_exit_handler()
return VMX_TEST_EXIT;
 }
 
+static int vmmcall_init(struct vmcs *vmcs  )
+{
+   vmcs_write(EXC_BITMAP, 1  UD_VECTOR);
+   return VMX_TEST_START;
+}
+
+static void vmmcall_main(void)
+{
+   asm volatile(
+   mov $0xABCD, %%rax\n\t
+   vmmcall\n\t
+   ::: rax);
+
+   report(VMMCALL, 0);
+}
+
+static int vmmcall_exit_handler()
+{
+   ulong reason;
+
+   reason = vmcs_read(EXI_REASON);
+   switch (reason) {
+   case VMX_VMCALL:
+   printf(here\n);
+   report(VMMCALL triggers #UD, 0);
+   break;
+   case VMX_EXC_NMI:
+   report(VMMCALL triggers #UD,
+  (vmcs_read(EXI_INTR_INFO)  0xff) == UD_VECTOR);
+   break;
+   default:
+   printf(Unknown exit reason, %d\n, reason);
+   print_vmexit_info();
+   }
+
+   return VMX_TEST_VMEXIT;
+}
+
 /* name/init/guest_main/exit_handler/syscall_handler/guest_regs */
 struct vmx_test vmx_tests[] = {
{ null, NULL, basic_guest_main, basic_exit_handler, NULL, {0} },
@@ -1516,5 +1555,6 @@ struct vmx_test vmx_tests[] = {
NULL, {0} },
{ MSR switch, msr_switch_init, msr_switch_main,
msr_switch_exit_handler, NULL, {0} },
+   { vmmcall, vmmcall_init, vmmcall_main, vmmcall_exit_handler, NULL, 
{0} },
{ NULL, NULL, NULL, NULL, NULL, {0} },
 };
-- 
2.1.4
--
To unsubscribe from this list: send the line unsubscribe kvm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html