[PATCH kvm-unit-tests 4/4] VMX: move execution control setup to setup_ept

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
---
 x86/vmx_tests.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index a61c9f2..4b3fc0e 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -943,6 +943,7 @@ static int setup_ept(bool enable_ad)
 {
 	int support_2m;
 	unsigned long end_of_memory;
+	u32 ctrl_cpu[2];
 
 	if (!(ept_vpid.val & EPT_CAP_UC) &&
 			!(ept_vpid.val & EPT_CAP_WB)) {
@@ -958,6 +959,14 @@ static int setup_ept(bool enable_ad)
 		printf("\tPWL4 is not supported\n");
 		return 1;
 	}
+	ctrl_cpu[0] = vmcs_read(CPU_EXEC_CTRL0);
+	ctrl_cpu[1] = vmcs_read(CPU_EXEC_CTRL1);
+	ctrl_cpu[0] = (ctrl_cpu[0] | CPU_SECONDARY)
+		& ctrl_cpu_rev[0].clr;
+	ctrl_cpu[1] = (ctrl_cpu[1] | CPU_EPT)
+		& ctrl_cpu_rev[1].clr;
+	vmcs_write(CPU_EXEC_CTRL0, ctrl_cpu[0]);
+	vmcs_write(CPU_EXEC_CTRL1, ctrl_cpu[1]);
 	eptp |= (3 << EPTP_PG_WALK_LEN_SHIFT);
 	pml4 = alloc_page();
 	memset(pml4, 0, PAGE_SIZE);
@@ -982,22 +991,12 @@ static int apic_version;
 
 static int ept_init_common(bool have_ad)
 {
-	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 VMX_TEST_EXIT;
 	}
 
-	ctrl_cpu[0] = vmcs_read(CPU_EXEC_CTRL0);
-	ctrl_cpu[1] = vmcs_read(CPU_EXEC_CTRL1);
-	ctrl_cpu[0] = (ctrl_cpu[0] | CPU_SECONDARY)
-		& ctrl_cpu_rev[0].clr;
-	ctrl_cpu[1] = (ctrl_cpu[1] | CPU_EPT)
-		& ctrl_cpu_rev[1].clr;
-	vmcs_write(CPU_EXEC_CTRL0, ctrl_cpu[0]);
-	vmcs_write(CPU_EXEC_CTRL1, ctrl_cpu[1]);
 	if (setup_ept(have_ad))
 		return VMX_TEST_EXIT;
 	data_page1 = alloc_page();
-- 
1.8.3.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux