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

[PATCH 4/4] amd/virt_ssbd: add to max HVM policy when SSB_NO is available


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Tue, 11 Oct 2022 18:02:45 +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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EAuwn7S5ftuN5uITAlZ8x3DI+7/sASR3Tb63nr2Rm4w=; b=c3kuLMxMJEL19KqMsiVIhY38Tqr10qZUYhvjIwO1oGQk6cx+Ldo1aszyh/FjX7BxSKN9ILxGQzeHyj8yRmQDi2NTc0MAQ5IA/jW6B5WEFRbArYsx5j0nCWTZz6WefOi6UhjqXHc1BwvKZU5CBXqHUQhQR3y6bZzL0yoZ7sEDovocbvU92f4Vy3aOKtt3UJUqTgRV4HyQ48U5uEHCg9Vuwz7BWqp7vQc5iQk85w2JPSCkDsAnIymC7CUAJG+h7krZvO9SZaibCc+TZXvfFJu5wpE5I9bBY/Q5Ckzx0Cnm2/CVNjaZjpal7TeLvDWAN5zU258IIvyNGoNcS4E/9yRAfw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DIlRJ08G0I0wiTd+qD6Th+7eJGiBY6yDNDzALXLPbDWiSTAu37Lj8zUiNyYmv9qKzYov/yqSfgqN024/yKQ/GKTSeQEx76tss0/K72ceEz2uX/peXuRIBiuBz0GMbpu/8cxr/rxlsFq2BFOGE2/x5ITrFtZZMKBP+cG7ijEiJAQtl0ixZjYu6EMEdR2GKSPDqV1EHqsuJXsrJyGxT7RrK+WA59yXPVpdafzrX2toczlxTVU6JkT/xBVbXpv4Qf9GuukWV1YgZGgAThRB6Mwm71VaZtofS4HqEjH2lRsmssa8s051VSG1h1TwfGuhzYGgj8OTGQXSMBE/v/bjijU7xg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Henry.Wang@xxxxxxx, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 11 Oct 2022 16:04:43 +0000
  • Ironport-data: A9a23:nuWw4a40B1cA5X/4Q3DuywxRtA/GchMFZxGqfqrLsTDasY5as4F+v mIcUWGCbK3YMWD2Kdkkb4y+9RgFu8TUxtVqSgdl+C9kHi5G8cbLO4+Ufxz6V8+wwm8vb2o8t plDNYOQRCwQZiWBzvt4GuG59RGQ7YnRGvymTras1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPewP9TlK6q4mlB5gVnPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c57MT9h7 cMWIgsyZwKhu86nmJiHb+5z05FLwMnDZOvzu1lG5BSAV7MMZ8CGRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/dqpTGNnWSd05C0WDbRUsaNSshP2F6Ru 0rN/njjAwFcP9uaodaA2iL237aRzXyhMG4UPJ6Br/tKhFua/WoeDRQKaF27kPChpHfrDrqzL GRRoELCt5Ma5EGtC9XwQRC8iHqFpQIHHcpdFfUg7wOAwbaS5ByWbkAkQzhbeZoZvck5bTUw0 xmCmNaBLT5lvaCRSHmd3qyJtj70Mi8QRUcdYQcUQA1D5MPsyLzflTrKR9dnVaSz3tv8HGiqx yjQ9XZvwbIOkcQMyqO3u0jdhC6hrYTISQhz4RjLWmWi7UVyY4vNi5GU1GU3JM1odO6xJmRtd lBe8yRCxIji1a2wqRE=
  • Ironport-hdrordr: A9a23:aNVeeqDF1ZIEZg3lHeg3sceALOsnbusQ8zAXPh9KJCC9I/bzqy nxpp8mPH/P5wr5lktQ++xoX5PwO080lKQFmrX5WI3PYOCIghrNEGgP1+vfKnjbalTDH41mpN hdmtZFebrN5DFB5K6VgTVQUexQuOVvmJrY+ds2pE0dKD2CBZsQjDuQXW2gYzBLrUR9dOwEPa vZwvACiyureHwRYMj+Ln4ZX9Lbr9mOsJ79exYJCzMu9QHL1FqTmfbHOind+i1bfyJEwL8k/2 SAuwvl5p+7u/X+7hPHzWfc47lfhdOk4NpeA86njNQTN1zX+0+VTbUkf4fHkCE+oemp5lpvuN 7Qoy04N8A20H/VdnHdm2qZ5yDQlBIVr1Pyw16RhnXu5ebjQighNsZHjYVFNjPE9ksJprhHoe 529lPck6ASIQLLnSz76dSNfQptjFCIrX0rlvNWp2BDULEZdKRaoeUkjQ5o+a87bWzHAb0cYa hT5Jm23ocXTbraVQGSgoBX+q3iYpxpdS32AXTruaSuokprdT5CvgklLfck7wc9HaIGOud5Dt v/Q9VVfcl1P6krhIJGdZM8qJiMexvwaCOJFl6uCnLaM4xCE07xivfMkcYIDaeRCdc18Kc=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hardware that exposes SSB_NO can implement the setting of SSBD as a
no-op because it's not affected by SSB.

Take advantage of that and allow exposing VIRT_SPEC_CTRL.SSBD to guest
running on hadrware that has SSB_NO.  Only set VIRT_SSBD on the max
policy though, as the feature is only intended to be used for
migration compatibility.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
As there's no hardware with SSB_NO so far the patch is untested.  Post
it for reference if there's hardware with the bit set.
---
 xen/arch/x86/cpu/amd.c | 4 +++-
 xen/arch/x86/cpuid.c   | 7 ++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index cfeb8d1daf..74cfeffc29 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -814,7 +814,9 @@ void amd_set_ssbd(bool enable)
                wrmsr(MSR_VIRT_SPEC_CTRL, enable ? SPEC_CTRL_SSBD : 0, 0);
        else if ( amd_legacy_ssbd )
                core_set_legacy_ssbd(enable);
-       else
+       else if ( cpu_has_ssb_no ) {
+               /* Nothing to do. */
+       } else
                ASSERT_UNREACHABLE();
 }
 
diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index acc2f606ce..e394dbe669 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -558,11 +558,16 @@ static void __init calculate_hvm_max_policy(void)
         __clear_bit(X86_FEATURE_IBRSB, hvm_featureset);
         __clear_bit(X86_FEATURE_IBRS, hvm_featureset);
     }
-    else if ( boot_cpu_has(X86_FEATURE_AMD_SSBD) )
+    else if ( boot_cpu_has(X86_FEATURE_AMD_SSBD) ||
+              boot_cpu_has(X86_FEATURE_SSB_NO) )
         /*
          * If SPEC_CTRL.SSBD is available VIRT_SPEC_CTRL.SSBD can be exposed
          * and implemented using the former. Expose in the max policy only as
          * the preference is for guests to use SPEC_CTRL.SSBD if available.
+         *
+         * Allow VIRT_SSBD in the max policy if SSB_NO is exposed for migration
+         * compatibility reasons.  If SSB_NO is present setting
+         * VIRT_SPEC_CTRL.SSBD is a no-op.
          */
         __set_bit(X86_FEATURE_VIRT_SSBD, hvm_featureset);
 
-- 
2.37.3




 


Rackspace

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