Blob Blame History Raw
From: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Date: Thu, 7 Jul 2022 13:41:52 -0300
Subject: [PATCH] x86/bugs: Do not enable IBPB-on-entry when IBPB is not supported
Patch-mainline: v5.19-rc4
Git-commit: 2259da159fbe5dba8ac00b560cf00b6a6537fa18
References: bsc#1199657 CVE-2022-29900 CVE-2022-29901

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: 3ebc17006888 ("x86/bugs: Add retbleed=ibpb")
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

  [ bp: The fallback to IBPB when RETBLEED_CMD_AUTO doesn't make sense for our
    trees because upstream has fine-grained config options which we didn't
    backport. ]

Signed-off-by: Borislav Petkov <bp@suse.de>
---
 arch/x86/kernel/cpu/bugs.c |    5 +++++
 1 file changed, 5 insertions(+)

--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -930,9 +930,14 @@ static void __init retbleed_select_mitig
 		break;
 
 	case RETBLEED_CMD_IBPB:
+		if (!boot_cpu_has(X86_FEATURE_IBPB)) {
+			pr_err("WARNING: CPU does not support IBPB.\n");
+			goto do_cmd_auto;
+		}
 		retbleed_mitigation = RETBLEED_MITIGATION_IBPB;
 		break;
 
+do_cmd_auto:
 	case RETBLEED_CMD_AUTO:
 	default:
 		if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||