Skip to contentSkip to conversation

x86: nVMX: Unrestricted guest fix and cleanups

PATCH New Sean Christopherson 1 participant 7 messages Feb 18, 2021 KVM

lore
Share & tools
lore

Sean Christopherson

author reviewer
#0 lore raw

cover x86: nVMX: Unrestricted guest fix and cleanups

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(-)
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
author reviewer
#1 lore raw

PATCH 1/6 x86: nVMX: Verify unrestricted guest is supported in segment tests

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 <[email protected]>
---
 x86/vmx_tests.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
x86/vmx_tests.c +13 -8
index da17b51..cf42619 100644
@@ -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);
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
author reviewer
#2 lore raw

PATCH 2/6 x86: nVMX: Skip unrestricted guest (URG) test if URG isn't supported

In reply to 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 <[email protected]>
---
 x86/vmx_tests.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
x86/vmx_tests.c +6 -4
index cf42619..35463b6 100644
@@ -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
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
author reviewer
#3 lore raw

PATCH 3/6 x86: nVMX: Improve report messages for segment selector tests

In reply to 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.

---
 x86/vmx_tests.c | 57 ++++++++++++++++++++++---------------------------
 1 file changed, 26 insertions(+), 31 deletions(-)
x86/vmx_tests.c +26 -31
index 35463b6..4ea2624 100644
@@ -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);
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
author reviewer
#4 lore raw

PATCH 4/6 x86: nVMX: Improve report messages for segment base tests

In reply to 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.

---
 x86/vmx_tests.c | 67 +++++++++++++++++++++++--------------------------
 1 file changed, 31 insertions(+), 36 deletions(-)
x86/vmx_tests.c +31 -36
index 4ea2624..94ab499 100644
@@ -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);
 }
 
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
author reviewer
#5 lore raw

PATCH 5/6 x86: nVMX: Use more descriptive name for GDT/IDT limit tests

In reply to 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.

---
 x86/vmx_tests.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
x86/vmx_tests.c +2 -2
index 94ab499..1097a53 100644
@@ -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);
 
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
author reviewer
#6 lore raw

PATCH 6/6 x86: nVMX: Add an equals sign to show value assoc. in test_guest_state()

In reply to 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.

---
 x86/vmx_tests.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
x86/vmx_tests.c +1 -1
index 1097a53..f9883f0 100644
@@ -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();
Signature · 1 line
2.30.0.478.g8a0d178c01-goog