diff mbox

[kvm-unit-tests,26/32] x86: setup_ept code motion

Message ID 20170421005004.137260-27-dmatlack@google.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Matlack April 21, 2017, 12:49 a.m. UTC
From: Peter Feiner <pfeiner@google.com>

Signed-off-by: Peter Feiner <pfeiner@google.com>
Signed-off-by: David Matlack <dmatlack@google.com>
---
 x86/vmx_tests.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 5758b6becfa6..be01709d3057 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -940,12 +940,20 @@  static int insn_intercept_exit_handler()
 }
 
 
+/* Enables EPT and sets up the identity map. */
 static int setup_ept(bool enable_ad)
 {
 	int support_2m;
 	unsigned long end_of_memory;
 	u32 ctrl_cpu[2];
 
+	if (!(ctrl_cpu_rev[0].clr & CPU_SECONDARY) ||
+	    !(ctrl_cpu_rev[1].clr & CPU_EPT)) {
+		printf("\tEPT is not supported");
+		return 1;
+	}
+
+
 	if (!(ept_vpid.val & EPT_CAP_UC) &&
 			!(ept_vpid.val & EPT_CAP_WB)) {
 		printf("\tEPT paging-structure memory type "
@@ -992,12 +1000,6 @@  static int apic_version;
 
 static int ept_init_common(bool have_ad)
 {
-	if (!(ctrl_cpu_rev[0].clr & CPU_SECONDARY) ||
-	    !(ctrl_cpu_rev[1].clr & CPU_EPT)) {
-		printf("\tEPT is not supported");
-		return VMX_TEST_EXIT;
-	}
-
 	if (setup_ept(have_ad))
 		return VMX_TEST_EXIT;
 	data_page1 = alloc_page();