diff mbox

[v4,3/7] x86/msr: read VMX MSRs values into Raw policy

Message ID 20171018082722.6279-4-sergey.dyasli@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sergey Dyasli Oct. 18, 2017, 8:27 a.m. UTC
Add calculate_raw_vmx_policy() which fills Raw policy with H/W values
of VMX MSRs. Host policy will contain a copy of these values.

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
---
 xen/arch/x86/msr.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
diff mbox

Patch

diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index 9dc3de8ce1..7ac0fceb49 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -32,6 +32,37 @@  struct msr_domain_policy __read_mostly     raw_msr_domain_policy,
 struct msr_vcpu_policy __read_mostly hvm_max_msr_vcpu_policy,
                        __read_mostly  pv_max_msr_vcpu_policy;
 
+static void __init calculate_raw_vmx_policy(struct msr_domain_policy *dp)
+{
+    unsigned int i;
+
+    if ( !cpu_has_vmx )
+        return;
+
+    for ( i = MSR_IA32_VMX_BASIC; i <= MSR_IA32_VMX_VMCS_ENUM; i++ )
+        rdmsrl(i, dp->vmx.raw[i - MSR_IA32_VMX_BASIC]);
+
+    if ( dp->vmx.procbased_ctls.allowed_1.activate_secondary_controls )
+    {
+        rdmsrl(MSR_IA32_VMX_PROCBASED_CTLS2, dp->vmx_procbased_ctls2.raw);
+
+        if ( dp->vmx_procbased_ctls2.allowed_1.enable_ept ||
+             dp->vmx_procbased_ctls2.allowed_1.enable_vpid )
+            rdmsrl(MSR_IA32_VMX_EPT_VPID_CAP, dp->vmx_ept_vpid_cap.raw);
+    }
+
+    if ( dp->vmx.basic.default1_zero )
+    {
+        for ( i = MSR_IA32_VMX_TRUE_PINBASED_CTLS;
+              i <= MSR_IA32_VMX_TRUE_ENTRY_CTLS; i++ )
+            rdmsrl(i,
+                   dp->vmx_true_ctls.raw[i - MSR_IA32_VMX_TRUE_PINBASED_CTLS]);
+    }
+
+    if ( dp->vmx_procbased_ctls2.allowed_1.enable_vm_functions )
+        rdmsrl(MSR_IA32_VMX_VMFUNC, dp->vmx_vmfunc.raw);
+}
+
 static void __init calculate_raw_policy(void)
 {
     struct msr_domain_policy *dp = &raw_msr_domain_policy;
@@ -43,6 +74,8 @@  static void __init calculate_raw_policy(void)
         if ( val & MSR_PLATFORM_INFO_CPUID_FAULTING )
             dp->plaform_info.cpuid_faulting = true;
     }
+
+    calculate_raw_vmx_policy(dp);
 }
 
 static void __init calculate_host_policy(void)