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

[PATCH v6 03/12] libs/guest: allow fetching a specific CPUID leaf from a cpu policy


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Mon, 17 Jan 2022 10:48:18 +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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ojngcjt1M2iDhn21AvZ+LOY3mmuCciu47e9GG4lJRbs=; b=C6oslnz5WWa5S/V2dagsREk/hlvqBB4+TQ/iZRHHZjykRB49vaJf35+0zZO5Pi1T6E03u7W8+jgUQMmMe4WeCUihAmTWvf8xPCV87/+9mA2smq7Hl5knvqwm8CjeeMNeGk0ss+QmRyTeGwXTKWGRs7FgMkF7icLkD87SqNMeIYqf9uIY3JYOMFck75EsZ+we37RnaXU0KqeRz/L1sEG4Ra4Bx4N5JuVrUtQo4b1JEhAPz50PUXCjn+fQgFgY/HfoHhoCjSw3l+VSaxBFJzoOGi/pkT3iF0mdMz/WnxMlK0acFbMlbdf1DYrijHg0f/Cq2D/82iTXOQjCWHl06/5ELQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZYsFJuqmSgbx7pNgIk1rnnw+P9/3yUA1KvXKDgt5o2RMR3ZpvOWQHcDcrqN9aMBBSNyJetI5GpwPKFurpmN8Y7cXDxErI1Eyjk4oVzRkf155bw+21MH+vUEcBvWhkREDotfhizukjPjfhBqFgybSHno5dyVViZGLlcVbUrxQ2mFTjdULRWlb16IWJy4TC+PX9x21oQGnJ8+7R3yGt5m2MGsgvCjYWoU2XhWbeNliquOkZuNuz4N0KVRx1+zxWWxQLz6EjPGGHPplwUVf4rXwVUDS6vOza2W9B1ROC8iVNSL4FFgu3npv1ByrgporIkjSpKz5Slm2gXmGt7a+mpvzKA==
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Mon, 17 Jan 2022 09:49:42 +0000
  • Ironport-data: A9a23:JE/FralCdVQuy5Fj/KsrGbzo5gxmIURdPkR7XQ2eYbSJt1+Wr1Gzt xIaWjyHaPbeYGr8KYh2OYvj9EpQ7JeAn95qT1A++yoxRSMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BClVlxJVF/fngqoDUUYYoAQgsA180IMsdoUg7wbRh29c32YHR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 PhQrpbvaxxxB5yPlOcgaRoAI3tzZpQTrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBNPsM44F/Glp0BnSDOo8QICFSKLPjTNd9Glq35seTa+PD yYfQT5lKyTlQRRRA3U0As4clcWylHjkfBQN/Tp5ooJoujOOnWSdyoPFMtXPfceRbd5IhUver WXDl0zmBjkKOdrZziCKmlq8i+mKkS7lVYY6ELyj6uUskFCV3nYUChAdSR28u/bRt6Klc4sBc QpOoHNo9PVsshzwJjXgY/GmiFOZpRRDecEIKtx55AKw8KmM01yUXVFRG1atd+canMMxQDUr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Wa+eAfGSS7/yKmTVQeuxIqLLskNHKuQ6d9QYWcegDUdAf0+4TMHf9LqQZfngiOXJvf6 Dsmfav6gDQMkg/X4CePD0oTuLDr9rEmNbPZgMHPQcu7E2rgSmz4LD3PhCE1lNGOgk/jIsKwC zgqUjU96+ju/a0xlv10HLS1Y1fnJ/ExsFYDMKBp8AJInHHixquZq5mR7qe1QpF6t2H2RIPqp 3hsh0gN8N85zf4eXy0mwLk303a3DMn+xbZuCmlqEqmhfa8aCMxCsJHi44cWADe8VAcsNZ117 8O936FtrJMZCmw0hjV1pztbVVHh0C0qX0tnao4lHpES7YTb7dXsMg24F5VKpEdByj3gbpXX9 WGNPuspMq+TGnqLEww5gJUsZ6RtzUIb1u7q3E5y42oO2M8pgE986MarPZv6UvouqhND6Ws3N 60QZiAoos+OvP+XZgNdNvpfvHHeFAlOSi8SF56AW6XXZ3vaEi946Ie3t0OlZSXkdozvdwPpK g=
  • Ironport-sdr: vwd4nTW/xkcN7l6O6dhjK0P8Qiyd/rSZqNM7ztjEyiVzFGjzIG3oMXJX5aAUztNiotrRmESirR T0e68OrjoSOUGKXvDXBX3RzJegufO3mUuLzPy9dAvj1JhvjN+pMgQPxVIUOyS7WX13iSHfj38M TBkNuE8cxf+0oCdCovLd/BJ9GDtCKTbAnC9dko0yAy98UKUxr4tV/Z5mXqxhwjZQ6rSm5doY2r 809UYRmmFiaZjqksaEHAK5GWfnhm8pwxU9S4unAR/dUPx4VSEomSMh5lr31EVGcTmpoRBViTOm a/Mb/KdivlunER18BI8tzmD7
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Introduce an interface that returns a specific leaf/subleaf from a cpu
policy in xen_cpuid_leaf_t format.

This is useful to callers can peek data from the opaque
xc_cpu_policy_t type.

No caller of the interface introduced on this patch.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Changes since v5:
 - Zero out parameter.

Changes since v3:
 - Use x86_cpuid_get_leaf.

Changes since v1:
 - Use find leaf.
---
 tools/include/xenguest.h        |  3 +++
 tools/libs/guest/xg_cpuid_x86.c | 25 +++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h
index e01f494b77..0a6fd99306 100644
--- a/tools/include/xenguest.h
+++ b/tools/include/xenguest.h
@@ -807,6 +807,9 @@ int xc_cpu_policy_update_cpuid(xc_interface *xch, 
xc_cpu_policy_t *policy,
                                uint32_t nr);
 int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cpu_policy_t *policy,
                               const xen_msr_entry_t *msrs, uint32_t nr);
+int xc_cpu_policy_get_cpuid(xc_interface *xch, const xc_cpu_policy_t *policy,
+                            uint32_t leaf, uint32_t subleaf,
+                            xen_cpuid_leaf_t *out);
 
 /* Compatibility calculations. */
 bool xc_cpu_policy_is_compatible(xc_interface *xch, xc_cpu_policy_t *host,
diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
index b9e827ce7e..aff4efe78d 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -855,6 +855,31 @@ int xc_cpu_policy_update_msrs(xc_interface *xch, 
xc_cpu_policy_t *policy,
     return rc;
 }
 
+int xc_cpu_policy_get_cpuid(xc_interface *xch, const xc_cpu_policy_t *policy,
+                            uint32_t leaf, uint32_t subleaf,
+                            xen_cpuid_leaf_t *out)
+{
+    const struct cpuid_leaf *tmp;
+
+    *out = (xen_cpuid_leaf_t){};
+
+    tmp = x86_cpuid_get_leaf(&policy->cpuid, leaf, subleaf);
+    if ( !tmp )
+    {
+        /* Unable to find a matching leaf. */
+        errno = ENOENT;
+        return -1;
+    }
+
+    out->leaf = leaf;
+    out->subleaf = subleaf;
+    out->a = tmp->a;
+    out->b = tmp->b;
+    out->c = tmp->c;
+    out->d = tmp->d;
+    return 0;
+}
+
 bool xc_cpu_policy_is_compatible(xc_interface *xch, xc_cpu_policy_t *host,
                                  xc_cpu_policy_t *guest)
 {
-- 
2.34.1




 


Rackspace

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