@@ -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);
@@ -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;
+}
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@citrix.com> --- tools/include/xenctrl.h | 5 +++++ tools/libs/guest/xg_cpuid_x86.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+)