Commit 4a26e703 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'core-bugs-2025-12-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull bug handling infrastructure updates from Ingo Molnar:
 "Core updates:

   - Improve WARN(), which has vararg printf like arguments, to work
     with the x86 #UD based WARN-optimizing infrastructure by hiding the
     format in the bug_table and replacing this first argument with the
     address of the bug-table entry, while making the actual function
     that's called a UD1 instruction (Peter Zijlstra)

   - Introduce the CONFIG_DEBUG_BUGVERBOSE_DETAILED Kconfig switch (Ingo
     Molnar, s390 support by Heiko Carstens)

  Fixes and cleanups:

   - bugs/s390: Remove private WARN_ON() implementation (Heiko Carstens)

   - <asm/bugs.h>: Make i386 use GENERIC_BUG_RELATIVE_POINTERS (Peter
     Zijlstra)"

* tag 'core-bugs-2025-12-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (31 commits)
  x86/bugs: Make i386 use GENERIC_BUG_RELATIVE_POINTERS
  x86/bug: Fix BUG_FORMAT vs KASLR
  x86_64/bug: Inline the UD1
  x86/bug: Implement WARN_ONCE()
  x86_64/bug: Implement __WARN_printf()
  x86/bug: Use BUG_FORMAT for DEBUG_BUGVERBOSE_DETAILED
  x86/bug: Add BUG_FORMAT basics
  bug: Allow architectures to provide __WARN_printf()
  bug: Implement WARN_ON() using __WARN_FLAGS()
  bug: Add report_bug_entry()
  bug: Add BUG_FORMAT_ARGS infrastructure
  bug: Clean up CONFIG_GENERIC_BUG_RELATIVE_POINTERS
  bug: Add BUG_FORMAT infrastructure
  x86: Rework __bug_table helpers
  bugs/s390: Remove private WARN_ON() implementation
  bugs/core: Reorganize fields in the first line of WARNING output, add ->comm[] output
  bugs/sh: Concatenate 'cond_str' with '__FILE__' in __WARN_FLAGS(), to extend WARN_ON/BUG_ON output
  bugs/parisc: Concatenate 'cond_str' with '__FILE__' in __WARN_FLAGS(), to extend WARN_ON/BUG_ON output
  bugs/riscv: Concatenate 'cond_str' with '__FILE__' in __BUG_FLAGS(), to extend WARN_ON/BUG_ON output
  bugs/riscv: Pass in 'cond_str' to __BUG_FLAGS()
  ...
parents dcd8637e b0a848f4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
	unreachable();					\
} while (0)

#define __WARN_FLAGS(flags) __BUG_FLAGS(BUGFLAG_WARNING|(flags))
#define __WARN_FLAGS(cond_str, flags) __BUG_FLAGS(BUGFLAG_WARNING|(flags))

#define HAVE_ARCH_BUG

+13 −14
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
#else
#define __BUGVERBOSE_LOCATION(file, line)			\
		.pushsection .rodata.str, "aMS", @progbits, 1;	\
	10002:	.string file;					\
	10002:	.ascii file "\0";				\
		.popsection;					\
								\
		.long 10002b - .;				\
@@ -20,39 +20,38 @@
#endif

#ifndef CONFIG_GENERIC_BUG
#define __BUG_ENTRY(flags)
#define __BUG_ENTRY(cond_str, flags)
#else
#define __BUG_ENTRY(flags) 					\
#define __BUG_ENTRY(cond_str, flags)				\
		.pushsection __bug_table, "aw";			\
		.align 2;					\
	10000:	.long 10001f - .;				\
		_BUGVERBOSE_LOCATION(__FILE__, __LINE__)	\
		_BUGVERBOSE_LOCATION(WARN_CONDITION_STR(cond_str) __FILE__, __LINE__) \
		.short flags;					\
		.popsection;					\
	10001:
#endif

#define ASM_BUG_FLAGS(flags)					\
	__BUG_ENTRY(flags)					\
#define ASM_BUG_FLAGS(cond_str, flags)				\
	__BUG_ENTRY(cond_str, flags)				\
	break		BRK_BUG;

#define ASM_BUG()	ASM_BUG_FLAGS(0)
#define ASM_BUG()	ASM_BUG_FLAGS("", 0)

#define __BUG_FLAGS(flags, extra)					\
	asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags))		\
			     extra);
#define __BUG_FLAGS(cond_str, flags, extra)			\
	asm_inline volatile (__stringify(ASM_BUG_FLAGS(cond_str, flags)) extra);

#define __WARN_FLAGS(flags)					\
#define __WARN_FLAGS(cond_str, flags)				\
do {								\
	instrumentation_begin();				\
	__BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE(10001b));\
	__BUG_FLAGS(cond_str, BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE(10001b));\
	instrumentation_end();					\
} while (0)

#define BUG()							\
do {								\
	instrumentation_begin();				\
	__BUG_FLAGS(0, "");					\
	__BUG_FLAGS("", 0, "");					\
	unreachable();						\
} while (0)

+3 −3
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@
#endif

#ifdef CONFIG_DEBUG_BUGVERBOSE
#define __WARN_FLAGS(flags)						\
#define __WARN_FLAGS(cond_str, flags)					\
	do {								\
		asm volatile("\n"					\
			     "1:\t" PARISC_BUG_BREAK_ASM "\n"		\
@@ -61,12 +61,12 @@
			     "\t.short %1, %2\n"			\
			     "\t.blockz %3-2*4-2*2\n"			\
			     "\t.popsection"				\
			     : : "i" (__FILE__), "i" (__LINE__),	\
			     : : "i" (WARN_CONDITION_STR(cond_str) __FILE__), "i" (__LINE__), \
			     "i" (BUGFLAG_WARNING|(flags)),		\
			     "i" (sizeof(struct bug_entry)) );		\
	} while(0)
#else
#define __WARN_FLAGS(flags)						\
#define __WARN_FLAGS(cond_str, flags)					\
	do {								\
		asm volatile("\n"					\
			     "1:\t" PARISC_BUG_BREAK_ASM "\n"		\
+6 −6
Original line number Diff line number Diff line
@@ -51,11 +51,11 @@
	".previous\n"
#endif

#define BUG_ENTRY(insn, flags, ...)			\
#define BUG_ENTRY(cond_str, insn, flags, ...)		\
	__asm__ __volatile__(				\
		"1:	" insn "\n"			\
		_EMIT_BUG_ENTRY				\
		: : "i" (__FILE__), "i" (__LINE__),	\
		: : "i" (WARN_CONDITION_STR(cond_str) __FILE__), "i" (__LINE__),	\
		  "i" (flags),				\
		  "i" (sizeof(struct bug_entry)),	\
		  ##__VA_ARGS__)
@@ -67,12 +67,12 @@
 */

#define BUG() do {						\
	BUG_ENTRY("twi 31, 0, 0", 0);				\
	BUG_ENTRY("", "twi 31, 0, 0", 0);			\
	unreachable();						\
} while (0)
#define HAVE_ARCH_BUG

#define __WARN_FLAGS(flags) BUG_ENTRY("twi 31, 0, 0", BUGFLAG_WARNING | (flags))
#define __WARN_FLAGS(cond_str, flags) BUG_ENTRY(cond_str, "twi 31, 0, 0", BUGFLAG_WARNING | (flags))

#ifdef CONFIG_PPC64
#define BUG_ON(x) do {						\
@@ -80,7 +80,7 @@
		if (x)						\
			BUG();					\
	} else {						\
		BUG_ENTRY(PPC_TLNEI " %4, 0", 0, "r" ((__force long)(x)));	\
		BUG_ENTRY(#x, PPC_TLNEI " %4, 0", 0, "r" ((__force long)(x)));	\
	}							\
} while (0)

@@ -90,7 +90,7 @@
		if (__ret_warn_on)				\
			__WARN();				\
	} else {						\
		BUG_ENTRY(PPC_TLNEI " %4, 0",			\
		BUG_ENTRY(#x, PPC_TLNEI " %4, 0",			\
			  BUGFLAG_WARNING | BUGFLAG_TAINT(TAINT_WARN),	\
			  "r" (__ret_warn_on));	\
	}							\
+5 −5
Original line number Diff line number Diff line
@@ -60,28 +60,28 @@ typedef u32 bug_insn_t;
			".org 2b + " size "\n\t"                \
			".popsection"				\

#define __BUG_FLAGS(flags)					\
#define __BUG_FLAGS(cond_str, flags)				\
do {								\
	__asm__ __volatile__ (					\
		ARCH_WARN_ASM("%0", "%1", "%2", "%3")		\
		:						\
		: "i" (__FILE__), "i" (__LINE__),		\
		: "i" (WARN_CONDITION_STR(cond_str) __FILE__), "i" (__LINE__),	\
		  "i" (flags),					\
		  "i" (sizeof(struct bug_entry)));              \
} while (0)

#else /* CONFIG_GENERIC_BUG */
#define __BUG_FLAGS(flags) do {					\
#define __BUG_FLAGS(cond_str, flags) do {			\
	__asm__ __volatile__ ("ebreak\n");			\
} while (0)
#endif /* CONFIG_GENERIC_BUG */

#define BUG() do {						\
	__BUG_FLAGS(0);						\
	__BUG_FLAGS("", 0);					\
	unreachable();						\
} while (0)

#define __WARN_FLAGS(flags) __BUG_FLAGS(BUGFLAG_WARNING|(flags))
#define __WARN_FLAGS(cond_str, flags) __BUG_FLAGS(cond_str, BUGFLAG_WARNING|(flags))

#define ARCH_WARN_REACHABLE

Loading