Commit c1ec863e authored by Jan Kiszka's avatar Jan Kiszka Committed by Marcelo Tosatti
Browse files

x86: vmx: Check #UD triggering of vmmcall



KVM tends to patch and emulated vmmcall on Intel. But that must not
happen for L2.
Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent a02f9602
......@@ -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} },
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment