diff mbox series

[4/9] tools/libx[cl]: Merge xc_cpuid_set() into xc_cpuid_apply_policy()

Message ID 20200615141532.1927-5-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show
Series XSA-320 follow for IvyBridge | expand

Commit Message

Andrew Cooper June 15, 2020, 2:15 p.m. UTC
This reduces the number of CPUID handling entry-points to just one.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Ian Jackson <Ian.Jackson@citrix.com>
CC: Wei Liu <wl@xen.org>
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Paul Durrant <paul@xen.org>
---
 tools/libxc/include/xenctrl.h | 9 ++++-----
 tools/libxc/xc_cpuid_x86.c    | 8 ++++++--
 tools/libxl/libxl_cpuid.c     | 8 +-------
 3 files changed, 11 insertions(+), 14 deletions(-)

Comments

Ian Jackson June 15, 2020, 2:55 p.m. UTC | #1
Andrew Cooper writes ("[PATCH 4/9] tools/libx[cl]: Merge xc_cpuid_set() into xc_cpuid_apply_policy()"):
> This reduces the number of CPUID handling entry-points to just one.
> 
> No functional change.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
diff mbox series

Patch

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 178144e8e2..5f0978e0e5 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -1819,20 +1819,19 @@  struct xc_xend_cpuid {
     char *policy[4];
 };
 
-int xc_cpuid_set(xc_interface *xch,
-                 uint32_t domid,
-                 const struct xc_xend_cpuid *xend);
-
 /*
  * Make adjustments to the CPUID settings for a domain.
  *
  * Either pass a full new @featureset (and @nr_features), or adjust individual
  * features (@pae).
+ *
+ * Then (optionally) apply legacy XEND overrides (@xend) to the result.
  */
 int xc_cpuid_apply_policy(xc_interface *xch,
                           uint32_t domid,
                           const uint32_t *featureset,
-                          unsigned int nr_features, bool pae);
+                          unsigned int nr_features, bool pae,
+                          const struct xc_xend_cpuid *xend);
 int xc_mca_op(xc_interface *xch, struct xen_mc *mc);
 int xc_mca_op_inject_v2(xc_interface *xch, unsigned int flags,
                         xc_cpumap_t cpumap, unsigned int nr_cpus);
diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index e827c48fd1..26a7b94dcf 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -280,7 +280,7 @@  static xen_cpuid_leaf_t *find_leaf(
     return bsearch(&key, leaves, nr_leaves, sizeof(*leaves), compare_leaves);
 }
 
-int xc_cpuid_set(
+static int xc_cpuid_xend_policy(
     xc_interface *xch, uint32_t domid, const struct xc_xend_cpuid *xend)
 {
     int rc;
@@ -427,7 +427,8 @@  int xc_cpuid_set(
 
 int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid,
                           const uint32_t *featureset, unsigned int nr_features,
-                          bool pae)
+                          bool pae,
+                          const struct xc_xend_cpuid *xend)
 {
     int rc;
     xc_dominfo_t di;
@@ -637,6 +638,9 @@  int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid,
         goto out;
     }
 
+    if ( xend && (rc = xc_cpuid_xend_policy(xch, domid, xend)) )
+        goto out;
+
     rc = 0;
 
 out:
diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c
index 6f7cf2054e..edfcf315ca 100644
--- a/tools/libxl/libxl_cpuid.c
+++ b/tools/libxl/libxl_cpuid.c
@@ -419,7 +419,6 @@  int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list *cpuid,
 void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid,
                          libxl_domain_build_info *info)
 {
-    libxl_cpuid_policy_list cpuid = info->cpuid;
     bool pae = true;
 
     /*
@@ -435,12 +434,7 @@  void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid,
     if (info->type == LIBXL_DOMAIN_TYPE_HVM)
         pae = libxl_defbool_val(info->u.hvm.pae);
 
-    xc_cpuid_apply_policy(ctx->xch, domid, NULL, 0, pae);
-
-    if (!cpuid)
-        return;
-
-    xc_cpuid_set(ctx->xch, domid, info->cpuid);
+    xc_cpuid_apply_policy(ctx->xch, domid, NULL, 0, pae, info->cpuid);
 }
 
 static const char *input_names[2] = { "leaf", "subleaf" };