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

[PATCH for-4.16] x86/cpuid: prevent shrinking migrated policies max leaves


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Wed, 10 Nov 2021 18:40:59 +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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=z62eFgG7TJsIfQgs8QdvZn2cNIXsrbyzLqH8IDsikzg=; b=XvXGQkaajc6Y2ymEDbkKnorEZhPnfJ5GKu+WHMxUYk6gXTMIHpQjiKhLPS66IMWGntwBvqGnJzwmtLDqi4A32Fw2XlNb2YXwAjj2/6sZI014CafTgXCbQ+ITQN6ygyHZZitYjwKkbIKkJ7HjNevYdnEkvGo3NC+INkJIrjsqgTNvoN/TApudXXANggDwv/fSqEtYPCUKkWGpI4qZlnDHv/BWCWXRK60sTEKE+WD2LNTLT1uLVnN0YIrpJjMrHg2XbPZX2XPSpbm5mFpBAN/57fVzHkEKky42C+D5zaR9R+tSAuYZskVmMW2kFfCj8sbLXO6XTl8SEp2nD0NTWISp/w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jBhZTZsG5Hq7cTDZR0pKwUzH4TkPo07YWVIwLWGVE9FKeuX1u6XI2AfkrSgJUazHY+yJoM4hBK2FZapbHJrc1p6fp8mbjpW0TDTiucDwsJHaFRwmNQgOgDsA5Ol869lEtPrdXUN71f8ng56V8Y+qPNIJkd2eBxU5ykHqnFMra8cIfnN1cPkqVLGFI6VehAbPdoc197+wBVRgV2X9hTgMki7mY44nmjI8ZkXi9W+J50jnf41dBFdbtBjoHiKJ9gTS7aF4ZndMF+m2jXyIwmQfobhbL7HcpSkNkVTvmbNzZGvfOitOdG/QWX0RroPvopuJPgA5FsBcE6b54eS9hg5nRw==
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>
  • Delivery-date: Wed, 10 Nov 2021 17:41:57 +0000
  • Ironport-data: A9a23:GF8FmqtpVhAxuWZo6TnVfsAMx+fnVNNZMUV32f8akzHdYApBsoF/q tZmKWCGO/iOajT8cot+PYXj8EoPsZfTxoI3TlRo/C8xEiND+JbJXdiXEBz9bniYRiHhoOOLz Cm8hv3odp1coqr0/0/1WlTZQP0VOZigHtIQMsadUsxKbVIiGHhJZS5LwbZj29cx2IDhWGthh PupyyHhEA79s9JLGjp8B5Kr8HuDa9yr5Vv0FnRnDRx6lAe2e0s9VfrzFonoR5fMeaFGH/bSe gr25OrRElU1XfsaIojNfr7TKiXmS1NJVOSEoiI+t6OK2nCuqsGuu0qS2TV1hUp/0l20c95NJ NplpZqeUBw7OrT2tMc8ShUHKXwvI4ga9+qSSZS/mZT7I0zudnLtx7NlDV0sPJ1e8eFyaY1M3 aVGcnZXNEnF3r/ohuLgIgVvrp1LwM3DJoQQt2sm1TjEJf0nXYrCU+PB4towMDIY258TRq2DO ZRxhTxHaCX7Ui1RBm8rApMxs+SVq0vSdBp4pwfAzUYwyzeKl1EguFT3C/LXcNGXQcRenm6Du 3nLuW/+B3kyNcOd4SqI9Gq2ge3Clj+9X5gdfJW6+eRtm0a73XEIBVsdUl7Tiem0jAuyVsxSL 2QQ+z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ICG9Ffbo8P xG/c5rsSMc7Qx7ZJhOo7y90cW7Lk80lqQU3WByB9mftWDd0QPDQb2KhrGC/xTQXwH46+5Bxe NBXsFFebjN5IFB/KXHCd+DYrQd/OU=
  • Ironport-sdr: xu2bCze7dVLkf8FWaYcLy63QyWKRNCex1IafC2FyOzBH2KrAmCuxShsH/q1f268YHiGC+GNaUK wmpOq4HVj99BYC9g2ehMAaor0cfN+I2BKyaXKX5xqxR2EVvGMI2HwPyJo/FKE1tps2cMheTT3k 7Dxb8Q4sT303nyE92z4UJIjOyrexgX5cNqD/FRDm0WmkVJfZV5OkWD/Ex7BIonAFdzF3HLW5Kr s3YF5r4TZz9Cgnl1v8zylciilgFCpnN1hmyj5enfZQy2QlaPBQGvO/b+f3wFNkb+fehROm3JwP m7kSloU0wIbStvJToTN0cXvq
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

CPUID policies from guest being migrated shouldn't have the maximum
leaves shrink, as that would be a guest visible change. The hypervisor
has no knowledge on whether a guest has been migrated or is build from
scratch, and hence it must not blindly shrink the CPUID policy in
recalculate_cpuid_policy. Remove the
x86_cpuid_policy_shrink_max_leaves call from recalculate_cpuid_policy.
Removing such call could be seen as a partial revert of 540d911c28.

Instead let the toolstack shrink the policies for newly created
guests, while keeping the previous values for guests that are migrated
in. Note that guests migrated in without a CPUID policy won't get any
kind of shrinking applied.

Fixes: 540d911c28 ('x86/CPUID: shrink max_{,sub}leaf fields according to actual 
leaf contents')
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Cc: Ian Jackson <iwj@xxxxxxxxxxxxxx>

This is a regression introduced in this release cycle, so we should
consider whether we want to take this patch. It's mostly moving a
shrink call from the hypervisor into the toolstack and making it more
selective.

Main risks would be this shrinking somehow altering the recalculations
of the CPUID policy done by the hypervisor. Removing the shirk itself
in the hypervisor shouldn't cause issues as that wasn't done before,
and reporting empty max leaf should be fine.
---
 tools/libs/guest/xg_cpuid_x86.c | 7 +++++++
 xen/arch/x86/cpuid.c            | 2 --
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
index 198892ebdf..3ffd5f683b 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -638,6 +638,13 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t 
domid, bool restore,
         }
     }
 
+    /*
+     * Do not try to shrink the policy if restoring, as that could cause
+     * guest visible changes in the maximum leaf fields.
+     */
+    if ( !restore )
+        x86_cpuid_policy_shrink_max_leaves(p);
+
     rc = x86_cpuid_copy_to_buffer(p, leaves, &nr_leaves);
     if ( rc )
     {
diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 2079a30ae4..8ac55f0806 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -719,8 +719,6 @@ void recalculate_cpuid_policy(struct domain *d)
 
     if ( !p->extd.page1gb )
         p->extd.raw[0x19] = EMPTY_LEAF;
-
-    x86_cpuid_policy_shrink_max_leaves(p);
 }
 
 int init_domain_cpuid_policy(struct domain *d)
-- 
2.33.0




 


Rackspace

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