Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bug: Add BUG_FORMAT infrastructure

Add BUG_FORMAT; an architecture opt-in feature that allows adding the
WARN_printf() format string to the bug_entry table.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20251110115757.223371452@infradead.org

+39 -7
+7
include/asm-generic/bug.h
··· 42 42 #else 43 43 signed int bug_addr_disp; 44 44 #endif 45 + #ifdef HAVE_ARCH_BUG_FORMAT 46 + #ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS 47 + const char *format; 48 + #else 49 + signed int format_disp; 50 + #endif 51 + #endif 45 52 #ifdef CONFIG_DEBUG_BUGVERBOSE 46 53 #ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS 47 54 const char *file;
+32 -7
lib/bug.c
··· 139 139 #endif 140 140 } 141 141 142 + static const char *bug_get_format(struct bug_entry *bug) 143 + { 144 + const char *format = NULL; 145 + #ifdef HAVE_ARCH_BUG_FORMAT 146 + #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS 147 + format = (const char *)&bug->format_disp + bug->format_disp; 148 + #else 149 + format = bug->format; 150 + #endif 151 + #endif 152 + return format; 153 + } 154 + 142 155 struct bug_entry *find_bug(unsigned long bugaddr) 143 156 { 144 157 struct bug_entry *bug; ··· 163 150 return module_find_bug(bugaddr); 164 151 } 165 152 153 + static void __warn_printf(const char *fmt) 154 + { 155 + if (!fmt) 156 + return; 157 + 158 + printk("%s", fmt); 159 + } 160 + 166 161 static enum bug_trap_type __report_bug(unsigned long bugaddr, struct pt_regs *regs) 167 162 { 168 - struct bug_entry *bug; 169 - const char *file; 170 - unsigned line, warning, once, done; 163 + bool warning, once, done, no_cut, has_args; 164 + const char *file, *fmt; 165 + unsigned line; 171 166 172 167 if (!is_valid_bugaddr(bugaddr)) 173 168 return BUG_TRAP_TYPE_NONE; ··· 187 166 disable_trace_on_warning(); 188 167 189 168 bug_get_file_line(bug, &file, &line); 169 + fmt = bug_get_format(bug); 190 170 191 - warning = (bug->flags & BUGFLAG_WARNING) != 0; 192 - once = (bug->flags & BUGFLAG_ONCE) != 0; 193 - done = (bug->flags & BUGFLAG_DONE) != 0; 171 + warning = bug->flags & BUGFLAG_WARNING; 172 + once = bug->flags & BUGFLAG_ONCE; 173 + done = bug->flags & BUGFLAG_DONE; 174 + no_cut = bug->flags & BUGFLAG_NO_CUT_HERE; 194 175 195 176 if (warning && once) { 196 177 if (done) ··· 210 187 * "cut here" line now. WARN() issues its own "cut here" before the 211 188 * extra debugging message it writes before triggering the handler. 212 189 */ 213 - if ((bug->flags & BUGFLAG_NO_CUT_HERE) == 0) 190 + if (!no_cut) { 214 191 printk(KERN_DEFAULT CUT_HERE); 192 + __warn_printf(fmt); 193 + } 215 194 216 195 if (warning) { 217 196 /* this is a WARN_ON rather than BUG/BUG_ON */