Skip to contentSkip to conversation

tools/libxc: Reduce feature handling complexity in xc_cpuid_apply_policy()

PATCH In review Andrew Cooper 3 participants 4 messages Mar 3, 2020 – May 13, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/libxc: Reduce feature handling complexity in xc_cpuid_apply_policy()

xc_cpuid_apply_policy() is gaining extra parameters to untangle CPUID complexity in Xen. While an improvement in general, it does have the unfortunate side effect of duplicating some settings across muliple parameters.

Rearrange the logic to only consider 'pae' if no explicit featureset is provided. This reduces the complexity for callers who have already provided a pae setting in the featureset.

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Ian Jackson <[email protected]>

---
 tools/libxc/include/xenctrl.h | 6 ++++++
 tools/libxc/xc_cpuid_x86.c    | 7 +++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
tools/libxc/include/xenctrl.h +6 -0
index fc6e57a1a0..8d13a7e20b 100644
@@ -1798,6 +1798,12 @@ int xc_cpuid_set(xc_interface *xch,
                  const unsigned int *input,
                  const char **config,
                  char **config_transformed);
+/*
+ * Make adjustments to the CPUID settings for a domain.
+ *
+ * Either pass a full new @featureset (and @nr_features), or adjust individual
+ * features (@pae).
+ */
 int xc_cpuid_apply_policy(xc_interface *xch,
                           uint32_t domid,
                           const uint32_t *featureset,
tools/libxc/xc_cpuid_x86.c +5 -2
index 5ced6d18b9..f045b03223 100644
@@ -532,6 +532,11 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid,
 
         cpuid_featureset_to_policy(feat, p);
     }
+    else
+    {
+        if ( di.hvm )
+            p->basic.pae = pae;
+    }
 
     if ( !di.hvm )
     {
@@ -615,8 +620,6 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid,
             break;
         }
 
-        p->basic.pae = pae;
-
         /*
          * These settings are necessary to cause earlier HVM_PARAM_NESTEDHVM /
          * XEN_DOMCTL_disable_migrate settings to be reflected correctly in
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by Paul Durrant on v1 1/1
#1 lore raw
Quoted 14 lines

-----Original Message-----
From: Xen-devel <[email protected]> On Behalf Of Andrew Cooper
Sent: 03 March 2020 18:23
To: Xen-devel <[email protected]>
Cc: Andrew Cooper <[email protected]>; Ian Jackson <[email protected]>; Wei Liu <[email protected]>; Jan Beulich <[email protected]>; Roger Pau Monné <[email protected]>
Subject: [Xen-devel] [PATCH] tools/libxc: Reduce feature handling complexity in xc_cpuid_apply_policy()

xc_cpuid_apply_policy() is gaining extra parameters to untangle CPUID complexity in Xen. While an improvement in general, it does have the unfortunate side effect of duplicating some settings across muliple parameters.

Quoted 5 lines

Rearrange the logic to only consider 'pae' if no explicit featureset is provided. This reduces the complexity for callers who have already provided a pae setting in the featureset.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
In reply to Andrew Cooper

Tools ping?

~Andrew

Quoted 62 lines · Andrew Cooper

xc_cpuid_apply_policy() is gaining extra parameters to untangle CPUID complexity in Xen. While an improvement in general, it does have the unfortunate side effect of duplicating some settings across muliple parameters.

Rearrange the logic to only consider 'pae' if no explicit featureset is provided. This reduces the complexity for callers who have already provided a pae setting in the featureset.

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Ian Jackson <[email protected]>

---
 tools/libxc/include/xenctrl.h | 6 ++++++
 tools/libxc/xc_cpuid_x86.c    | 7 +++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
tools/libxc/include/xenctrl.h +6 -0
index fc6e57a1a0..8d13a7e20b 100644
@@ -1798,6 +1798,12 @@ int xc_cpuid_set(xc_interface *xch,
                  const unsigned int *input,
                  const char **config,
                  char **config_transformed);
+/*
+ * Make adjustments to the CPUID settings for a domain.
+ *
+ * Either pass a full new @featureset (and @nr_features), or adjust individual
+ * features (@pae).
+ */
 int xc_cpuid_apply_policy(xc_interface *xch,
                           uint32_t domid,
                           const uint32_t *featureset,
tools/libxc/xc_cpuid_x86.c +5 -2
index 5ced6d18b9..f045b03223 100644
@@ -532,6 +532,11 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid,
 
         cpuid_featureset_to_policy(feat, p);
     }
+    else
+    {
+        if ( di.hvm )
+            p->basic.pae = pae;
+    }
 
     if ( !di.hvm )
     {
@@ -615,8 +620,6 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid,
             break;
         }
 
-        p->basic.pae = pae;
-
         /*
          * These settings are necessary to cause earlier HVM_PARAM_NESTEDHVM /
          * XEN_DOMCTL_disable_migrate settings to be reflected correctly in
Acked-by on v1 1/1
#3 lore raw
In reply to Andrew Cooper
Quoted 10 lines · Andrew Cooper

xc_cpuid_apply_policy() is gaining extra parameters to untangle CPUID complexity in Xen. While an improvement in general, it does have the unfortunate side effect of duplicating some settings across muliple parameters.

Rearrange the logic to only consider 'pae' if no explicit featureset is provided. This reduces the complexity for callers who have already provided a pae setting in the featureset.