Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __ASM_BUG_H
3#define __ASM_BUG_H
4
5#include <asm/break.h>
6#include <linux/stringify.h>
7#include <linux/objtool.h>
8
9#ifndef CONFIG_DEBUG_BUGVERBOSE
10#define _BUGVERBOSE_LOCATION(file, line)
11#else
12#define __BUGVERBOSE_LOCATION(file, line) \
13 .pushsection .rodata.str, "aMS", @progbits, 1; \
14 10002: .ascii file "\0"; \
15 .popsection; \
16 \
17 .long 10002b - .; \
18 .short line;
19#define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line)
20#endif
21
22#ifndef CONFIG_GENERIC_BUG
23#define __BUG_ENTRY(cond_str, flags)
24#else
25#define __BUG_ENTRY(cond_str, flags) \
26 .pushsection __bug_table, "aw"; \
27 .align 2; \
28 10000: .long 10001f - .; \
29 _BUGVERBOSE_LOCATION(WARN_CONDITION_STR(cond_str) __FILE__, __LINE__) \
30 .short flags; \
31 .popsection; \
32 10001:
33#endif
34
35#define ASM_BUG_FLAGS(cond_str, flags) \
36 __BUG_ENTRY(cond_str, flags) \
37 break BRK_BUG;
38
39#define ASM_BUG() ASM_BUG_FLAGS("", 0)
40
41#define __BUG_FLAGS(cond_str, flags, extra) \
42 asm_inline volatile (__stringify(ASM_BUG_FLAGS(cond_str, flags)) extra);
43
44#define __WARN_FLAGS(cond_str, flags) \
45do { \
46 instrumentation_begin(); \
47 __BUG_FLAGS(cond_str, BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE(10001b));\
48 instrumentation_end(); \
49} while (0)
50
51#define BUG() \
52do { \
53 instrumentation_begin(); \
54 __BUG_FLAGS("", 0, ""); \
55 unreachable(); \
56} while (0)
57
58#define HAVE_ARCH_BUG
59
60#include <asm-generic/bug.h>
61
62#endif /* __ASM_BUG_H */