diff mbox

[v3,1/6] x86/msr: add Raw and Host domain policies

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

Commit Message

Sergey Dyasli Oct. 13, 2017, 12:35 p.m. UTC
Raw policy contains the actual values from H/W MSRs. PLATFORM_INFO msr
needs to be read again because probe_intel_cpuid_faulting() records
the presence of X86_FEATURE_CPUID_FAULTING but not the presence of msr
itself (if cpuid faulting is not available).

Host policy might have certain features disabled if Xen decides not
to use them. For now, make Host policy equal to Raw policy.

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

Patch

diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index baba44f43d..9737ed706e 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -24,12 +24,34 @@ 
 #include <xen/sched.h>
 #include <asm/msr.h>
 
-struct msr_domain_policy __read_mostly hvm_max_msr_domain_policy,
+struct msr_domain_policy __read_mostly     raw_msr_domain_policy,
+                         __read_mostly    host_msr_domain_policy,
+                         __read_mostly hvm_max_msr_domain_policy,
                          __read_mostly  pv_max_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_policy(void)
+{
+    struct msr_domain_policy *dp = &raw_msr_domain_policy;
+    uint64_t val;
+
+    if ( rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val) == 0 )
+    {
+        dp->plaform_info.available = true;
+        if ( val & MSR_PLATFORM_INFO_CPUID_FAULTING )
+            dp->plaform_info.cpuid_faulting = true;
+    }
+}
+
+static void __init calculate_host_policy(void)
+{
+    struct msr_domain_policy *dp = &host_msr_domain_policy;
+
+    *dp = raw_msr_domain_policy;
+}
+
 static void __init calculate_hvm_max_policy(void)
 {
     struct msr_domain_policy *dp = &hvm_max_msr_domain_policy;
@@ -67,6 +89,8 @@  static void __init calculate_pv_max_policy(void)
 
 void __init init_guest_msr_policy(void)
 {
+    calculate_raw_policy();
+    calculate_host_policy();
     calculate_hvm_max_policy();
     calculate_pv_max_policy();
 }