Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #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 | */ |
| 10 | struct bug_frame { |
Andi Kleen | b6a68a1 | 2005-07-28 21:15:45 -0700 | [diff] [blame^] | 11 | unsigned char ud2[2]; |
| 12 | unsigned char mov; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | /* should use 32bit offset instead, but the assembler doesn't |
| 14 | like it */ |
| 15 | char *filename; |
Andi Kleen | b6a68a1 | 2005-07-28 21:15:45 -0700 | [diff] [blame^] | 16 | unsigned char ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | unsigned short line; |
| 18 | } __attribute__((packed)); |
| 19 | |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 20 | #ifdef CONFIG_BUG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #define HAVE_ARCH_BUG |
Andi Kleen | b6a68a1 | 2005-07-28 21:15:45 -0700 | [diff] [blame^] | 22 | /* 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 Kleen | f18de45 | 2005-04-16 15:24:51 -0700 | [diff] [blame] | 29 | "i"(__LINE__), "i" (__stringify(__FILE__))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | void out_of_line_bug(void); |
Alexander Nyberg | 4f60fdf | 2005-05-25 12:31:28 -0700 | [diff] [blame] | 31 | #else |
| 32 | static inline void out_of_line_bug(void) { } |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 33 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Matt Mackall | c8538a7 | 2005-05-01 08:59:01 -0700 | [diff] [blame] | 35 | #include <asm-generic/bug.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #endif |