Skip to content

Commit 8c8efa9

Browse files
fujitaojeda
authored andcommitted
x86/bug: Add ARCH_WARN_ASM macro for BUG/WARN asm code sharing with Rust
Add new ARCH_WARN_ASM macro for BUG/WARN assembly code sharing with Rust to avoid the duplication. No functional changes. Acked-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: FUJITA Tomonori <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Fixed typo in macro parameter name. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 07dad44 commit 8c8efa9

File tree

1 file changed

+28
-28
lines changed
  • arch/x86/include/asm

1 file changed

+28
-28
lines changed

arch/x86/include/asm/bug.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,45 +32,42 @@
3232
#ifdef CONFIG_GENERIC_BUG
3333

3434
#ifdef CONFIG_X86_32
35-
# define __BUG_REL(val) ".long " __stringify(val)
35+
# define __BUG_REL(val) ".long " val
3636
#else
37-
# define __BUG_REL(val) ".long " __stringify(val) " - ."
37+
# define __BUG_REL(val) ".long " val " - ."
3838
#endif
3939

4040
#ifdef CONFIG_DEBUG_BUGVERBOSE
41+
#define __BUG_ENTRY(file, line, flags) \
42+
"2:\t" __BUG_REL("1b") "\t# bug_entry::bug_addr\n" \
43+
"\t" __BUG_REL(file) "\t# bug_entry::file\n" \
44+
"\t.word " line "\t# bug_entry::line\n" \
45+
"\t.word " flags "\t# bug_entry::flags\n"
46+
#else
47+
#define __BUG_ENTRY(file, line, flags) \
48+
"2:\t" __BUG_REL("1b") "\t# bug_entry::bug_addr\n" \
49+
"\t.word " flags "\t# bug_entry::flags\n"
50+
#endif
51+
52+
#define _BUG_FLAGS_ASM(ins, file, line, flags, size, extra) \
53+
"1:\t" ins "\n" \
54+
".pushsection __bug_table,\"aw\"\n" \
55+
__BUG_ENTRY(file, line, flags) \
56+
"\t.org 2b + " size "\n" \
57+
".popsection\n" \
58+
extra
4159

4260
#define _BUG_FLAGS(ins, flags, extra) \
4361
do { \
44-
asm_inline volatile("1:\t" ins "\n" \
45-
".pushsection __bug_table,\"aw\"\n" \
46-
"2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
47-
"\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \
48-
"\t.word %c1" "\t# bug_entry::line\n" \
49-
"\t.word %c2" "\t# bug_entry::flags\n" \
50-
"\t.org 2b+%c3\n" \
51-
".popsection\n" \
52-
extra \
62+
asm_inline volatile(_BUG_FLAGS_ASM(ins, "%c0", \
63+
"%c1", "%c2", "%c3", extra) \
5364
: : "i" (__FILE__), "i" (__LINE__), \
5465
"i" (flags), \
5566
"i" (sizeof(struct bug_entry))); \
5667
} while (0)
5768

58-
#else /* !CONFIG_DEBUG_BUGVERBOSE */
59-
60-
#define _BUG_FLAGS(ins, flags, extra) \
61-
do { \
62-
asm_inline volatile("1:\t" ins "\n" \
63-
".pushsection __bug_table,\"aw\"\n" \
64-
"2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
65-
"\t.word %c0" "\t# bug_entry::flags\n" \
66-
"\t.org 2b+%c1\n" \
67-
".popsection\n" \
68-
extra \
69-
: : "i" (flags), \
70-
"i" (sizeof(struct bug_entry))); \
71-
} while (0)
72-
73-
#endif /* CONFIG_DEBUG_BUGVERBOSE */
69+
#define ARCH_WARN_ASM(file, line, flags, size) \
70+
_BUG_FLAGS_ASM(ASM_UD2, file, line, flags, size, "")
7471

7572
#else
7673

@@ -92,11 +89,14 @@ do { \
9289
* were to trigger, we'd rather wreck the machine in an attempt to get the
9390
* message out than not know about it.
9491
*/
92+
93+
#define ARCH_WARN_REACHABLE ANNOTATE_REACHABLE(1b)
94+
9595
#define __WARN_FLAGS(flags) \
9696
do { \
9797
__auto_type __flags = BUGFLAG_WARNING|(flags); \
9898
instrumentation_begin(); \
99-
_BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE(1b)); \
99+
_BUG_FLAGS(ASM_UD2, __flags, ARCH_WARN_REACHABLE); \
100100
instrumentation_end(); \
101101
} while (0)
102102

0 commit comments

Comments
 (0)