blob: 0b25f28351edc496ddfe728b169a4700e724cd7f [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_S390_BUG_H
3#define _ASM_S390_BUG_H
4
Olivier Deprez157378f2022-04-04 15:47:50 +02005#include <linux/compiler.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00006
7#ifdef CONFIG_BUG
8
9#ifdef CONFIG_DEBUG_BUGVERBOSE
10
11#define __EMIT_BUG(x) do { \
Olivier Deprez157378f2022-04-04 15:47:50 +020012 asm_inline volatile( \
13 "0: mc 0,0\n" \
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000014 ".section .rodata.str,\"aMS\",@progbits,1\n" \
Olivier Deprez157378f2022-04-04 15:47:50 +020015 "1: .asciz \""__FILE__"\"\n" \
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000016 ".previous\n" \
David Brazdil0f672f62019-12-10 10:32:29 +000017 ".section __bug_table,\"awM\",@progbits,%2\n" \
Olivier Deprez157378f2022-04-04 15:47:50 +020018 "2: .long 0b-2b,1b-2b\n" \
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000019 " .short %0,%1\n" \
Olivier Deprez157378f2022-04-04 15:47:50 +020020 " .org 2b+%2\n" \
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000021 ".previous\n" \
22 : : "i" (__LINE__), \
23 "i" (x), \
24 "i" (sizeof(struct bug_entry))); \
25} while (0)
26
27#else /* CONFIG_DEBUG_BUGVERBOSE */
28
David Brazdil0f672f62019-12-10 10:32:29 +000029#define __EMIT_BUG(x) do { \
Olivier Deprez157378f2022-04-04 15:47:50 +020030 asm_inline volatile( \
31 "0: mc 0,0\n" \
David Brazdil0f672f62019-12-10 10:32:29 +000032 ".section __bug_table,\"awM\",@progbits,%1\n" \
Olivier Deprez157378f2022-04-04 15:47:50 +020033 "1: .long 0b-1b\n" \
David Brazdil0f672f62019-12-10 10:32:29 +000034 " .short %0\n" \
Olivier Deprez157378f2022-04-04 15:47:50 +020035 " .org 1b+%1\n" \
David Brazdil0f672f62019-12-10 10:32:29 +000036 ".previous\n" \
37 : : "i" (x), \
38 "i" (sizeof(struct bug_entry))); \
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000039} while (0)
40
41#endif /* CONFIG_DEBUG_BUGVERBOSE */
42
43#define BUG() do { \
44 __EMIT_BUG(0); \
45 unreachable(); \
46} while (0)
47
48#define __WARN_FLAGS(flags) do { \
49 __EMIT_BUG(BUGFLAG_WARNING|(flags)); \
50} while (0)
51
52#define WARN_ON(x) ({ \
53 int __ret_warn_on = !!(x); \
54 if (__builtin_constant_p(__ret_warn_on)) { \
55 if (__ret_warn_on) \
56 __WARN(); \
57 } else { \
58 if (unlikely(__ret_warn_on)) \
59 __WARN(); \
60 } \
61 unlikely(__ret_warn_on); \
62})
63
64#define HAVE_ARCH_BUG
65#define HAVE_ARCH_WARN_ON
66#endif /* CONFIG_BUG */
67
68#include <asm-generic/bug.h>
69
70#endif /* _ASM_S390_BUG_H */