diff mbox series

[kvm-unit-tests,2/6] x86: nVMX: Skip unrestricted guest (URG) test if URG isn't supported

Message ID 20210218002212.2904647-3-seanjc@google.com (mailing list archive)
State New, archived
Headers show
Series x86: nVMX: Unrestricted guest fix and cleanups | expand

Commit Message

Sean Christopherson Feb. 18, 2021, 12:22 a.m. UTC
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 mbox series

Patch

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