blob: eed785667289fa34b0e287ba7240db98ab9866d3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_X8664_BUG_H
2#define __ASM_X8664_BUG_H 1
3
4#include <linux/stringify.h>
5
6/*
7 * Tell the user there is some problem. The exception handler decodes
8 * this frame.
9 */
10struct bug_frame {
Andi Kleenb6a68a12005-07-28 21:15:45 -070011 unsigned char ud2[2];
12 unsigned char mov;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 /* should use 32bit offset instead, but the assembler doesn't
14 like it */
15 char *filename;
Andi Kleenb6a68a12005-07-28 21:15:45 -070016 unsigned char ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 unsigned short line;
18} __attribute__((packed));
19
Matt Mackallc8538a72005-05-01 08:59:01 -070020#ifdef CONFIG_BUG
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#define HAVE_ARCH_BUG
Andi Kleenb6a68a12005-07-28 21:15:45 -070022/* We turn the bug frame into valid instructions to not confuse
23 the disassembler. Thanks to Jan Beulich & Suresh Siddha
24 for nice instruction selection.
25 The magic numbers generate mov $64bitimm,%eax ; ret $offset. */
26#define BUG() \
27 asm volatile( \
28 "ud2 ; .byte 0xa3 ; .quad %c1 ; .byte 0xc2 ; .short %c0" :: \
Andi Kleenf18de452005-04-16 15:24:51 -070029 "i"(__LINE__), "i" (__stringify(__FILE__)))
Linus Torvalds1da177e2005-04-16 15:20:36 -070030void out_of_line_bug(void);
Alexander Nyberg4f60fdf2005-05-25 12:31:28 -070031#else
32static inline void out_of_line_bug(void) { }
Matt Mackallc8538a72005-05-01 08:59:01 -070033#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Matt Mackallc8538a72005-05-01 08:59:01 -070035#include <asm-generic/bug.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#endif