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

[Xen-devel] [PATCH 08/13] x86: Collect policies together into groups



This is mainly prep work for the following patch, but this specific
abstraction is also specifically useful for the future auditing logic.

Not all of msr_vcpu_policy will be interesting from a domain building
perspective, but some soon-to-appear fields will be (SGX Launch Hash
specifically).  The exact split of MSRs between domain and vcpu policies is
internal to Xen and liable to change moving forwards, so treat the two
structures consistently from the start to avoid problems in the future.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Sergey Dyasli <sergey.dyasli@xxxxxxxxxx>
CC: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 xen/arch/x86/msr.c                |  4 +++-
 xen/arch/x86/sysctl.c             | 23 +++++++++++++++++++++++
 xen/include/asm-x86/cpuid.h       |  3 +++
 xen/include/asm-x86/msr.h         | 16 +++++++++-------
 xen/include/xen/libx86/policies.h | 25 +++++++++++++++++++++++++
 5 files changed, 63 insertions(+), 8 deletions(-)
 create mode 100644 xen/include/xen/libx86/policies.h

diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index d035c67..233eeaf 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -31,7 +31,9 @@ struct msr_domain_policy __read_mostly     
raw_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,
+struct msr_vcpu_policy __read_mostly     raw_msr_vcpu_policy,
+                       __read_mostly    host_msr_vcpu_policy,
+                       __read_mostly hvm_max_msr_vcpu_policy,
                        __read_mostly  pv_max_msr_vcpu_policy;
 
 static void __init calculate_raw_policy(void)
diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index 4d372db..c5c00d0 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -31,6 +31,29 @@
 #include <asm/psr.h>
 #include <asm/cpuid.h>
 
+const struct policy_group system_policies[] = {
+    {
+        &raw_cpuid_policy,
+        &raw_msr_domain_policy,
+        &raw_msr_vcpu_policy,
+    },
+    {
+        &host_cpuid_policy,
+        &host_msr_domain_policy,
+        &host_msr_vcpu_policy,
+    },
+    {
+        &pv_max_cpuid_policy,
+        &pv_max_msr_domain_policy,
+        &pv_max_msr_vcpu_policy,
+    },
+    {
+        &hvm_max_cpuid_policy,
+        &hvm_max_msr_domain_policy,
+        &hvm_max_msr_vcpu_policy,
+    },
+};
+
 struct l3_cache_info {
     int ret;
     unsigned long size;
diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h
index ea79445..5454e44 100644
--- a/xen/include/asm-x86/cpuid.h
+++ b/xen/include/asm-x86/cpuid.h
@@ -9,6 +9,7 @@
 #include <xen/kernel.h>
 
 #include <xen/libx86/cpuid.h>
+#include <xen/libx86/policies.h>
 
 #include <public/sysctl.h>
 
@@ -50,6 +51,8 @@ extern struct cpuidmasks cpuidmask_defaults;
 extern struct cpuid_policy raw_cpuid_policy, host_cpuid_policy,
     pv_max_cpuid_policy, hvm_max_cpuid_policy;
 
+extern const struct policy_group system_policies[];
+
 /* Check that all previously present features are still available. */
 bool recheck_cpu_features(unsigned int cpu);
 
diff --git a/xen/include/asm-x86/msr.h b/xen/include/asm-x86/msr.h
index d8cb638..e306f97 100644
--- a/xen/include/asm-x86/msr.h
+++ b/xen/include/asm-x86/msr.h
@@ -260,13 +260,15 @@ static inline void wrmsr_tsc_aux(uint32_t val)
     }
 }
 
-/* RAW msr domain policy: contains the actual values from H/W MSRs */
-extern struct msr_domain_policy raw_msr_domain_policy;
-/*
- * HOST msr domain policy: features that Xen actually decided to use,
- * a subset of RAW policy.
- */
-extern struct msr_domain_policy host_msr_domain_policy;
+extern 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;
+
+extern struct msr_vcpu_policy __read_mostly     raw_msr_vcpu_policy,
+                              __read_mostly    host_msr_vcpu_policy,
+                              __read_mostly hvm_max_msr_vcpu_policy,
+                              __read_mostly  pv_max_msr_vcpu_policy;
 
 void init_guest_msr_policy(void);
 int init_domain_msr_policy(struct domain *d);
diff --git a/xen/include/xen/libx86/policies.h 
b/xen/include/xen/libx86/policies.h
new file mode 100644
index 0000000..d6fa1bc
--- /dev/null
+++ b/xen/include/xen/libx86/policies.h
@@ -0,0 +1,25 @@
+/* Common data structures and functions consumed by hypervisor and toolstack */
+#ifndef XEN_LIBX86_POLICIES_H
+#define XEN_LIBX86_POLICIES_H
+
+#include <xen/libx86/cpuid.h>
+#include <xen/libx86/msr.h>
+
+struct policy_group
+{
+    struct cpuid_policy *cp;
+    struct msr_domain_policy *dp;
+    struct msr_vcpu_policy *vp;
+};
+
+#endif /* !XEN_LIBX86_POLICIES_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.