xref: /openbmc/linux/arch/s390/include/asm/bug.h (revision 612cf4d2)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_S390_BUG_H
3 #define _ASM_S390_BUG_H
4 
5 #include <linux/compiler.h>
6 
7 #ifdef CONFIG_BUG
8 
9 #ifdef CONFIG_DEBUG_BUGVERBOSE
10 
11 #define __EMIT_BUG(x) do {					\
12 	asm_inline volatile(					\
13 		"0:	mc	0,0\n"				\
14 		".section .rodata.str,\"aMS\",@progbits,1\n"	\
15 		"1:	.asciz	\""__FILE__"\"\n"		\
16 		".previous\n"					\
17 		".section __bug_table,\"awM\",@progbits,%2\n"	\
18 		"2:	.long	0b-.\n"				\
19 		"	.long	1b-.\n"				\
20 		"	.short	%0,%1\n"			\
21 		"	.org	2b+%2\n"			\
22 		".previous\n"					\
23 		: : "i" (__LINE__),				\
24 		    "i" (x),					\
25 		    "i" (sizeof(struct bug_entry)));		\
26 } while (0)
27 
28 #else /* CONFIG_DEBUG_BUGVERBOSE */
29 
30 #define __EMIT_BUG(x) do {					\
31 	asm_inline volatile(					\
32 		"0:	mc	0,0\n"				\
33 		".section __bug_table,\"awM\",@progbits,%1\n"	\
34 		"1:	.long	0b-.\n"				\
35 		"	.short	%0\n"				\
36 		"	.org	1b+%1\n"			\
37 		".previous\n"					\
38 		: : "i" (x),					\
39 		    "i" (sizeof(struct bug_entry)));		\
40 } while (0)
41 
42 #endif /* CONFIG_DEBUG_BUGVERBOSE */
43 
44 #define BUG() do {					\
45 	__EMIT_BUG(0);					\
46 	unreachable();					\
47 } while (0)
48 
49 #define __WARN_FLAGS(flags) do {			\
50 	__EMIT_BUG(BUGFLAG_WARNING|(flags));		\
51 } while (0)
52 
53 #define WARN_ON(x) ({					\
54 	int __ret_warn_on = !!(x);			\
55 	if (__builtin_constant_p(__ret_warn_on)) {	\
56 		if (__ret_warn_on)			\
57 			__WARN();			\
58 	} else {					\
59 		if (unlikely(__ret_warn_on))		\
60 			__WARN();			\
61 	}						\
62 	unlikely(__ret_warn_on);			\
63 })
64 
65 #define HAVE_ARCH_BUG
66 #define HAVE_ARCH_WARN_ON
67 #endif /* CONFIG_BUG */
68 
69 #include <asm-generic/bug.h>
70 
71 #endif /* _ASM_S390_BUG_H */
72