]> xenbits.xensource.com Git - xen.git/commitdiff
x86/sysctl: Retrofit XEN_SYSCTL_cpu_featureset_{pv,hvm}_max
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 10 Mar 2023 19:37:56 +0000 (19:37 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 3 Aug 2023 18:14:19 +0000 (19:14 +0100)
Featuresets are supposed to be disappearing when the CPU policy infrastructure
is complete, but that has taken longer than expected, and isn't going to be
complete imminently either.

In the meantime, Xen does have proper default/max featuresets, and xen-cpuid
can even get them via the XEN_SYSCTL_cpu_policy_* interface, but only knows
now to render them nicely via the featureset interface.

Differences between default and max are a frequent source of errors,
frequently too in secret leading up to an embargo, so extend the featureset
sysctl to allow xen-cpuid to render them all nicely.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Christian Lindig <christian.lindig@cloud.com>
(cherry picked from commit 433d012c6c2737ad5a9aaa994355a4140d601852)

tools/misc/xen-cpuid.c
tools/ocaml/libs/xc/xenctrl.ml
tools/ocaml/libs/xc/xenctrl.mli
xen/arch/x86/sysctl.c
xen/include/public/sysctl.h

index 6cb805c16255f296d382a830af0201965ca67401..1e6baf98f6f2c7ca89676ee351c97cca0424e398 100644 (file)
@@ -233,10 +233,12 @@ static const struct {
 #define COL_ALIGN "18"
 
 static const char *const fs_names[] = {
-    [XEN_SYSCTL_cpu_featureset_host] = "Host",
-    [XEN_SYSCTL_cpu_featureset_raw]  = "Raw",
-    [XEN_SYSCTL_cpu_featureset_pv]   = "PV",
-    [XEN_SYSCTL_cpu_featureset_hvm]  = "HVM",
+    [XEN_SYSCTL_cpu_featureset_raw]     = "Raw",
+    [XEN_SYSCTL_cpu_featureset_host]    = "Host",
+    [XEN_SYSCTL_cpu_featureset_pv]      = "PV Default",
+    [XEN_SYSCTL_cpu_featureset_hvm]     = "HVM Default",
+    [XEN_SYSCTL_cpu_featureset_pv_max]  = "PV Max",
+    [XEN_SYSCTL_cpu_featureset_hvm_max] = "HVM Max",
 };
 
 static void dump_leaf(uint32_t leaf, const char *const *strs)
index 497ded7ce26b7434b3db5cbe54aac352f3ec089e..780cc71278a394c0262e72f841f6890483932e4d 100644 (file)
@@ -274,7 +274,13 @@ external version_changeset: handle -> string = "stub_xc_version_changeset"
 external version_capabilities: handle -> string =
   "stub_xc_version_capabilities"
 
-type featureset_index = Featureset_raw | Featureset_host | Featureset_pv | Featureset_hvm
+type featureset_index =
+  | Featureset_raw
+  | Featureset_host
+  | Featureset_pv
+  | Featureset_hvm
+  | Featureset_pv_max
+  | Featureset_hvm_max
 external get_cpu_featureset : handle -> featureset_index -> int64 array = "stub_xc_get_cpu_featureset"
 
 external watchdog : handle -> int -> int32 -> int
index 26ec7e59b131555a1749e7361d287454bf6af165..508f4ae829c13164fe12c37e8234b7069873779b 100644 (file)
@@ -212,7 +212,13 @@ external version_changeset : handle -> string = "stub_xc_version_changeset"
 external version_capabilities : handle -> string
   = "stub_xc_version_capabilities"
 
-type featureset_index = Featureset_raw | Featureset_host | Featureset_pv | Featureset_hvm
+type featureset_index =
+  | Featureset_raw
+  | Featureset_host
+  | Featureset_pv
+  | Featureset_hvm
+  | Featureset_pv_max
+  | Featureset_hvm_max
 external get_cpu_featureset : handle -> featureset_index -> int64 array = "stub_xc_get_cpu_featureset"
 
 external pages_to_kib : int64 -> int64 = "stub_pages_to_kib"
index b0cb1b57e79960f20b63185a06a48b4fc46e4d9b..dc105cb463e6bf355a77fbd33b9136840af7c49d 100644 (file)
@@ -357,14 +357,16 @@ long arch_do_sysctl(
 
     case XEN_SYSCTL_get_cpu_featureset:
     {
-        static const struct cpuid_policy *const policy_table[4] = {
+        static const struct cpuid_policy *const policy_table[6] = {
             [XEN_SYSCTL_cpu_featureset_raw]  = &raw_cpuid_policy,
             [XEN_SYSCTL_cpu_featureset_host] = &host_cpuid_policy,
 #ifdef CONFIG_PV
             [XEN_SYSCTL_cpu_featureset_pv]   = &pv_def_cpuid_policy,
+            [XEN_SYSCTL_cpu_featureset_pv_max] = &pv_max_cpuid_policy,
 #endif
 #ifdef CONFIG_HVM
             [XEN_SYSCTL_cpu_featureset_hvm]  = &hvm_def_cpuid_policy,
+            [XEN_SYSCTL_cpu_featureset_hvm_max] = &hvm_max_cpuid_policy,
 #endif
         };
         const struct cpuid_policy *p = NULL;
index 7439cc154f70c3c71ff6b31ec76683a8cb56e5d3..9091b469e2194d96009e0b84f2a6339fe994c51e 100644 (file)
@@ -804,6 +804,8 @@ struct xen_sysctl_cpu_featureset {
 #define XEN_SYSCTL_cpu_featureset_host     1
 #define XEN_SYSCTL_cpu_featureset_pv       2
 #define XEN_SYSCTL_cpu_featureset_hvm      3
+#define XEN_SYSCTL_cpu_featureset_pv_max   4
+#define XEN_SYSCTL_cpu_featureset_hvm_max  5
     uint32_t index;       /* IN: Which featureset to query? */
     uint32_t nr_features; /* IN/OUT: Number of entries in/written to
                            * 'features', or the maximum number of features if