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

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


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Fri, 7 May 2021 13:04:16 +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=ZFiEJE/7tweLfCqiWGwMSdcuoNYoTfrGmGb2P+8nYGc=; b=lhP3T70AXPGiR/NGd+UtLjlkgEAHJfirCuYZGnMLdbRfRWrDvUjT3poFh/w2WCCkqA4L0x1A2W3b06v7uCG4Q+DrIExAJu2WV9/0foygMMFoaC6Rhhi9IBgNW4QrAeC6Zw81h8IzPWwdK6BfcNcfxfwcRVjxVO//dDN4M1Y6+rHHImVfT6W0yH+YwV+oYr+ilcUL4EQIfjm04iYNHa2N4j0HSRtVrlBMKd896Nli49b7kwfVAUQ6VfRRVbQCpu5gGrokLBj3ZZZb+/CutfLc7zNTM6BtPvd+jfbE6cBAnTTSQ/lftJsAMzT5AXiJ0lmjtd4v1thutKLAfkXZpaUluQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TtBUQR/5Vfr9FzBxfvpAet6RymtnqRWfcpqg4BtAiwED9JhDre5rvgf+jBR8qsu3KMdHccTgmxod7yMLwRllWXM/dXMmrzTSzDbWrPUTwEkyHRkEPwNl8yHS3WlGtea34p/kXzbk9KsqNsYNKR2ggItS00HNgCT1t2ADYonFf4qRt89nnxQIOuAqftwSlTFTtT6PdhML6XVgFytOHq5atn/TjcXtHyaEu0OiLQHYHDv5A+X8Rrb4FxCfwkm+soJ858clzQa8K9Jn+zjAhQcSChXqDi9EdKNo1t5Qy571E7u4AeKDmGPsvEYVQKr9w1HfO3B+lqeVvueQOavd9bWw+Q==
  • Authentication-results: esa5.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:14 +0000
  • Ironport-hdrordr: A9a23:gXwzZ6zyPKc9zSPfDdMmKrPw1r1zdoMgy1knxilNoHxuH/BwWf rPoB17726RtN91YhsdcL+7V5VoLUmzyXcX2/h1AV7BZniEhILAFugLgbcKqweKJ8SUzJ8+6U 4PSclD4N2bNykGsS75ijPIb+rJFrO8gd+VbeS19QYScelzAZsQiDuQkmygYzZLrA8tP+teKL OsovBpihCHYnotYsGyFhA+LpL+T42iruOeXfYebSRXkDWzsQ==
  • Ironport-sdr: 0XEVxeCkgPP3MJ8zvkOM9bW3fa7tRXOPah6AlJsP6IJK/7PSvjmNkIANF+uJHcu9GdVauWf2/R 2uX+pmAc4MJneBqeE7IH8o6XMAI4xRSCOQbB0b6bDopLeWSm4i9UFIJKmU4Wqm+81oyV4s3KgH n2etB9Y6HwLrxv5xowRZPmKu7sSViByCYndlIsegkhTAi5oJu/+nZHaEP2QJR9DuHEbynlALPL yhsCZD5CzjKtaqTQoimhgAw4hgSpuO1gDVNgf3m8GzELCUuJAOtSMjRv6pG3j9UDxrFfpbSKpl NtA=
  • 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>
---
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 7001e04e88d..8e8461b0660 100644
--- a/tools/include/xenguest.h
+++ b/tools/include/xenguest.h
@@ -747,6 +747,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 460512d063b..cdfc79a86e7 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -883,6 +883,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.31.1




 


Rackspace

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