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