kprobes: fix sparse NULL warning
[linux-2.6-block.git] / arch / i386 / kernel / traps.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
44#include <asm/processor.h>
45#include <asm/system.h>
1da177e4
LT
46#include <asm/io.h>
47#include <asm/atomic.h>
48#include <asm/debugreg.h>
49#include <asm/desc.h>
50#include <asm/i387.h>
51#include <asm/nmi.h>
176a2718 52#include <asm/unwind.h>
1da177e4
LT
53#include <asm/smp.h>
54#include <asm/arch_hooks.h>
55#include <asm/kdebug.h>
2b14a78c 56#include <asm/stacktrace.h>
1da177e4 57
1da177e4
LT
58#include <linux/module.h>
59
60#include "mach_traps.h"
61
29cbc78b
AK
62int panic_on_unrecovered_nmi;
63
1da177e4
LT
64asmlinkage int system_call(void);
65
1da177e4
LT
66/* Do we ignore FPU interrupts ? */
67char ignore_fpu_irq = 0;
68
69/*
70 * The IDT has to be page-aligned to simplify the Pentium
71 * F0 0F bug workaround.. We have a special link segment
72 * for this.
73 */
74struct desc_struct idt_table[256] __attribute__((__section__(".data.idt"))) = { {0, 0}, };
75
76asmlinkage void divide_error(void);
77asmlinkage void debug(void);
78asmlinkage void nmi(void);
79asmlinkage void int3(void);
80asmlinkage void overflow(void);
81asmlinkage void bounds(void);
82asmlinkage void invalid_op(void);
83asmlinkage void device_not_available(void);
84asmlinkage void coprocessor_segment_overrun(void);
85asmlinkage void invalid_TSS(void);
86asmlinkage void segment_not_present(void);
87asmlinkage void stack_segment(void);
88asmlinkage void general_protection(void);
89asmlinkage void page_fault(void);
90asmlinkage void coprocessor_error(void);
91asmlinkage void simd_coprocessor_error(void);
92asmlinkage void alignment_check(void);
93asmlinkage void spurious_interrupt_bug(void);
94asmlinkage void machine_check(void);
95
0741f4d2 96int kstack_depth_to_print = 24;
86c41837 97static unsigned int code_bytes = 64;
e041c683 98ATOMIC_NOTIFIER_HEAD(i386die_chain);
1da177e4
LT
99
100int register_die_notifier(struct notifier_block *nb)
101{
101f12af 102 vmalloc_sync_all();
e041c683 103 return atomic_notifier_chain_register(&i386die_chain, nb);
1da177e4 104}
1454aed9 105EXPORT_SYMBOL(register_die_notifier); /* used modular by kdb */
1da177e4 106
e041c683
AS
107int unregister_die_notifier(struct notifier_block *nb)
108{
109 return atomic_notifier_chain_unregister(&i386die_chain, nb);
110}
1454aed9 111EXPORT_SYMBOL(unregister_die_notifier); /* used modular by kdb */
e041c683 112
1da177e4
LT
113static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
114{
115 return p > (void *)tinfo &&
116 p < (void *)tinfo + THREAD_SIZE - 3;
117}
118
119static inline unsigned long print_context_stack(struct thread_info *tinfo,
7aa89746 120 unsigned long *stack, unsigned long ebp,
2b14a78c 121 struct stacktrace_ops *ops, void *data)
1da177e4
LT
122{
123 unsigned long addr;
124
125#ifdef CONFIG_FRAME_POINTER
126 while (valid_stack_ptr(tinfo, (void *)ebp)) {
808dbbb6 127 unsigned long new_ebp;
1da177e4 128 addr = *(unsigned long *)(ebp + 4);
2b14a78c 129 ops->address(data, addr);
b88d4f1d
IM
130 /*
131 * break out of recursive entries (such as
808dbbb6
LT
132 * end_of_stack_stop_unwind_function). Also,
133 * we can never allow a frame pointer to
134 * move downwards!
b88d4f1d 135 */
808dbbb6
LT
136 new_ebp = *(unsigned long *)ebp;
137 if (new_ebp <= ebp)
b88d4f1d 138 break;
808dbbb6 139 ebp = new_ebp;
1da177e4
LT
140 }
141#else
142 while (valid_stack_ptr(tinfo, stack)) {
143 addr = *stack++;
7aa89746 144 if (__kernel_text_address(addr))
2b14a78c 145 ops->address(data, addr);
1da177e4
LT
146 }
147#endif
148 return ebp;
149}
150
b615ebda
AK
151#define MSG(msg) ops->warning(data, msg)
152
2b14a78c
AK
153void dump_trace(struct task_struct *task, struct pt_regs *regs,
154 unsigned long *stack,
155 struct stacktrace_ops *ops, void *data)
1da177e4 156{
a32cf397 157 unsigned long ebp = 0;
1da177e4
LT
158
159 if (!task)
160 task = current;
161
a32cf397 162 if (!stack) {
2b14a78c
AK
163 unsigned long dummy;
164 stack = &dummy;
165 if (task && task != current)
166 stack = (unsigned long *)task->thread.esp;
176a2718
JB
167 }
168
a32cf397
AK
169#ifdef CONFIG_FRAME_POINTER
170 if (!ebp) {
171 if (task == current) {
172 /* Grab ebp right from our regs */
173 asm ("movl %%ebp, %0" : "=r" (ebp) : );
174 } else {
175 /* ebp is the last reg pushed by switch_to */
176 ebp = *(unsigned long *) task->thread.esp;
177 }
1da177e4 178 }
a32cf397 179#endif
1da177e4
LT
180
181 while (1) {
182 struct thread_info *context;
183 context = (struct thread_info *)
184 ((unsigned long)stack & (~(THREAD_SIZE - 1)));
2b14a78c
AK
185 ebp = print_context_stack(context, stack, ebp, ops, data);
186 /* Should be after the line below, but somewhere
187 in early boot context comes out corrupted and we
188 can't reference it -AK */
189 if (ops->stack(data, "IRQ") < 0)
190 break;
1da177e4
LT
191 stack = (unsigned long*)context->previous_esp;
192 if (!stack)
193 break;
a36df98a 194 touch_nmi_watchdog();
1da177e4
LT
195 }
196}
2b14a78c
AK
197EXPORT_SYMBOL(dump_trace);
198
199static void
200print_trace_warning_symbol(void *data, char *msg, unsigned long symbol)
201{
202 printk(data);
203 print_symbol(msg, symbol);
204 printk("\n");
205}
206
207static void print_trace_warning(void *data, char *msg)
208{
209 printk("%s%s\n", (char *)data, msg);
210}
211
212static int print_trace_stack(void *data, char *name)
213{
214 return 0;
215}
216
217/*
218 * Print one address/symbol entries per line.
219 */
220static void print_trace_address(void *data, unsigned long addr)
221{
222 printk("%s [<%08lx>] ", (char *)data, addr);
223 print_symbol("%s\n", addr);
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,
322 current_thread_info(), current, current->thread_info);
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
91768d6c
JF
407 report_bug(regs->eip);
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;
e43d674f 450 spin_unlock_irqrestore(&die.lock, flags);
6e274d14 451
20c0d2d4
JB
452 if (!regs)
453 return;
454
6e274d14
AN
455 if (kexec_should_crash(current))
456 crash_kexec(regs);
457
1da177e4
LT
458 if (in_interrupt())
459 panic("Fatal exception in interrupt");
460
cea6a4ba 461 if (panic_on_oops)
012c437d 462 panic("Fatal exception");
cea6a4ba 463
dd287796 464 oops_exit();
1da177e4
LT
465 do_exit(SIGSEGV);
466}
467
468static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
469{
717b594a 470 if (!user_mode_vm(regs))
1da177e4
LT
471 die(str, regs, err);
472}
473
3d97ae5b
PP
474static void __kprobes do_trap(int trapnr, int signr, char *str, int vm86,
475 struct pt_regs * regs, long error_code,
476 siginfo_t *info)
1da177e4 477{
4f339ecb 478 struct task_struct *tsk = current;
4f339ecb 479
1da177e4
LT
480 if (regs->eflags & VM_MASK) {
481 if (vm86)
482 goto vm86_trap;
483 goto trap_signal;
484 }
485
717b594a 486 if (!user_mode(regs))
1da177e4
LT
487 goto kernel_trap;
488
489 trap_signal: {
d1895183
AK
490 /*
491 * We want error_code and trap_no set for userspace faults and
492 * kernelspace faults which result in die(), but not
493 * kernelspace faults which are fixed up. die() gives the
494 * process no chance to handle the signal and notice the
495 * kernel fault information, so that won't result in polluting
496 * the information about previously queued, but not yet
497 * delivered, faults. See also do_general_protection below.
498 */
499 tsk->thread.error_code = error_code;
500 tsk->thread.trap_no = trapnr;
501
1da177e4
LT
502 if (info)
503 force_sig_info(signr, info, tsk);
504 else
505 force_sig(signr, tsk);
506 return;
507 }
508
509 kernel_trap: {
d1895183
AK
510 if (!fixup_exception(regs)) {
511 tsk->thread.error_code = error_code;
512 tsk->thread.trap_no = trapnr;
1da177e4 513 die(str, regs, error_code);
d1895183 514 }
1da177e4
LT
515 return;
516 }
517
518 vm86_trap: {
519 int ret = handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code, trapnr);
520 if (ret) goto trap_signal;
521 return;
522 }
523}
524
525#define DO_ERROR(trapnr, signr, str, name) \
526fastcall void do_##name(struct pt_regs * regs, long error_code) \
527{ \
528 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
529 == NOTIFY_STOP) \
530 return; \
531 do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \
532}
533
534#define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
535fastcall void do_##name(struct pt_regs * regs, long error_code) \
536{ \
537 siginfo_t info; \
538 info.si_signo = signr; \
539 info.si_errno = 0; \
540 info.si_code = sicode; \
541 info.si_addr = (void __user *)siaddr; \
542 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
543 == NOTIFY_STOP) \
544 return; \
545 do_trap(trapnr, signr, str, 0, regs, error_code, &info); \
546}
547
548#define DO_VM86_ERROR(trapnr, signr, str, name) \
549fastcall void do_##name(struct pt_regs * regs, long error_code) \
550{ \
551 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
552 == NOTIFY_STOP) \
553 return; \
554 do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \
555}
556
557#define DO_VM86_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
558fastcall void do_##name(struct pt_regs * regs, long error_code) \
559{ \
560 siginfo_t info; \
561 info.si_signo = signr; \
562 info.si_errno = 0; \
563 info.si_code = sicode; \
564 info.si_addr = (void __user *)siaddr; \
565 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
566 == NOTIFY_STOP) \
567 return; \
568 do_trap(trapnr, signr, str, 1, regs, error_code, &info); \
569}
570
571DO_VM86_ERROR_INFO( 0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->eip)
572#ifndef CONFIG_KPROBES
573DO_VM86_ERROR( 3, SIGTRAP, "int3", int3)
574#endif
575DO_VM86_ERROR( 4, SIGSEGV, "overflow", overflow)
576DO_VM86_ERROR( 5, SIGSEGV, "bounds", bounds)
631b0347 577DO_ERROR_INFO( 6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->eip)
1da177e4
LT
578DO_ERROR( 9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
579DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
580DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
581DO_ERROR(12, SIGBUS, "stack segment", stack_segment)
582DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
a879cbbb 583DO_ERROR_INFO(32, SIGSEGV, "iret exception", iret_error, ILL_BADSTK, 0)
1da177e4 584
3d97ae5b
PP
585fastcall void __kprobes do_general_protection(struct pt_regs * regs,
586 long error_code)
1da177e4
LT
587{
588 int cpu = get_cpu();
589 struct tss_struct *tss = &per_cpu(init_tss, cpu);
590 struct thread_struct *thread = &current->thread;
591
592 /*
593 * Perform the lazy TSS's I/O bitmap copy. If the TSS has an
594 * invalid offset set (the LAZY one) and the faulting thread has
595 * a valid I/O bitmap pointer, we copy the I/O bitmap in the TSS
596 * and we set the offset field correctly. Then we let the CPU to
597 * restart the faulting instruction.
598 */
a75c54f9 599 if (tss->x86_tss.io_bitmap_base == INVALID_IO_BITMAP_OFFSET_LAZY &&
1da177e4
LT
600 thread->io_bitmap_ptr) {
601 memcpy(tss->io_bitmap, thread->io_bitmap_ptr,
602 thread->io_bitmap_max);
603 /*
604 * If the previously set map was extending to higher ports
605 * than the current one, pad extra space with 0xff (no access).
606 */
607 if (thread->io_bitmap_max < tss->io_bitmap_max)
608 memset((char *) tss->io_bitmap +
609 thread->io_bitmap_max, 0xff,
610 tss->io_bitmap_max - thread->io_bitmap_max);
611 tss->io_bitmap_max = thread->io_bitmap_max;
a75c54f9 612 tss->x86_tss.io_bitmap_base = IO_BITMAP_OFFSET;
d5cd4aad 613 tss->io_bitmap_owner = thread;
1da177e4
LT
614 put_cpu();
615 return;
616 }
617 put_cpu();
618
619 if (regs->eflags & VM_MASK)
620 goto gp_in_vm86;
621
717b594a 622 if (!user_mode(regs))
1da177e4
LT
623 goto gp_in_kernel;
624
625 current->thread.error_code = error_code;
626 current->thread.trap_no = 13;
627 force_sig(SIGSEGV, current);
628 return;
629
630gp_in_vm86:
631 local_irq_enable();
632 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
633 return;
634
635gp_in_kernel:
636 if (!fixup_exception(regs)) {
d1895183
AK
637 current->thread.error_code = error_code;
638 current->thread.trap_no = 13;
1da177e4
LT
639 if (notify_die(DIE_GPF, "general protection fault", regs,
640 error_code, 13, SIGSEGV) == NOTIFY_STOP)
641 return;
642 die("general protection fault", regs, error_code);
643 }
644}
645