]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
retpoline: set IBRS and IBPB in use only on the boot CPU call to init_scattered_cpuid...
authorChuck Anderson <chuck.anderson@oracle.com>
Mon, 26 Feb 2018 09:40:58 +0000 (01:40 -0800)
committerChuck Anderson <chuck.anderson@oracle.com>
Sat, 3 Mar 2018 01:58:46 +0000 (17:58 -0800)
Setting IBRS and IBPB in use is a system wide issue, not a per-CPU
issue.  Set them only on the boot CPU's call to
init_scattered_cpuid_features().

Orabug: 27625404
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Conflicts:
arch/x86/kernel/cpu/scattered.c
(merged with be596ab27 ("x86/speculation: Use IBRS if available before
 calling into firmware"))

arch/x86/kernel/cpu/scattered.c

index 5d0cd6bcc459415e323f735b3fed2f43b303b4d4..3f2183d6027b66d67544802281356dd99d76af1c 100644 (file)
@@ -185,23 +185,21 @@ void init_scattered_cpuid_features(struct cpuinfo_x86 *c,
                clear_cpu_cap(c, X86_FEATURE_STIBP);
        }
 
-       mutex_lock(&spec_ctrl_mutex);
-
-       if (cpu_has(c, X86_FEATURE_IBRS)) {
-               set_ibrs_supported();
-               /*
-                * Don't do this after disable_ibrs_and_friends as we would
-                * re-enable it (say if spectre_v2=off is used).
-                */
-               if (&boot_cpu_data == c)
+       if (&boot_cpu_data == c) {
+               mutex_lock(&spec_ctrl_mutex);
+               if (cpu_has(c, X86_FEATURE_IBRS)) {
+                       set_ibrs_supported();
+                       /*
+                        * Don't do this after disable_ibrs_and_friends as we
+                        * would re-enable it (say if spectre_v2=off is used).
+                        */
                        set_ibrs_firmware();
-               sysctl_ibrs_enabled = ibrs_inuse ? 1 : 0;
-       }
-
-       if (cpu_has(c, X86_FEATURE_IBPB)) {
-               set_ibpb_supported();
-               sysctl_ibpb_enabled = ibpb_inuse ? 1 : 0;
+                       sysctl_ibrs_enabled = ibrs_inuse ? 1 : 0;
+               }
+               if (cpu_has(c, X86_FEATURE_IBPB)) {
+                       set_ibpb_supported();
+                       sysctl_ibpb_enabled = ibpb_inuse ? 1 : 0;
+               }
+               mutex_unlock(&spec_ctrl_mutex);
        }
-
-       mutex_unlock(&spec_ctrl_mutex);
 }