[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/21] libs/guest: introduce helper to fetch a domain cpu policy
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Date: Tue, 23 Mar 2021 10:58:33 +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=XiniRgb9Usi7cOKyAntrG74P2w6ZoVZ1eSYmJ4efxZU=; b=PdEDnW8tL8CSRxxAukw/wrUPNe7sjHUYj8wARYpMVvtWW+fbfYvG6UkFcGlaHkXqTJ/4ymSusy1va8xxRrBTDjB49GYP1vPZrTPiKR9ldSjKF2nKvtczaDOtNdlBVb2ZGvtIl8K9PcFXSLQwyYCYheNjjNnfP/h3Unlil+JpSDJV1UxjYxfYF0WrZb4nCLzpZilyyoLv++YsMCeiKDzGFSPO27wIgORZ8vBACikK13WQxag7Q0AaPZNajo3RwBkbcs9XqEDRXNaucHvybVz55lj0Yqw/2FWd6C/QMP8c08FZkqsLiPKNg5ARoCORgIcpPf3f95EhZcvBlrW4E3wnKQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ikA4WW9FVNw8sQq9FVBmUh2iYFw9X8pd5utQylRER89bmHB7IM1Q73QOfIgqgOrueBwlcy9rzxVuD0GiL+stTP01zHWwzTF2jNK3aPabZQ0wteb+TtTEYT5OabZa8gZ6v1wNuaRJvLxsLUKZL8cDBB5EbDeKulc5EmIiREUfUzbCGt+lul3LnlNaZALQr1SNMCsWPbL0RDEZZmbPhtLp/bhVo4dadAplTCuVomw6Ad45ORump55z7kpFiXWnVcCLtj6tYGXuoIw8kVmnhM0Q2+4RwmJHSHh9ff6Z+l6cmDBuNsrqF3lad9d+8c55W44KXivR6hDs8LiE8Hm4x5W+Gg==
- Authentication-results: esa1.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:12 +0000
- Ironport-hdrordr: A9a23:8NXDdaxVIRa8umfn2WASKrPxqe4kLtp033Aq2lEZdDV8Sebdv9 yynfgdyB//gCsQXnZlotybJKycWxrnmqJdybI6eZOvRhPvtmftFoFt6oP+3ybtcheTysd07o 0lSaR3DbTLYGRSpdrm4QW+DtYryMSG9qftvuvF03JxV2hRCp1IxS0RMHf+LmRdQg5aCZ0lUK eG7s1cqDa6PVgRZMK3Bn4KNtKz2+HjvpTgfBIAGlob+BCD5AnYlYLSPjq5+lMlUz1Jyao/6m StqWLEz4iqrv3T8G6760b99JJT8eGRqOdrJMvJscQNLyWptwDAXvUbZ5SnnBQY5N6i80wrlt 6kmWZRA+1W52nKdm+45TvBsjOQqQoG0HPpxV+GjXaLm6WQL1hbeqkx975xSRfX51Etu9txys twrhiknqFaEA/am2DF78XIPisa53acm2YokuIYkhVkIOwjQYJWxLZvmX99IdMrGSL3750fC+ 9+DM3Qz+Y+SyLlU1np+kZo29CiRXI1A1OvRVUDoNWc13xskGl+1FZw/r1Sol4wsLYGD7VU7e XNNapl0JlIU88tdKp4QMMMW9G+BGDhSQ/FWVjibmjPJeUiATbgupT36LI66KWBY5oT1qY/n5 zHTRdxqXMyU1iGM7zP4LR7tjT2BEmtVzXkzc9To7JjvKfnebbtOSqfDHgzjsqbpekFCMGzYY fzBLtmR9vYaUf+E4dA2APzH7NIL2MFbcETstEnH32UpMbmLZDrq/z7fP7fKKGFK0dnZkrPRl 84GBTjLs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NN+zWkRCbjsq9mVLs/qVMUvLlyXZ6V0atOK3Xm9Ieb0BOJmB6XdXxrucsUBGuJI5znnUBAK05 zFcBS+Fc28lcpgFdxHHCDYaf7G9DUTAdq5TH81Oatd1p3bTPCbNem5Rf7+Tc17m6SCH4BMHndZ HKw=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Such helper is based on the existing functions to fetch a CPUID and
MSR policies, but uses the xc_cpu_policy_t type to return the data to
the caller.
No user of the interface introduced on the patch.
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
tools/include/xenctrl.h | 2 ++
tools/libs/guest/xg_cpuid_x86.c | 34 +++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index fc8e4b28781..8b8b30a2764 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2599,6 +2599,8 @@ void xc_cpu_policy_destroy(xc_cpu_policy_t policy);
/* Retrieve a system policy, or get/set a domains policy. */
int xc_cpu_policy_get_system(xc_interface *xch, unsigned int idx,
xc_cpu_policy_t policy);
+int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid,
+ 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,
diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
index 3710fb63839..75ac70996ac 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -777,3 +777,37 @@ int xc_cpu_policy_get_system(xc_interface *xch, unsigned
int idx,
free(msrs);
return rc;
}
+
+int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid,
+ xc_cpu_policy_t policy)
+{
+ unsigned int nr_leaves, nr_msrs;
+ xen_cpuid_leaf_t *leaves = NULL;
+ xen_msr_entry_t *msrs = NULL;
+ int rc;
+
+ rc = allocate_buffers(xch, &nr_leaves, &leaves, &nr_msrs, &msrs);
+ if ( rc )
+ {
+ errno = -rc;
+ return -1;
+ }
+
+ rc = xc_get_domain_cpu_policy(xch, domid, &nr_leaves, leaves, &nr_msrs,
+ msrs);
+ if ( rc )
+ {
+ PERROR("Failed to obtain domain %u policy", domid);
+ rc = -1;
+ goto out;
+ }
+
+ rc = deserialize_policy(xch, policy, nr_leaves, leaves, nr_msrs, msrs);
+ if ( rc )
+ errno = -rc;
+
+ out:
+ free(leaves);
+ free(msrs);
+ return rc;
+}
--
2.30.1
|