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

[PATCH v5 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, 29 Nov 2021 16:33:46 +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=m1+vUAFlvux2wXM0/t+OqbhuL51Rq/ENxTsQGJDXxM8=; b=jMTDTY9KwRBXc7Lw/GNPeO7RiG9RzZtTMKMrruVk0jF1GMQjS+3ubJfG5KJwG6L4rkhHXDhtO2d0pks3AZ/KdmbgP0V1dJRHJ5g3818koTZN9YQDuCjW5XwbKThV2mdNfjGoCUqGZqgUAc35HRMiZE1BZ3hk7DhU21atjn662C/0pAwOcWmAfonZTku3o8UyjtsTi9jbMW33Mk/x4Pb4saGIQw9K9eOWF1Y/CaOR4pSD0VcoQicKbf9fLJqX6whx91ZL2Ad9hHHfpWbMxWDTGJCXV2uivILhnDVQ2K51cTOemI4/JpVLjTzh5puL6f48EI8RynfNqdjbUra4U74hNw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f55NV7oVqNkETdXKYfOD1m4cC8U4yAsYj1IHyEh4bbU/W1Bm85fm6RVM4puLQoLLU4cO3O2h4Kl2ptfz2ZGf1CMotN4WQhI47fpi9qTBmx76UQqv8cQD939iwJb1BZ9ni8dYCJTRuEJS4+lrkEfQt2eZ5ayn0G8pTnWnma1tCZv0nK32ZTVNyjG5SUmQIEHi6ZvcnXNPtKmm6UfLpnFgQ29giMcWrowfONV8v1TDsnrMp+TNImDgZ/Gogl+vc897mqc+P7vGoIk0vsWxajmgucYooCjuROn/xyPIqZSSzjutUC6u6lUMaAhG2f12aqwvImuwwzD66ld+31MSf7ZPuA==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Mon, 29 Nov 2021 15:35:41 +0000
  • Ironport-data: A9a23:ol4skqNMrgz5AiXvrR1GkMFynXyQoLVcMsEvi/4bfWQNrUpx0DYHz DYcXmCHbPeDZ2v3LdB/ao6yp00GsZHQmtIySwto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdpJYz/uUGuCJQUNUjMlkfZKhTr6bUsxNbVU8En540Egyw7dRbrNA2rBVPSvc4 bsenOWHULOV82Yc3rU8sv/rRLtH5ZweiRtA1rAMTakjUGz2zhH5OKk3N6CpR0YUd6EPdgKMq 0Qv+5nilo/R109F5tpICd8XeGVSKlLZFVDmZna7x8FOK/WNz8A/+v9TCRYSVatYozakjvBa9 9V9icS1FCx0N7HNn8A5dBYNRkmSPYUekFPGCX22sMjVxEzaaXr8hf5pCSnaP6VBpLwxWzsXs 6VFdnZdNXhvhMrvqF6/YvNrick5atHiIasUu216zCGfBvEjKXzGa/iauoADhmph7ixINffnO s4DZShNVi3/MiB+PF4wLtFmzc790xETdBUH8QnI9MLb+VP70whZwLXrdt3PdbSiR8pPmV2Dj nnb5Gm/CRYfXPSPxDzA/n+yi+vnmSLgRJlUBLC+7uRtglCY2ioUEhJ+fVqko9Gph0imQdVdJ kcIvC00osAPGFeDF4enGUfi+Tjd40BaC4E4//AGBB+lyYfFwy2mBlg4FjscQ4EvqM4xYRgN2 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IxZYEv1ndBhht+OlhgjUT03imn8oVkwOBL d2Zg9qZAsnrN1W0IESBFvYCKUuBOmE3cXiqwg5ex6a2gf7ltXT61XQboeQztKMrIhGEhOuWV3N aVq8zMQcIWq43T9GW0+9PKL73+kOoUW+Y5JB6ovZzvXEd8l4u95fJgdZjVzmqLayrEJfO45aAK MWYUHI8nmO7EShnV0I4IXs73OvvKRkfMonXntx3cVS5Q3lij2F3YUjm6OB5dScZdyRotnLYbbi ztmj0CZh9aOOgoRV9debsiCn
  • 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.

Note that callers of find_leaf need to be slightly adjusted to use the
new helper parameters.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
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 | 23 +++++++++++++++++++++++
 2 files changed, 26 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..7779a3e1dd 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -855,6 +855,29 @@ 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;
+
+    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.33.0




 


Rackspace

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