@@ -795,8 +795,12 @@ int xc_cpu_policy_get_system(xc_interface *xch, unsigned int policy_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_cpu_policy_set_domain(xc_interface *xch, uint32_t domid,
- xc_cpu_policy_t *policy);
+int xc_cpu_policy_set_domain_from_serialised(xc_interface *xch,
+ uint32_t domid,
+ xc_cpu_policy_t *policy);
+int xc_cpu_policy_set_domain_from_deserialised(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,
@@ -985,20 +985,24 @@ int xc_cpu_policy_get_domain(xc_interface *xch, uint32_t domid,
return rc;
}
-int xc_cpu_policy_set_domain(xc_interface *xch, uint32_t domid,
- xc_cpu_policy_t *policy)
+int xc_cpu_policy_set_domain_from_deserialised(xc_interface *xch, uint32_t domid,
+ xc_cpu_policy_t *policy)
{
- uint32_t err_leaf = -1, err_subleaf = -1, err_msr = -1;
int rc;
-
- rc = cpu_policy_serialise_on_self(xch, policy);
- if ( rc )
+ if ( (rc = cpu_policy_serialise_on_self(xch, policy)) )
return rc;
- rc = xc_set_domain_cpu_policy(xch, domid,
- policy->leaves.len, policy->leaves.buf,
- policy->msrs.len, policy->msrs.buf,
- &err_leaf, &err_subleaf, &err_msr);
+ return xc_cpu_policy_set_domain_from_serialised(xch, domid, policy);
+}
+
+int xc_cpu_policy_set_domain_from_serialised(xc_interface *xch, uint32_t domid,
+ xc_cpu_policy_t *policy)
+{
+ uint32_t err_leaf = -1, err_subleaf = -1, err_msr = -1;
+ int rc = xc_set_domain_cpu_policy(xch, domid,
+ policy->leaves.len, policy->leaves.buf,
+ policy->msrs.len, policy->msrs.buf,
+ &err_leaf, &err_subleaf, &err_msr);
if ( rc )
{
ERROR("Failed to set domain %u policy (%d = %s)", domid, -rc,
@@ -405,7 +405,7 @@ static void test_guest(struct xen_domctl_createdomain *c)
(bitmaskof(X86_FEATURE_HLE) | bitmaskof(X86_FEATURE_RTM)));
/* Set the new policy. */
- rc = xc_cpu_policy_set_domain(xch, domid, guest_policy);
+ rc = xc_cpu_policy_set_domain_from_deserialised(xch, domid, guest_policy);
if ( rc )
{
fail(" Failed to set domain policy: %d - %s\n",
xc_cpu_policy_set_domain_from_serialised() converts the cpu policy into its serialised form first and then sends that to Xen. Meanwhile, xc_cpu_policy_domain_set_from_deserialised() uses whatever is already in the internal serialisation buffer of the policy object. This split helps in a future patch where modifications are done in the serialized form and we don't want to do a serialization round-trip to send it to Xen. Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com> --- tools/include/xenguest.h | 8 ++++++-- tools/libs/guest/xg_cpuid_x86.c | 24 ++++++++++++++---------- tools/tests/tsx/test-tsx.c | 2 +- 3 files changed, 21 insertions(+), 13 deletions(-)