x86: Rework __bug_table helpers

Rework the __bug_table helpers such that extension becomes easier.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20251110115757.111187573@infradead.org
This commit is contained in:
Peter Zijlstra
2024-10-07 10:16:56 +02:00
parent 2ace527183
commit 1be1fac648

View File

@@ -37,39 +37,42 @@
#ifdef CONFIG_GENERIC_BUG
#ifdef CONFIG_X86_32
# define __BUG_REL(val) ".long " val
#define __BUG_REL(val) ".long " val
#else
# define __BUG_REL(val) ".long " val " - ."
#define __BUG_REL(val) ".long " val " - ."
#endif
#ifdef CONFIG_DEBUG_BUGVERBOSE
#define __BUG_ENTRY(file, line, flags) \
"2:\t" __BUG_REL("1b") "\t# bug_entry::bug_addr\n" \
#define __BUG_ENTRY_VERBOSE(file, line) \
"\t" __BUG_REL(file) "\t# bug_entry::file\n" \
"\t.word " line "\t# bug_entry::line\n" \
"\t.word " flags "\t# bug_entry::flags\n"
"\t.word " line "\t# bug_entry::line\n"
#else
#define __BUG_ENTRY(file, line, flags) \
"2:\t" __BUG_REL("1b") "\t# bug_entry::bug_addr\n" \
"\t.word " flags "\t# bug_entry::flags\n"
#define __BUG_ENTRY_VERBOSE(file, line)
#endif
#define __BUG_ENTRY(file, line, flags) \
__BUG_REL("1b") "\t# bug_entry::bug_addr\n" \
__BUG_ENTRY_VERBOSE(file, line) \
"\t.word " flags "\t# bug_entry::flags\n"
#define _BUG_FLAGS_ASM(ins, file, line, flags, size, extra) \
"1:\t" ins "\n" \
".pushsection __bug_table,\"aw\"\n" \
".pushsection __bug_table,\"aw\"\n\t" \
ANNOTATE_DATA_SPECIAL \
"2:\n\t" \
__BUG_ENTRY(file, line, flags) \
"\t.org 2b + " size "\n" \
".popsection\n" \
extra
#define _BUG_FLAGS(cond_str, ins, flags, extra) \
do { \
asm_inline volatile(_BUG_FLAGS_ASM(ins, "%c0", \
"%c1", "%c2", "%c3", extra) \
: : "i" (WARN_CONDITION_STR(cond_str) __FILE__), "i" (__LINE__), \
"i" (flags), \
"i" (sizeof(struct bug_entry))); \
#define _BUG_FLAGS(cond_str, ins, flags, extra) \
do { \
asm_inline volatile(_BUG_FLAGS_ASM(ins, "%c0", \
"%c1", "%c2", "%c3", extra) \
: : "i" (WARN_CONDITION_STR(cond_str) __FILE__), \
"i" (__LINE__), \
"i" (flags), \
"i" (sizeof(struct bug_entry))); \
} while (0)
#define ARCH_WARN_ASM(file, line, flags, size) \