x86: use generic register name in the thread and tss structures
[linux-2.6] / arch / x86 / kernel / doublefault_32.c
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",
39                                t->ip, t->sp);
40
41                         printk(KERN_EMERG "eax = %08lx, ebx = %08lx, ecx = %08lx, edx = %08lx\n",
42                                 t->ax, t->bx, t->cx, t->dx);
43                         printk(KERN_EMERG "esi = %08lx, edi = %08lx\n",
44                                 t->si, t->di);
45                 }
46         }
47
48         for (;;)
49                 cpu_relax();
50 }
51
52 struct tss_struct doublefault_tss __cacheline_aligned = {
53         .x86_tss = {
54                 .sp0            = STACK_START,
55                 .ss0            = __KERNEL_DS,
56                 .ldt            = 0,
57                 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET,
58
59                 .ip             = (unsigned long) doublefault_fn,
60                 /* 0x2 bit is always set */
61                 .flags          = X86_EFLAGS_SF | 0x2,
62                 .sp             = STACK_START,
63                 .es             = __USER_DS,
64                 .cs             = __KERNEL_CS,
65                 .ss             = __KERNEL_DS,
66                 .ds             = __USER_DS,
67                 .fs             = __KERNEL_PERCPU,
68
69                 .__cr3          = __pa(swapper_pg_dir)
70         }
71 };