Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef _ASM_S390_BUG_H |
| 3 | #define _ASM_S390_BUG_H |
| 4 | |
| 5 | #include <linux/kernel.h> |
| 6 | |
| 7 | #ifdef CONFIG_BUG |
| 8 | |
| 9 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
| 10 | |
| 11 | #define __EMIT_BUG(x) do { \ |
| 12 | asm volatile( \ |
| 13 | "0: j 0b+2\n" \ |
| 14 | "1:\n" \ |
| 15 | ".section .rodata.str,\"aMS\",@progbits,1\n" \ |
| 16 | "2: .asciz \""__FILE__"\"\n" \ |
| 17 | ".previous\n" \ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 18 | ".section __bug_table,\"awM\",@progbits,%2\n" \ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 19 | "3: .long 1b-3b,2b-3b\n" \ |
| 20 | " .short %0,%1\n" \ |
| 21 | " .org 3b+%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 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 30 | #define __EMIT_BUG(x) do { \ |
| 31 | asm volatile( \ |
| 32 | "0: j 0b+2\n" \ |
| 33 | "1:\n" \ |
| 34 | ".section __bug_table,\"awM\",@progbits,%1\n" \ |
| 35 | "2: .long 1b-2b\n" \ |
| 36 | " .short %0\n" \ |
| 37 | " .org 2b+%1\n" \ |
| 38 | ".previous\n" \ |
| 39 | : : "i" (x), \ |
| 40 | "i" (sizeof(struct bug_entry))); \ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 41 | } while (0) |
| 42 | |
| 43 | #endif /* CONFIG_DEBUG_BUGVERBOSE */ |
| 44 | |
| 45 | #define BUG() do { \ |
| 46 | __EMIT_BUG(0); \ |
| 47 | unreachable(); \ |
| 48 | } while (0) |
| 49 | |
| 50 | #define __WARN_FLAGS(flags) do { \ |
| 51 | __EMIT_BUG(BUGFLAG_WARNING|(flags)); \ |
| 52 | } while (0) |
| 53 | |
| 54 | #define WARN_ON(x) ({ \ |
| 55 | int __ret_warn_on = !!(x); \ |
| 56 | if (__builtin_constant_p(__ret_warn_on)) { \ |
| 57 | if (__ret_warn_on) \ |
| 58 | __WARN(); \ |
| 59 | } else { \ |
| 60 | if (unlikely(__ret_warn_on)) \ |
| 61 | __WARN(); \ |
| 62 | } \ |
| 63 | unlikely(__ret_warn_on); \ |
| 64 | }) |
| 65 | |
| 66 | #define HAVE_ARCH_BUG |
| 67 | #define HAVE_ARCH_WARN_ON |
| 68 | #endif /* CONFIG_BUG */ |
| 69 | |
| 70 | #include <asm-generic/bug.h> |
| 71 | |
| 72 | #endif /* _ASM_S390_BUG_H */ |