* [PATCH] x86/cfi: mark cfi_debug as __maybe_unused
@ 2026-11-16 17:30 Ali Nasrollahi
2026-11-17 18:35 ` Peter Zijlstra
0 siblings, 1 reply; 2+ messages in thread
From: Ali Nasrollahi @ 2026-11-16 17:30 UTC (permalink / raw)
To: x86; +Cc: linux-kernel, llvm, kees, peterz, nathan, Ali Nasrollahi
When CONFIG_FINEIBT is disabled, cfi_debug is never read, but
alternative_instructions() still resets it after calling
__apply_fineibt(). Clang 23 diagnoses this as -Wunused-but-set-global
with W=1, causing a build failure when CONFIG_WERROR=y. Mark cfi_debug
as __maybe_unused to account for configurations without FineIBT.
Signed-off-by: Ali Nasrollahi <A.Nasrolahi01@gmail.com>
---
arch/x86/kernel/alternative.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index efbc11f8c336..cc2bdca06f81 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -1195,7 +1195,7 @@ void __init_or_module apply_seal_endbr(s32 *start, s32 *end) { }
#endif
enum cfi_mode cfi_mode __ro_after_init = __CFI_DEFAULT;
-static bool cfi_debug __ro_after_init;
+static bool cfi_debug __ro_after_init __maybe_unused;
#ifdef CONFIG_FINEIBT_BHI
bool cfi_bhi __ro_after_init = false;
--
2.56.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] x86/cfi: mark cfi_debug as __maybe_unused
2026-11-16 17:30 [PATCH] x86/cfi: mark cfi_debug as __maybe_unused Ali Nasrollahi
@ 2026-11-17 18:35 ` Peter Zijlstra
0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2026-11-17 18:35 UTC (permalink / raw)
To: Ali Nasrollahi; +Cc: x86, linux-kernel, llvm, kees, nathan
On Mon, Nov 16, 2026 at 09:00:27PM +0330, Ali Nasrollahi wrote:
> When CONFIG_FINEIBT is disabled, cfi_debug is never read, but
> alternative_instructions() still resets it after calling
> __apply_fineibt(). Clang 23 diagnoses this as -Wunused-but-set-global
> with W=1, causing a build failure when CONFIG_WERROR=y. Mark cfi_debug
> as __maybe_unused to account for configurations without FineIBT.
>
> Signed-off-by: Ali Nasrollahi <A.Nasrolahi01@gmail.com>
Does something like so also work?
---
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index efbc11f8c336..9bfc36566e17 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -1195,9 +1195,9 @@ void __init_or_module apply_seal_endbr(s32 *start, s32 *end) { }
#endif
enum cfi_mode cfi_mode __ro_after_init = __CFI_DEFAULT;
-static bool cfi_debug __ro_after_init;
#ifdef CONFIG_FINEIBT_BHI
+static bool cfi_debug __ro_after_init;
bool cfi_bhi __ro_after_init = false;
#endif
@@ -1894,6 +1894,7 @@ static void __init_or_module __apply_fineibt(s32 *start_retpoline, s32 *end_retp
break;
}
+ cfi_debug = false;
err:
pr_err("Something went horribly wrong trying to rewrite the CFI implementation.\n");
}
@@ -2281,7 +2282,6 @@ void __init alternative_instructions(void)
__apply_fineibt(__retpoline_sites, __retpoline_sites_end,
__cfi_sites, __cfi_sites_end, true);
- cfi_debug = false;
/*
* Rewrite the retpolines, must be done before alternatives since
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-17 18:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 17:30 [PATCH] x86/cfi: mark cfi_debug as __maybe_unused Ali Nasrollahi
2026-11-17 18:35 ` Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®