1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/linkage.h>
7 #define TRAPA_BUG_OPCODE 0xc33e /* trapa #0x3e */
8 #define BUGFLAG_UNWINDER (1 << 1)
10 #ifdef CONFIG_GENERIC_BUG
12 #define HAVE_ARCH_WARN_ON
19 * %4 - sizeof(struct bug_entry)
21 * The trapa opcode itself sits in %0.
22 * The %O notation is used to avoid # generation.
24 * The offending file and line are encoded in the __bug_table section.
26 #ifdef CONFIG_DEBUG_BUGVERBOSE
27 #define _EMIT_BUG_ENTRY \
28 "\t.pushsection __bug_table,\"aw\"\n" \
29 "2:\t.long 1b, %O1\n" \
30 "\t.short %O2, %O3\n" \
34 #define _EMIT_BUG_ENTRY \
35 "\t.pushsection __bug_table,\"aw\"\n" \
44 __asm__ __volatile__ ( \
48 : "n" (TRAPA_BUG_OPCODE), \
50 "i" (__LINE__), "i" (0), \
51 "i" (sizeof(struct bug_entry))); \
55 #define __WARN_FLAGS(flags) \
57 __asm__ __volatile__ ( \
61 : "n" (TRAPA_BUG_OPCODE), \
64 "i" (BUGFLAG_WARNING|(flags)), \
65 "i" (sizeof(struct bug_entry))); \
68 #define WARN_ON(x) ({ \
69 int __ret_warn_on = !!(x); \
70 if (__builtin_constant_p(__ret_warn_on)) { \
74 if (unlikely(__ret_warn_on)) \
77 unlikely(__ret_warn_on); \
80 #define UNWINDER_BUG() \
82 __asm__ __volatile__ ( \
86 : "n" (TRAPA_BUG_OPCODE), \
89 "i" (BUGFLAG_UNWINDER), \
90 "i" (sizeof(struct bug_entry))); \
93 #define UNWINDER_BUG_ON(x) ({ \
94 int __ret_unwinder_on = !!(x); \
95 if (__builtin_constant_p(__ret_unwinder_on)) { \
96 if (__ret_unwinder_on) \
99 if (unlikely(__ret_unwinder_on)) \
102 unlikely(__ret_unwinder_on); \
107 #define UNWINDER_BUG BUG
108 #define UNWINDER_BUG_ON BUG_ON
110 #endif /* CONFIG_GENERIC_BUG */
112 #include <asm-generic/bug.h>
116 /* arch/sh/kernel/traps.c */
117 extern void die(const char *str
, struct pt_regs
*regs
, long err
) __attribute__ ((noreturn
));
118 extern void die_if_kernel(const char *str
, struct pt_regs
*regs
, long err
);
119 extern void die_if_no_fixup(const char *str
, struct pt_regs
*regs
, long err
);
121 #endif /* __ASM_SH_BUG_H */