x86/msr: Use the architectural layout for MSR_{MISC_ENABLES,PLATFORM_INFO}
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 27 Jun 2018 11:34:47 +0000 (12:34 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 2 Jul 2018 17:04:21 +0000 (18:04 +0100)
This simplifies future interactions with the toolstack, by removing the need
for per-MSR custom accessors when shuffling data in/out of a policy.

Use a 32bit raw backing integer (for simplicity), and use a bitfield to move
the cpuid_faulting field to its appropriate position.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/msr.c
xen/include/asm-x86/msr.h

index 6599f10d32d247fc549ae541d9c4a43e3b5bf46a..d035c67d4ce0500234775b699dc31308729574a0 100644 (file)
@@ -139,8 +139,7 @@ int guest_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
         break;
 
     case MSR_INTEL_PLATFORM_INFO:
-        *val = (uint64_t)dp->plaform_info.cpuid_faulting <<
-               _MSR_PLATFORM_INFO_CPUID_FAULTING;
+        *val = dp->plaform_info.raw;
         break;
 
     case MSR_ARCH_CAPABILITIES:
@@ -148,8 +147,7 @@ int guest_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
         goto gp_fault;
 
     case MSR_INTEL_MISC_FEATURES_ENABLES:
-        *val = (uint64_t)vp->misc_features_enables.cpuid_faulting <<
-               _MSR_MISC_FEATURES_CPUID_FAULTING;
+        *val = vp->misc_features_enables.raw;
         break;
 
     default:
@@ -240,8 +238,7 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
         if ( val & rsvd )
             goto gp_fault;
 
-        vp->misc_features_enables.cpuid_faulting =
-            val & MSR_MISC_FEATURES_CPUID_FAULTING;
+        vp->misc_features_enables.raw = val;
 
         if ( v == curr && is_hvm_domain(d) && cpu_has_cpuid_faulting &&
              (old_cpuid_faulting ^ vp->misc_features_enables.cpuid_faulting) )
index 627b7ced93f7fe88cdd0048245856987c4bbf6fa..68ee7ea17a91fec7ad0f1736e8d984b73908cec7 100644 (file)
@@ -268,8 +268,12 @@ struct msr_domain_policy
      * guests so can be offered unconditionally, while support for PV guests
      * is dependent on real hardware support.
      */
-    struct {
-        bool cpuid_faulting;
+    union {
+        uint32_t raw;
+        struct {
+            uint32_t :31;
+            bool cpuid_faulting:1;
+        };
     } plaform_info;
 };
 
@@ -301,8 +305,11 @@ struct msr_vcpu_policy
      * unconditionally.  The CPUID Faulting bit is the only writeable bit, and
      * only if enumerated by MSR_PLATFORM_INFO.
      */
-    struct {
-        bool cpuid_faulting;
+    union {
+        uint32_t raw;
+        struct {
+            bool cpuid_faulting:1;
+        };
     } misc_features_enables;
 };