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

[PATCH v4 02/10] libs/guest: allow fetching a specific CPUID leaf from a cpu policy


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Fri, 7 May 2021 13:04:14 +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=ZdUXkdSYmtbpTEHoBo3BerLgBTlLuL2N/x2tV5e9+AQ=; b=S+ARTF047uxONLDRhH+ir5109MsbWv4kMQ1dBVb3+ws7oRjxTQBpT2iU4HXhhqOGNzIzMfJ2v0G1kOemsxTuYlJ3vk2lkVZRkMI37lqYoSF/YTy/GFWrToUJrQTJFV39w5R6rTlfKD1oDqYQ0JGP/ErjjF3FoiZNqWsrP9Kqd/rVvdR4Td1nwAbR7nmhuR1/yhctt1VSQilbq9M5Tki8WYaDy1hS3NZMbzloT+gBBwtXD8I56b6GflfHapl5Ladvi23jGiLnrr+T44giujWCjyIoN62g4MIh4bniMqkrKWyte88AWu/sAvgHQ5V0RWyAbh/hL1YPijbQhuCBPfS3QQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hjzPXbhvnFEbXX7cCcIyoBTT0QLqD49qzP+6v9RGBX61kHFIEwMaJX51BGs3AnIB7pdH2jowxTo5F+rrircmWgvPnd3drnF3pW5tuGIZc65unwuDR4CL443wHSU7xMGkfHwqcUzVcsZsAIO+3WuMpwOd+e+dy2Dpn0l8k2OHuqyO+HpH5d1n+TWaZKoBQgI/ByshAtEsrrn14rWAsYposbjKist2a5p2Sn8KHCHg6qV+mOaYHjLqAdfpeUIhbhD45Kh23/cnJ+PFuBL9b/uNKWpUWUPdxCAQN9InR2g2NiLZ4GtN7M0LFqs2yR4GRzkT/sA0Pra9s6LdcDX9wtBeTw==
  • Authentication-results: esa3.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: Fri, 07 May 2021 11:07:05 +0000
  • Ironport-hdrordr: A9a23:rdygc6/9Z1MpzR2XNR1uk+Eddb1zdoMgy1knxilNoERuA6ulfr OV7ZImPH7P+XMssR4b6LW90cW7L080lqQFpbX5X43SODUO0VHAROsOgeTfKlbbexEWg9Qtt5 uIBJIOa+EYY2IasS6kizPSLz9q+qj/zEnhv5an857Gd3AsV0go1XYCNu5HencGBzWv1fICZd qhz9sCqDy6dXsNaMOnQnEDQujYvtXO0InreBgcGnccmXyzZJyTmc/H+jWjr2Qjugl0sMUfGG P+4njEz7Tmt+v+xg7X1mfV4ZgTktPlxtxPDNfJkMQPKjn3zgaufploXLeP+DA5ydvflWoCgZ 3JuVMtLs5z43TeciW+uh32wRTt1z4o9jvr1UKYiWGLm72OeBsqT85awY5JeBrQ7EQt+Ntm1r hQwm6fv51LSRvdgSXm4cTSXR0CrDv8nZJq+dRjxUC2J+MlGfJsRaJ1xjIYLH9AdBiKoLzOZ4 FVfYrhDNY8SyLUU5ir1lMfjuBEe05DaStubnJyxfB94gIm7EyRlXFov/D3tk1wiq7UnPF/lq X524pT5c1zps1/V9M+ONs8
  • Ironport-sdr: bcF+QtuDdJx+VJ6xD91c+1BdMz65+Hm75orNzZDBrpBs/GjqCy3MF/fSJV8BSL8SxFeMLOWWh/ fXdINb9JzQMv6yFo+pPXKzqBslav8Vhi0vtk4kDyuSj4d/oujFYnEBXQ8oaDv3BlHlpwUVAdE4 jMIycqOYsZvRzlsXY8XVjmEtNnnAgMpkyqcYMYu1hUSAj5xmFH3xP7+iPPpl6GvggrSK+d6lOp Ikr7ta5AymAqx6RPgIok2WrcQKK9Ic+DNxHyTSWr2fdZwhNvJTHfnqfJtyNirAQ/xLdkJiiH0F tzU=
  • 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 03c813a0d78..7001e04e88d 100644
--- a/tools/include/xenguest.h
+++ b/tools/include/xenguest.h
@@ -744,6 +744,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 144b5a5aee6..460512d063b 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -860,6 +860,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.31.1




 


Rackspace

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