public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH kvm-unit-test] x86: vmx: Check #UD triggering of vmmcall
@ 2015-03-09 20:00 Jan Kiszka
  2015-03-13 16:49 ` Marcelo Tosatti
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2015-03-09 20:00 UTC (permalink / raw)
  To: kvm, Paolo Bonzini, Marcelo Tosatti

KVM tends to patch and emulated vmmcall on Intel. But that must not
happen for L2.

Signed-off-by: Jan Kiszka <jan.kiszka@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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH kvm-unit-test] x86: vmx: Check #UD triggering of vmmcall
  2015-03-09 20:00 [PATCH kvm-unit-test] x86: vmx: Check #UD triggering of vmmcall Jan Kiszka
@ 2015-03-13 16:49 ` Marcelo Tosatti
  0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2015-03-13 16:49 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: kvm, Paolo Bonzini

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.kiszka@siemens.com>

Applied, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-13 18:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-09 20:00 [PATCH kvm-unit-test] x86: vmx: Check #UD triggering of vmmcall Jan Kiszka
2015-03-13 16:49 ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox