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

[PATCH for-4.17 2/4] amd: remove VIRT_SC_MSR_HVM synthetic feature


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Tue, 11 Oct 2022 18:02:43 +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=mVBkPo8rhBfvYMAMsLwRzoqZwqTHfHHJ+OE47LmFpUc=; b=g9BlfC1711NwbNs1++vxCAFS3byz0XpvB4v9cen74Oxh+IdHxn8PwmSipJmbOqrEoWNPJI6Fbc063QDP5rX+XegGikyeBI8f74UCjjSrfs+qpP44mMlse/AEzrFMLDx1pQBaZ2JE+T3U+LXgsTrZB9heMoIWNwXEFUUfigKd1GneOE8RgWfjEa6PYX2fEgq/5R1DuaY3WIs9ywMgbKOPb3yvaFucIWbO2+ywA3bJEsLD5/z3OqW9cWtgoHjsJHQlvDUYjJbna7WBewQUuf+eXVtZFydnwDYqbe+EWagOnUDs4b4V6hS0HJ4EdxbtqCDSA2p6C7Oqje88H16z/uZHpQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iEhkBnZmCWeIVJ8G7xcK5s2JGWxzr3aJWqsbR1c8/xvDr36GSCBKUTXByF7Io4fI+/EbK2TMLR7RJ42swHK5oKK3BoKgjKjtaxa4jsCXxLb6ffVq6xzL1TCQI6Zh8WboHFZaHmxmkUJOlFySiCb+9UFkAUd0IKbAaQH8x2o3duvhMIgBFQCsyDQ6gm3hDWFGVSmZN17Kvq1Gji80RtHXKb7OXWWbsUw04On0ceV7OLTHd03xNKd2Iv6FytAZHzIpopd1TkeoxWyHGHnFhlwt7Q0uKetWGOprZyxPlT/BQBwoGEiMPOt8vVEklsFif9DxybnQoqKl5+OullBF73p6GA==
  • 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:30 +0000
  • Ironport-data: A9a23:7MPMSKvJ6HapvVm7EUP75dsNn+fnOphVZkK7ncifNrXfiXmJ3RbKv53rLJtujFZ2djzeF6albpmDQlW6GbJGpuSZ81+gdvYUUcCbsp2Rci4ADJQz5KxWHqycTEAhj6Qu1YD2XPEqi4EHTiggwQoAnDHA8389WshYBmgwtZR8SZnqDVkaKxyZFD8SDormiG1OYSxZFBVuFjkN0Z2UKGdtCmepj5MgmeKyPrCPpadJJ5zy6XpBDB6FTXykKqRrEfssoWexd/PkyzlqnTB6yY8acMjuxjAXDU8H0e9vbbpapJLTM6dUYX5kZlV5ajwNuqaiOycm+75YBLBWs2p0H8GOHYyGKcTXRaQv7qm1LQZTqFT7zl2cDR1DxcD6wqVK80G8RUxOVm8L04K9/pwD82HdBdz9eet21AjQ7cGsflkSsTNMEM1ojNvRRy8fegFTn7GsZazsOFxWYvMZ2PqiPgL4692dxOt7Ewgl20yo7KYVEPL7SCt9tdqUHCYmlWd0aiIfgCUl1U0a5ihjSihSWYj3JGTUWAulhccE/Z7a1A5M92Tc8dw6sKLqMRXZgVRby2vyDW1ZqLZz7MZs+BPbi+BXNxJ485vKShaoqHpj4ZheC6tNQTBlmi9HNXlCpOjVZgywU06UEiPgYN0ez5oHPKk4V9gLVgcxXsnIySf+gDj28T4RzBrU6Tdv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cHes6TuKshoM+RpCUkgnXrR2IPJzepNFQ1CaGMSeuqrq7hHfQJmIT2IlLiwnRiu+9jHp0p9G31zxSv+8h1Dfr/rCBFDCyR+6x/isVrhjEzeJTymkw5Ks7RbQG5w8s16pFAdDE9Zk1oe9Fr7nTXgaKDRJ8E9Ps3OYje1NdzuIdDyyO6bVg4msv+SAJCDPussrFRwoJ0w1vj5R2RwGl6U2U0wGLSWErCJUwhDu8j4zBrXS+GrTlKN16YmpEcW1cPcQYfVh+mrVZ6FwM3iR7qNC4CUw7EzChDlkjhDnzOx/oJQfxMThTUu0IQ6gXa0w3crT4s4JlELoLrBIc5hwQwLqO3v646ThsEF4G+vVi/yClW/ScbeBXuF9vGE4guyl9zlakjDsWN8rv7gPbtE3ftaLy5rbbqkHtd3bikft6WzWVL6ER+oRxDE70FyiG+aVDVM5tmHw5oqoytNDdXWLj5cFud2h/3lvs1A8NF06xWaZucufSnisnff2/X54NLU2FbenI/IxFWfj6SZ1qGs8PRoeU0lUcVNqllGN+IzoK1ykIpXyGxRBoYuW0OQeqdHvI8L4I8NtopjhysdA9MKI2GueVLOMziumSlpuLe1reUuxANeluoZavfc5UTz5g+dcuwkp5DnDmUNYCBejhexp6MsonqgENaANm8=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Since the VIRT_SPEC_CTRL.SSBD selection is no longer context switched
on vm{entry,exit} there's no need to use a synthetic feature bit for
it anymore.

Remove the bit and instead use a global variable.

No functional change intended.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/arch/x86/cpu/amd.c                 | 1 +
 xen/arch/x86/cpuid.c                   | 9 +++++----
 xen/arch/x86/include/asm/amd.h         | 1 +
 xen/arch/x86/include/asm/cpufeatures.h | 2 +-
 xen/arch/x86/spec_ctrl.c               | 8 ++++----
 5 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index a1582e1cc9..c28f2d5220 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -49,6 +49,7 @@ boolean_param("allow_unsafe", opt_allow_unsafe);
 /* Signal whether the ACPI C1E quirk is required. */
 bool __read_mostly amd_acpi_c1e_quirk;
 bool __ro_after_init amd_legacy_ssbd;
+bool __ro_after_init amd_virt_spec_ctrl;
 
 static inline int rdmsr_amd_safe(unsigned int msr, unsigned int *lo,
                                 unsigned int *hi)
diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 822f9ace10..acc2f606ce 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -3,6 +3,7 @@
 #include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/nospec.h>
+#include <asm/amd.h>
 #include <asm/cpuid.h>
 #include <asm/hvm/hvm.h>
 #include <asm/hvm/nestedhvm.h>
@@ -543,9 +544,9 @@ static void __init calculate_hvm_max_policy(void)
 
     /*
      * VIRT_SSBD is exposed in the default policy as a result of
-     * VIRT_SC_MSR_HVM being set, it also needs exposing in the max policy.
+     * amd_virt_spec_ctrl being set, it also needs exposing in the max policy.
      */
-    if ( boot_cpu_has(X86_FEATURE_VIRT_SC_MSR_HVM) )
+    if ( amd_virt_spec_ctrl )
         __set_bit(X86_FEATURE_VIRT_SSBD, hvm_featureset);
 
     /*
@@ -606,9 +607,9 @@ static void __init calculate_hvm_def_policy(void)
 
     /*
      * Only expose VIRT_SSBD if AMD_SSBD is not available, and thus
-     * VIRT_SC_MSR_HVM is set.
+     * amd_virt_spec_ctrl is set.
      */
-    if ( boot_cpu_has(X86_FEATURE_VIRT_SC_MSR_HVM) )
+    if ( amd_virt_spec_ctrl )
         __set_bit(X86_FEATURE_VIRT_SSBD, hvm_featureset);
 
     sanitise_featureset(hvm_featureset);
diff --git a/xen/arch/x86/include/asm/amd.h b/xen/arch/x86/include/asm/amd.h
index 81ed71710f..5c100784dd 100644
--- a/xen/arch/x86/include/asm/amd.h
+++ b/xen/arch/x86/include/asm/amd.h
@@ -152,6 +152,7 @@ extern bool amd_acpi_c1e_quirk;
 void amd_check_disable_c1e(unsigned int port, u8 value);
 
 extern bool amd_legacy_ssbd;
+extern bool amd_virt_spec_ctrl;
 bool amd_setup_legacy_ssbd(void);
 void amd_set_ssbd(bool enable);
 
diff --git a/xen/arch/x86/include/asm/cpufeatures.h 
b/xen/arch/x86/include/asm/cpufeatures.h
index 3895de4faf..efd3a667ef 100644
--- a/xen/arch/x86/include/asm/cpufeatures.h
+++ b/xen/arch/x86/include/asm/cpufeatures.h
@@ -24,7 +24,7 @@ XEN_CPUFEATURE(APERFMPERF,        X86_SYNTH( 8)) /* 
APERFMPERF */
 XEN_CPUFEATURE(MFENCE_RDTSC,      X86_SYNTH( 9)) /* MFENCE synchronizes RDTSC 
*/
 XEN_CPUFEATURE(XEN_SMEP,          X86_SYNTH(10)) /* SMEP gets used by Xen 
itself */
 XEN_CPUFEATURE(XEN_SMAP,          X86_SYNTH(11)) /* SMAP gets used by Xen 
itself */
-XEN_CPUFEATURE(VIRT_SC_MSR_HVM,   X86_SYNTH(12)) /* MSR_VIRT_SPEC_CTRL exposed 
to HVM */
+/* Bit 12 unused. */
 XEN_CPUFEATURE(IND_THUNK_LFENCE,  X86_SYNTH(13)) /* Use IND_THUNK_LFENCE */
 XEN_CPUFEATURE(IND_THUNK_JMP,     X86_SYNTH(14)) /* Use IND_THUNK_JMP */
 XEN_CPUFEATURE(SC_NO_BRANCH_HARDEN, X86_SYNTH(15)) /* (Disable) Conditional 
branch hardening */
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 4e53056624..0b94af6b86 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -514,12 +514,12 @@ static void __init print_details(enum ind_thunk thunk, 
uint64_t caps)
            (boot_cpu_has(X86_FEATURE_SC_MSR_HVM) ||
             boot_cpu_has(X86_FEATURE_SC_RSB_HVM) ||
             boot_cpu_has(X86_FEATURE_IBPB_ENTRY_HVM) ||
-            boot_cpu_has(X86_FEATURE_VIRT_SC_MSR_HVM) ||
+            amd_virt_spec_ctrl ||
             opt_eager_fpu || opt_md_clear_hvm)       ? ""               : " 
None",
            boot_cpu_has(X86_FEATURE_SC_MSR_HVM)      ? " MSR_SPEC_CTRL" : "",
            (boot_cpu_has(X86_FEATURE_SC_MSR_HVM) ||
-            boot_cpu_has(X86_FEATURE_VIRT_SC_MSR_HVM)) ? " MSR_VIRT_SPEC_CTRL"
-                                                       : "",
+            amd_virt_spec_ctrl)                      ? " MSR_VIRT_SPEC_CTRL"
+                                                     : "",
            boot_cpu_has(X86_FEATURE_SC_RSB_HVM)      ? " RSB"           : "",
            opt_eager_fpu                             ? " EAGER_FPU"     : "",
            opt_md_clear_hvm                          ? " MD_CLEAR"      : "",
@@ -1247,7 +1247,7 @@ void __init init_speculation_mitigations(void)
     /* Support VIRT_SPEC_CTRL.SSBD if AMD_SSBD is not available. */
     if ( opt_msr_sc_hvm && !cpu_has_amd_ssbd &&
          (cpu_has_virt_ssbd || (amd_legacy_ssbd && amd_setup_legacy_ssbd())) )
-        setup_force_cpu_cap(X86_FEATURE_VIRT_SC_MSR_HVM);
+        amd_virt_spec_ctrl = true;
 
     /* Figure out default_xen_spec_ctrl. */
     if ( has_spec_ctrl && ibrs )
-- 
2.37.3




 


Rackspace

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