diff mbox series

[kvm-unit-tests,1/8] x86: vmx: Refactor init of VMX caps to separate function

Message ID 20190919125211.18152-2-liran.alon@oracle.com (mailing list archive)
State New, archived
Headers show
Series : x86: vmx: Test INIT processing in various CPU VMX states | expand

Commit Message

Liran Alon Sept. 19, 2019, 12:52 p.m. UTC
This is done as a preparation to future patches that will
introduce ability to run VMX on CPUs other than BSP.

Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
---
 x86/vmx.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/x86/vmx.c b/x86/vmx.c
index 6079420db33a..d74365049eeb 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -1247,19 +1247,8 @@  static int init_vmcs(struct vmcs **vmcs)
 	return 0;
 }
 
-static void init_vmx(void)
+static void init_vmx_caps(void)
 {
-	ulong fix_cr0_set, fix_cr0_clr;
-	ulong fix_cr4_set, fix_cr4_clr;
-
-	vmxon_region = alloc_page();
-
-	vmcs_root = alloc_page();
-
-	fix_cr0_set =  rdmsr(MSR_IA32_VMX_CR0_FIXED0);
-	fix_cr0_clr =  rdmsr(MSR_IA32_VMX_CR0_FIXED1);
-	fix_cr4_set =  rdmsr(MSR_IA32_VMX_CR4_FIXED0);
-	fix_cr4_clr = rdmsr(MSR_IA32_VMX_CR4_FIXED1);
 	basic.val = rdmsr(MSR_IA32_VMX_BASIC);
 	ctrl_pin_rev.val = rdmsr(basic.ctrl ? MSR_IA32_VMX_TRUE_PIN
 			: MSR_IA32_VMX_PINBASED_CTLS);
@@ -1277,6 +1266,23 @@  static void init_vmx(void)
 		ept_vpid.val = rdmsr(MSR_IA32_VMX_EPT_VPID_CAP);
 	else
 		ept_vpid.val = 0;
+}
+
+static void init_vmx(void)
+{
+	ulong fix_cr0_set, fix_cr0_clr;
+	ulong fix_cr4_set, fix_cr4_clr;
+
+	vmxon_region = alloc_page();
+
+	vmcs_root = alloc_page();
+
+	fix_cr0_set =  rdmsr(MSR_IA32_VMX_CR0_FIXED0);
+	fix_cr0_clr =  rdmsr(MSR_IA32_VMX_CR0_FIXED1);
+	fix_cr4_set =  rdmsr(MSR_IA32_VMX_CR4_FIXED0);
+	fix_cr4_clr = rdmsr(MSR_IA32_VMX_CR4_FIXED1);
+
+	init_vmx_caps();
 
 	write_cr0((read_cr0() & fix_cr0_clr) | fix_cr0_set);
 	write_cr4((read_cr4() & fix_cr4_clr) | fix_cr4_set | X86_CR4_VMXE);