Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney...
[deliverable/linux.git] / arch / x86 / kernel / traps_32.c
CommitLineData
1da177e4
LT
1/*
2 * linux/arch/i386/traps.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 *
6 * Pentium III FXSR, SSE support
7 * Gareth Hughes <gareth@valinux.com>, May 2000
8 */
9
10/*
11 * 'Traps.c' handles hardware traps and faults after we have saved some
12 * state in 'asm.s'.
13 */
1da177e4
LT
14#include <linux/sched.h>
15#include <linux/kernel.h>
16#include <linux/string.h>
17#include <linux/errno.h>
18#include <linux/timer.h>
19#include <linux/mm.h>
20#include <linux/init.h>
21#include <linux/delay.h>
22#include <linux/spinlock.h>
23#include <linux/interrupt.h>
24#include <linux/highmem.h>
25#include <linux/kallsyms.h>
26#include <linux/ptrace.h>
27#include <linux/utsname.h>
28#include <linux/kprobes.h>
6e274d14 29#include <linux/kexec.h>
176a2718 30#include <linux/unwind.h>
1e2af92e 31#include <linux/uaccess.h>
a36df98a 32#include <linux/nmi.h>
91768d6c 33#include <linux/bug.h>
1da177e4
LT
34
35#ifdef CONFIG_EISA
36#include <linux/ioport.h>
37#include <linux/eisa.h>
38#endif
39
40#ifdef CONFIG_MCA
41#include <linux/mca.h>
42#endif
43
c0d12172
DJ
44#if defined(CONFIG_EDAC)
45#include <linux/edac.h>
46#endif
47
1da177e4
LT
48#include <asm/processor.h>
49#include <asm/system.h>
1da177e4
LT
50#include <asm/io.h>
51#include <asm/atomic.h>
52#include <asm/debugreg.h>
53#include <asm/desc.h>
54#include <asm/i387.h>
55#include <asm/nmi.h>
176a2718 56#include <asm/unwind.h>
1da177e4
LT
57#include <asm/smp.h>
58#include <asm/arch_hooks.h>
1eeb66a1 59#include <linux/kdebug.h>
2b14a78c 60#include <asm/stacktrace.h>
1da177e4 61
1da177e4
LT
62#include <linux/module.h>
63
64#include "mach_traps.h"
65
29cbc78b
AK
66int panic_on_unrecovered_nmi;
67
1da177e4
LT
68asmlinkage int system_call(void);
69
1da177e4
LT
70/* Do we ignore FPU interrupts ? */
71char ignore_fpu_irq = 0;
72
73/*
74 * The IDT has to be page-aligned to simplify the Pentium
75 * F0 0F bug workaround.. We have a special link segment
76 * for this.
77 */
78struct desc_struct idt_table[256] __attribute__((__section__(".data.idt"))) = { {0, 0}, };
79
80asmlinkage void divide_error(void);
81asmlinkage void debug(void);
82asmlinkage void nmi(void);
83asmlinkage void int3(void);
84asmlinkage void overflow(void);
85asmlinkage void bounds(void);
86asmlinkage void invalid_op(void);
87asmlinkage void device_not_available(void);
88asmlinkage void coprocessor_segment_overrun(void);
89asmlinkage void invalid_TSS(void);
90asmlinkage void segment_not_present(void);
91asmlinkage void stack_segment(void);
92asmlinkage void general_protection(void);
93asmlinkage void page_fault(void);
94asmlinkage void coprocessor_error(void);
95asmlinkage void simd_coprocessor_error(void);
96asmlinkage void alignment_check(void);
97asmlinkage void spurious_interrupt_bug(void);
98asmlinkage void machine_check(void);
99
0741f4d2 100int kstack_depth_to_print = 24;
86c41837 101static unsigned int code_bytes = 64;
e041c683 102
36ad4885 103static inline int valid_stack_ptr(struct thread_info *tinfo, void *p, unsigned size)
1da177e4
LT
104{
105 return p > (void *)tinfo &&
36ad4885 106 p <= (void *)tinfo + THREAD_SIZE - size;
1da177e4
LT
107}
108
36ad4885
LT
109/* The form of the top of the frame on the stack */
110struct stack_frame {
111 struct stack_frame *next_frame;
112 unsigned long return_address;
113};
114
1da177e4 115static inline unsigned long print_context_stack(struct thread_info *tinfo,
7aa89746 116 unsigned long *stack, unsigned long ebp,
2b14a78c 117 struct stacktrace_ops *ops, void *data)
1da177e4 118{
1da177e4 119#ifdef CONFIG_FRAME_POINTER
36ad4885
LT
120 struct stack_frame *frame = (struct stack_frame *)ebp;
121 while (valid_stack_ptr(tinfo, frame, sizeof(*frame))) {
122 struct stack_frame *next;
123 unsigned long addr;
124
125 addr = frame->return_address;
2b14a78c 126 ops->address(data, addr);
b88d4f1d
IM
127 /*
128 * break out of recursive entries (such as
808dbbb6
LT
129 * end_of_stack_stop_unwind_function). Also,
130 * we can never allow a frame pointer to
131 * move downwards!
36ad4885
LT
132 */
133 next = frame->next_frame;
134 if (next <= frame)
b88d4f1d 135 break;
36ad4885 136 frame = next;
1da177e4
LT
137 }
138#else
36ad4885
LT
139 while (valid_stack_ptr(tinfo, stack, sizeof(*stack))) {
140 unsigned long addr;
141
1da177e4 142 addr = *stack++;
7aa89746 143 if (__kernel_text_address(addr))
2b14a78c 144 ops->address(data, addr);
1da177e4
LT
145 }
146#endif
147 return ebp;
148}
149
b615ebda
AK
150#define MSG(msg) ops->warning(data, msg)
151
2b14a78c
AK
152void dump_trace(struct task_struct *task, struct pt_regs *regs,
153 unsigned long *stack,
154 struct stacktrace_ops *ops, void *data)
1da177e4 155{
a32cf397 156 unsigned long ebp = 0;
1da177e4
LT
157
158 if (!task)
159 task = current;
160
a32cf397 161 if (!stack) {
2b14a78c
AK
162 unsigned long dummy;
163 stack = &dummy;
028a690a 164 if (task != current)
2b14a78c 165 stack = (unsigned long *)task->thread.esp;
176a2718
JB
166 }
167
a32cf397
AK
168#ifdef CONFIG_FRAME_POINTER
169 if (!ebp) {
170 if (task == current) {
171 /* Grab ebp right from our regs */
172 asm ("movl %%ebp, %0" : "=r" (ebp) : );
173 } else {
174 /* ebp is the last reg pushed by switch_to */
175 ebp = *(unsigned long *) task->thread.esp;
176 }
1da177e4 177 }
a32cf397 178#endif
1da177e4
LT
179
180 while (1) {
181 struct thread_info *context;
182 context = (struct thread_info *)
183 ((unsigned long)stack & (~(THREAD_SIZE - 1)));
2b14a78c
AK
184 ebp = print_context_stack(context, stack, ebp, ops, data);
185 /* Should be after the line below, but somewhere
186 in early boot context comes out corrupted and we
187 can't reference it -AK */
188 if (ops->stack(data, "IRQ") < 0)
189 break;
1da177e4
LT
190 stack = (unsigned long*)context->previous_esp;
191 if (!stack)
192 break;
a36df98a 193 touch_nmi_watchdog();
1da177e4
LT
194 }
195}
2b14a78c
AK
196EXPORT_SYMBOL(dump_trace);
197
198static void
199print_trace_warning_symbol(void *data, char *msg, unsigned long symbol)
200{
201 printk(data);
202 print_symbol(msg, symbol);
203 printk("\n");
204}
205
206static void print_trace_warning(void *data, char *msg)
207{
208 printk("%s%s\n", (char *)data, msg);
209}
210
211static int print_trace_stack(void *data, char *name)
212{
213 return 0;
214}
215
216/*
217 * Print one address/symbol entries per line.
218 */
219static void print_trace_address(void *data, unsigned long addr)
220{
221 printk("%s [<%08lx>] ", (char *)data, addr);
222 print_symbol("%s\n", addr);
601e6255 223 touch_nmi_watchdog();
2b14a78c
AK
224}
225
226static struct stacktrace_ops print_trace_ops = {
227 .warning = print_trace_warning,
228 .warning_symbol = print_trace_warning_symbol,
229 .stack = print_trace_stack,
230 .address = print_trace_address,
231};
232
233static void
234show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
235 unsigned long * stack, char *log_lvl)
236{
237 dump_trace(task, regs, stack, &print_trace_ops, log_lvl);
238 printk("%s =======================\n", log_lvl);
239}
1da177e4 240
2b14a78c
AK
241void show_trace(struct task_struct *task, struct pt_regs *regs,
242 unsigned long * stack)
7aa89746 243{
176a2718 244 show_trace_log_lvl(task, regs, stack, "");
7aa89746
CE
245}
246
176a2718
JB
247static void show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
248 unsigned long *esp, char *log_lvl)
1da177e4
LT
249{
250 unsigned long *stack;
251 int i;
252
253 if (esp == NULL) {
254 if (task)
255 esp = (unsigned long*)task->thread.esp;
256 else
257 esp = (unsigned long *)&esp;
258 }
259
260 stack = esp;
261 for(i = 0; i < kstack_depth_to_print; i++) {
262 if (kstack_end(stack))
263 break;
75874d5c
CE
264 if (i && ((i % 8) == 0))
265 printk("\n%s ", log_lvl);
1da177e4
LT
266 printk("%08lx ", *stack++);
267 }
75874d5c 268 printk("\n%sCall Trace:\n", log_lvl);
176a2718 269 show_trace_log_lvl(task, regs, esp, log_lvl);
7aa89746
CE
270}
271
272void show_stack(struct task_struct *task, unsigned long *esp)
273{
75874d5c 274 printk(" ");
176a2718 275 show_stack_log_lvl(task, NULL, esp, "");
1da177e4
LT
276}
277
278/*
279 * The architecture-independent dump_stack generator
280 */
281void dump_stack(void)
282{
283 unsigned long stack;
284
176a2718 285 show_trace(current, NULL, &stack);
1da177e4
LT
286}
287
288EXPORT_SYMBOL(dump_stack);
289
290void show_registers(struct pt_regs *regs)
291{
292 int i;
293 int in_kernel = 1;
294 unsigned long esp;
464d1a78 295 unsigned short ss, gs;
1da177e4
LT
296
297 esp = (unsigned long) (&regs->esp);
0998e422 298 savesegment(ss, ss);
464d1a78 299 savesegment(gs, gs);
db753bdf 300 if (user_mode_vm(regs)) {
1da177e4
LT
301 in_kernel = 0;
302 esp = regs->esp;
303 ss = regs->xss & 0xffff;
304 }
305 print_modules();
f354b3a9
DJ
306 printk(KERN_EMERG "CPU: %d\n"
307 KERN_EMERG "EIP: %04x:[<%08lx>] %s VLI\n"
308 KERN_EMERG "EFLAGS: %08lx (%s %.*s)\n",
1da177e4 309 smp_processor_id(), 0xffff & regs->xcs, regs->eip,
96b644bd
SH
310 print_tainted(), regs->eflags, init_utsname()->release,
311 (int)strcspn(init_utsname()->version, " "),
312 init_utsname()->version);
9c107805
DJ
313 print_symbol(KERN_EMERG "EIP is at %s\n", regs->eip);
314 printk(KERN_EMERG "eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n",
1da177e4 315 regs->eax, regs->ebx, regs->ecx, regs->edx);
9c107805 316 printk(KERN_EMERG "esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n",
1da177e4 317 regs->esi, regs->edi, regs->ebp, esp);
464d1a78
JF
318 printk(KERN_EMERG "ds: %04x es: %04x fs: %04x gs: %04x ss: %04x\n",
319 regs->xds & 0xffff, regs->xes & 0xffff, regs->xfs & 0xffff, gs, ss);
7e04a118
CE
320 printk(KERN_EMERG "Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)",
321 TASK_COMM_LEN, current->comm, current->pid,
c9f4f06d 322 current_thread_info(), current, task_thread_info(current));
1da177e4
LT
323 /*
324 * When in-kernel, we also print out the stack and code at the
325 * time of the fault..
326 */
327 if (in_kernel) {
11a4180c 328 u8 *eip;
86c41837
CE
329 unsigned int code_prologue = code_bytes * 43 / 64;
330 unsigned int code_len = code_bytes;
99325326 331 unsigned char c;
1da177e4 332
9c107805 333 printk("\n" KERN_EMERG "Stack: ");
176a2718 334 show_stack_log_lvl(NULL, regs, (unsigned long *)esp, KERN_EMERG);
1da177e4 335
9c107805 336 printk(KERN_EMERG "Code: ");
1da177e4 337
86c41837 338 eip = (u8 *)regs->eip - code_prologue;
11a4180c
AK
339 if (eip < (u8 *)PAGE_OFFSET ||
340 probe_kernel_address(eip, c)) {
99325326 341 /* try starting at EIP */
11a4180c 342 eip = (u8 *)regs->eip;
86c41837 343 code_len = code_len - code_prologue + 1;
99325326 344 }
86c41837 345 for (i = 0; i < code_len; i++, eip++) {
11a4180c
AK
346 if (eip < (u8 *)PAGE_OFFSET ||
347 probe_kernel_address(eip, c)) {
1da177e4
LT
348 printk(" Bad EIP value.");
349 break;
350 }
11a4180c 351 if (eip == (u8 *)regs->eip)
1da177e4
LT
352 printk("<%02x> ", c);
353 else
354 printk("%02x ", c);
355 }
356 }
357 printk("\n");
358}
359
91768d6c 360int is_valid_bugaddr(unsigned long eip)
1da177e4
LT
361{
362 unsigned short ud2;
1da177e4
LT
363
364 if (eip < PAGE_OFFSET)
91768d6c 365 return 0;
11a4180c 366 if (probe_kernel_address((unsigned short *)eip, ud2))
91768d6c 367 return 0;
1da177e4 368
91768d6c 369 return ud2 == 0x0b0f;
1da177e4
LT
370}
371
91768d6c
JF
372/*
373 * This is gone through when something in the kernel has done something bad and
374 * is about to be terminated.
375 */
1da177e4
LT
376void die(const char * str, struct pt_regs * regs, long err)
377{
378 static struct {
379 spinlock_t lock;
380 u32 lock_owner;
381 int lock_owner_depth;
382 } die = {
6cfd76a2 383 .lock = __SPIN_LOCK_UNLOCKED(die.lock),
1da177e4
LT
384 .lock_owner = -1,
385 .lock_owner_depth = 0
386 };
387 static int die_counter;
e43d674f 388 unsigned long flags;
1da177e4 389
dd287796
AM
390 oops_enter();
391
39c715b7 392 if (die.lock_owner != raw_smp_processor_id()) {
1da177e4 393 console_verbose();
e43d674f 394 spin_lock_irqsave(&die.lock, flags);
1da177e4
LT
395 die.lock_owner = smp_processor_id();
396 die.lock_owner_depth = 0;
397 bust_spinlocks(1);
398 }
e43d674f
JB
399 else
400 local_save_flags(flags);
1da177e4
LT
401
402 if (++die.lock_owner_depth < 3) {
403 int nl = 0;
7bee5c0f
RD
404 unsigned long esp;
405 unsigned short ss;
406
608e2619 407 report_bug(regs->eip, regs);
91768d6c 408
9c107805 409 printk(KERN_EMERG "%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
1da177e4 410#ifdef CONFIG_PREEMPT
9c107805 411 printk(KERN_EMERG "PREEMPT ");
1da177e4
LT
412 nl = 1;
413#endif
414#ifdef CONFIG_SMP
9c107805
DJ
415 if (!nl)
416 printk(KERN_EMERG);
1da177e4
LT
417 printk("SMP ");
418 nl = 1;
419#endif
420#ifdef CONFIG_DEBUG_PAGEALLOC
9c107805
DJ
421 if (!nl)
422 printk(KERN_EMERG);
1da177e4
LT
423 printk("DEBUG_PAGEALLOC");
424 nl = 1;
425#endif
426 if (nl)
427 printk("\n");
20c0d2d4
JB
428 if (notify_die(DIE_OOPS, str, regs, err,
429 current->thread.trap_no, SIGSEGV) !=
7bee5c0f 430 NOTIFY_STOP) {
20c0d2d4 431 show_registers(regs);
7bee5c0f
RD
432 /* Executive summary in case the oops scrolled away */
433 esp = (unsigned long) (&regs->esp);
434 savesegment(ss, ss);
435 if (user_mode(regs)) {
436 esp = regs->esp;
437 ss = regs->xss & 0xffff;
438 }
439 printk(KERN_EMERG "EIP: [<%08lx>] ", regs->eip);
440 print_symbol("%s", regs->eip);
441 printk(" SS:ESP %04x:%08lx\n", ss, esp);
442 }
20c0d2d4
JB
443 else
444 regs = NULL;
1da177e4 445 } else
9c107805 446 printk(KERN_EMERG "Recursive die() failure, output suppressed\n");
1da177e4
LT
447
448 bust_spinlocks(0);
449 die.lock_owner = -1;
bcdcd8e7 450 add_taint(TAINT_DIE);
e43d674f 451 spin_unlock_irqrestore(&die.lock, flags);
6e274d14 452
20c0d2d4
JB
453 if (!regs)
454 return;
455
6e274d14
AN
456 if (kexec_should_crash(current))
457 crash_kexec(regs);
458
1da177e4
LT
459 if (in_interrupt())
460 panic("Fatal exception in interrupt");
461
cea6a4ba 462 if (panic_on_oops)
012c437d 463 panic("Fatal exception");
cea6a4ba 464
dd287796 465 oops_exit();
1da177e4
LT
466 do_exit(SIGSEGV);
467}
468
469static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
470{
717b594a 471 if (!user_mode_vm(regs))
1da177e4
LT
472 die(str, regs, err);
473}
474
3d97ae5b
PP
475static void __kprobes do_trap(int trapnr, int signr, char *str, int vm86,
476 struct pt_regs * regs, long error_code,
477 siginfo_t *info)
1da177e4 478{
4f339ecb 479 struct task_struct *tsk = current;
4f339ecb 480
1da177e4
LT
481 if (regs->eflags & VM_MASK) {
482 if (vm86)
483 goto vm86_trap;
484 goto trap_signal;
485 }
486
717b594a 487 if (!user_mode(regs))
1da177e4
LT
488 goto kernel_trap;
489
490 trap_signal: {
d1895183
AK
491 /*
492 * We want error_code and trap_no set for userspace faults and
493 * kernelspace faults which result in die(), but not
494 * kernelspace faults which are fixed up. die() gives the
495 * process no chance to handle the signal and notice the
496 * kernel fault information, so that won't result in polluting
497 * the information about previously queued, but not yet
498 * delivered, faults. See also do_general_protection below.
499 */
500 tsk->thread.error_code = error_code;
501 tsk->thread.trap_no = trapnr;
502
1da177e4
LT
503 if (info)
504 force_sig_info(signr, info, tsk);
505 else
506 force_sig(signr, tsk);
507 return;
508 }
509
510 kernel_trap: {
d1895183
AK
511 if (!fixup_exception(regs)) {
512 tsk->thread.error_code = error_code;
513 tsk->thread.trap_no = trapnr;
1da177e4 514 die(str, regs, error_code);
d1895183 515 }
1da177e4
LT
516 return;
517 }
518
519 vm86_trap: {
520 int ret = handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code, trapnr);
521 if (ret) goto trap_signal;
522 return;
523 }
524}
525
526#define DO_ERROR(trapnr, signr, str, name) \
527fastcall void do_##name(struct pt_regs * regs, long error_code) \
528{ \
529 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
530 == NOTIFY_STOP) \
531 return; \
532 do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \
533}
534
a10d9a71 535#define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr, irq) \
1da177e4
LT
536fastcall void do_##name(struct pt_regs * regs, long error_code) \
537{ \
538 siginfo_t info; \
a10d9a71
PZ
539 if (irq) \
540 local_irq_enable(); \
1da177e4
LT
541 info.si_signo = signr; \
542 info.si_errno = 0; \
543 info.si_code = sicode; \
544 info.si_addr = (void __user *)siaddr; \
545 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
546 == NOTIFY_STOP) \
547 return; \
548 do_trap(trapnr, signr, str, 0, regs, error_code, &info); \
549}
550
551#define DO_VM86_ERROR(trapnr, signr, str, name) \
552fastcall void do_##name(struct pt_regs * regs, long error_code) \
553{ \
554 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
555 == NOTIFY_STOP) \
556 return; \
557 do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \
558}
559
560#define DO_VM86_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
561fastcall void do_##name(struct pt_regs * regs, long error_code) \
562{ \
563 siginfo_t info; \
564 info.si_signo = signr; \
565 info.si_errno = 0; \
566 info.si_code = sicode; \
567 info.si_addr = (void __user *)siaddr; \
568 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
569 == NOTIFY_STOP) \
570 return; \
571 do_trap(trapnr, signr, str, 1, regs, error_code, &info); \
572}
573
574DO_VM86_ERROR_INFO( 0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->eip)
575#ifndef CONFIG_KPROBES
576DO_VM86_ERROR( 3, SIGTRAP, "int3", int3)
577#endif
578DO_VM86_ERROR( 4, SIGSEGV, "overflow", overflow)
579DO_VM86_ERROR( 5, SIGSEGV, "bounds", bounds)
a10d9a71 580DO_ERROR_INFO( 6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->eip, 0)
1da177e4
LT
581DO_ERROR( 9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
582DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
583DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
584DO_ERROR(12, SIGBUS, "stack segment", stack_segment)
a10d9a71
PZ
585DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0, 0)
586DO_ERROR_INFO(32, SIGSEGV, "iret exception", iret_error, ILL_BADSTK, 0, 1)
1da177e4 587
3d97ae5b
PP
588fastcall void __kprobes do_general_protection(struct pt_regs * regs,
589 long error_code)
1da177e4
LT
590{
591 int cpu = get_cpu();
592 struct tss_struct *tss = &per_cpu(init_tss, cpu);
593 struct thread_struct *thread = &current->thread;
594
595 /*
596 * Perform the lazy TSS's I/O bitmap copy. If the TSS has an
597 * invalid offset set (the LAZY one) and the faulting thread has
598 * a valid I/O bitmap pointer, we copy the I/O bitmap in the TSS
599 * and we set the offset field correctly. Then we let the CPU to
600 * restart the faulting instruction.
601 */
a75c54f9 602 if (tss->x86_tss.io_bitmap_base == INVALID_IO_BITMAP_OFFSET_LAZY &&
1da177e4
LT
603 thread->io_bitmap_ptr) {
604 memcpy(tss->io_bitmap, thread->io_bitmap_ptr,
605 thread->io_bitmap_max);
606 /*
607 * If the previously set map was extending to higher ports
608 * than the current one, pad extra space with 0xff (no access).
609 */
610 if (thread->io_bitmap_max < tss->io_bitmap_max)
611 memset((char *) tss->io_bitmap +
612 thread->io_bitmap_max, 0xff,
613 tss->io_bitmap_max - thread->io_bitmap_max);
614 tss->io_bitmap_max = thread->io_bitmap_max;
a75c54f9 615 tss->x86_tss.io_bitmap_base = IO_BITMAP_OFFSET;
d5cd4aad 616 tss->io_bitmap_owner = thread;
1da177e4
LT
617 put_cpu();
618 return;
619 }
620 put_cpu();
621
622 if (regs->eflags & VM_MASK)
623 goto gp_in_vm86;
624
717b594a 625 if (!user_mode(regs))
1da177e4
LT
626 goto gp_in_kernel;
627
628 current->thread.error_code = error_code;
629 current->thread.trap_no = 13;
abd4f750
MAS
630 if (show_unhandled_signals && unhandled_signal(current, SIGSEGV) &&
631 printk_ratelimit())
632 printk(KERN_INFO
633 "%s[%d] general protection eip:%lx esp:%lx error:%lx\n",
634 current->comm, current->pid,
635 regs->eip, regs->esp, error_code);
636
1da177e4
LT
637 force_sig(SIGSEGV, current);
638 return;
639
640gp_in_vm86:
641 local_irq_enable();
642 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
643 return;
644
645gp_in_kernel:
646 if (!fixup_exception(regs)) {
d1895183
AK
647 current->thread.error_code = error_code;
648 current->thread.trap_no = 13;
1da177e4
LT
649 if (notify_die(DIE_GPF, "general protection fault", regs,
650 error_code, 13, SIGSEGV) == NOTIFY_STOP)
651 return;
652 die("general protection fault", regs, error_code);
653 }
654}
655