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

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


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Tue, 25 Jan 2022 15:49:26 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=KZ0k7g5jZeIdNY9/Tfsnttg1bIIKhfsWZFaLo0n4ZLI=; b=oahEqM1ilqGjNxMj8Rx0iBTC3DdEhW53Kvoocyu87tzeVNBLrd92OZWF2xgch6wahm2x6cDSyTRf5/E0zjAlnSjar2TQ1ZEvxbF1+1ZLZfdSc9p3PZ0E+P0NStRSYkT96LaRAzAU7CYF8pnP+33EIsKp8vdkh1yzxYf4/sGj27b0//fuYgbw/pFQkloIOJLAwMN0f0laG9rx9QTftzO69JeAguhstCQ2uYQbW2vfO/jp1DfkRtdCJnqz9sndnF9HV0g5glp36WoXy2DA5zNs+K2I3IdG2DastMy/jcMwVGSRLHMBrZze/Da1WovAnVc9jou9bp5Q0tCjwvzLVPy+MA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DlMh7iq6qrR0Jc28xd8xMJqvfVnuOvcqUypXjCjrjUf1xWuUspXySDMC4dZtmfd7iKz/7m+1hvQqMw0t0PF3JyFZerGVD2F812omdQOd9aLFK+zaG2wIg81AU07HjfEnpmriifcVSfccSohIBmOB3rWBVSFOjE5LFcoJzHtSXMEnmZS1q2F7Ruu9bnifpObs5AqzOjSe00sWEws+2GBhHiOi1dNK5fDRCyGXfuE5g7kJ7tDdV4vqt04KC7FdOzlZfEDHsedzPU7j7+eEPyt+Pl9NTUtsqwMS4qi9zlmRI7mtHPNIlTJhCtoIr/LfXK+8vcYQIOMXKA9TAUgCh1VPgA==
  • Authentication-results: esa5.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>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Tue, 25 Jan 2022 14:50:01 +0000
  • Ironport-data: A9a23:n1K4vK+PyaFYpYv+kpBeDrUDcXmTJUtcMsCJ2f8bNWPcYEJGY0x3x jMWWD2AM/+IZGSgfIolad60/RsCu5eBmtExGQVk/no8E34SpcT7XtnIdU2Y0wF+jyHgoOCLy +1EN7Es+ehtFie0Si9AttENlFEkvU2ybuOU5NXsZ2YhFWeIdA970Ug5w7dj39Yy6TSEK1jlV e3a8pW31GCNg1aYAkpMg05UgEoy1BhakGpwUm0WPZinjneH/5UmJMt3yZWKB2n5WuFp8tuSH I4v+l0bElTxpH/BAvv9+lryn9ZjrrT6ZWBigVIOM0Sub4QrSoXfHc/XOdJFAXq7hQllkPhh7 /pd77uJQD4iN/T9k/szUDZ0Ky1haPguFL/veRBTsOSWxkzCNXDt3+9vHAc9OohwFuRfWD8Us 6ZCcXZUM07F17neLLGTE4GAguw5K8bmJsUHs2xIxjDFF/c2B5vERs0m4PcGhm5g2J4QQZ4yY eIHNTFSNEvHPCYWYHkaNM8Clu61gnDWJmgwRFW9+vNsvjm7IBZK+LriKt3OYfSRWN5Y2E2fo wru/W70HxUbP9y30iee/zSngeqntTP2XsceGaO18tZugUaP3SoDBRsOT1y5rPKlzEmkVLp3N Eg86ico668o+ySWosLVBkPi5iTe51hFBoQWQ7ZSBByxJrT88yG2FjIjdzd4Y9V/hcQpaz8F+ meFgIa8bdB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ts2jU0dNz2CA5sQkTuRYTzrdXGeKjM2YKbQQ/ Gnl7V6TnebCD8qR/X+IkNAc/nIptXNmp6jSRkaByQ/4A3LqT+z8rb1HzWRwx9bClp0sPof2F mAtza8yrSosvm9xBOZ/2jP765OkN+k7tdYHsSDhuUcNz2poAe1Y4ZKXaGEoVkO0auSwWdvtO OJjwYrPsx15X+UVmapoSH10w2l6zoq42+K8y7vvVLT5ejCAB4qActIgoxUNjHD7VA7gd162K VXm0qEqpt+F3r77WrAzumNcysvulu/oHIkn+JWpWdYS5EiZLhYqpFa1F9JEa0HADnx5OkcYa ZT5fnnlbZrmG6hHjPkVjEF+q3vYp1zJGbLfqE6gL3V79AM90oJinfxx6Qk7wA9HdwGOt15Dt //Q9dVfYd1P7srhJJGdZc8qPSMex7wqGr3QRqvyHTcZeg60iH22tbKCItc3pDeRHVP9up0pK j8
  • Ironport-sdr: KutWxlx6cZDbxosUtTTMvCbcP+A817KsCd+UKyrif3/SBhSu04DB5S1Pk/77mG4Ad8hWr+Uwpv c2XAna6ZZzRlCeYf0WRXzVcxCmKo9HQ0cP/DjTIC8mg4U3e67gW2fuFk2G5q5qKKH7fPY9XQpe qwoQ6bPZ5UaJXnI/S2JBjfqf0yFTAjI8ZI4nRDp6ucAG3vNdbXQ7QKScOLjVejTs5+dZtlC/G8 QbihNus5HrwoYltSI5ijnrM11RbNxshHPW9j0JMpTZkG/DN+hruirG2/MTqyHVrLAD5LbF7iM7 SYHcLFvPW9S3BYAhiawwqgZ+
  • 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>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Changes since v6:
 - Add newline before return.

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 | 26 ++++++++++++++++++++++++++
 2 files changed, 29 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..ad6b349680 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -855,6 +855,32 @@ 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®.