]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/ibt: Make cfi_bhi a constant for FINEIBT_BHI=n
authorPeter Zijlstra <peterz@infradead.org>
Mon, 3 Mar 2025 09:21:47 +0000 (10:21 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 3 Mar 2025 09:54:11 +0000 (10:54 +0100)
Robot yielded a .config that tripped:

  vmlinux.o: warning: objtool: do_jit+0x276: relocation to !ENDBR: .noinstr.text+0x6a60

This is the result of using __bhi_args[1] in unreachable code; make
sure the compiler is able to determine this is unreachable and trigger
DCE.

Closes: https://lore.kernel.org/oe-kbuild-all/202503030704.H9KFysNS-lkp@intel.com/
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20250303094911.GL5880@noisy.programming.kicks-ass.net
arch/x86/include/asm/cfi.h
arch/x86/kernel/alternative.c

index 2f6a01f098b5c6d56850cf84a716dd66a9a88a20..3e51ba4591546fe571a02b1859f8b9ef306f915d 100644 (file)
@@ -100,7 +100,12 @@ enum cfi_mode {
 };
 
 extern enum cfi_mode cfi_mode;
+
+#ifdef CONFIG_FINEIBT_BHI
 extern bool cfi_bhi;
+#else
+#define cfi_bhi (0)
+#endif
 
 typedef u8 bhi_thunk[32];
 extern bhi_thunk __bhi_args[];
index 32e4b801db991a1a80499571d2c38641ac751067..bf82c6f7d690557dd76efef6fab216f94005ed54 100644 (file)
@@ -936,7 +936,10 @@ void __init_or_module apply_seal_endbr(s32 *start, s32 *end) { }
 #endif
 
 enum cfi_mode cfi_mode __ro_after_init = __CFI_DEFAULT;
+
+#ifdef CONFIG_FINEIBT_BHI
 bool cfi_bhi __ro_after_init = false;
+#endif
 
 #ifdef CONFIG_CFI_CLANG
 struct bpf_insn;
@@ -1070,11 +1073,15 @@ static __init int cfi_parse_cmdline(char *str)
                                pr_err("Ignoring paranoid; depends on fineibt.\n");
                        }
                } else if (!strcmp(str, "bhi")) {
+#ifdef CONFIG_FINEIBT_BHI
                        if (cfi_mode == CFI_FINEIBT) {
                                cfi_bhi = true;
                        } else {
                                pr_err("Ignoring bhi; depends on fineibt.\n");
                        }
+#else
+                       pr_err("Ignoring bhi; depends on FINEIBT_BHI=y.\n");
+#endif
                } else {
                        pr_err("Ignoring unknown cfi option (%s).", str);
                }