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

[PATCH 13/21] libs/guest: switch users of xc_set_domain_cpu_policy


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Tue, 23 Mar 2021 10:58:41 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hY3Kjsh0dxbfkIPBdEUM6WIbCGm2IEEAQFQ7pR2GimY=; b=YA8mMe2Zy+0BtGxjhPMCSr3QU8o3EzRaHD2Or8eF1RwQqtj1eZq1BoBzMk21UMmNEErTH2gYHyGO0jSqjr+R0143vfbyRZoLiAaJOHlDTqy0lJc8nbaCW0DQPu5T2/oK12FNQiSfczJVpwK0XhDIQ/8ApsP9D12N6z/Se0EHp0TDMhgqc5S/b6bgDJSXYbBoq2WUf9Qn1G7oReiBokF1uXkPbNcz22bGQgwgq1Hg+BGFhShkuOwgfVhKp7j1FNhAEmO1+sFFW3eH8lcH8/fivfzJiShMtxNpQ9V7jB6a11PTVpTBP61cVXZUw6aix4tpfDNQJs/2M9x0fC4Yepyiew==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hSN2XjNK30WKoKDpaOaZ4ktG/uQLzwTvI7jCXmZbjIuYSogteQtby63ZrGztfSyUjRZQd448eUVCdyCH0Q1Y7tZRenitqKnllJH2+n2CU93wGIYJ3S6GyLUDJkFnjGR/941JR7FsP6k1CeNIHXkA+zTgyHQSCy9VjLsGkhzsWXBVpqCCh/Po20xC1SebLT9R3NSIOEzX8f/G/ghHy5cAjUjyvMuQMwJW715Azmq4fUZT84PnCBn01CkROZCWR2IY2oXYDp2a0KGdawTdnUcd4pryfDer6uFGhtLI1hV8sRAgL51wfV6KW+BuHxCUDkez3gbALXQv96zDpHncnB+DgQ==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 23 Mar 2021 10:07:50 +0000
  • Ironport-hdrordr: A9a23:WKVnSq+UZ5A3TXsdg1Ruk+Gncb1zdoIgy1knxilNYDRvWIixi9 2ukPMH1RX9lTYWXzUalcqdPbSbKEmxybdc2qNUGbu5RgHptC+TLI9k5Zb/2DGIIUDD38Zn/+ Nbf6B6YeebMXFTh8z3+RT9Nt4mzsWO/qzAv5am815GZ2hRCp1IxQF/FwqdDwlSTA5JGZI2GP Onl7J6jhCnfmkaadn+O2kdU4H41pb2vb/FQTpDPR4o7wGSkSilgYSQLzG01goTOgk/pIsK3n PCl2XCiZmLk/b+8RPE0n+W0pI+oqqG9vJmJOihzvcYMS/tjAHAXvUqZ5SnsCouqO+irHYG+e O8xysIBMh453PPcmzdm3KE5yDa3Dkj8HPkw1OD6EGTxvDRfi4wCMZKmOtiEifx1ks6sNlwlI JN0m6J3qAnby/ooSXn69DEEyxtj0q/yEBS8tI7sno3a+UjQY4UibZa0FJeEZ8GEi6/wpsgCv NSAMbV4+sTWU+GbljC11MfjeCEbzAWJFOrU0ICssua33x9h3Zi1XYVw8QZgzMp6I89cZ9Z/O 7JW54Y2I1mf4szV+ZQFe0BScy4BijmWhTXKl+fJlzhCeUhN2/SrYX0pJE4/vujdpBN7JZaou WPbHpo8UoJP27+A8yH25NGtjrXRn+mYDjrwsZCo5djvLnxQ6fqLD2DRFgin9DImYRfPuTrH9 KIfL5GCf7qKmXjXaxT2RflZpVUIX4CFM0Z0+xLG26mk4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p5Q7HZE1NaaoTm2tbjSxVMDFdERRAA3k93Eavxly1OMcUi6Plsmw9 4EyAgVuQ/M9mPS7av4kvM8LFpOuDMCQ5Tz3sB2xWfvN+mwigvIjTAaPRbnyJNX0CPEdX738l8E qS0Npd/Zb/YkoNIsVgdW9/BJ98yGLhf2hJWjufbgpaA1COyhsKVdwqmVobZss2Y19fXBHU2WJ8 Cj14H8caTNKmGMAQac8o/INumoOiMri9BB9XIdUqhkZePiJdrLZV41xAS8l7/cOxUISuGfp5je bgM=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

To use the new cpu policy interface xc_cpu_policy_set_domain. Note
that xc_set_domain_cpu_policy is removed from the interface and the
function is made static to xg_cpuid_x86.c for it's internal callers.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 tools/include/xenctrl.h             |  5 -----
 tools/libs/guest/xg_cpuid_x86.c     | 22 +++++++++++-----------
 tools/libs/guest/xg_sr_common_x86.c | 28 +++++++++++++++++++++-------
 3 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index 46f5026081c..164a287b367 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2625,11 +2625,6 @@ int xc_get_cpu_featureset(xc_interface *xch, uint32_t 
index,
 
 int xc_cpu_policy_get_size(xc_interface *xch, uint32_t *nr_leaves,
                            uint32_t *nr_msrs);
-int xc_set_domain_cpu_policy(xc_interface *xch, uint32_t domid,
-                             uint32_t nr_leaves, xen_cpuid_leaf_t *leaves,
-                             uint32_t nr_msrs, xen_msr_entry_t *msrs,
-                             uint32_t *err_leaf_p, uint32_t *err_subleaf_p,
-                             uint32_t *err_msr_p);
 
 uint32_t xc_get_cpu_featureset_size(void);
 
diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
index 07756743e76..f7b662f31aa 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -204,11 +204,11 @@ static int get_domain_cpu_policy(xc_interface *xch, 
uint32_t domid,
     return ret;
 }
 
-int xc_set_domain_cpu_policy(xc_interface *xch, uint32_t domid,
-                             uint32_t nr_leaves, xen_cpuid_leaf_t *leaves,
-                             uint32_t nr_msrs, xen_msr_entry_t *msrs,
-                             uint32_t *err_leaf_p, uint32_t *err_subleaf_p,
-                             uint32_t *err_msr_p)
+static int set_domain_cpu_policy(xc_interface *xch, uint32_t domid,
+                                 uint32_t nr_leaves, xen_cpuid_leaf_t *leaves,
+                                 uint32_t nr_msrs, xen_msr_entry_t *msrs,
+                                 uint32_t *err_leaf_p, uint32_t *err_subleaf_p,
+                                 uint32_t *err_msr_p)
 {
     DECLARE_DOMCTL;
     DECLARE_HYPERCALL_BOUNCE(leaves,
@@ -405,8 +405,8 @@ static int xc_cpuid_xend_policy(
     }
 
     /* Feed the transformed currrent policy back up to Xen. */
-    rc = xc_set_domain_cpu_policy(xch, domid, nr_cur, cur, 0, NULL,
-                                  &err_leaf, &err_subleaf, &err_msr);
+    rc = set_domain_cpu_policy(xch, domid, nr_cur, cur, 0, NULL,
+                               &err_leaf, &err_subleaf, &err_msr);
     if ( rc )
     {
         PERROR("Failed to set d%d's policy (err leaf %#x, subleaf %#x, msr 
%#x)",
@@ -638,8 +638,8 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t 
domid, bool restore,
         goto out;
     }
 
-    rc = xc_set_domain_cpu_policy(xch, domid, nr_leaves, leaves, 0, NULL,
-                                  &err_leaf, &err_subleaf, &err_msr);
+    rc = set_domain_cpu_policy(xch, domid, nr_leaves, leaves, 0, NULL,
+                               &err_leaf, &err_subleaf, &err_msr);
     if ( rc )
     {
         PERROR("Failed to set d%d's policy (err leaf %#x, subleaf %#x, msr 
%#x)",
@@ -833,8 +833,8 @@ int xc_cpu_policy_set_domain(xc_interface *xch, uint32_t 
domid,
     if ( rc )
         goto out;
 
-    rc = xc_set_domain_cpu_policy(xch, domid, nr_leaves, leaves, nr_msrs, msrs,
-                                  &err_leaf, &err_subleaf, &err_msr);
+    rc = set_domain_cpu_policy(xch, domid, nr_leaves, leaves, nr_msrs, msrs,
+                               &err_leaf, &err_subleaf, &err_msr);
     if ( rc )
     {
         ERROR("Failed to set domain %u policy (%d = %s)", domid, -rc,
diff --git a/tools/libs/guest/xg_sr_common_x86.c 
b/tools/libs/guest/xg_sr_common_x86.c
index 15265e7a331..02f0c3ae9ed 100644
--- a/tools/libs/guest/xg_sr_common_x86.c
+++ b/tools/libs/guest/xg_sr_common_x86.c
@@ -151,7 +151,10 @@ int x86_static_data_complete(struct xc_sr_context *ctx, 
unsigned int *missing)
 {
     xc_interface *xch = ctx->xch;
     uint32_t nr_leaves = 0, nr_msrs = 0;
-    uint32_t err_l = ~0, err_s = ~0, err_m = ~0;
+    xc_cpu_policy_t policy = xc_cpu_policy_init();
+
+    if ( !policy )
+        return -1;
 
     if ( ctx->x86.restore.cpuid.ptr )
         nr_leaves = ctx->x86.restore.cpuid.size / sizeof(xen_cpuid_leaf_t);
@@ -163,14 +166,25 @@ int x86_static_data_complete(struct xc_sr_context *ctx, 
unsigned int *missing)
     else
         *missing |= XGR_SDD_MISSING_MSR;
 
+    if ( nr_leaves &&
+         xc_cpu_policy_update_cpuid(xch, policy,
+                                    ctx->x86.restore.cpuid.ptr, nr_leaves) )
+    {
+        PERROR("Failed to update CPUID policy");
+        return -1;
+    }
+    if ( nr_msrs &&
+         xc_cpu_policy_update_msrs(xch, policy,
+                                   ctx->x86.restore.msr.ptr, nr_msrs) )
+    {
+        PERROR("Failed to update MSR policy");
+        return -1;
+    }
+
     if ( (nr_leaves || nr_msrs) &&
-         xc_set_domain_cpu_policy(xch, ctx->domid,
-                                  nr_leaves, ctx->x86.restore.cpuid.ptr,
-                                  nr_msrs,   ctx->x86.restore.msr.ptr,
-                                  &err_l, &err_s, &err_m) )
+         xc_cpu_policy_set_domain(xch, ctx->domid, policy) )
     {
-        PERROR("Failed to set CPUID policy: leaf %08x, subleaf %08x, msr %08x",
-               err_l, err_s, err_m);
+        PERROR("Failed to set CPUID policy");
         return -1;
     }
 
-- 
2.30.1




 


Rackspace

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