[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 03/21] libs/guest: introduce xc_cpu_policy_t


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Tue, 23 Mar 2021 10:58:31 +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=gTCmGbFvBsxXZnJ6Z7hVKQ43JE3lWvZovCCAb8H7ohw=; b=HvnkHgbWMoHT5Og3I292wIFJ+Y+o51+ee8DxkDpkQzLmtMPfWxGbz7CZtBw8cP/+rfWukAqZXn/MbW6yFZmZCKvo8TtgMMz5G56YAWhaBxDOgi4OAwn+ywrxPmyJO949fSAg9lQTZDF/xvut1j9QI68PwK18jWBsVdd20TZMP9UqpjOOy0oW9kFm/vOIRuUgMr3qx39K/8pMC9VNGPLml0V+YMnxOPoA3L4Du6S2sHEHxAD+2MpJF3yR/nsCmBCnzNyXA8mBMMVDoldY8Wu03uCai5932QA4+TOWXkemxpA2uI3ACgmIiFgFOwIzwVxO5ZC/HOZbXx/C0zclomj4Sw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Egt3gICVYG9PWWnrHbDpz0D7bT5zGRqJPSXh0xKHax+f4Al0618ZZVqEySH8/R5MLgvEds1E8slTZczaSmghfeFBliL7F/ymqLY3dv40LTJyQHIZPraa6XYH3bss6uob0j7oAY3j/1weVlw00Bk3/C3ka5puwtQPNMEzp6K13Qy//upHtuKB4zb/qoKn3U0kvJ3k/3FFamEEZKa+q9RBvv96Cme80zKrhxwSbjc+jBVcO1VW7LzawMYUb6VWf/7MwqRfRpRpoTmSQMz58SJreYtq9z24a2qRpl4DsxRFwjwXpGa/+tk9awBny1Dn7eOgoJ83ewMP6CuFlazfj0I5gQ==
  • Authentication-results: esa6.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:09 +0000
  • Ironport-hdrordr: A9a23:i7m16Kt+oYjsieunWxZsjk2L7skCCYcji2hD6mlwRA09T+WxrO rrtOgH1BPylTYaUGwhn9fFA6WbXXbA7/dOjbU5FYyJGC3ronGhIo0n14vtxDX8Bzbzn9Qx6Y 5JSII7MtH5CDFB5/rSyAOzH888hPyO9661jenTpk0dND1CQYsI1WZEIyycFVB7QxQDIJI/Go aV6MYvnUvZRV08aMOnCn4ZG9XSvtGjruOsXTcqJT4CrDOPgzSh9aLgH3GjtSs2fjtTzd4ZgA 34uiPj4KHLiZ6G4z/ak1Te9pFH3Obmo+EzYvCkrugwBnHShh2zZIJnMofy9gwdhO208l4lnJ 3tjn4bTqBOwkjcdG20vhfhsjOIuAoG0HPsxUSVhnHuu6XCNVUHIvBcjoFUeAax0Sodlex8y6 5C0ia4sJdaHHr77UbAzuXITB1jmw6Ip2Mjm4co/h9ieLYZAYU+kaUvuGduVLsQFiPz744qVM N0CtvH2fpQeVSGK1jEo2hG2rWXLzkONybDZnJHlt2e0jBQknw85VAf3tYjknAJ8494Y4VY5t 7DLr9jmNh1P4MrRJM4IN1Ebdq8C2TLTx6JGnmVO07bGKYOPG+IjJLr/rMv5qWPdIYTxJU/3L TNOWko+lIaSgbLM4mjzZdL+hfCTCGWRjL20PxT4JB/p/nyX7zuPSqfSE0/kseprvkFa/erGs qbCdZzObvOPGHuEYFG00nVQJ9JM0QTV8UTp5I6Vju104L2A7yvktaeXOfYJbL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HHlZKtof4HRwmfoZEjUQRbFuzQ3v86PEz87J9 pWWODA/SpKVTXgBCfPznSJ0npzyjDYV7uXKYAPIYQs5SsKud3PSpcGeK31nsufrvG+yNclEJ7R AyIbB+qtMOYfvfHR/NCgQNhhylGWNqr5KMpqXLS/XTseeWkPen7GO3gW6LDEHjNY96lYJ/L1D8 zQHLLQOfR7a0a5he9ZZIXTKsZR/ATkdLB7R2HFkri1pnOKoz6pUMZBcVR846et9YgE3XDWP95V 4cE=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Introduce an opaque type that is used to store the CPUID and MSRs
policies of a domain. Such type uses the existing cpu_policy structure
to store the data, but doesn't expose the type to the users of the
xenguest library.

Introduce an allocation (init) and freeing function (destroy) to
manage the type.

Note the type is not yet used anywhere.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 tools/include/xenctrl.h         |  6 ++++++
 tools/libs/guest/xg_cpuid_x86.c | 28 ++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index e91ff92b9b1..ffb3024bfeb 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2590,6 +2590,12 @@ int xc_psr_get_domain_data(xc_interface *xch, uint32_t 
domid,
 int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket,
                        xc_psr_feat_type type, xc_psr_hw_info *hw_info);
 
+typedef struct cpu_policy *xc_cpu_policy_t;
+
+/* Create and free a xc_cpu_policy object. */
+xc_cpu_policy_t xc_cpu_policy_init(void);
+void xc_cpu_policy_destroy(xc_cpu_policy_t policy);
+
 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 9846f81e1f1..ade5281c178 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -659,3 +659,31 @@ out:
 
     return rc;
 }
+
+xc_cpu_policy_t xc_cpu_policy_init(void)
+{
+    xc_cpu_policy_t policy = calloc(1, sizeof(*policy));
+
+    if ( !policy )
+        return NULL;
+
+    policy->cpuid = calloc(1, sizeof(*policy->cpuid));
+    policy->msr = calloc(1, sizeof(*policy->msr));
+    if ( !policy->cpuid || !policy->msr )
+    {
+        xc_cpu_policy_destroy(policy);
+        return NULL;
+    }
+
+    return policy;
+}
+
+void xc_cpu_policy_destroy(xc_cpu_policy_t policy)
+{
+    if ( !policy )
+        return;
+
+    free(policy->cpuid);
+    free(policy->msr);
+    free(policy);
+}
-- 
2.30.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.