[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 04/13] libs/guest: allow updating a cpu policy CPUID data
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Date: Fri, 30 Apr 2021 17:52:02 +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=KrqI6833NbHxFCO57sSX2aG8FrkbJegAmboNZQJdf7M=; b=No8HaK2DuEFNeR0ANtDMOwCsHi5AqjjxSVcni+U8VFXPElmfMLkLsSXvLHf+be2xXTrnjaVqM9Wy9+Qi9qh5LR1zPYYl5AbrmweW4AdJoJNK7LkpvkU2znW7KTKei/SBKRmC6rbm5I1JkfFctWeZoVh9EwY1oG3EzAlEbdaCtHv6F7in1zl5PNQYBX3ZK4nAIK0plEXvRjjOtuXZZV/c9On8fgovkm8AUtg9DzYE7o7jyakYMzCFfmdqHgfoCB7PIsLBlZ7fUA7xWzDprADsWx27Ct/4XFhq05Czc4nobawTk/q/PvNXAI3SASvHehZSHDZ2pWlFLJr2zK9WwAEdjA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RorquNSTBsfgsLMkm0Anag3Yp5OPbuWQNAqMmUbDPHcZG2G8krTo/qsPumFNoHooh3qRq/nfurK1Rvw57Wtms+gsxWjePQXhyU/PYAMy87o9Hlu0nYx2ZzZS1pkuHmXbJfP9PBYyBeW8GFMRwx+4NA+mGoqEJcWD8ZBxN3Hk8tum950cuqLqgQxrNlCQLUUtDwXw50a/IXWgxr01NIBDRs+IQ5rwcN+Zp+CwrV8cya2FX3e3Td2EgcRgrJCQc/O7gVqEljGZgXncMKguIshw2MrzsAksct8d0oF60sMQB3nFyOfIdT07T4mDuAZ16x0Bj/XlhEH3Ah3U+hoVFY9gQA==
- Authentication-results: esa4.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: Fri, 30 Apr 2021 15:54:04 +0000
- Ironport-hdrordr: A9a23:3UPkQqnmmKSNMLge4myFAzn/EjnpDfO+j2dD5ilNYBxZY6Wkvu iUtrAyyQL0hDENWHsphNCHP+26TWnB8INuiLN9AZ6LZyOjnGezNolt4c/ZwzPmEzDj7eI178 1dWoBEIpnLAVB+5PyQ3CCRGdwt2cTC1aiui/vXwXsFd3ASV4hL6QBlBgGHVmh/QwdbDZQ0fa DsnvZvjTymZHgRc4CHFmAINtKz7OHjuZr6bXc9dnsawSaUizfA0tDHOjiemiwTSjZehYolmF K19TDRwoWGn7WFxgTH12nVhq4m0ufJ7tdYHsSDhow0B1zX+2KVTb9sUbGDozw5ydvHgDpErP D2rxgtJMh14X/KF1vFxifF4RXq0zol9hbZqWOwvHr5rcT1ABI8BsZR7LgpECfx1ks6sNlwlJ 9MxmKS3qAnbi/ooSKV3bn1fiAvsnDxjWspkOYVgXAae5AZcqVtoYsW+14QOIscHQrhgbpXXN VGPYX53rJ7YFmaZ3fWsi1E29q3REk+GR+AXwwrptGV6T5Lh3p0pnFoi/A3rzMlztYQWpNE7+ PLPuBDj7dVVPIbaqp7GaMnTdaoDHfOBTbBKnibL1iiNKxvAQOCl7fHpJEOoM26cp0By5U/3L 7bVklDiGI0c0XyTcKU2plG9Q3MXXW9UTzhxto23ek4hpTMAJ7QdQGTQlEnlMWt598FBNfAZv q1MJVKR//vRFGeWrph7knbYd1/OHMeWMoatpIQQFSVuP/GLYXsq6jeePbXL7z9DC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HNW+uqhV1Nuva0CdeZ+xQr9a5CYgD0SZo+ORkyHq7THvpY6992RKMK+JARU9TeLLHXc3SaujqW xjkojvYqCl4nTd8zYFspN6qj8nApRkni6ySWFwosQQ2RqGbZsivecTrSZIx+CpcWNZJczCneJh mas=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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é <roger.pau@xxxxxxxxxx>
---
Changes since v1:
- Don't use memcpy.
- Drop logic to update the leaf manually - x86_cpuid_copy_from_buffer
already does it.
- Only print a failure message if err_leaf != -1.
---
tools/include/xenctrl.h | 3 +++
tools/libs/guest/xg_cpuid_x86.c | 20 ++++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index 605c632cf30..49f919f16a7 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2613,6 +2613,9 @@ int xc_cpu_policy_get_cpuid(xc_interface *xch, const
xc_cpu_policy_t policy,
xen_cpuid_leaf_t *out);
int xc_cpu_policy_get_msr(xc_interface *xch, const xc_cpu_policy_t policy,
uint32_t msr, xen_msr_entry_t *out);
+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 9e83daca0e6..a38e75f8fb1 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -892,3 +892,23 @@ int xc_cpu_policy_get_msr(xc_interface *xch, const
xc_cpu_policy_t policy,
*out = *tmp;
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;
+}
--
2.31.1
|