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