From: Roger Pau Monne Date: Wed, 17 Mar 2021 15:49:55 +0000 (+0100) Subject: libs/guest: allow updating a cpu policy CPUID data X-Git-Tag: archive/raspbian/4.16.0+51-g0941d6cb-1+rpi1~2^2~42^2~565 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2d09c97e58ea455242a3862c16e732592841ddde;p=xen.git libs/guest: allow updating a cpu policy CPUID data Introduce a helper to update the CPUID policy using an array of xen_cpuid_leaf_t entries. Note the leaves present in the input xen_cpuid_leaf_t array will replace any existing leaves on the policy. No user of the interface introduced on this patch. Signed-off-by: Roger Pau Monné Acked-by: Andrew Cooper --- diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h index 27cec1b93f..543bd2a4c2 100644 --- a/tools/include/xenctrl.h +++ b/tools/include/xenctrl.h @@ -2608,6 +2608,9 @@ int xc_cpu_policy_set_domain(xc_interface *xch, uint32_t domid, 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_cpu_policy_update_cpuid(xc_interface *xch, xc_cpu_policy_t policy, + const xen_cpuid_leaf_t *leaves, + uint32_t nr); 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 0c9b3a960f..713649edde 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -822,3 +822,23 @@ int xc_cpu_policy_serialise(xc_interface *xch, const xc_cpu_policy_t p, errno = 0; return 0; } + +int xc_cpu_policy_update_cpuid(xc_interface *xch, xc_cpu_policy_t policy, + const xen_cpuid_leaf_t *leaves, + uint32_t nr) +{ + unsigned int err_leaf = -1, err_subleaf = -1; + int rc = x86_cpuid_copy_from_buffer(&policy->cpuid, leaves, nr, + &err_leaf, &err_subleaf); + + if ( rc ) + { + if ( err_leaf != -1 ) + ERROR("Failed to update CPUID (err leaf %#x, subleaf %#x) (%d = %s)", + err_leaf, err_subleaf, -rc, strerror(-rc)); + errno = -rc; + rc = -1; + } + + return rc; +}