Skip to content

Commit b28d3f4

Browse files
skttgregkh
authored andcommitted
x86/cpufeatures: Add a IBPB_NO_RET BUG flag
commit 3ea87df upstream. 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 <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Cc: <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6ccc10e commit b28d3f4

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,4 +517,5 @@
517517
#define X86_BUG_DIV0 X86_BUG(1*32 + 1) /* AMD DIV0 speculation bug */
518518
#define X86_BUG_RFDS X86_BUG(1*32 + 2) /* CPU is vulnerable to Register File Data Sampling */
519519
#define X86_BUG_BHI X86_BUG(1*32 + 3) /* CPU is affected by Branch History Injection */
520+
#define X86_BUG_IBPB_NO_RET X86_BUG(1*32 + 4) /* "ibpb_no_ret" IBPB omits return target predictions */
520521
#endif /* _ASM_X86_CPUFEATURES_H */

arch/x86/kernel/cpu/common.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,9 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
14831483
boot_cpu_has(X86_FEATURE_HYPERVISOR)))
14841484
setup_force_cpu_bug(X86_BUG_BHI);
14851485

1486+
if (cpu_has(c, X86_FEATURE_AMD_IBPB) && !cpu_has(c, X86_FEATURE_AMD_IBPB_RET))
1487+
setup_force_cpu_bug(X86_BUG_IBPB_NO_RET);
1488+
14861489
if (cpu_matches(cpu_vuln_whitelist, NO_MELTDOWN))
14871490
return;
14881491

0 commit comments

Comments
 (0)