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

[PATCH 14/21] libs/guest: introduce helper to check cpu policy compatibility


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Tue, 23 Mar 2021 10:58:42 +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=aI7Y7A0OHymM1N3AAaa+CIA8yVMw6gOJwUG3C50vFTg=; b=ho+xaKbrYGwgFkICAp6aMq4ole1Y53uMJgaxSn6R6/ahLZviov6o1Ey3wZ4gO7vQmnfjJX3JHIKqTNu20K+u1lFXRKmzG6ska0lWRlhqScsWdrCByTF05Inelc9Slp7U0sSnnwq8S4dHtIADqTu4360imm2WWa2F/AxMWrFr0rSii/JF+ONVAS79s4MT/mGl0GnDCxWgmv/7w2AKEOR0cJ+L5qKvE0kRb2K1gjKmHzXW6zX7nsm8mP9ipnxCGs7lR3ghIiTHexVUTIHUIiS3iC3xqgahS2K8ZalOJoJDFX7wrgNTXPhkfzr5rkxTxLWlfTxcHzY6R6kxJ1p1PIw9Fw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ksIQ7JeM1Hfh/GKl3D4Wu7VUEA48MYckKlPo6DM/ERI8BUhrHIPI0nHQOLOYdB6H7oigssEcA9AbKlkbzw2pTFemFHDPdglYGdR+U2+rLJm76HcokgJQLXq2m0sIIVLfB7aMLBofWvba4vV33CX0XhO9hx6g0Krji9K6aHimZbuVtB4AR8+nFz1v5WBxqA7L+y7jHR2gOonpv7igJwaMTzPcIK9IJWdb7u1r13TcEy5uRor1AOBGGAS7qgYC4Vy6HH8vt6El5jKxuVoyRnfW7pQUrngJrGliBtT3BmcV2uWDnfmacguGzFqVBJ98XBCTAAlXFwDv5pNiNDbHKyWltw==
  • 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:01:14 +0000
  • Ironport-hdrordr: A9a23:PfEHMqGCEqtD0lZupLqFDpTXdLJzesId70hD6mlYcjYQWtCEls yogfQQ3QL1jjFUY307hdWcIsC7L0/03aVepa0cJ62rUgWjgmunK4l+8ZDvqgeOJwTXzcQY76 tpdsFFZOHYJURmjMr8/QmzG8shxt7Cy6yzmeLC1R5WLT1CQYsI1XYfNi+wFEpqSA5aQacjHJ 2H6cZd4xamc3IbbsO0b0N1ItTrjdvNiZ7gfFo6FwcqgTP+9w+AxZzbN1yj3hkYWy5S2rtKyw n4uiHw+6nLiYDD9jbyzGnWhq4m/efJ7vtmKIiyhtMOKjPq4zzYFbhJf7GZpjg6rKWOxT8R4a HxiiwtNchy9H/dF1vdyXCGtniCoVRemEPK8lOEnWDl5fXwWTNSMbs+uatibhDb50A81esMtp 5j4mTxjesyMTrw2A7559TOSihwkFu1rXcIgYco/gNieLpbR7lLoYMF+kRJVL8GASLh8YgiVN JjFcfG+Z9tAB6nRkGcmlMq7M2nX3w1EBvDak8euvaN2zwTuHxi1UMXyOEWg39ozuNwd7B0o8 D/doh4nrBHScEbKYhnAv0afMexAmvRBTrRLWO7Oz3cZeA6EkOIj6SyzKQ+5emsdpBN5oA1go 79XFRRsnN3U17yCPeJwIZA/nn2MSuAdAWo7vsby4lyu7X6SrauGzaEUkoSn8yppOhaLdbcX9 q1JZJKE97uJWbjAu9yrk7DcqgXDUNbfNweu949VV7LiNnMMJfWuuvSd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GK0DmnJhwVlX7adOnBM63ndHN4eu6ch2BbgYxqLAwkUypyqrBRhLTXA/9zyRMXLvxpLLq TbLveF989wPst8h+TUEqyYgsRRslEt968TGKC7vSs9stwGsbTHeZ0xvTfzjhkjpQ3gGAMTJstu xlk=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Such helpers is just a wrapper to the existing
x86_cpu_policies_are_compatible function. This requires building
policy.c from libx86 on user land also.

No user of the interface introduced.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 tools/include/xenctrl.h         |  4 ++++
 tools/libs/guest/Makefile       |  2 +-
 tools/libs/guest/xg_cpuid_x86.c | 17 +++++++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index 164a287b367..165beff330f 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2619,6 +2619,10 @@ int xc_cpu_policy_update_cpuid(xc_interface *xch, 
xc_cpu_policy_t policy,
 int xc_cpu_policy_update_msrs(xc_interface *xch, xc_cpu_policy_t policy,
                               const xen_msr_entry_t *msrs, uint32_t nr);
 
+/* Compatibility calculations. */
+bool xc_cpu_policy_is_compatible(xc_interface *xch, const xc_cpu_policy_t p1,
+                                 const xc_cpu_policy_t p2);
+
 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/Makefile b/tools/libs/guest/Makefile
index 604e1695d6a..6d2a1d5bbc0 100644
--- a/tools/libs/guest/Makefile
+++ b/tools/libs/guest/Makefile
@@ -40,7 +40,7 @@ $(patsubst %.c,%.opic,$(ELF_SRCS-y)): CFLAGS += 
-Wno-pointer-sign
 ifeq ($(CONFIG_X86),y) # Add libx86 to the build
 vpath %.c ../../../xen/lib/x86
 
-SRCS-y                 += cpuid.c msr.c
+SRCS-y                 += cpuid.c msr.c policy.c
 endif
 
 # new domain builder
diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
index f7b662f31aa..30ea02a0f31 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -1098,3 +1098,20 @@ int xc_cpu_policy_update_msrs(xc_interface *xch, 
xc_cpu_policy_t policy,
     return rc;
 
 }
+
+bool xc_cpu_policy_is_compatible(xc_interface *xch, const xc_cpu_policy_t p1,
+                                 const xc_cpu_policy_t p2)
+{
+    struct cpu_policy_errors err;
+    int rc = x86_cpu_policies_are_compatible(p1, p2, &err);
+
+    if ( !rc )
+        return true;
+
+    if ( err.leaf != -1 )
+        ERROR("Leaf %#x subleaf %#x is not compatible", err.leaf, err.subleaf);
+    if ( err.msr != -1 )
+        ERROR("MSR index %#x is not compatible", err.msr);
+
+    return false;
+}
-- 
2.30.1




 


Rackspace

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