Skip to content

Commit 2259da1

Browse files
Thadeu Lima de Souza Cascardosuryasaimadhu
authored andcommitted
x86/bugs: Do not enable IBPB-on-entry when IBPB is not supported
There are some VM configurations which have Skylake model but do not support IBPB. In those cases, when using retbleed=ibpb, userspace is going to be killed and kernel is going to panic. If the CPU does not support IBPB, warn and proceed with the auto option. Also, do not fallback to IBPB on AMD/Hygon systems if it is not supported. Fixes: 3ebc170 ("x86/bugs: Add retbleed=ibpb") Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]> Signed-off-by: Borislav Petkov <[email protected]>
1 parent 2c08b9b commit 2259da1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arch/x86/kernel/cpu/bugs.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,10 @@ static void __init retbleed_select_mitigation(void)
865865
break;
866866

867867
case RETBLEED_CMD_IBPB:
868-
if (IS_ENABLED(CONFIG_CPU_IBPB_ENTRY)) {
868+
if (!boot_cpu_has(X86_FEATURE_IBPB)) {
869+
pr_err("WARNING: CPU does not support IBPB.\n");
870+
goto do_cmd_auto;
871+
} else if (IS_ENABLED(CONFIG_CPU_IBPB_ENTRY)) {
869872
retbleed_mitigation = RETBLEED_MITIGATION_IBPB;
870873
} else {
871874
pr_err("WARNING: kernel not compiled with CPU_IBPB_ENTRY.\n");
@@ -880,7 +883,7 @@ static void __init retbleed_select_mitigation(void)
880883
boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) {
881884
if (IS_ENABLED(CONFIG_CPU_UNRET_ENTRY))
882885
retbleed_mitigation = RETBLEED_MITIGATION_UNRET;
883-
else if (IS_ENABLED(CONFIG_CPU_IBPB_ENTRY))
886+
else if (IS_ENABLED(CONFIG_CPU_IBPB_ENTRY) && boot_cpu_has(X86_FEATURE_IBPB))
884887
retbleed_mitigation = RETBLEED_MITIGATION_IBPB;
885888
}
886889

0 commit comments

Comments
 (0)