2 #include <linux/sched.h>
3 #include <linux/init_task.h>
6 #include <asm/uaccess.h>
7 #include <asm/pgtable.h>
8 #include <asm/processor.h>
13 #define DOUBLEFAULT_STACKSIZE (1024)
14 static unsigned long doublefault_stack
[DOUBLEFAULT_STACKSIZE
];
15 #define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
19 static void doublefault_fn(void)
21 struct desc_ptr gdt_desc
= {0, 0};
22 unsigned long gdt
, tss
;
24 native_store_gdt(&gdt_desc
);
25 gdt
= gdt_desc
.address
;
27 printk(KERN_EMERG
"PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt
, gdt_desc
.size
);
30 gdt
+= GDT_ENTRY_TSS
<< 3;
31 tss
= get_desc_base((struct desc_struct
*)gdt
);
32 printk(KERN_EMERG
"double fault, tss at %08lx\n", tss
);
35 struct x86_hw_tss
*t
= (struct x86_hw_tss
*)tss
;
37 printk(KERN_EMERG
"eip = %08lx, esp = %08lx\n",
40 printk(KERN_EMERG
"eax = %08lx, ebx = %08lx, ecx = %08lx, edx = %08lx\n",
41 t
->ax
, t
->bx
, t
->cx
, t
->dx
);
42 printk(KERN_EMERG
"esi = %08lx, edi = %08lx\n",
51 struct tss_struct doublefault_tss __cacheline_aligned
= {
56 .io_bitmap_base
= INVALID_IO_BITMAP_OFFSET
,
58 .ip
= (unsigned long) doublefault_fn
,
59 /* 0x2 bit is always set */
60 .flags
= X86_EFLAGS_SF
| 0x2,
66 .fs
= __KERNEL_PERCPU
,
68 .__cr3
= __pa_nodebug(swapper_pg_dir
),
72 /* dummy for do_double_fault() call */
73 void df_debug(struct pt_regs
*regs
, long error_code
) {}
75 #else /* !CONFIG_X86_32 */
77 void df_debug(struct pt_regs
*regs
, long error_code
)
79 pr_emerg("PANIC: double fault, error_code: 0x%lx\n", error_code
);
81 panic("Machine halted.");