[xen staging] x86: Introduce struct cpu_policy to refer to a group of individual policies

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen staging] x86: Introduce struct cpu_policy to refer to a group of individual policies

patchbot
commit 9b2d12455b1eb06acb9e28049fc0786f10420482
Author:     Andrew Cooper <[hidden email]>
AuthorDate: Mon Jul 2 16:05:33 2018 +0000
Commit:     Andrew Cooper <[hidden email]>
CommitDate: Tue Nov 6 17:51:18 2018 +0000

    x86: Introduce struct cpu_policy to refer to a group of individual policies
   
    This is prep work for the following patch - please refer to it as well.
   
    When auditing and manipulating policies, it is necessary to do so with a
    complete set of policies, due to the interdependences of the contents.  A
    containing structure like this will allow for clearer APIs and code.
   
    As a first user, this structure is convenient for the mapping used by
    XEN_SYSCTL_get_cpu_policy (implemented in the next patch), and for auditing
    (later when XEN_DOMCTL_set_cpu_policy is implemented).
   
    At this point, the distinction between *_max and *_default is introduced into
    the ABI.  For now, *_default is mapped to *_max, but future development work
    will result in *_default being a logical subset of *_max.
   
    Signed-off-by: Andrew Cooper <[hidden email]>
    Reviewed-by: Roger Pau Monné <[hidden email]>
    Reviewed-by: Wei Liu <[hidden email]>
    Acked-by: Jan Beulich <[hidden email]>
---
 xen/arch/x86/sysctl.c                | 27 +++++++++++++++++++++++++++
 xen/include/asm-x86/cpuid.h          |  3 +++
 xen/include/public/sysctl.h          | 20 ++++++++++++++++++++
 xen/include/xen/lib/x86/cpu-policy.h | 24 ++++++++++++++++++++++++
 4 files changed, 74 insertions(+)

diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index 456dc58d8f..ecb51f999e 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -32,6 +32,33 @@
 #include <asm/psr.h>
 #include <asm/cpuid.h>
 
+const struct cpu_policy system_policies[] = {
+    [ XEN_SYSCTL_cpu_policy_raw ] = {
+        &raw_cpuid_policy,
+        &raw_msr_policy,
+    },
+    [ XEN_SYSCTL_cpu_policy_host ] = {
+        &host_cpuid_policy,
+        &host_msr_policy,
+    },
+    [ XEN_SYSCTL_cpu_policy_pv_max ] = {
+        &pv_max_cpuid_policy,
+        &pv_max_msr_policy,
+    },
+    [ XEN_SYSCTL_cpu_policy_hvm_max ] = {
+        &hvm_max_cpuid_policy,
+        &hvm_max_msr_policy,
+    },
+    [ XEN_SYSCTL_cpu_policy_pv_default ] = {
+        &pv_max_cpuid_policy,
+        &pv_max_msr_policy,
+    },
+    [ XEN_SYSCTL_cpu_policy_hvm_default ] = {
+        &hvm_max_cpuid_policy,
+        &hvm_max_msr_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 f109c6ffb4..548108f948 100644
--- a/xen/include/asm-x86/cpuid.h
+++ b/xen/include/asm-x86/cpuid.h
@@ -8,6 +8,7 @@
 #include <xen/types.h>
 #include <xen/kernel.h>
 
+#include <xen/lib/x86/cpu-policy.h>
 #include <xen/lib/x86/cpuid.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 cpu_policy system_policies[];
+
 /* Check that all previously present features are still available. */
 bool recheck_cpu_features(unsigned int cpu);
 
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index 8cd0a9cb0d..9070007222 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -1063,6 +1063,26 @@ struct xen_sysctl_set_parameter {
     uint16_t pad[3];                        /* IN: MUST be zero. */
 };
 
+#if defined(__i386__) || defined(__x86_64__)
+/*
+ * XEN_SYSCTL_get_cpu_policy (x86 specific)
+ *
+ * Return information about CPUID and MSR policies available on this host.
+ *  -       Raw: The real H/W values.
+ *  -      Host: The values Xen is using, (after command line overrides, etc).
+ *  -     Max_*: Maximum set of features a PV or HVM guest can use.  Includes
+ *               experimental features outside of security support.
+ *  - Default_*: Default set of features a PV or HVM guest can use.  This is
+ *               the security supported set.
+ */
+#define XEN_SYSCTL_cpu_policy_raw          0
+#define XEN_SYSCTL_cpu_policy_host         1
+#define XEN_SYSCTL_cpu_policy_pv_max       2
+#define XEN_SYSCTL_cpu_policy_hvm_max      3
+#define XEN_SYSCTL_cpu_policy_pv_default   4
+#define XEN_SYSCTL_cpu_policy_hvm_default  5
+#endif
+
 struct xen_sysctl {
     uint32_t cmd;
 #define XEN_SYSCTL_readconsole                    1
diff --git a/xen/include/xen/lib/x86/cpu-policy.h b/xen/include/xen/lib/x86/cpu-policy.h
new file mode 100644
index 0000000000..6f07c4b493
--- /dev/null
+++ b/xen/include/xen/lib/x86/cpu-policy.h
@@ -0,0 +1,24 @@
+/* Common data structures and functions consumed by hypervisor and toolstack */
+#ifndef XEN_LIB_X86_POLICIES_H
+#define XEN_LIB_X86_POLICIES_H
+
+#include <xen/lib/x86/cpuid.h>
+#include <xen/lib/x86/msr.h>
+
+struct cpu_policy
+{
+    struct cpuid_policy *cpuid;
+    struct msr_policy *msr;
+};
+
+#endif /* !XEN_LIB_X86_POLICIES_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog