]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
x86/cpufeatures: Add a IBPB_NO_RET BUG flag
authorJohannes Wikner <kwikner@ethz.ch>
Mon, 23 Sep 2024 18:49:34 +0000 (20:49 +0200)
committerBorislav Petkov (AMD) <bp@alien8.de>
Thu, 10 Oct 2024 08:34:29 +0000 (10:34 +0200)
Set this flag if the CPU has an IBPB implementation that does not
invalidate return target predictions. Zen generations < 4 do not flush
the RSB when executing an IBPB and this bug flag denotes that.

  [ bp: Massage. ]

Signed-off-by: Johannes Wikner <kwikner@ethz.ch>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Cc: <stable@kernel.org>
arch/x86/include/asm/cpufeatures.h
arch/x86/kernel/cpu/common.c

index a222a24677d74b2a6e75bc3583142200fbd1e62c..913fd3a7bac6506141de65f33b9ee61c615c7d7d 100644 (file)
 #define X86_BUG_DIV0                   X86_BUG(1*32 + 1) /* "div0" AMD DIV0 speculation bug */
 #define X86_BUG_RFDS                   X86_BUG(1*32 + 2) /* "rfds" CPU is vulnerable to Register File Data Sampling */
 #define X86_BUG_BHI                    X86_BUG(1*32 + 3) /* "bhi" CPU is affected by Branch History Injection */
+#define X86_BUG_IBPB_NO_RET            X86_BUG(1*32 + 4) /* "ibpb_no_ret" IBPB omits return target predictions */
 #endif /* _ASM_X86_CPUFEATURES_H */
index 07a34d723505741c2308e27a6a349e0c78717580..f1040cb648414ba61ba83bf2324d3ac9e5ae20ff 100644 (file)
@@ -1443,6 +1443,9 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
             boot_cpu_has(X86_FEATURE_HYPERVISOR)))
                setup_force_cpu_bug(X86_BUG_BHI);
 
+       if (cpu_has(c, X86_FEATURE_AMD_IBPB) && !cpu_has(c, X86_FEATURE_AMD_IBPB_RET))
+               setup_force_cpu_bug(X86_BUG_IBPB_NO_RET);
+
        if (cpu_matches(cpu_vuln_whitelist, NO_MELTDOWN))
                return;