..with value read from EXI_INST_LEN field. Signed-off-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx> Reviewed-by: Liran Alon <liran.alon@xxxxxxxxxx> Reviewed-by: Karl Heubaum <karl.heubaum@xxxxxxxxxx> --- x86/vmx_tests.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 4aebc3f..7d73ee3 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -87,6 +87,7 @@ static int vmenter_exit_handler(void) { u64 guest_rip; ulong reason; + u32 insn_len = vmcs_read(EXI_INST_LEN); guest_rip = vmcs_read(GUEST_RIP); reason = vmcs_read(EXI_REASON) & 0xff; @@ -97,7 +98,7 @@ static int vmenter_exit_handler(void) return VMX_TEST_VMEXIT; } regs.rax = 0xFFFF; - vmcs_write(GUEST_RIP, guest_rip + 3); + vmcs_write(GUEST_RIP, guest_rip + insn_len); return VMX_TEST_RESUME; default: report("test vmresume", 0); @@ -340,7 +341,9 @@ static int test_ctrl_pat_exit_handler(void) u64 guest_rip; ulong reason; u64 guest_pat; + u32 insn_len; + insn_len = vmcs_read(EXI_INST_LEN); guest_rip = vmcs_read(GUEST_RIP); reason = vmcs_read(EXI_REASON) & 0xff; switch (reason) { @@ -357,7 +360,7 @@ static int test_ctrl_pat_exit_handler(void) else report("Exit load PAT", rdmsr(MSR_IA32_CR_PAT) == ia32_pat); vmcs_write(GUEST_PAT, ia32_pat); - vmcs_write(GUEST_RIP, guest_rip + 3); + vmcs_write(GUEST_RIP, guest_rip + insn_len); return VMX_TEST_RESUME; default: printf("ERROR : Undefined exit reason, reason = %ld.\n", reason); @@ -407,7 +410,9 @@ static int test_ctrl_efer_exit_handler(void) u64 guest_rip; ulong reason; u64 guest_efer; + u32 insn_len; + insn_len = vmcs_read(EXI_INST_LEN); guest_rip = vmcs_read(GUEST_RIP); reason = vmcs_read(EXI_REASON) & 0xff; switch (reason) { @@ -426,7 +431,7 @@ static int test_ctrl_efer_exit_handler(void) report("Exit load EFER", rdmsr(MSR_EFER) == (ia32_efer ^ EFER_NX)); } vmcs_write(GUEST_PAT, ia32_efer); - vmcs_write(GUEST_RIP, guest_rip + 3); + vmcs_write(GUEST_RIP, guest_rip + insn_len); return VMX_TEST_RESUME; default: printf("ERROR : Undefined exit reason, reason = %ld.\n", reason); @@ -2076,6 +2081,11 @@ static void disable_rdtscp_main(void) static int disable_rdtscp_exit_handler(void) { unsigned int reason = vmcs_read(EXI_REASON) & 0xff; + u64 guest_rip; + u32 insn_len; + + guest_rip = vmcs_read(GUEST_RIP); + insn_len = vmcs_read(EXI_INST_LEN); switch (reason) { case VMX_VMCALL: @@ -2086,7 +2096,7 @@ static int disable_rdtscp_exit_handler(void) /* fallthrough */ case 1: vmx_inc_test_stage(); - vmcs_write(GUEST_RIP, vmcs_read(GUEST_RIP) + 3); + vmcs_write(GUEST_RIP, guest_rip + insn_len); return VMX_TEST_RESUME; case 2: report("RDPID triggers #UD", false); -- 2.20.1