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....@citrix.com> --- 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