[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 06/21] libs/guest: introduce helper to serialize a cpu policy
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Date: Tue, 13 Apr 2021 16:01:24 +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=+C8NC1XmcgG+hR7rhDwEzRtSVqk3ZTRRhzEbmJGLd68=; b=e8x7s+BD5l63z9wD4u/e6dU5iwqd+JTcJXbfwRlsBd8vpsoctt56hjyA/clY4v18IdXT9+a8+BBD+ethVwo/XHFKadtLvk+01CCNaHo7/PUT3xXgP7oe3BcUq/NaIKT4+fLxES+grOYOITm9NHSa5lMkPpV64Zh4t1wTBU4+P4OW9cWVBDO64JEryhZ0VLUmDukQp00nfQcFCTRBJdjuhq6hO9RaVuOPJJHgpB2Dfb1bYYuYaV2kMVXCg5PlW6JaHyJNxa/LGXa+TFubFEADrD/80TxHc5zhcwD7/o3kFfOgxm8B3oYkpamrx2USo/OQhp9hLm3c8MYBlYkaP5jZ8w==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=joEvALicDJ1p3S8vig9ZE65tnZQWRau/K/sqzSa/PSfs2X8bZbID+cgsA7JmnmBGuTXZWVyDmIzNO0iOCrEkAlTBU5zcFYrM1uOgo1IphCbcttEs9u4jdywXTTXv6i3TDAC1SDKIgQ55gllklStD8bltYuegYe+y5i560hoLEIEJ2fMWk/N3Eer2HNcC8EkJ/Ua+z2ZwZA0zTqQGFJq/7saRo7d0w0rpfHL9vUT+BGa0A7ktTYV0GC56Lmf7vR/CnzGF8d0fcRsizZrbERTBVDONa9CSttoL8cZFdqai+oq3lEoHks0ybULoh+npVU87tZkp+vURG9hR+RA0asMuqg==
- 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: Tue, 13 Apr 2021 14:02:36 +0000
- Ironport-hdrordr: A9a23:LH1h+aGQWsRdwelIpLqFMpHXdLJzesId70hD6mlYVQFVfsuEl8 qngfQc0lvOhCwMXWw78OrsBICrR3TA+ZlppbQAJLvKZniChEKEDqFHqbHjzTrpBjHk+odmv5 tIXqBiBLTLYmRSot395GCDfeoI5Pmi3OSWifzFz3FrJDsaCZ1IywtiEA6UHglXaWB9ZaYRL5 aX6spZqzfIQx1+AviTPXUZQ/PF4+TCiZOOW3U7LiQ64wqDhy7A0s+YLzGk2H4lMg9n8PMZ3k Xu1yf44aiitP/T8G6n60bjq654tfGk5t9KBMmngtUYJDP2mm+TFflccozHhh8ZiqWC70srjc ntrn4bTrhOwkKURE6Zi1/M3BTtyzkn4XOK8y7mvVLT5fbXaRh/Lugpv/M8TjLpr3AOkfs57Y dwm0WejJZTBQOoplWE2/H4EytEu2DxnWAvioco/htieLpbUpB9h6oF8nhYFZ8RdRiKk7wPIa 1VAMbQ6O0+SyL9U1np+m1mwNmbVn8uBBuxQk8bpsyP0zRN9UoJtncl+A==
- Ironport-sdr: Sj/Xa0h65LTdNTab4d1DHs0sDv20l4Se/NuzOXOEUPv86hEb+/+HxMH9JU5lvU/TiR9FRg3NIq ArJRa34fNTxQDGBWBmG6AXmK11Uk+ZyJH3SCKJDNZFAT4/9tx+/x787SUDTSCM8McvLQMck6L8 st6Uq2bsa12otf0vA6FXePoNU7kGHi+XSMQjEw/DiqxQ3ewnZzEM5+AKopFiweZcxX42hT129L yvxfyZ5qH3BhY/2uBrKt6h4lXYAedggDTeiQCoV8ox4CGE3t5l3FmTNY0I6FCXNK9LKp+/39Xr ZH4=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Such helper allow converting a cpu policy into an array of
xen_cpuid_leaf_t and xen_msr_entry_t elements, which matches the
current interface of the CPUID/MSR functions. This is required in
order for the user to be able to parse the CPUID/MSR data.
No user of the interface introduced in this patch.
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
tools/include/xenctrl.h | 5 +++++
tools/libs/guest/xg_cpuid_x86.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index 34d979d11da..a4827b1ae6a 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2602,6 +2602,11 @@ int xc_cpu_policy_get_system(xc_interface *xch, unsigned
int policy_idx,
int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid,
xc_cpu_policy_t policy);
+/* Manipulate a policy via architectural representations. */
+int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t policy,
+ xen_cpuid_leaf_t *leaves, uint32_t *nr_leaves,
+ xen_msr_entry_t *msrs, uint32_t *nr_msrs);
+
int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps);
int xc_get_cpu_featureset(xc_interface *xch, uint32_t index,
uint32_t *nr_features, uint32_t *featureset);
diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
index 1394e503f3d..918591a128c 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -757,3 +757,35 @@ int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t
domid,
return rc;
}
+
+int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t p,
+ xen_cpuid_leaf_t *leaves, uint32_t *nr_leaves,
+ xen_msr_entry_t *msrs, uint32_t *nr_msrs)
+{
+ int rc;
+
+ if ( leaves )
+ {
+ rc = x86_cpuid_copy_to_buffer(&p->cpuid, leaves, nr_leaves);
+ if ( rc )
+ {
+ ERROR("Failed to serialize CPUID policy");
+ errno = -rc;
+ return -1;
+ }
+ }
+
+ if ( msrs )
+ {
+ rc = x86_msr_copy_to_buffer(&p->msr, msrs, nr_msrs);
+ if ( rc )
+ {
+ ERROR("Failed to serialize MSR policy");
+ errno = -rc;
+ return -1;
+ }
+ }
+
+ errno = 0;
+ return 0;
+}
--
2.30.1
|