From: Krish Sadhukhan <krish.sadhukhan@oracle.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com, jmattson@google.com
Subject: [PATCH 1/4] kvm-unit-test: VMX: Replace hard-coded exit instruction length
Date: Mon, 14 Oct 2019 20:16:30 -0400 [thread overview]
Message-ID: <20191015001633.8603-2-krish.sadhukhan@oracle.com> (raw)
In-Reply-To: <20191015001633.8603-1-krish.sadhukhan@oracle.com>
..with value read from EXI_INST_LEN field.
Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Reviewed-by: Liran Alon <liran.alon@oracle.com>
Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com>
---
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
next prev parent reply other threads:[~2019-10-15 0:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-15 0:16 [PATCH 0/4]: kvm-unit-test: nVMX: Test deferring of error from VM-entry MSR-load area Krish Sadhukhan
2019-10-15 0:16 ` Krish Sadhukhan [this message]
2019-10-16 16:39 ` [PATCH 1/4] kvm-unit-test: VMX: Replace hard-coded exit instruction length Jim Mattson
2019-10-15 0:16 ` [PATCH 2/4] kvm-unit-test: nVMX: __enter_guest() needs to also check for VMX_FAIL_STATE Krish Sadhukhan
2019-10-16 17:55 ` Jim Mattson
2019-10-17 18:24 ` Sean Christopherson
2019-10-15 0:16 ` [PATCH 3/4] kvm-unit-test: nVMX: Test deferring of error from VM-entry MSR-load area Krish Sadhukhan
2019-10-15 0:16 ` [PATCH 4/4] kvm-unit-test: nVMX: Use #defines for exit reason in advance_guest_state_test() Krish Sadhukhan
2019-10-16 17:51 ` Jim Mattson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191015001633.8603-2-krish.sadhukhan@oracle.com \
--to=krish.sadhukhan@oracle.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).