]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/x86/include/asm/bug.h
1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/stringify.h>
8 * Since some emulators terminate on UD2, we cannot use it for WARN.
9 * Since various instruction decoders disagree on the length of UD1,
10 * we cannot use it either. So use UD0 for WARN.
12 * (binutils knows about "ud1" but {en,de}codes it as 2 bytes, whereas
13 * our kernel decoder thinks it takes a ModRM byte, which seems consistent
14 * with various things like the Intel SDM instruction encoding rules)
17 #define ASM_UD0 ".byte 0x0f, 0xff"
18 #define ASM_UD1 ".byte 0x0f, 0xb9" /* + ModRM */
19 #define ASM_UD2 ".byte 0x0f, 0x0b"
21 #define INSN_UD0 0xff0f
22 #define INSN_UD2 0x0b0f
26 #ifdef CONFIG_GENERIC_BUG
29 # define __BUG_REL(val) ".long " __stringify(val)
31 # define __BUG_REL(val) ".long " __stringify(val) " - 2b"
34 #ifdef CONFIG_DEBUG_BUGVERBOSE
36 #define _BUG_FLAGS(ins, flags) \
38 asm volatile("1:\t" ins "\n" \
39 ".pushsection __bug_table,\"aw\"\n" \
40 "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
41 "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \
42 "\t.word %c1" "\t# bug_entry::line\n" \
43 "\t.word %c2" "\t# bug_entry::flags\n" \
46 : : "i" (__FILE__), "i" (__LINE__), \
48 "i" (sizeof(struct bug_entry))); \
51 #else /* !CONFIG_DEBUG_BUGVERBOSE */
53 #define _BUG_FLAGS(ins, flags) \
55 asm volatile("1:\t" ins "\n" \
56 ".pushsection __bug_table,\"aw\"\n" \
57 "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
58 "\t.word %c0" "\t# bug_entry::flags\n" \
62 "i" (sizeof(struct bug_entry))); \
65 #endif /* CONFIG_DEBUG_BUGVERBOSE */
69 #define _BUG_FLAGS(ins, flags) asm volatile(ins)
71 #endif /* CONFIG_GENERIC_BUG */
76 _BUG_FLAGS(ASM_UD2, 0); \
80 #define __WARN_FLAGS(flags) _BUG_FLAGS(ASM_UD0, BUGFLAG_WARNING|(flags))
82 #include <asm-generic/bug.h>
84 #endif /* _ASM_X86_BUG_H */