[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/21] 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, 23 Mar 2021 10:58:38 +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-SenderADCheck; bh=tLD0gqExlSO+XE2AhvF0loGaIpssKAiJtCEzPFIxt+I=; b=mM4qGr6DrUO1XCpWDLopRqflOsOmaZt++8DtePWEfDyuZZqKQI0uo0KkIYhwLgbxkSHrH6CJElH7/Z/lmJO+wdCoJqjUj0F3EMm/Afbwq1efiAPH9IbjT6wYlTTIVcwLe/1573TexNrSMiC49iFMPGoSvdIFNyVGMeo7Cg+v5xzmD3QI46/I5eroTaZ54R+duP/fE9mUc6H2o6Iy/Gl8U0oebybHkVGyM9SP9akPxKc1A0dJBCygnRIDo09LdLKjWWj6j8RkK9jxFilO07tz6FibqiTp9bMW9lQx8FbhoirXfuKFLYFcSXJNUCpFksA09uGBphkCkn82SdR4Rl5iyw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e4T+UxrA1vFb2VU7u6rOYvVMqWlLUTSndwSRVvhrNalwAhg0502GGSU7r68hLc0fOSGjnp4k9TCVuRLaRFVw0C36IGX/5HR5X7kzhWF8xtIMlrxaLF1x863dDRWanhxxfSL76hmCDHAwBPojm0hunYTCAo08vQY0DKfTe9xSaWZFbleygycvAEJRkDFx5C3meu0EGr+c2UbQ90BoEE0Py/aHwOPePDoXfcQ/tXiHTHtjUA9FcC2tdE8cmNUMiOJvpvj8wZPb0UHaNqgBBLYC7tfWC9NAQkRpsDJ1IYrY7G93tYmWHlAW5zNqEfwQvNhs/2DVxpEn69V9QlwQ6EQJOA==
- Authentication-results: esa2.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: Tue, 23 Mar 2021 10:01:00 +0000
- Ironport-hdrordr: A9a23:gNsv8KoOWVYjYSLLCSg654EaV5v5L9V00zAX/kB9WHVpW+SFis Gjm+ka3xfoiDAXHEotg8yEJbPoex7h3LR+iLNwAZ6JWg76tGy0aLxz9IeK+UyFJwTS1M54kZ 1hfa93FcHqATFB5/rSzQGkH78br+Wv37uvgY7loUtFaSFPR+Ve4xxiCgCde3cGITVuIZYiDp KT6o5milObCBcqR/+2DHUEQOTPzuej/P7bSCULGgI97022hS6ogYSQLzGjwhwcXzlTqI1Sk1 TtrgqR3MSemsD+8DDw/Sv575NamNzuo+EzefCku4wuBRjHziqtbIRlcbWesD4yu/HH0idXrP D85y0OEu42x3TNfnykgRaF4Xie7B8er0XM5HXdoXz/rdf3TDg3YvAx+75xQ1/ixGcL+PRfuZ g7uF6xht5sIj7r2BnZ3ZzuUSpnk0KlyEBS6tI7vjhkfqY1LINKoZd3xjIyLL4wWBjUxaoAC+ dUAMTV9J9tACmnRkGchGVpzdC2N05DZyuucwwHssyR5TBcgGp0+Use3NAehXcN7vsGOuF529 g=
- Ironport-sdr: DoQAdXkY97gRg0xOI82IKO2YpwLHJeSaoo5SLrVHhfW2tVadrVJsD81WdeNze+YHrTCUEAHnZV s5Ln591fNZGgaa6JQfzRVDFl2lE+1FvWF+o4Ni2pvOMVU9c96C0m1DblSxlOcQ3wZpTjwjcY4W Kq4/rBXW3cRRdRcAkMjxqA9vAf7KxMn1d6FeT/xW9e9ZHNmZZ0sc9/zVL7fOqicIZ+/BVBFB7D 4lgpUu3oCdLo6LuZLkSLeoY8U6S6xFLQVNXLIKz5gSYat7z1tiN8VehX5yc9or+trGEtqCpIHg eEE=
- 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>
---
tools/include/xenctrl.h | 2 ++
tools/libs/guest/xg_cpuid_x86.c | 41 +++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index 983e4c11d93..ab34df1dc98 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2611,6 +2611,8 @@ int xc_cpu_policy_serialise(xc_interface *xch, const
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);
int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps);
int xc_get_cpu_featureset(xc_interface *xch, uint32_t index,
diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
index a1e1bf10d5c..091aeb70c9c 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -925,3 +925,44 @@ int xc_cpu_policy_get_cpuid(xc_interface *xch, const
xc_cpu_policy_t policy,
free(leaves);
return rc;
}
+
+int xc_cpu_policy_get_msr(xc_interface *xch, const xc_cpu_policy_t policy,
+ uint32_t msr, xen_msr_entry_t *out)
+{
+ unsigned int nr_leaves, nr_msrs, i;
+ xen_msr_entry_t *msrs;
+ int rc = xc_cpu_policy_get_size(xch, &nr_leaves, &nr_msrs);
+
+ if ( rc )
+ {
+ PERROR("Failed to obtain policy info size");
+ return -1;
+ }
+
+ msrs = calloc(nr_msrs, sizeof(*msrs));
+ if ( !msrs )
+ {
+ PERROR("Failed to allocate resources");
+ errno = ENOMEM;
+ return -1;
+ }
+
+ rc = xc_cpu_policy_serialise(xch, policy, NULL, 0, msrs, &nr_msrs);
+ if ( rc )
+ goto out;
+
+ for ( i = 0; i < nr_msrs; i++ )
+ if ( msrs[i].idx == msr )
+ {
+ *out = msrs[i];
+ goto out;
+ }
+
+ /* Unable to find a matching MSR. */
+ errno = ENOENT;
+ rc = -1;
+
+ out:
+ free(msrs);
+ return rc;
+}
--
2.30.1
|