Skip to content

Commit 0a52d33

Browse files
author
Peter Zijlstra
committed
x86/bug: Add BUG_FORMAT basics
Opt-in to BUG_FORMAT for x86_64, adjust the BUGTABLE helper and for now, just store NULL pointers. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20251110115757.980264454@infradead.org
1 parent b9b2c45 commit 0a52d33

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

  • arch/x86/include/asm

arch/x86/include/asm/bug.h

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,44 @@
5050
#define __BUG_ENTRY_VERBOSE(file, line)
5151
#endif
5252

53-
#define __BUG_ENTRY(file, line, flags) \
53+
#if defined(CONFIG_X86_64) || defined(CONFIG_DEBUG_BUGVERBOSE_DETAILED)
54+
#define HAVE_ARCH_BUG_FORMAT
55+
#define __BUG_ENTRY_FORMAT(format) \
56+
"\t" __BUG_REL(format) "\t# bug_entry::format\n"
57+
#else
58+
#define __BUG_ENTRY_FORMAT(format)
59+
#endif
60+
61+
#define __BUG_ENTRY(format, file, line, flags) \
5462
__BUG_REL("1b") "\t# bug_entry::bug_addr\n" \
63+
__BUG_ENTRY_FORMAT(format) \
5564
__BUG_ENTRY_VERBOSE(file, line) \
5665
"\t.word " flags "\t# bug_entry::flags\n"
5766

58-
#define _BUG_FLAGS_ASM(ins, file, line, flags, size, extra) \
67+
#define _BUG_FLAGS_ASM(ins, format, file, line, flags, size, extra) \
5968
"1:\t" ins "\n" \
6069
".pushsection __bug_table,\"aw\"\n\t" \
6170
ANNOTATE_DATA_SPECIAL \
6271
"2:\n\t" \
63-
__BUG_ENTRY(file, line, flags) \
72+
__BUG_ENTRY(format, file, line, flags) \
6473
"\t.org 2b + " size "\n" \
6574
".popsection\n" \
6675
extra
6776

6877
#define _BUG_FLAGS(cond_str, ins, flags, extra) \
6978
do { \
70-
asm_inline volatile(_BUG_FLAGS_ASM(ins, "%c0", \
71-
"%c1", "%c2", "%c3", extra) \
72-
: : "i" (WARN_CONDITION_STR(cond_str) __FILE__), \
73-
"i" (__LINE__), \
74-
"i" (flags), \
75-
"i" (sizeof(struct bug_entry))); \
79+
asm_inline volatile(_BUG_FLAGS_ASM(ins, "%c[fmt]", "%c[file]", \
80+
"%c[line]", "%c[fl]", \
81+
"%c[size]", extra) \
82+
: : [fmt] "i" (NULL), \
83+
[file] "i" (WARN_CONDITION_STR(cond_str) __FILE__), \
84+
[line] "i" (__LINE__), \
85+
[fl] "i" (flags), \
86+
[size] "i" (sizeof(struct bug_entry))); \
7687
} while (0)
7788

7889
#define ARCH_WARN_ASM(file, line, flags, size) \
79-
_BUG_FLAGS_ASM(ASM_UD2, file, line, flags, size, "")
90+
_BUG_FLAGS_ASM(ASM_UD2, "0", file, line, flags, size, "")
8091

8192
#else
8293

0 commit comments

Comments
 (0)