Skip to content

Commit be8de49

Browse files
tlendackybonzini
authored andcommitted
x86/speculation: Identify processors vulnerable to SMT RSB predictions
Certain AMD processors are vulnerable to a cross-thread return address predictions bug. When running in SMT mode and one of the sibling threads transitions out of C0 state, the other sibling thread could use return target predictions from the sibling thread that transitioned out of C0. The Spectre v2 mitigations cover the Linux kernel, as it fills the RSB when context switching to the idle thread. However, KVM allows a VMM to prevent exiting guest mode when transitioning out of C0. A guest could act maliciously in this situation, so create a new x86 BUG that can be used to detect if the processor is vulnerable. Reviewed-by: Borislav Petkov (AMD) <bp@alien8.de> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Message-Id: <91cec885656ca1fcd4f0185ce403a53dd9edecb7.1675956146.git.thomas.lendacky@amd.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 6d796c5 commit be8de49

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,5 +466,6 @@
466466
#define X86_BUG_MMIO_UNKNOWN X86_BUG(26) /* CPU is too old and its MMIO Stale Data status is unknown */
467467
#define X86_BUG_RETBLEED X86_BUG(27) /* CPU is affected by RETBleed */
468468
#define X86_BUG_EIBRS_PBRSB X86_BUG(28) /* EIBRS is vulnerable to Post Barrier RSB Predictions */
469+
#define X86_BUG_SMT_RSB X86_BUG(29) /* CPU is vulnerable to Cross-Thread Return Address Predictions */
469470

470471
#endif /* _ASM_X86_CPUFEATURES_H */

arch/x86/kernel/cpu/common.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,8 @@ static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = {
12561256
#define MMIO_SBDS BIT(2)
12571257
/* CPU is affected by RETbleed, speculating where you would not expect it */
12581258
#define RETBLEED BIT(3)
1259+
/* CPU is affected by SMT (cross-thread) return predictions */
1260+
#define SMT_RSB BIT(4)
12591261

12601262
static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {
12611263
VULNBL_INTEL_STEPPINGS(IVYBRIDGE, X86_STEPPING_ANY, SRBDS),
@@ -1287,8 +1289,8 @@ static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {
12871289

12881290
VULNBL_AMD(0x15, RETBLEED),
12891291
VULNBL_AMD(0x16, RETBLEED),
1290-
VULNBL_AMD(0x17, RETBLEED),
1291-
VULNBL_HYGON(0x18, RETBLEED),
1292+
VULNBL_AMD(0x17, RETBLEED | SMT_RSB),
1293+
VULNBL_HYGON(0x18, RETBLEED | SMT_RSB),
12921294
{}
12931295
};
12941296

@@ -1406,6 +1408,9 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
14061408
!(ia32_cap & ARCH_CAP_PBRSB_NO))
14071409
setup_force_cpu_bug(X86_BUG_EIBRS_PBRSB);
14081410

1411+
if (cpu_matches(cpu_vuln_blacklist, SMT_RSB))
1412+
setup_force_cpu_bug(X86_BUG_SMT_RSB);
1413+
14091414
if (cpu_matches(cpu_vuln_whitelist, NO_MELTDOWN))
14101415
return;
14111416

0 commit comments

Comments
 (0)