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

[PATCH v2] x86/cpuid: do not expand max leaves on restore


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Fri, 23 Apr 2021 15:17:47 +0200
  • 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=3p/Ut8DacIxUWFHt2eeL0cnHg88Tl8H2rMUHE2PjCrA=; b=DYD8YZtHCd+ThgQwF3xcbFTlXTyF/+NwgzNaOK9fZgVcoa8ZdMOtBSWQeZIRke9Z4Z0JjxdiTDhlhcIMceaOcacgPEzaQHmUVtEycUBcMtRyGgP+yZqL7jMJ9s6ZXvdIST2x92el3jfcV+IBRW3AjQg9N1C68PAyvXW4nAS/Y6Epm2siE0t5YsjcT6vWWm193pqoE5GlUwD/vhPE2G6T3fSbN4fDCpYDiJdvMMJrRyB24yOySapJEVkWZZhL4XaqlPo16mTXatwc+RlzKW2XxHvSk9Rx0/rAS2M9MeY03ONBrg2Y8pfeFugb6mw1VxgnqHKVl/wuetP8x4Iicwf1ZQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kwMqkiXYq6/t+6JJ7LIsx1rsAW09UZxTDWs8mT2oXuYayMPknmTyRqx5nGHKelFLbkq4cNd3hVOUTcXPX85DzmZkOPDDHdZ4wuH8qdO7zaGVvIxhFhI4ZBo8PzhP8W4kvZaZLgI7ln5jxYAbcGiduZ1yo3vRwAiDah+ff+uYlS4PcG4FbwF/Q41mAqHAXzbXJsVEFlS2Er+t6FHrRrmyzLXhC1L5MlOA7Hzb05ZsyOkOvsx1Sj+alR0qgKcMGfIhN9sRA3GJuRv9pSBhMqMK3hV9dIfgA961PdR0Rvso8kMsnb/1vkqI1MYbkLPYkbc0BNRuWkaIKIIUj4qh3n4CHA==
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Fri, 23 Apr 2021 13:18:05 +0000
  • Ironport-hdrordr: A9a23:gYsrcKN85J56LcBcT3/w55DYdL4zR+YMi2QD/3taDTRIb82VkN 2vlvwH1RnyzA0cQm0khMroAsa9aFvm39pQ7ZMKNbmvGDPntmyhMZ144eLZrwHIMxbVstRQ3a IIScVDIfX7B1RikILe6A63D94vzLC8gd2VrM31pk0dKD1CQadm8gt/F0K/Gkp5WAFJCfMCZe ahz+BAoCetfmlSU9SjChA+LqT+jvDotLajWx4JABY79BKD5AnH1JfWGwWVty1uKg9n7qwl9Q H+4m/Ez4Wl98q20xrNk1LUhq4m4ufJ7vtmKIiyhtMOKjPq4zzYK7hJf7GZpjg6rKWOxT8R4a HxiiwtNchy9H/dF1vdyXCGumnd+Q0j5HP4xViTjWGLm72DeBsAB9dcnoUcSxPF6iMbzYhB+Z hW1GGUvYc/N2KloA3B5sPFXxwvtk24rWtKq590s1VjUJATYLIUkIoH/Ek9KuZmIAvG7ukcYY tTJfCZwMwTXUKRbnjfsGUq6serRG4PEhCPRVVHktCJ0hBN9UoJgXcw9Yg6pDMt5Zg9Q55L66 DvKaJzjoxDSccQcOZUGPoBe82qEWbAKCi8cV66EBDCLuUqKnjNo5n47PEe/+exYqEFy5M0hd DnXE5Hs3UxP2bjE9eH0pEO0h2lehT8YR3djuVlo7RpsLz1Q7TmdQeZTko1rsemq/IDRsLBXf K+P49XHu/jIWPiFZ0h5Xy9Z7BibV0lFOEFs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jc1JQtUYd/0yyRBg84/Udm0BtzbH+u0zFwPRy8vymCI9JdY/3TgY+6hzJfZ5vcLTWi nTBgchq0xV89B0i7ZfcbL67b4cswJZtyTyTFNevTVng9CSt5zzmzsHEkJM8PUZEyRFaj+1r0me 6mhJh615I4Bd+qWPZ+7A20BU2iKVR+N/Bq3I+3+zIA3nMEcUMkXWleuTB8MqWjSP1ZHez9zc5i vM8=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

When restoring limit the maximum leaves to the ones supported by Xen
4.12 in order to not expand the maximum leaves a guests sees. Note
this is unlikely to cause real issues.

Guests restored from Xen versions 4.13 or greater will contain CPUID
data on the stream that will override the values set by
xc_cpuid_apply_policy.

Reported-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 - Fix commit message.
 - Adjust max feature subleaf to 0.
 - Move and amend comments.
---
 tools/libs/guest/xg_cpuid_x86.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
index 5ea69ad3d51..bf9a3750b58 100644
--- a/tools/libs/guest/xg_cpuid_x86.c
+++ b/tools/libs/guest/xg_cpuid_x86.c
@@ -498,18 +498,23 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t 
domid, bool restore,
         goto out;
     }
 
-    /*
-     * Account for feature which have been disabled by default since Xen 4.13,
-     * so migrated-in VM's don't risk seeing features disappearing.
-     */
     if ( restore )
     {
+        /*
+         * Account for feature which have been disabled by default since Xen 
4.13,
+         * so migrated-in VM's don't risk seeing features disappearing.
+         */
         p->basic.rdrand = test_bit(X86_FEATURE_RDRAND, host_featureset);
 
         if ( di.hvm )
         {
             p->feat.mpx = test_bit(X86_FEATURE_MPX, host_featureset);
         }
+
+        /* Clamp maximum leaves to the ones supported on 4.12. */
+        p->basic.max_leaf = min(p->basic.max_leaf, 0xdu);
+        p->feat.max_subleaf = 0;
+        p->extd.max_leaf = min(p->extd.max_leaf, 0x1cu);
     }
 
     if ( featureset )
-- 
2.30.1




 


Rackspace

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