[PATCH] x86/alternative: Replace DPRINTK with pr_debug

hugopoggetti posted 1 patch 5 days, 12 hours ago
arch/x86/kernel/alternative.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
[PATCH] x86/alternative: Replace DPRINTK with pr_debug
Posted by hugopoggetti 5 days, 12 hours ago
Replace the custom DPRINTK macro with the standard pr_debug()
to use the kernel's standard debugging infrastructure.

Signed-off-by: hugopoggetti <hugo.poggetti@epitech.eu>
---
 arch/x86/kernel/alternative.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 28518371d8bf..f462d47e3344 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #define pr_fmt(fmt) "SMP alternatives: " fmt
 
+#include <linux/kernel.h>
 #include <linux/mmu_context.h>
 #include <linux/perf_event.h>
 #include <linux/vmalloc.h>
@@ -50,12 +51,6 @@ static int __init setup_noreplace_smp(char *str)
 }
 __setup("noreplace-smp", setup_noreplace_smp);
 
-#define DPRINTK(type, fmt, args...)					\
-do {									\
-	if (debug_alternative & DA_##type)				\
-		printk(KERN_DEBUG pr_fmt(fmt) "\n", ##args);		\
-} while (0)
-
 #define DUMP_BYTES(type, buf, len, fmt, args...)			\
 do {									\
 	if (unlikely(debug_alternative & DA_##type)) {			\
@@ -603,7 +598,7 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
 	u8 *instr, *replacement;
 	struct alt_instr *a, *b;
 
-	DPRINTK(ALT, "alt table %px, -> %px", start, end);
+	pr_debug("alt table %px, -> %px", start, end);
 
 	/*
 	 * KASAN_SHADOW_START is defined using
@@ -656,7 +651,7 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
 			continue;
 		}
 
-		DPRINTK(ALT, "feat: %d*32+%d, old: (%pS (%px) len: %d), repl: (%px, len: %d) flags: 0x%x",
+		pr_debug("feat: %d*32+%d, old: (%pS (%px) len: %d), repl: (%px, len: %d) flags: 0x%x",
 			a->cpuid >> 5,
 			a->cpuid & 0x1f,
 			instr, instr, a->instrlen,
@@ -974,7 +969,7 @@ void __init_or_module noinline apply_retpolines(s32 *start, s32 *end)
 			continue;
 		}
 
-		DPRINTK(RETPOLINE, "retpoline at: %pS (%px) len: %d to: %pS",
+		pr_debug("retpoline at: %pS (%px) len: %d to: %pS",
 			addr, addr, insn.length,
 			addr + insn.length + insn.immediate.value);
 
@@ -1062,7 +1057,7 @@ void __init_or_module noinline apply_returns(s32 *start, s32 *end)
 			      addr, dest, 5, addr))
 			continue;
 
-		DPRINTK(RET, "return thunk at: %pS (%px) len: %d to: %pS",
+		pr_debug("return thunk at: %pS (%px) len: %d to: %pS",
 			addr, addr, insn.length,
 			addr + insn.length + insn.immediate.value);
 
@@ -1122,7 +1117,7 @@ static void __init_or_module poison_endbr(void *addr)
 	if (WARN_ON_ONCE(!is_endbr(addr)))
 		return;
 
-	DPRINTK(ENDBR, "ENDBR at: %pS (%px)", addr, addr);
+	pr_debug("ENDBR at: %pS (%px)", addr, addr);
 
 	/*
 	 * When we have IBT, the lack of ENDBR will trigger #CP
@@ -2136,7 +2131,7 @@ void __init_or_module alternatives_smp_module_add(struct module *mod,
 	smp->locks_end	= locks_end;
 	smp->text	= text;
 	smp->text_end	= text_end;
-	DPRINTK(SMP, "locks %p -> %p, text %p -> %p, name %s\n",
+	pr_debug("locks %p -> %p, text %p -> %p, name %s\n",
 		smp->locks, smp->locks_end,
 		smp->text, smp->text_end, smp->name);
 
-- 
2.52.0
Re: [PATCH] x86/alternative: Replace DPRINTK with pr_debug
Posted by Borislav Petkov 5 days, 12 hours ago
On Sun, Feb 01, 2026 at 07:58:28PM +0100, hugopoggetti wrote:
> Replace the custom DPRINTK macro with the standard pr_debug()
> to use the kernel's standard debugging infrastructure.

No thanks. pr_debug() depends on a bunch of config options and we want
alternatives debugging to JustWork(tm), without a bunch of fuss.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
Re: [PATCH] x86/alternative: Replace DPRINTK with pr_debug
Posted by Peter Zijlstra 4 days, 21 hours ago
On Sun, Feb 01, 2026 at 08:05:27PM +0100, Borislav Petkov wrote:
> On Sun, Feb 01, 2026 at 07:58:28PM +0100, hugopoggetti wrote:
> > Replace the custom DPRINTK macro with the standard pr_debug()
> > to use the kernel's standard debugging infrastructure.
> 
> No thanks. pr_debug() depends on a bunch of config options and we want
> alternatives debugging to JustWork(tm), without a bunch of fuss.

Also, he completely broke 'debug_alternative' for bonus points..

So yeah, no touching unless you've actually went through the pain of
debugging the alternative code :-)