Skip to content

Commit 8ad470d

Browse files
fujitaojeda
authored andcommitted
riscv/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: Alexandre Ghiti <[email protected]> Signed-off-by: FUJITA Tomonori <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Remove ending newline in `ARCH_WARN_ASM` content to be closer to the original. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 8c8efa9 commit 8ad470d

File tree

1 file changed

+21
-14
lines changed
  • arch/riscv/include/asm

1 file changed

+21
-14
lines changed

arch/riscv/include/asm/bug.h

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,40 +31,45 @@ typedef u32 bug_insn_t;
3131

3232
#ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
3333
#define __BUG_ENTRY_ADDR RISCV_INT " 1b - ."
34-
#define __BUG_ENTRY_FILE RISCV_INT " %0 - ."
34+
#define __BUG_ENTRY_FILE(file) RISCV_INT " " file " - ."
3535
#else
3636
#define __BUG_ENTRY_ADDR RISCV_PTR " 1b"
37-
#define __BUG_ENTRY_FILE RISCV_PTR " %0"
37+
#define __BUG_ENTRY_FILE(file) RISCV_PTR " " file
3838
#endif
3939

4040
#ifdef CONFIG_DEBUG_BUGVERBOSE
41-
#define __BUG_ENTRY \
41+
#define __BUG_ENTRY(file, line, flags) \
4242
__BUG_ENTRY_ADDR "\n\t" \
43-
__BUG_ENTRY_FILE "\n\t" \
44-
RISCV_SHORT " %1\n\t" \
45-
RISCV_SHORT " %2"
43+
__BUG_ENTRY_FILE(file) "\n\t" \
44+
RISCV_SHORT " " line "\n\t" \
45+
RISCV_SHORT " " flags
4646
#else
47-
#define __BUG_ENTRY \
48-
__BUG_ENTRY_ADDR "\n\t" \
49-
RISCV_SHORT " %2"
47+
#define __BUG_ENTRY(file, line, flags) \
48+
__BUG_ENTRY_ADDR "\n\t" \
49+
RISCV_SHORT " " flags
5050
#endif
5151

5252
#ifdef CONFIG_GENERIC_BUG
53-
#define __BUG_FLAGS(flags) \
54-
do { \
55-
__asm__ __volatile__ ( \
53+
54+
#define ARCH_WARN_ASM(file, line, flags, size) \
5655
"1:\n\t" \
5756
"ebreak\n" \
5857
".pushsection __bug_table,\"aw\"\n\t" \
5958
"2:\n\t" \
60-
__BUG_ENTRY "\n\t" \
61-
".org 2b + %3\n\t" \
59+
__BUG_ENTRY(file, line, flags) "\n\t" \
60+
".org 2b + " size "\n\t" \
6261
".popsection" \
62+
63+
#define __BUG_FLAGS(flags) \
64+
do { \
65+
__asm__ __volatile__ ( \
66+
ARCH_WARN_ASM("%0", "%1", "%2", "%3") \
6367
: \
6468
: "i" (__FILE__), "i" (__LINE__), \
6569
"i" (flags), \
6670
"i" (sizeof(struct bug_entry))); \
6771
} while (0)
72+
6873
#else /* CONFIG_GENERIC_BUG */
6974
#define __BUG_FLAGS(flags) do { \
7075
__asm__ __volatile__ ("ebreak\n"); \
@@ -78,6 +83,8 @@ do { \
7883

7984
#define __WARN_FLAGS(flags) __BUG_FLAGS(BUGFLAG_WARNING|(flags))
8085

86+
#define ARCH_WARN_REACHABLE
87+
8188
#define HAVE_ARCH_BUG
8289

8390
#include <asm-generic/bug.h>

0 commit comments

Comments
 (0)