Skip to content

Commit 8778188

Browse files
committed
x86/bugs: Add SRSO_USER_KERNEL_NO support
If the machine has: CPUID Fn8000_0021_EAX[30] (SRSO_USER_KERNEL_NO) -- If this bit is 1, it indicates the CPU is not subject to the SRSO vulnerability across user/kernel boundaries. have it fall back to IBPB on VMEXIT only, in the case it is going to run VMs: Speculative Return Stack Overflow: Mitigation: IBPB on VMEXIT only Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fc033cf commit 8778188

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@
465465
#define X86_FEATURE_SBPB (20*32+27) /* Selective Branch Prediction Barrier */
466466
#define X86_FEATURE_IBPB_BRTYPE (20*32+28) /* MSR_PRED_CMD[IBPB] flushes all branch type predictions */
467467
#define X86_FEATURE_SRSO_NO (20*32+29) /* CPU is not affected by SRSO */
468+
#define X86_FEATURE_SRSO_USER_KERNEL_NO (20*32+30) /* CPU is not affected by SRSO across user/kernel boundaries */
468469

469470
/*
470471
* Extended auxiliary flags: Linux defined - for features scattered in various

arch/x86/kernel/cpu/bugs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,6 +2615,9 @@ static void __init srso_select_mitigation(void)
26152615
break;
26162616

26172617
case SRSO_CMD_SAFE_RET:
2618+
if (boot_cpu_has(X86_FEATURE_SRSO_USER_KERNEL_NO))
2619+
goto ibpb_on_vmexit;
2620+
26182621
if (IS_ENABLED(CONFIG_MITIGATION_SRSO)) {
26192622
/*
26202623
* Enable the return thunk for generated code
@@ -2658,6 +2661,7 @@ static void __init srso_select_mitigation(void)
26582661
}
26592662
break;
26602663

2664+
ibpb_on_vmexit:
26612665
case SRSO_CMD_IBPB_ON_VMEXIT:
26622666
if (IS_ENABLED(CONFIG_MITIGATION_SRSO)) {
26632667
if (!boot_cpu_has(X86_FEATURE_ENTRY_IBPB) && has_microcode) {

arch/x86/kernel/cpu/common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,7 @@ static const struct x86_cpu_id cpu_vuln_blacklist[] __initconst = {
12701270
VULNBL_AMD(0x17, RETBLEED | SMT_RSB | SRSO),
12711271
VULNBL_HYGON(0x18, RETBLEED | SMT_RSB | SRSO),
12721272
VULNBL_AMD(0x19, SRSO),
1273+
VULNBL_AMD(0x1a, SRSO),
12731274
{}
12741275
};
12751276

0 commit comments

Comments
 (0)