diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2007-10-11 05:17:01 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2007-10-11 05:17:01 -0400 |
commit | 9a163ed8e0552fdcffe405d2ea7134819a81456e (patch) | |
tree | b322fd2afbb812ba7ddfd22f3734aaab007c2aa5 /arch/x86/kernel/doublefault_32.c | |
parent | f7627e2513987bb5d4e8cb13c4e0a478352141ac (diff) |
i386: move kernel
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/doublefault_32.c')
-rw-r--r-- | arch/x86/kernel/doublefault_32.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c new file mode 100644 index 000000000000..40978af630e7 --- /dev/null +++ b/arch/x86/kernel/doublefault_32.c | |||
@@ -0,0 +1,70 @@ | |||
1 | #include <linux/mm.h> | ||
2 | #include <linux/sched.h> | ||
3 | #include <linux/init.h> | ||
4 | #include <linux/init_task.h> | ||
5 | #include <linux/fs.h> | ||
6 | |||
7 | #include <asm/uaccess.h> | ||
8 | #include <asm/pgtable.h> | ||
9 | #include <asm/processor.h> | ||
10 | #include <asm/desc.h> | ||
11 | |||
12 | #define DOUBLEFAULT_STACKSIZE (1024) | ||
13 | static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE]; | ||
14 | #define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE) | ||
15 | |||
16 | #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM) | ||
17 | |||
18 | static void doublefault_fn(void) | ||
19 | { | ||
20 | struct Xgt_desc_struct gdt_desc = {0, 0}; | ||
21 | unsigned long gdt, tss; | ||
22 | |||
23 | store_gdt(&gdt_desc); | ||
24 | gdt = gdt_desc.address; | ||
25 | |||
26 | printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size); | ||
27 | |||
28 | if (ptr_ok(gdt)) { | ||
29 | gdt += GDT_ENTRY_TSS << 3; | ||
30 | tss = *(u16 *)(gdt+2); | ||
31 | tss += *(u8 *)(gdt+4) << 16; | ||
32 | tss += *(u8 *)(gdt+7) << 24; | ||
33 | printk(KERN_EMERG "double fault, tss at %08lx\n", tss); | ||
34 | |||
35 | if (ptr_ok(tss)) { | ||
36 | struct i386_hw_tss *t = (struct i386_hw_tss *)tss; | ||
37 | |||
38 | printk(KERN_EMERG "eip = %08lx, esp = %08lx\n", t->eip, t->esp); | ||
39 | |||
40 | printk(KERN_EMERG "eax = %08lx, ebx = %08lx, ecx = %08lx, edx = %08lx\n", | ||
41 | t->eax, t->ebx, t->ecx, t->edx); | ||
42 | printk(KERN_EMERG "esi = %08lx, edi = %08lx\n", | ||
43 | t->esi, t->edi); | ||
44 | } | ||
45 | } | ||
46 | |||
47 | for (;;) | ||
48 | cpu_relax(); | ||
49 | } | ||
50 | |||
51 | struct tss_struct doublefault_tss __cacheline_aligned = { | ||
52 | .x86_tss = { | ||
53 | .esp0 = STACK_START, | ||
54 | .ss0 = __KERNEL_DS, | ||
55 | .ldt = 0, | ||
56 | .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, | ||
57 | |||
58 | .eip = (unsigned long) doublefault_fn, | ||
59 | /* 0x2 bit is always set */ | ||
60 | .eflags = X86_EFLAGS_SF | 0x2, | ||
61 | .esp = STACK_START, | ||
62 | .es = __USER_DS, | ||
63 | .cs = __KERNEL_CS, | ||
64 | .ss = __KERNEL_DS, | ||
65 | .ds = __USER_DS, | ||
66 | .fs = __KERNEL_PERCPU, | ||
67 | |||
68 | .__cr3 = __pa(swapper_pg_dir) | ||
69 | } | ||
70 | }; | ||