aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/kernel/traps.c
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@goop.org>2006-12-08 05:36:22 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 11:28:39 -0500
commitc31a0bf3e1bc581676618db7492f18798fd0a73f (patch)
tree68eb38dbc58d647c3b20cd73fb812cafe93eb663 /arch/x86_64/kernel/traps.c
parent91768d6c2bad0d2766a166f13f2f57e197de3458 (diff)
[PATCH] Generic BUG for x86-64
This makes x86-64 use the generic BUG machinery. The main advantage in using the generic BUG machinery for x86-64 is that the inlined overhead of BUG is just the ud2a instruction; the file+line information are no longer inlined into the instruction stream. This reduces cache pollution. Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org> Cc: Andi Kleen <ak@muc.de> Cc: Hugh Dickens <hugh@veritas.com> Cc: Michael Ellerman <michael@ellerman.id.au> Cc: Paul Mackerras <paulus@samba.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/x86_64/kernel/traps.c')
-rw-r--r--arch/x86_64/kernel/traps.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index a1641ffdffcf..b54ccc07f379 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -31,6 +31,7 @@
31#include <linux/kexec.h> 31#include <linux/kexec.h>
32#include <linux/unwind.h> 32#include <linux/unwind.h>
33#include <linux/uaccess.h> 33#include <linux/uaccess.h>
34#include <linux/bug.h>
34 35
35#include <asm/system.h> 36#include <asm/system.h>
36#include <asm/io.h> 37#include <asm/io.h>
@@ -524,30 +525,15 @@ bad:
524 printk("\n"); 525 printk("\n");
525} 526}
526 527
527void handle_BUG(struct pt_regs *regs) 528int is_valid_bugaddr(unsigned long rip)
528{ 529{
529 struct bug_frame f; 530 unsigned short ud2;
530 long len;
531 const char *prefix = "";
532 531
533 if (user_mode(regs)) 532 if (__copy_from_user(&ud2, (const void __user *) rip, sizeof(ud2)))
534 return; 533 return 0;
535 if (__copy_from_user(&f, (const void __user *) regs->rip, 534
536 sizeof(struct bug_frame))) 535 return ud2 == 0x0b0f;
537 return; 536}
538 if (f.filename >= 0 ||
539 f.ud2[0] != 0x0f || f.ud2[1] != 0x0b)
540 return;
541 len = __strnlen_user((char *)(long)f.filename, PATH_MAX) - 1;
542 if (len < 0 || len >= PATH_MAX)
543 f.filename = (int)(long)"unmapped filename";
544 else if (len > 50) {
545 f.filename += len - 50;
546 prefix = "...";
547 }
548 printk("----------- [cut here ] --------- [please bite here ] ---------\n");
549 printk(KERN_ALERT "Kernel BUG at %s%.50s:%d\n", prefix, (char *)(long)f.filename, f.line);
550}
551 537
552#ifdef CONFIG_BUG 538#ifdef CONFIG_BUG
553void out_of_line_bug(void) 539void out_of_line_bug(void)
@@ -627,7 +613,9 @@ void die(const char * str, struct pt_regs * regs, long err)
627{ 613{
628 unsigned long flags = oops_begin(); 614 unsigned long flags = oops_begin();
629 615
630 handle_BUG(regs); 616 if (!user_mode(regs))
617 report_bug(regs->rip);
618
631 __die(str, regs, err); 619 __die(str, regs, err);
632 oops_end(flags); 620 oops_end(flags);
633 do_exit(SIGSEGV); 621 do_exit(SIGSEGV);