From: Krish Sadhukhan <krish.sadhukhan@oracle.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, jmattson@google.com
Subject: [PATCH 2/4] kvm-unit-test: nVMX: Modify test_canonical() to process guest fields also
Date: Fri, 6 Dec 2019 18:13:00 -0500 [thread overview]
Message-ID: <20191206231302.3466-3-krish.sadhukhan@oracle.com> (raw)
In-Reply-To: <20191206231302.3466-1-krish.sadhukhan@oracle.com>
Signed-off-by: Krish Sadhukhkan <krish.sadhukhan@oracle.com>
Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com>
---
x86/vmx_tests.c | 54 +++++++++++++++++++++++++++++++++++++------------
1 file changed, 41 insertions(+), 13 deletions(-)
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index a456bd1..7905861 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -7232,24 +7232,52 @@ static void test_vmcs_field(u64 field, const char *field_name, u32 bit_start,
vmcs_write(field, field_saved);
}
-static void test_canonical(u64 field, const char * field_name)
+static void test_canonical(u64 field, const char * field_name, bool host)
{
u64 addr_saved = vmcs_read(field);
- report_prefix_pushf("%s %lx", field_name, addr_saved);
if (is_canonical(addr_saved)) {
- test_vmx_vmlaunch(0);
- report_prefix_pop();
+ if (host) {
+ report_prefix_pushf("%s %lx", field_name, addr_saved);
+ test_vmx_vmlaunch(0);
+ report_prefix_pop();
+ } else {
+ enter_guest();
+ report_guest_state_test("%s",
+ VMX_VMCALL, addr_saved,
+ "GUEST_XXXXXXX");
+ }
vmcs_write(field, NONCANONICAL);
- report_prefix_pushf("%s %llx", field_name, NONCANONICAL);
- test_vmx_vmlaunch(VMXERR_ENTRY_INVALID_HOST_STATE_FIELD);
+
+ if (host) {
+ report_prefix_pushf("%s %llx", field_name, NONCANONICAL);
+ test_vmx_vmlaunch(VMXERR_ENTRY_INVALID_HOST_STATE_FIELD);
+ report_prefix_pop();
+ } else {
+ enter_guest_with_invalid_guest_state();
+ report_guest_state_test("ENT_LOAD_PAT "
+ "enabled",
+ VMX_FAIL_STATE | VMX_ENTRY_FAILURE,
+ addr_saved,
+ "GUEST_PAT");
+ }
vmcs_write(field, addr_saved);
} else {
- test_vmx_vmlaunch(VMXERR_ENTRY_INVALID_HOST_STATE_FIELD);
+ if (host) {
+ report_prefix_pushf("%s %llx", field_name, NONCANONICAL);
+ test_vmx_vmlaunch(VMXERR_ENTRY_INVALID_HOST_STATE_FIELD);
+ report_prefix_pop();
+ } else {
+ enter_guest_with_invalid_guest_state();
+ report_guest_state_test("ENT_LOAD_PAT "
+ "enabled",
+ VMX_FAIL_STATE | VMX_ENTRY_FAILURE,
+ addr_saved,
+ "GUEST_PAT");
+ }
}
- report_prefix_pop();
}
#define TEST_RPL_TI_FLAGS(reg, name) \
@@ -7310,9 +7338,9 @@ static void test_host_segment_regs(void)
/*
* Base address for FS, GS and TR must be canonical
*/
- test_canonical(HOST_BASE_FS, "HOST_BASE_FS");
- test_canonical(HOST_BASE_GS, "HOST_BASE_GS");
- test_canonical(HOST_BASE_TR, "HOST_BASE_TR");
+ test_canonical(HOST_BASE_FS, "HOST_BASE_FS", true);
+ test_canonical(HOST_BASE_GS, "HOST_BASE_GS", true);
+ test_canonical(HOST_BASE_TR, "HOST_BASE_TR", true);
#endif
}
@@ -7323,8 +7351,8 @@ static void test_host_segment_regs(void)
static void test_host_desc_tables(void)
{
#ifdef __x86_64__
- test_canonical(HOST_BASE_GDTR, "HOST_BASE_GDTR");
- test_canonical(HOST_BASE_IDTR, "HOST_BASE_IDTR");
+ test_canonical(HOST_BASE_GDTR, "HOST_BASE_GDTR", true);
+ test_canonical(HOST_BASE_IDTR, "HOST_BASE_IDTR", true);
#endif
}
--
2.20.1
next prev parent reply other threads:[~2019-12-06 23:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-06 23:12 [PATCH 0/4] KVM: nVMX: Check GUEST_SYSENTER_ESP and GUEST_SYSENTER_EIP on vmentry of nested guests Krish Sadhukhan
2019-12-06 23:12 ` [PATCH 1/4] " Krish Sadhukhan
2019-12-10 17:30 ` Paolo Bonzini
2019-12-10 17:57 ` Jim Mattson
2019-12-10 19:35 ` Krish Sadhukhan
2019-12-10 19:48 ` Jim Mattson
2019-12-10 20:29 ` Krish Sadhukhan
2019-12-10 20:36 ` Paolo Bonzini
2019-12-06 23:13 ` Krish Sadhukhan [this message]
2019-12-06 23:13 ` [PATCH 3/4] kvm-unit-test: nVMX: Remove test_sysenter_field() and use test_canonical() instead Krish Sadhukhan
2019-12-06 23:13 ` [PATCH 4/4] kvm-unit-test: nVMX: Test GUEST_SYSENTER_ESP and GUEST_SYSENTER_EIP on vmentry of nested guests Krish Sadhukhan
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=20191206231302.3466-3-krish.sadhukhan@oracle.com \
--to=krish.sadhukhan@oracle.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@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