]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
x86/spectre: If IBRS is enabled disable "Filling RSB on context switch"
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Thu, 1 Feb 2018 21:20:54 +0000 (16:20 -0500)
committerJack Vogel <jack.vogel@oracle.com>
Thu, 8 Feb 2018 18:15:28 +0000 (10:15 -0800)
As that is only needed if the machine is running IBRS and !SMEP.

The comment above the conditional says it all:

 Skylake era CPUs have a separate issue with *underflow* of the
 RSB, when they will predict 'ret' targets from the generic BTB.
 The proper mitigation for this is IBRS. If IBRS is not supported
 or deactivated in favour of retpolines the RSB fill on context

.. and if we have IBRS then we should ignore this conditional.

Note that the check (!SMEP) and using the STUFF_RSB is already
done in:
x86/spectre_v2: Figure out if STUFF_RSB macro needs to be used.

Orabug: 27477743
CVE: CVE-2017-5715

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Pavel Tatashin <pasha.tatashin@oracle.com>
arch/x86/kernel/cpu/bugs_64.c

index a363f9cab12deb95fb08e38ac51a7ff185f66c76..933beab407c82cca7aa89d7da8304e8bf020582e 100644 (file)
@@ -357,8 +357,9 @@ out:
         * or deactivated in favour of retpolines the RSB fill on context
         * switch is required.
         */
-       if ((!boot_cpu_has(X86_FEATURE_PTI) &&
-            !boot_cpu_has(X86_FEATURE_SMEP)) || is_skylake_era()) {
+       if (((mode != SPECTRE_V2_IBRS) && (mode != SPECTRE_V2_IBRS_LFENCE)) &&
+           ((!boot_cpu_has(X86_FEATURE_PTI) &&
+            !boot_cpu_has(X86_FEATURE_SMEP)) || is_skylake_era())) {
                setup_force_cpu_cap(X86_FEATURE_RSB_CTXSW);
                pr_info("Filling RSB on context switch\n");
        }