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

[PATCH v7 04/11] libs/guest: allow fetching a specific MSR entry from a cpu policy


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Tue, 25 Jan 2022 15:49:28 +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=2UP6F+DQsCKngxfuXZykNG42jx0HaHpJ8RyucFFd0lY=; b=hOlJhNxhktgA02qQ+OcSFHhb80vQ+zpPPkGdr7ad9ZFrzk0dBxapFGhDNTP0iQEjT55SQ7eWYFQ4gi2M08W9qMloHfrm3T5cNkahAuKXVotSBneSxlMB+jRt/KPMZZTNZrdI6MWc733OX80y7+haHnvUk+RFYBXbnqoJQuPZKd7HL6WbijeneedNJcU7bjPYvPVtm9kG/4XL+jQ1C/2ssUQcnFmpFbgtsOyCKGmcsaUEaaesJUC5I/lJR9aLtJOLVS6jja6m3Kiars+RpcFBZSsRdj9jgY8NF3lf852/ur3ZWMY+LFbP2aq5xN+ltNdExJqX67s2F6LI4yX9siIwQQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eekxc+HW1UDGs70oPp3o71pMTQ2NwtI1P1znXComzjMifa4CvnNS6//RFAnGQ7Ok1vdDFDwHmdJ8zuvqaN1TxqdUHpWklo9Tb4hMAiDW16zO1G6BYI8FL1/G+UIneUOJ5S0sQxLDrNi1N5M5FXd1rmCQ1qzWdoBT7WnpISOjZQwrJST4hLNdsaShM3Tv5kZp6BAhiwI68IaRNYeCFN0nFR5mHIjpwcUgA3W4dQK7ykB+olsKWblkSIi9UixH1ud91b4jc205qHIMSaEtRdz3rQrekl9FjOH33JGigwrrthxBlcSelWAVFJJHzaOYmC41+k24gNRhgsPwNn8AhnuKog==
  • Authentication-results: esa4.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:10 +0000
  • Ironport-data: A9a23:q4Wyeaq1iOy3PCJ4deK/AvB5HXBeBmLpYhIvgKrLsJaIsI4StFCzt garIBnXPamIajb9fdp+Oo+09kNVvpLdn9NhS1E9rC4xFX4X8puZCYyVIHmrMnLJJKUvbq7GA +byyDXkBJppJpMJjk71atANlZT4vE2xbuKU5NTsY0idfic5Dndx4f5fs7Rh2NQw2ILkW1nlV e7a+KUzBnf0g1aYDUpMg06zgEsHUCPa4W5wUvQWPJinjXeG/5UnJMt3yZKZdhMUdrJ8DO+iL 9sv+Znilo/vE7XBPfv++lrzWhVirrc/pmFigFIOM0SpqkAqSiDfTs/XnRfTAKtao2zhojx/9 DlCnaKxZAsMJfDlo+EyFBNITnAvBrBN2IaSdBBTseTLp6HHW37lwvEoB0AqJ4wIvO1wBAmi9 9RBdmpLNErawbvrnvTrEYGAhex6RCXvFJkYtXx6iynQEN4tQIzZQrWM7thdtNs1rp4STaaGP 5JGAdZpRATKZTx+O1E8M707xLqWukT1eSVcrF3A8MLb5ECMlVcsgdABKuH9eNOQQt5Otl2Fv W+A9GP8ajkYPtGCzTuO8lq3m/TC2yj8Xeo6BLC+s/JnnlCX7mgSEwENE0u2p+GjjUyzUM4ZL FYbkgIxqYAi+UrtScPyNyBUu1bd4ERaAYAJVbRntkfdkcI4/jp1GEA6TxNNTcd7nfQzansgx gLYzuj0DhxW5ej9p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PoSiTPQe71LoKjlzEnrv5al854Ed3AVV0gK1XYfNu/0KDwSeOEQbqBJa6 Z0q/A37AaISDAyVICWF3MFV+/Mq5nik4/nWwcPA1oC5BOVhT2lxbbmG1zAty1uHg9n8PMHyy zoggb57qKsv7WSzQLd7Xba69BzlMH6wtVOKcSQgow+KynqiCyveIN9Mofy9gwdkaWK0hIHgd PMqxAvM4Ba7G7QRHi8pV/X1wzpwF8Vmgnf4G7dpUGmjd3yRTo8BcYEr5leaAHl500pu8w5+L 5X3kqC3qAnQy/orWDY3ZzlRhtqnk27rT4JiugIlUFSVoMYdft4sZEfxkVIC50NdRiKp7zPKN MeTP002cwmMm9zNxvizytSKZ2XLzgO9y69Mwk/Upf/6UkSoJh7p3Fos/D30E1wsK7VcKM0lN gsBJ4Y4I2mfvVmHZ6VO91xM/dfcla9OS4kEFjiaGgPR5t3c04klfbMkcAIDaeRCds18Kc=
  • Ironport-sdr: TtqoIkttRPuZ5a0Yl4W8lu8MFtC52jinK4d1Do1ndrzzwl3ljTFPYUxIZwmpP4MsH+6McWbkp6 dcRNmPiqOB3LBpqzFKwq6rQ4AjB6nhSNp8UspioaDmi0KA8Hpf56b7eysFoLl1cUwINA1hwNyH ahENqpCrqci2mTb7iU5NoRVUGTqGbBKFcn03wHXH7r2w1PC6l47YgIdWqeCfWmStMMFetUv+/A SnBLfRHu9mSCpGnFoUbZcGuDID5wwm3QhqaWN8SXKUzCe5LtPvDOni0wA3pQBo8f3oOS6+YBXF sVo0i6McWMgWsFXUG1kKhodW
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Introduce an interface that returns a specific MSR entry from a cpu
policy in xen_msr_entry_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 v3:
 - Use x86_msr_get_entry.

Changes since v1:
 - Introduce a helper to perform a binary search of the MSR entries
   array.
---
 tools/include/xenguest.h        |  2 ++
 tools/libs/guest/xg_cpuid_x86.c | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h
index 0a6fd99306..2672fd043c 100644
--- a/tools/include/xenguest.h
+++ b/tools/include/xenguest.h
@@ -810,6 +810,8 @@ int xc_cpu_policy_update_msrs(xc_interface *xch, 
xc_cpu_policy_t *policy,
 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);
+int xc_cpu_policy_get_msr(xc_interface *xch, const xc_cpu_policy_t *policy,
+                          uint32_t msr, xen_msr_entry_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 ad6b349680..af5b8e47f4 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -881,6 +881,26 @@ int xc_cpu_policy_get_cpuid(xc_interface *xch, const 
xc_cpu_policy_t *policy,
     return 0;
 }
 
+int xc_cpu_policy_get_msr(xc_interface *xch, const xc_cpu_policy_t *policy,
+                          uint32_t msr, xen_msr_entry_t *out)
+{
+    const uint64_t *val;
+
+    *out = (xen_msr_entry_t){};
+
+    val = x86_msr_get_entry(&policy->msr, msr);
+    if ( !val )
+    {
+        errno = ENOENT;
+        return -1;
+    }
+
+    out->idx = msr;
+    out->val = *val;
+
+    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®.