[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/21] libs/guest: introduce helper to serialize a cpu policy
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Date: Tue, 23 Mar 2021 10:58:34 +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=x96POU3Rped/M3iZclAcVyiA8U+JKnNokSoJ4Bo8H4w=; b=QxxxS9mldxbpf9U1yhZOnwLE6bEk3bWXn9cIUhc8mvrYLFrT+ZrOJzK9HX8twmgpLPPa2/moPgsPrnQBAuzmWHFJ2iqSkwqrvAf/X2Wg2y9XC++4DAl2bMDK/2vwpXNc9UekJMPDsFasX2mvNqilVRWxf48Lgoed2CdAlgM3KkrHChhQ9QVMCMSxNnw9f6NQQD/cL8jl4j347Im5IeE0oHZtGL8s/YaF41sAJ9qOf3cLSHqsZ2DQ5+QVgNefTwbANlswGdOx4w4Fweny/pYgUwedZ8USyEQe3XNmusygdOM5Cj0eUYKK60r04cS9njej5hbM2Amy7P1jkdUlU0vq2g==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gXJ1iYuw4/bok+tKQ7fDpj75KpBnWo4cbSXSA/uzhFay4Clfuk6Yy+Xaga1sfOfENCEcLJm1fCuSMwXNf9RzMWr+6zlgesRerDbRR7AlWJ0dosMdKX6xJwLfvvxSGDbIx5FbsobMiOfkFSOpVE5+Ggd/Y+IwOK2Pf8rQhwtKW25nP7YDfwu4f9L89rYd7u8bChBwjwRryxZTlZlvKboUV+G/Vmwix/h5zlugyOHLvWJkEFhyyATFFD3lO53FqahAeCBsEhIeygeb0hVckq/uxH1HfYSoSOYI5Zn3PCNlLGrX2n7E5F5rp8gNuYA2EYiy9p5jR2iP4DCS7KvdfKe0nA==
- 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:00:33 +0000
- Ironport-hdrordr: A9a23:68XtpaCBQjI8bbjlHejTtceALOonbusQ8zAX/mhLY1h8btGYm8 eynP4SyB/zj3IrVGs9nM2bUZPtfVr1zrQwxYUKJ7+tUE3duGWuJJx/9oeK+VDdMgXE3Kpm2a 9kGpIVNPTZB1J3lNu/xQG+HcopztXvytHQuc715R5WLD1CQadm8gt/F0K/Gkp5WAFJCfMCZe Khz+BAoCetfmlSU9SjChA+LqP+jvDotLajWx4JABY79BKD5AnC1JfWGwWVty1uNg9n7qwl9Q H+/DDRxqLmiP2jzw+Z6mm71eUxpPLE6v9uQPOBkdIULDKEsHfjWK1EV6eZtD445MGDgWxa9O XkmBsrM8Rt5365RAjcnTLX1wbtyzoo4XP5oGXo5kfLm9DzRz4xFqN65b5xTxrD50Is+PF63a 5btljp1aZ/MBLakCzxo+XPThFh/3DEwkYKrOh7tRJieLpbTIUUgZ0U/UtTHptFNjn98pobHO 5nC9yZzOpKcHuBBkqp81VH8ZiJZDAeDx2GSk8Ntoi+yD5Nhk10yEMe2Yg2gmoAzpQgUJNJjt 60fphApfVrdIs7fKh9DOAOTY+cEWrWWy/BN2qUPBDBGLwYPWnO77r6+q886u3vWJFg9up8pL 3xFHdj8UIicUPnDsODmLdR9ArWfWm7VTPxjs5E4Zx0vaD9WarrPSWPREtGqbrgn9wvRungH9 qjMpNfBPHuaUH0H5xS4gH4U55ObXkSOfdl+uoTaharmIbmO4fqvuvUfLL4P7z2C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Tt+VH+cZHrxf4xTk98NRvEB5x25qrcf/nKuvJg0+r3 DWi+bbARwa00W0oIY9khdGpDycK7xOyrPEOnS9gTeChH3NwDxSu0QiIothywpu6vz7AHuPCGGF dEuaj5zkNV0K2VBBI5IfKYlDGLLwZzc1rfBzZ2Qg/qdkpAk0XJlgsX8AxGKnjzwjg4Xde4jjjG K/Jf1OFZtdbAy8Otb5xIpMEDlSRuY7sIUtXPSTNFMwms2Hhr8AEfcelDbnYtNkPraSHou5HS5K 3Ig=
- 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 8b8b30a2764..983bb027a04 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 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 75ac70996ac..812ef14fbcd 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -811,3 +811,35 @@ int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t
domid,
free(msrs);
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
|