All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH 0/6] x86: nVMX: Unrestricted guest fix and cleanups
@ 2021-02-18  0:22 Sean Christopherson
  2021-02-18  0:22 ` [kvm-unit-tests PATCH 1/6] x86: nVMX: Verify unrestricted guest is supported in segment tests Sean Christopherson
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Sean Christopherson @ 2021-02-18  0:22 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, Krish Sadhukhan, Sean Christopherson

Two fixes to skip (sub)tests that rely on unrestricted guest if URG isn't
supported, clean ups for related code to make triaging test failures a bit
easier. Ideally, even more info would be provided on failure, e.g. line
number, but that'd best be done as a (much) larger overhaul.

Sean Christopherson (6):
  x86: nVMX: Verify unrestricted guest is supported in segment tests
  x86: nVMX: Skip unrestricted guest (URG) test if URG isn't supported
  x86: nVMX: Improve report messages for segment selector tests
  x86: nVMX: Improve report messages for segment base tests
  x86: nVMX: Use more descriptive name for GDT/IDT limit tests
  x86: nVMX: Add an equals sign to show value assoc. in
    test_guest_state()

 x86/vmx_tests.c | 157 ++++++++++++++++++++++++------------------------
 1 file changed, 77 insertions(+), 80 deletions(-)

-- 
2.30.0.478.g8a0d178c01-goog


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

* [kvm-unit-tests PATCH 1/6] x86: nVMX: Verify unrestricted guest is supported in segment tests
  2021-02-18  0:22 [kvm-unit-tests PATCH 0/6] x86: nVMX: Unrestricted guest fix and cleanups Sean Christopherson
@ 2021-02-18  0:22 ` Sean Christopherson
  2021-02-18  0:22 ` [kvm-unit-tests PATCH 2/6] x86: nVMX: Skip unrestricted guest (URG) test if URG isn't supported Sean Christopherson
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sean Christopherson @ 2021-02-18  0:22 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, Krish Sadhukhan, Sean Christopherson

Enhance enable_unrestricted_guest() to allow configuring a fully valid
EPT tree, and use the updated helper to verify unrestricted guest can be
enabled before testing SS segment properties that are specific to
unrestricted guest.

Fixes: 7820ac5 ("nVMX: Test Selector and Base Address fields of Guest Segment Registers on vmentry of nested guests")
Cc: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 x86/vmx_tests.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index da17b51..cf42619 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -1101,14 +1101,17 @@ static void setup_dummy_ept(void)
 		report_abort("EPT setup unexpectedly failed");
 }
 
-static int enable_unrestricted_guest(void)
+static int enable_unrestricted_guest(bool need_valid_ept)
 {
 	if (!(ctrl_cpu_rev[0].clr & CPU_SECONDARY) ||
 	    !(ctrl_cpu_rev[1].clr & CPU_URG) ||
 	    !(ctrl_cpu_rev[1].clr & CPU_EPT))
 		return 1;
 
-	setup_dummy_ept();
+	if (need_valid_ept)
+		setup_ept(false);
+	else
+		setup_dummy_ept();
 
 	vmcs_write(CPU_EXEC_CTRL0, vmcs_read(CPU_EXEC_CTRL0) | CPU_SECONDARY);
 	vmcs_write(CPU_EXEC_CTRL1, vmcs_read(CPU_EXEC_CTRL1) | CPU_URG);
@@ -4347,7 +4350,7 @@ static void test_invalid_event_injection(void)
 	test_vmx_valid_controls();
 	report_prefix_pop();
 
-	if (enable_unrestricted_guest())
+	if (enable_unrestricted_guest(false))
 		goto skip_unrestricted_guest;
 
 	ent_intr_info = ent_intr_info_base | INTR_INFO_DELIVER_CODE_MASK |
@@ -8059,12 +8062,13 @@ static void test_guest_segment_sel_fields(void)
 				 ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3)));
 	TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS",
 				 ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3)));
+	vmcs_write(CPU_EXEC_CTRL0, cpu_ctrl0_saved);
+	vmcs_write(CPU_EXEC_CTRL1, cpu_ctrl1_saved);
+
+	/* Need a valid EPTP as the passing case fully enters the guest. */
+	if (enable_unrestricted_guest(true))
+		goto skip_ss_tests;
 
-	/* Turn on "unrestricted guest" vm-execution control */
-	vmcs_write(CPU_EXEC_CTRL0, cpu_ctrl0_saved | CPU_SECONDARY);
-	vmcs_write(CPU_EXEC_CTRL1, cpu_ctrl1_saved | CPU_URG);
-	/* EPT and EPTP must be setup when "unrestricted guest" is on */
-	setup_ept(false);
 	TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS",
 				 ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3)));
 	TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS",
@@ -8078,6 +8082,7 @@ static void test_guest_segment_sel_fields(void)
 				 ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3)));
 	TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS",
 				 ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3)));
+skip_ss_tests:
 
 	vmcs_write(GUEST_AR_SS, ar_saved);
 	vmcs_write(GUEST_SEL_SS, sel_saved);
-- 
2.30.0.478.g8a0d178c01-goog


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

* [kvm-unit-tests PATCH 2/6] x86: nVMX: Skip unrestricted guest (URG) test if URG isn't supported
  2021-02-18  0:22 [kvm-unit-tests PATCH 0/6] x86: nVMX: Unrestricted guest fix and cleanups Sean Christopherson
  2021-02-18  0:22 ` [kvm-unit-tests PATCH 1/6] x86: nVMX: Verify unrestricted guest is supported in segment tests Sean Christopherson
@ 2021-02-18  0:22 ` Sean Christopherson
  2021-02-18  0:22 ` [kvm-unit-tests PATCH 3/6] x86: nVMX: Improve report messages for segment selector tests Sean Christopherson
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sean Christopherson @ 2021-02-18  0:22 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, Krish Sadhukhan, Sean Christopherson

Use the enable_unrestricted_guest() helper to enable URG and bail if it
URG isn't supported.  EPT is also required for URG, but EPT can be
enabled independent of URG, and some hardware support EPT but not URG,
e.g. NHM.

Fixes: f441716 ("nVMX: Test vmentry of unrestricted (PG=0/PE=1) nested guest")
Cc: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 x86/vmx_tests.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index cf42619..35463b6 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -8266,12 +8266,14 @@ static void unsetup_unrestricted_guest(void)
  */
 static void vmentry_unrestricted_guest_test(void)
 {
+	if (enable_unrestricted_guest(true)) {
+		report_skip("Unrestricted guest not supported");
+		return;
+	}
+
 	test_set_guest(unrestricted_guest_main);
 	setup_unrestricted_guest();
-	if (setup_ept(false))
-		test_skip("EPT not supported");
-       vmcs_write(CPU_EXEC_CTRL1, vmcs_read(CPU_EXEC_CTRL1) | CPU_URG);
-       test_guest_state("Unrestricted guest test", false, CPU_URG, "CPU_URG");
+	test_guest_state("Unrestricted guest test", false, CPU_URG, "CPU_URG");
 
 	/*
 	 * Let the guest finish execution as a regular guest
-- 
2.30.0.478.g8a0d178c01-goog


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

* [kvm-unit-tests PATCH 3/6] x86: nVMX: Improve report messages for segment selector tests
  2021-02-18  0:22 [kvm-unit-tests PATCH 0/6] x86: nVMX: Unrestricted guest fix and cleanups Sean Christopherson
  2021-02-18  0:22 ` [kvm-unit-tests PATCH 1/6] x86: nVMX: Verify unrestricted guest is supported in segment tests Sean Christopherson
  2021-02-18  0:22 ` [kvm-unit-tests PATCH 2/6] x86: nVMX: Skip unrestricted guest (URG) test if URG isn't supported Sean Christopherson
@ 2021-02-18  0:22 ` Sean Christopherson
  2021-02-18  0:22 ` [kvm-unit-tests PATCH 4/6] x86: nVMX: Improve report messages for segment base tests Sean Christopherson
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sean Christopherson @ 2021-02-18  0:22 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, Krish Sadhukhan, Sean Christopherson

Tweak the segment selector tests to clarify if they are testing a valid
versus invalid condition, display the actual condition, and stringify
the name of the field instead of copy-pasting the field name into a
string.

Opportunistically wrap the complex macro in a do-while.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 x86/vmx_tests.c | 57 ++++++++++++++++++++++---------------------------
 1 file changed, 26 insertions(+), 31 deletions(-)

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 35463b6..4ea2624 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -7985,10 +7985,19 @@ static void test_load_guest_bndcfgs(void)
 
 #define	GUEST_SEG_UNUSABLE_MASK	(1u << 16)
 #define	GUEST_SEG_SEL_TI_MASK	(1u << 2)
-#define	TEST_SEGMENT_SEL(xfail, sel, sel_name, val)			\
+
+
+#define	TEST_SEGMENT_SEL(test, xfail, sel, val)				\
+do {									\
 	vmcs_write(sel, val);						\
-	test_guest_state("Test Guest Segment Selector",	xfail, val,	\
-			 sel_name);
+	test_guest_state(test " segment", xfail, val, xstr(sel));	\
+} while (0)
+
+#define	TEST_INVALID_SEG_SEL(sel, val) \
+	TEST_SEGMENT_SEL("Invalid: " xstr(val), true, sel, val);
+
+#define	TEST_VALID_SEG_SEL(sel, val) \
+	TEST_SEGMENT_SEL("Valid: " xstr(val), false, sel, val);
 
 /*
  * The following checks are done on the Selector field of the Guest Segment
@@ -8013,8 +8022,7 @@ static void test_guest_segment_sel_fields(void)
 	 * Test for GUEST_SEL_TR
 	 */
 	sel_saved = vmcs_read(GUEST_SEL_TR);
-	TEST_SEGMENT_SEL(true, GUEST_SEL_TR, "GUEST_SEL_TR",
-			 sel_saved | GUEST_SEG_SEL_TI_MASK);
+	TEST_INVALID_SEG_SEL(GUEST_SEL_TR, sel_saved | GUEST_SEG_SEL_TI_MASK);
 	vmcs_write(GUEST_SEL_TR, sel_saved);
 
 	/*
@@ -8024,17 +8032,13 @@ static void test_guest_segment_sel_fields(void)
 	ar_saved = vmcs_read(GUEST_AR_LDTR);
 	/* LDTR is set unusable */
 	vmcs_write(GUEST_AR_LDTR, ar_saved | GUEST_SEG_UNUSABLE_MASK);
-	TEST_SEGMENT_SEL(false, GUEST_SEL_LDTR, "GUEST_SEL_LDTR",
-			 sel_saved | GUEST_SEG_SEL_TI_MASK);
-	TEST_SEGMENT_SEL(false, GUEST_SEL_LDTR, "GUEST_SEL_LDTR",
-			 sel_saved & ~GUEST_SEG_SEL_TI_MASK);
+	TEST_VALID_SEG_SEL(GUEST_SEL_LDTR, sel_saved | GUEST_SEG_SEL_TI_MASK);
+	TEST_VALID_SEG_SEL(GUEST_SEL_LDTR, sel_saved & ~GUEST_SEG_SEL_TI_MASK);
 	/* LDTR is set usable */
 	vmcs_write(GUEST_AR_LDTR, ar_saved & ~GUEST_SEG_UNUSABLE_MASK);
-	TEST_SEGMENT_SEL(true, GUEST_SEL_LDTR, "GUEST_SEL_LDTR",
-			 sel_saved | GUEST_SEG_SEL_TI_MASK);
+	TEST_INVALID_SEG_SEL(GUEST_SEL_LDTR, sel_saved | GUEST_SEG_SEL_TI_MASK);
 
-	TEST_SEGMENT_SEL(false, GUEST_SEL_LDTR, "GUEST_SEL_LDTR",
-			 sel_saved & ~GUEST_SEG_SEL_TI_MASK);
+	TEST_VALID_SEG_SEL(GUEST_SEL_LDTR, sel_saved & ~GUEST_SEG_SEL_TI_MASK);
 
 	vmcs_write(GUEST_AR_LDTR, ar_saved);
 	vmcs_write(GUEST_SEL_LDTR, sel_saved);
@@ -8049,39 +8053,30 @@ static void test_guest_segment_sel_fields(void)
 	vmcs_write(CPU_EXEC_CTRL1, cpu_ctrl1_saved & ~CPU_URG);
 	cs_rpl_bits = vmcs_read(GUEST_SEL_CS) & 0x3;
 	sel_saved = vmcs_read(GUEST_SEL_SS);
-	TEST_SEGMENT_SEL(true, GUEST_SEL_SS, "GUEST_SEL_SS",
-				 ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3)));
-	TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS",
-				 ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3)));
+	TEST_INVALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3)));
+	TEST_VALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3)));
 	/* Make SS usable if it's unusable or vice-versa */
 	if (ar_saved & GUEST_SEG_UNUSABLE_MASK)
 		vmcs_write(GUEST_AR_SS, ar_saved & ~GUEST_SEG_UNUSABLE_MASK);
 	else
 		vmcs_write(GUEST_AR_SS, ar_saved | GUEST_SEG_UNUSABLE_MASK);
-	TEST_SEGMENT_SEL(true, GUEST_SEL_SS, "GUEST_SEL_SS",
-				 ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3)));
-	TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS",
-				 ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3)));
-	vmcs_write(CPU_EXEC_CTRL0, cpu_ctrl0_saved);
-	vmcs_write(CPU_EXEC_CTRL1, cpu_ctrl1_saved);
+	TEST_INVALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3)));
+	TEST_VALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3)));
 
 	/* Need a valid EPTP as the passing case fully enters the guest. */
 	if (enable_unrestricted_guest(true))
 		goto skip_ss_tests;
 
-	TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS",
-				 ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3)));
-	TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS",
-				 ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3)));
+	TEST_VALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3)));
+	TEST_VALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3)));
+
 	/* Make SS usable if it's unusable or vice-versa */
 	if (vmcs_read(GUEST_AR_SS) & GUEST_SEG_UNUSABLE_MASK)
 		vmcs_write(GUEST_AR_SS, ar_saved & ~GUEST_SEG_UNUSABLE_MASK);
 	else
 		vmcs_write(GUEST_AR_SS, ar_saved | GUEST_SEG_UNUSABLE_MASK);
-	TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS",
-				 ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3)));
-	TEST_SEGMENT_SEL(false, GUEST_SEL_SS, "GUEST_SEL_SS",
-				 ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3)));
+	TEST_VALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (~cs_rpl_bits & 0x3)));
+	TEST_VALID_SEG_SEL(GUEST_SEL_SS, ((sel_saved & ~0x3) | (cs_rpl_bits & 0x3)));
 skip_ss_tests:
 
 	vmcs_write(GUEST_AR_SS, ar_saved);
-- 
2.30.0.478.g8a0d178c01-goog


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

* [kvm-unit-tests PATCH 4/6] x86: nVMX: Improve report messages for segment base tests
  2021-02-18  0:22 [kvm-unit-tests PATCH 0/6] x86: nVMX: Unrestricted guest fix and cleanups Sean Christopherson
                   ` (2 preceding siblings ...)
  2021-02-18  0:22 ` [kvm-unit-tests PATCH 3/6] x86: nVMX: Improve report messages for segment selector tests Sean Christopherson
@ 2021-02-18  0:22 ` Sean Christopherson
  2021-02-18  0:22 ` [kvm-unit-tests PATCH 5/6] x86: nVMX: Use more descriptive name for GDT/IDT limit tests Sean Christopherson
  2021-02-18  0:22 ` [kvm-unit-tests PATCH 6/6] x86: nVMX: Add an equals sign to show value assoc. in test_guest_state() Sean Christopherson
  5 siblings, 0 replies; 7+ messages in thread
From: Sean Christopherson @ 2021-02-18  0:22 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, Krish Sadhukhan, Sean Christopherson

Tweak the segment base tests to state exactly what's being tested, note
whether or not the segment is usable, and stringify the name of the field
instead of copy-pasting the field name into a string.

Opportunistically wrap the complex macros in do-while.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 x86/vmx_tests.c | 67 +++++++++++++++++++++++--------------------------
 1 file changed, 31 insertions(+), 36 deletions(-)

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 4ea2624..94ab499 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -8085,22 +8085,26 @@ skip_ss_tests:
 	vmcs_write(CPU_EXEC_CTRL1, cpu_ctrl1_saved);
 }
 
-#define	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(xfail, seg_base, seg_base_name)\
-	addr_saved = vmcs_read(seg_base);				\
-	for (i = 32; i < 63; i = i + 4) {				\
-		addr = addr_saved | 1ull << i;				\
-		vmcs_write(seg_base, addr);				\
-		test_guest_state(seg_base_name,	xfail, addr,		\
-				seg_base_name);				\
-	}								\
-	vmcs_write(seg_base, addr_saved);
+#define	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(xfail, seg_base)			\
+do {										\
+	addr_saved = vmcs_read(seg_base);					\
+	for (i = 32; i < 63; i = i + 4) {					\
+		addr = addr_saved | 1ull << i;					\
+		vmcs_write(seg_base, addr);					\
+		test_guest_state("seg.BASE[63:32] != 0, usable = " xstr(xfail),	\
+				 xfail, addr, xstr(seg_base));			\
+	}									\
+	vmcs_write(seg_base, addr_saved);					\
+} while (0)
 
-#define	TEST_SEGMENT_BASE_ADDR_CANONICAL(xfail, seg_base, seg_base_name)\
-	addr_saved = vmcs_read(seg_base);				\
-	vmcs_write(seg_base, NONCANONICAL);				\
-	test_guest_state(seg_base_name,	xfail, NONCANONICAL,		\
-			seg_base_name);					\
-	vmcs_write(seg_base, addr_saved);
+#define	TEST_SEGMENT_BASE_ADDR_CANONICAL(xfail, seg_base)		  \
+do {									  \
+	addr_saved = vmcs_read(seg_base);				  \
+	vmcs_write(seg_base, NONCANONICAL);				  \
+	test_guest_state("seg.BASE non-canonical, usable = " xstr(xfail), \
+			 xfail, NONCANONICAL, xstr(seg_base));		  \
+	vmcs_write(seg_base, addr_saved);				  \
+} while (0)
 
 /*
  * The following checks are done on the Base Address field of the Guest
@@ -8123,57 +8127,48 @@ static void test_guest_segment_base_addr_fields(void)
 	/*
 	 * The address of TR, FS, GS and LDTR must be canonical.
 	 */
-	TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_TR, "GUEST_BASE_TR");
-	TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_FS, "GUEST_BASE_FS");
-	TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_GS, "GUEST_BASE_GS");
+	TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_TR);
+	TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_FS);
+	TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_GS);
 	ar_saved = vmcs_read(GUEST_AR_LDTR);
 	/* Make LDTR unusable */
 	vmcs_write(GUEST_AR_LDTR, ar_saved | GUEST_SEG_UNUSABLE_MASK);
-	TEST_SEGMENT_BASE_ADDR_CANONICAL(false, GUEST_BASE_LDTR,
-					"GUEST_BASE_LDTR");
+	TEST_SEGMENT_BASE_ADDR_CANONICAL(false, GUEST_BASE_LDTR);
 	/* Make LDTR usable */
 	vmcs_write(GUEST_AR_LDTR, ar_saved & ~GUEST_SEG_UNUSABLE_MASK);
-	TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_LDTR,
-					"GUEST_BASE_LDTR");
+	TEST_SEGMENT_BASE_ADDR_CANONICAL(true, GUEST_BASE_LDTR);
 
 	vmcs_write(GUEST_AR_LDTR, ar_saved);
 
 	/*
 	 * Bits 63:32 in CS, SS, DS and ES base address must be zero
 	 */
-	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_CS,
-					 "GUEST_BASE_CS");
+	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_CS);
 	ar_saved = vmcs_read(GUEST_AR_SS);
 	/* Make SS unusable */
 	vmcs_write(GUEST_AR_SS, ar_saved | GUEST_SEG_UNUSABLE_MASK);
-	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(false, GUEST_BASE_SS,
-					 "GUEST_BASE_SS");
+	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(false, GUEST_BASE_SS);
 	/* Make SS usable */
 	vmcs_write(GUEST_AR_SS, ar_saved & ~GUEST_SEG_UNUSABLE_MASK);
-	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_SS,
-					 "GUEST_BASE_SS");
+	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_SS);
 	vmcs_write(GUEST_AR_SS, ar_saved);
 
 	ar_saved = vmcs_read(GUEST_AR_DS);
 	/* Make DS unusable */
 	vmcs_write(GUEST_AR_DS, ar_saved | GUEST_SEG_UNUSABLE_MASK);
-	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(false, GUEST_BASE_DS,
-					 "GUEST_BASE_DS");
+	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(false, GUEST_BASE_DS);
 	/* Make DS usable */
 	vmcs_write(GUEST_AR_DS, ar_saved & ~GUEST_SEG_UNUSABLE_MASK);
-	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_DS,
-					 "GUEST_BASE_DS");
+	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_DS);
 	vmcs_write(GUEST_AR_DS, ar_saved);
 
 	ar_saved = vmcs_read(GUEST_AR_ES);
 	/* Make ES unusable */
 	vmcs_write(GUEST_AR_ES, ar_saved | GUEST_SEG_UNUSABLE_MASK);
-	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(false, GUEST_BASE_ES,
-					 "GUEST_BASE_ES");
+	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(false, GUEST_BASE_ES);
 	/* Make ES usable */
 	vmcs_write(GUEST_AR_ES, ar_saved & ~GUEST_SEG_UNUSABLE_MASK);
-	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_ES,
-					 "GUEST_BASE_ES");
+	TEST_SEGMENT_BASE_ADDR_UPPER_BITS(true, GUEST_BASE_ES);
 	vmcs_write(GUEST_AR_ES, ar_saved);
 }
 
-- 
2.30.0.478.g8a0d178c01-goog


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

* [kvm-unit-tests PATCH 5/6] x86: nVMX: Use more descriptive name for GDT/IDT limit tests
  2021-02-18  0:22 [kvm-unit-tests PATCH 0/6] x86: nVMX: Unrestricted guest fix and cleanups Sean Christopherson
                   ` (3 preceding siblings ...)
  2021-02-18  0:22 ` [kvm-unit-tests PATCH 4/6] x86: nVMX: Improve report messages for segment base tests Sean Christopherson
@ 2021-02-18  0:22 ` Sean Christopherson
  2021-02-18  0:22 ` [kvm-unit-tests PATCH 6/6] x86: nVMX: Add an equals sign to show value assoc. in test_guest_state() Sean Christopherson
  5 siblings, 0 replies; 7+ messages in thread
From: Sean Christopherson @ 2021-02-18  0:22 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, Krish Sadhukhan, Sean Christopherson

Explicitly state that the invalid limit tests are testing a limit
greater than 0xffff.  Simply stating the field name is not helpful since
it's already printed on failure.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 x86/vmx_tests.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 94ab499..1097a53 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -8205,7 +8205,7 @@ static void vmx_guest_state_area_test(void)
 	for (i = 16; i <= 31; i++) {
 		u32 tmp = guest_desc_limit_saved | (1ull << i);
 		vmcs_write(GUEST_LIMIT_GDTR, tmp);
-		test_guest_state("GUEST_LIMIT_GDTR", true, tmp, "GUEST_LIMIT_GDTR");
+		test_guest_state("GDT.limit > 0xffff", true, tmp, "GUEST_LIMIT_GDTR");
 	}
 	vmcs_write(GUEST_LIMIT_GDTR, guest_desc_limit_saved);
 
@@ -8213,7 +8213,7 @@ static void vmx_guest_state_area_test(void)
 	for (i = 16; i <= 31; i++) {
 		u32 tmp = guest_desc_limit_saved | (1ull << i);
 		vmcs_write(GUEST_LIMIT_IDTR, tmp);
-		test_guest_state("GUEST_LIMIT_IDTR", true, tmp, "GUEST_LIMIT_IDTR");
+		test_guest_state("IDT.limit > 0xffff", true, tmp, "GUEST_LIMIT_IDTR");
 	}
 	vmcs_write(GUEST_LIMIT_IDTR, guest_desc_limit_saved);
 
-- 
2.30.0.478.g8a0d178c01-goog


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

* [kvm-unit-tests PATCH 6/6] x86: nVMX: Add an equals sign to show value assoc. in test_guest_state()
  2021-02-18  0:22 [kvm-unit-tests PATCH 0/6] x86: nVMX: Unrestricted guest fix and cleanups Sean Christopherson
                   ` (4 preceding siblings ...)
  2021-02-18  0:22 ` [kvm-unit-tests PATCH 5/6] x86: nVMX: Use more descriptive name for GDT/IDT limit tests Sean Christopherson
@ 2021-02-18  0:22 ` Sean Christopherson
  5 siblings, 0 replies; 7+ messages in thread
From: Sean Christopherson @ 2021-02-18  0:22 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, Krish Sadhukhan, Sean Christopherson

Insert "=" between the field name and its value when reporting a failure
in test_guest_state() to make it obvious that the number is the value of
the field.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 x86/vmx_tests.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 1097a53..f9883f0 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -5556,7 +5556,7 @@ static void test_guest_state(const char *test, bool xfail, u64 field,
 	       ((xfail && result.exit_reason.basic == VMX_FAIL_STATE) ||
 	        (!xfail && result.exit_reason.basic == VMX_VMCALL)) &&
 		(!xfail || vmcs_read(EXI_QUALIFICATION) == ENTRY_FAIL_DEFAULT),
-	        "%s, %s %lx", test, field_name, field);
+	        "%s, %s = %lx", test, field_name, field);
 
 	if (!result.exit_reason.failed_vmentry)
 		skip_exit_insn();
-- 
2.30.0.478.g8a0d178c01-goog


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

end of thread, other threads:[~2021-02-18  0:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-18  0:22 [kvm-unit-tests PATCH 0/6] x86: nVMX: Unrestricted guest fix and cleanups Sean Christopherson
2021-02-18  0:22 ` [kvm-unit-tests PATCH 1/6] x86: nVMX: Verify unrestricted guest is supported in segment tests Sean Christopherson
2021-02-18  0:22 ` [kvm-unit-tests PATCH 2/6] x86: nVMX: Skip unrestricted guest (URG) test if URG isn't supported Sean Christopherson
2021-02-18  0:22 ` [kvm-unit-tests PATCH 3/6] x86: nVMX: Improve report messages for segment selector tests Sean Christopherson
2021-02-18  0:22 ` [kvm-unit-tests PATCH 4/6] x86: nVMX: Improve report messages for segment base tests Sean Christopherson
2021-02-18  0:22 ` [kvm-unit-tests PATCH 5/6] x86: nVMX: Use more descriptive name for GDT/IDT limit tests Sean Christopherson
2021-02-18  0:22 ` [kvm-unit-tests PATCH 6/6] x86: nVMX: Add an equals sign to show value assoc. in test_guest_state() Sean Christopherson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.