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

[PATCH v2 08/21] libs/guest: introduce a helper to apply a cpu policy to a domain


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Tue, 13 Apr 2021 16:01:26 +0200
  • 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=Ace5hGQHWZBVqrsl47aMLF18dvATzg1Wl0vS5Bxau5Y=; b=HNaOC0qzi5Cr+RUbJP1PcqV8zbsoxoyItSsm0qSQlcfX7oK80ZTY0zAGSJDUeZie8YiYzYzSMFlMq/qfEJhIQqCadVyJsX2UexC57CKBoFQRaODp04bJmCk1TU+anPDTRdw0nkqjtmtDGK3mIQMkal55l/YzeX0vaY3QCQP+zCdhcug3RfSmYzOig0xzut00JhZbIhCzlstY8VbkHM9ip6KZ+87R9wafqrtYDL3j35KWr0t/lUDOR18eJFfH4lUscpr7L6VHdhU3O8BoWma4nLavYIS/13VV2u3j09c0g32WjnToIsVH8L73EIXGi8uwiKiXMIiW8yvXOakc24dwYg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ImeAnWUtT4HOIU1JcRi3DPv2dJlJVz26OK+V1BeChRMqR+Y/vglIbxDTXpU+Oos1lGhWSlmoKFPJhY/jjOxNFEoWxPrLpz/vybS/9wN/8M3TGwN2cAl+9akTy+kkYaRVNDVgwpVDvYqmQD6PQlymPKZ0rL+r7F8kqu5EbmWNqQANjGj9I2JdmuI3XNA/TiFMQWPWsg7MY0A+Y4eYok3fWciYRDITrA3AcA4zxjNvcEezV65j1M7eG+4lHuNuOJp6u+u77BnlhrHEEhVoqegotqM39PiPs4G3dWtBbEdpdRUC1xaIz22JBddNQMVcQH+SQqELnxmzvJOzht0uCwpSFQ==
  • Authentication-results: esa5.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, 13 Apr 2021 14:02:46 +0000
  • Ironport-hdrordr: A9a23:ohTAla1Jdk1/K7i/S073TwqjBWhyeYIsi2QD101hICF9WtCEls yogfQQ3QL1jjFUY307hdWcIsC7LE/035hz/IUXIPOeTBDr0VHYSb1KwKnD53nbGyP4/vNAzq sIScJDIfD5EFQSt6nHySaiFdJI+re62YSJocub8Ht3VwFtbMhbnmVEIyKWCFd/SgUDJbdRLv qhz/FKrTahZngbB/7TbhU4dtPOusHRk9beaQMGbiRN1CC1kTiq5LTmeiLovSs2bjUn+9Yf2F mAqSPVzOGJs/a3yhjTvlWjlah+qZ/a5fZoQOCJgsgRAD3whgivf5QJYcz+gBkF5NuBxXxvvN 7QowoxH8kb0QKsQkiF5SHD9iOl8DEy52TswVWV6EGT3vDRdXYBJOdqwad6GyGpj3YIjZVH/4 9gm1+9jd5xCyjNmSzsjuK4Ly1Cpw6PjlcJ1dIIg2c3a/p4VJZh6bYx0WlyC5k6ECfz+OkcYZ JTJfCZ3vpQfF+ABkqp2FVH8ZipVnQ3KB+MXlIPjMyTyyRXh3B01SIjtbUioks=
  • Ironport-sdr: 2NbV4rYqUDXgZ5UCmNABXCVnZ+KDdBd0ryP1I98GHYD1xaS79HzB4oY0jKiKqAkYMWROmm5tjr AtOhrPe8tde13VxDQo38sXg1sjULyNvM16ef19LppKCMQyJktyyQ8VkVe3lUtiNsTJHYfc5sjh iQ0oivb2GVlsQw3MNM/LMTD6tsN5lUAZxY5qe+2Sha2fdh+wFbaSRrnJ/KkkTK+we+XgzI5kzn wx3o3BkqnTAUmjF1XU9THVDApuIoC3G3jebACxyIKk8Oln3hYAzyU753UxlkgMpG4fzKPwp2zN wB4=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Such helper is very similar to the existing xc_set_domain_cpu_policy
interface, but takes an opaque xc_cpu_policy_t instead of arrays of
CPUID leaves and MSRs.

No callers of the interface introduced in this patch.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 tools/include/xenctrl.h         |  2 ++
 tools/libs/guest/xg_cpuid_x86.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index e9a86d63bad..27cec1b93ff 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2601,6 +2601,8 @@ int xc_cpu_policy_get_system(xc_interface *xch, unsigned 
int policy_idx,
                              xc_cpu_policy_t policy);
 int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid,
                              xc_cpu_policy_t policy);
+int xc_cpu_policy_set_domain(xc_interface *xch, uint32_t domid,
+                             const xc_cpu_policy_t policy);
 
 /* Manipulate a policy via architectural representations. */
 int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t policy,
diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
index 208a247bb6e..8b48c51a8ee 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -757,6 +757,35 @@ int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t 
domid,
     return rc;
 }
 
+int xc_cpu_policy_set_domain(xc_interface *xch, uint32_t domid,
+                             const xc_cpu_policy_t policy)
+{
+    uint32_t err_leaf = -1, err_subleaf = -1, err_msr = -1;
+    unsigned int nr_leaves = ARRAY_SIZE(policy->leaves);
+    unsigned int nr_entries = ARRAY_SIZE(policy->entries);
+    int rc;
+
+    rc = xc_cpu_policy_serialise(xch, policy, policy->leaves, &nr_leaves,
+                                 policy->entries, &nr_entries);
+    if ( rc )
+        return rc;
+
+    rc = xc_set_domain_cpu_policy(xch, domid, nr_leaves, policy->leaves,
+                                  nr_entries, policy->entries,
+                                  &err_leaf, &err_subleaf, &err_msr);
+    if ( rc )
+    {
+        ERROR("Failed to set domain %u policy (%d = %s)", domid, -rc,
+              strerror(-rc));
+        if ( err_leaf != -1 )
+            ERROR("CPUID leaf %u subleaf %u", err_leaf, err_subleaf);
+        if ( err_msr != -1 )
+            ERROR("MSR index %#x\n", err_msr);
+    }
+
+    return rc;
+}
+
 int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t p,
                             xen_cpuid_leaf_t *leaves, uint32_t *nr_leaves,
                             xen_msr_entry_t *msrs, uint32_t *nr_msrs)
-- 
2.30.1




 


Rackspace

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