diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/i386/kernel/doublefault.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/i386/kernel/doublefault.c')
-rw-r--r-- | arch/i386/kernel/doublefault.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/arch/i386/kernel/doublefault.c b/arch/i386/kernel/doublefault.c new file mode 100644 index 000000000000..789af3e9fb1f --- /dev/null +++ b/arch/i386/kernel/doublefault.c | |||
@@ -0,0 +1,65 @@ | |||
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 + 0x1000000) | ||
17 | |||
18 | static void doublefault_fn(void) | ||
19 | { | ||
20 | struct Xgt_desc_struct gdt_desc = {0, 0}; | ||
21 | unsigned long gdt, tss; | ||
22 | |||
23 | __asm__ __volatile__("sgdt %0": "=m" (gdt_desc): :"memory"); | ||
24 | gdt = gdt_desc.address; | ||
25 | |||
26 | printk("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("double fault, tss at %08lx\n", tss); | ||
34 | |||
35 | if (ptr_ok(tss)) { | ||
36 | struct tss_struct *t = (struct tss_struct *)tss; | ||
37 | |||
38 | printk("eip = %08lx, esp = %08lx\n", t->eip, t->esp); | ||
39 | |||
40 | printk("eax = %08lx, ebx = %08lx, ecx = %08lx, edx = %08lx\n", | ||
41 | t->eax, t->ebx, t->ecx, t->edx); | ||
42 | printk("esi = %08lx, edi = %08lx\n", | ||
43 | t->esi, t->edi); | ||
44 | } | ||
45 | } | ||
46 | |||
47 | for (;;) /* nothing */; | ||
48 | } | ||
49 | |||
50 | struct tss_struct doublefault_tss __cacheline_aligned = { | ||
51 | .esp0 = STACK_START, | ||
52 | .ss0 = __KERNEL_DS, | ||
53 | .ldt = 0, | ||
54 | .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, | ||
55 | |||
56 | .eip = (unsigned long) doublefault_fn, | ||
57 | .eflags = X86_EFLAGS_SF | 0x2, /* 0x2 bit is always set */ | ||
58 | .esp = STACK_START, | ||
59 | .es = __USER_DS, | ||
60 | .cs = __KERNEL_CS, | ||
61 | .ss = __KERNEL_DS, | ||
62 | .ds = __USER_DS, | ||
63 | |||
64 | .__cr3 = __pa(swapper_pg_dir) | ||
65 | }; | ||