Merge tag 'ofs-pull-tag-1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap...
[deliverable/linux.git] / arch / x86 / kernel / doublefault.c
CommitLineData
1da177e4
LT
1#include <linux/mm.h>
2#include <linux/sched.h>
1da177e4
LT
3#include <linux/init_task.h>
4#include <linux/fs.h>
5
6#include <asm/uaccess.h>
7#include <asm/pgtable.h>
8#include <asm/processor.h>
9#include <asm/desc.h>
10
4d067d8e
BP
11#ifdef CONFIG_X86_32
12
1da177e4
LT
13#define DOUBLEFAULT_STACKSIZE (1024)
14static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
15#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
16
3dab307e 17#define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
1da177e4
LT
18
19static void doublefault_fn(void)
20{
6b68f01b 21 struct desc_ptr gdt_desc = {0, 0};
1da177e4
LT
22 unsigned long gdt, tss;
23
357d1226 24 native_store_gdt(&gdt_desc);
1da177e4
LT
25 gdt = gdt_desc.address;
26
3dab307e 27 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
1da177e4
LT
28
29 if (ptr_ok(gdt)) {
30 gdt += GDT_ENTRY_TSS << 3;
254e0a6b 31 tss = get_desc_base((struct desc_struct *)gdt);
3dab307e 32 printk(KERN_EMERG "double fault, tss at %08lx\n", tss);
1da177e4
LT
33
34 if (ptr_ok(tss)) {
ca241c75 35 struct x86_hw_tss *t = (struct x86_hw_tss *)tss;
1da177e4 36
faca6227
PA
37 printk(KERN_EMERG "eip = %08lx, esp = %08lx\n",
38 t->ip, t->sp);
1da177e4 39
3dab307e 40 printk(KERN_EMERG "eax = %08lx, ebx = %08lx, ecx = %08lx, edx = %08lx\n",
faca6227 41 t->ax, t->bx, t->cx, t->dx);
3dab307e 42 printk(KERN_EMERG "esi = %08lx, edi = %08lx\n",
faca6227 43 t->si, t->di);
1da177e4
LT
44 }
45 }
46
caad3c2a
CE
47 for (;;)
48 cpu_relax();
1da177e4
LT
49}
50
51struct tss_struct doublefault_tss __cacheline_aligned = {
a75c54f9 52 .x86_tss = {
faca6227 53 .sp0 = STACK_START,
a75c54f9
RR
54 .ss0 = __KERNEL_DS,
55 .ldt = 0,
56 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET,
1da177e4 57
faca6227 58 .ip = (unsigned long) doublefault_fn,
a75c54f9 59 /* 0x2 bit is always set */
faca6227
PA
60 .flags = X86_EFLAGS_SF | 0x2,
61 .sp = STACK_START,
a75c54f9
RR
62 .es = __USER_DS,
63 .cs = __KERNEL_CS,
64 .ss = __KERNEL_DS,
65 .ds = __USER_DS,
3dab307e 66 .fs = __KERNEL_PERCPU,
1da177e4 67
af5c2bd1 68 .__cr3 = __pa_nodebug(swapper_pg_dir),
a75c54f9 69 }
1da177e4 70};
4d067d8e
BP
71
72/* dummy for do_double_fault() call */
73void df_debug(struct pt_regs *regs, long error_code) {}
74
75#else /* !CONFIG_X86_32 */
76
77void df_debug(struct pt_regs *regs, long error_code)
78{
79 pr_emerg("PANIC: double fault, error_code: 0x%lx\n", error_code);
80 show_regs(regs);
81 panic("Machine halted.");
82}
83#endif
This page took 0.724563 seconds and 5 git commands to generate.