~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/kernel/doublefault.c

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.11 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.84 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.154 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.201 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.201 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.77 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #include <linux/mm.h>
  2 #include <linux/sched.h>
  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 
 11 #ifdef CONFIG_X86_32
 12 
 13 #define DOUBLEFAULT_STACKSIZE (1024)
 14 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
 15 #define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
 16 
 17 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
 18 
 19 static void doublefault_fn(void)
 20 {
 21         struct desc_ptr gdt_desc = {0, 0};
 22         unsigned long gdt, tss;
 23 
 24         native_store_gdt(&gdt_desc);
 25         gdt = gdt_desc.address;
 26 
 27         printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
 28 
 29         if (ptr_ok(gdt)) {
 30                 gdt += GDT_ENTRY_TSS << 3;
 31                 tss = get_desc_base((struct desc_struct *)gdt);
 32                 printk(KERN_EMERG "double fault, tss at %08lx\n", tss);
 33 
 34                 if (ptr_ok(tss)) {
 35                         struct x86_hw_tss *t = (struct x86_hw_tss *)tss;
 36 
 37                         printk(KERN_EMERG "eip = %08lx, esp = %08lx\n",
 38                                t->ip, t->sp);
 39 
 40                         printk(KERN_EMERG "eax = %08lx, ebx = %08lx, ecx = %08lx, edx = %08lx\n",
 41                                 t->ax, t->bx, t->cx, t->dx);
 42                         printk(KERN_EMERG "esi = %08lx, edi = %08lx\n",
 43                                 t->si, t->di);
 44                 }
 45         }
 46 
 47         for (;;)
 48                 cpu_relax();
 49 }
 50 
 51 struct tss_struct doublefault_tss __cacheline_aligned = {
 52         .x86_tss = {
 53                 .sp0            = STACK_START,
 54                 .ss0            = __KERNEL_DS,
 55                 .ldt            = 0,
 56                 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET,
 57 
 58                 .ip             = (unsigned long) doublefault_fn,
 59                 /* 0x2 bit is always set */
 60                 .flags          = X86_EFLAGS_SF | 0x2,
 61                 .sp             = 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_nodebug(swapper_pg_dir),
 69         }
 70 };
 71 
 72 /* dummy for do_double_fault() call */
 73 void df_debug(struct pt_regs *regs, long error_code) {}
 74 
 75 #else /* !CONFIG_X86_32 */
 76 
 77 void 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
 84 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp