+ use-generic-bug-for-i386.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     Use generic BUG for i386

has been added to the -mm tree.  Its filename is

     use-generic-bug-for-i386.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: Use generic BUG for i386
From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>

This makes i386 use the generic BUG machinery.  This changes the behaviour of
BUG in a few ways; most significantly, i386 now also records the function name
as well andthe file and line number of each BUG.  This was done to make it
consistent with the powerpc.

The main advantage in using the generic BUG machinery for i386 is that the
inlined overhead of BUG is just the ud2a instruction; the file+line(+function)
information are no longer inlined into the instruction stream.  This reduces
cache pollution, and makes disassembly work properly.

Signed-off-by: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxx>
Cc: Andi Kleen <ak@xxxxxx>
Cc: Hugh Dickens <hugh@xxxxxxxxxxx>
Cc: Michael Ellerman <michael@xxxxxxxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>
Cc: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 arch/i386/Kconfig              |    5 ++
 arch/i386/kernel/module.c      |    5 +-
 arch/i386/kernel/traps.c       |   23 +++++++++-
 arch/i386/kernel/vmlinux.lds.S |    2 
 include/asm-i386/bug.h         |   65 +++++++++++++++++++++++++++----
 5 files changed, 87 insertions(+), 13 deletions(-)

diff -puN arch/i386/Kconfig~use-generic-bug-for-i386 arch/i386/Kconfig
--- a/arch/i386/Kconfig~use-generic-bug-for-i386
+++ a/arch/i386/Kconfig
@@ -45,6 +45,11 @@ config GENERIC_IOMAP
 	bool
 	default y
 
+config GENERIC_BUG
+	bool
+	default y
+	depends on BUG
+
 config GENERIC_HWEIGHT
 	bool
 	default y
diff -puN arch/i386/kernel/module.c~use-generic-bug-for-i386 arch/i386/kernel/module.c
--- a/arch/i386/kernel/module.c~use-generic-bug-for-i386
+++ a/arch/i386/kernel/module.c
@@ -21,6 +21,7 @@
 #include <linux/fs.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
+#include <linux/bug.h>
 
 #if 0
 #define DEBUGP printk
@@ -132,10 +133,12 @@ int module_finalize(const Elf_Ehdr *hdr,
 					    lseg, lseg + locks->sh_size,
 					    tseg, tseg + text->sh_size);
 	}
-	return 0;
+
+	return module_bug_finalize(hdr, sechdrs, me);
 }
 
 void module_arch_cleanup(struct module *mod)
 {
 	alternatives_smp_module_del(mod);
+	module_bug_cleanup(mod);
 }
diff -puN arch/i386/kernel/traps.c~use-generic-bug-for-i386 arch/i386/kernel/traps.c
--- a/arch/i386/kernel/traps.c~use-generic-bug-for-i386
+++ a/arch/i386/kernel/traps.c
@@ -29,6 +29,7 @@
 #include <linux/kexec.h>
 #include <linux/unwind.h>
 #include <linux/uaccess.h>
+#include <linux/bug.h>
 
 #ifdef CONFIG_EISA
 #include <linux/ioport.h>
@@ -441,9 +442,22 @@ static void handle_BUG(struct pt_regs *r
 	printk(KERN_EMERG "Kernel BUG at [verbose debug info unavailable]\n");
 }
 
-/* This is gone through when something in the kernel
- * has done something bad and is about to be terminated.
-*/
+int is_valid_bugaddr(unsigned long eip)
+{
+	unsigned short ud2;
+
+	if (eip < PAGE_OFFSET)
+		return 0;
+	if (probe_kernel_address((unsigned short __user *)eip, ud2))
+		return 0;
+
+	return ud2 == 0x0b0f;
+}
+
+/*
+ * This is gone through when something in the kernel has done something bad and
+ * is about to be terminated.
+ */
 void die(const char * str, struct pt_regs * regs, long err)
 {
 	static struct {
@@ -476,7 +490,8 @@ void die(const char * str, struct pt_reg
 		unsigned long esp;
 		unsigned short ss;
 
-		handle_BUG(regs);
+		report_bug(regs->eip);
+
 		printk(KERN_EMERG "%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
 #ifdef CONFIG_PREEMPT
 		printk(KERN_EMERG "PREEMPT ");
diff -puN arch/i386/kernel/vmlinux.lds.S~use-generic-bug-for-i386 arch/i386/kernel/vmlinux.lds.S
--- a/arch/i386/kernel/vmlinux.lds.S~use-generic-bug-for-i386
+++ a/arch/i386/kernel/vmlinux.lds.S
@@ -45,6 +45,8 @@ SECTIONS
 
   RODATA
 
+  BUG_TABLE
+
   . = ALIGN(4);
   __tracedata_start = .;
   .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
diff -puN include/asm-i386/bug.h~use-generic-bug-for-i386 include/asm-i386/bug.h
--- a/include/asm-i386/bug.h~use-generic-bug-for-i386
+++ a/include/asm-i386/bug.h
@@ -4,20 +4,69 @@
 
 /*
  * Tell the user there is some problem.
- * The offending file and line are encoded after the "officially
- * undefined" opcode for parsing in the trap handler.
+ * The offending file and line are encoded encoded in the __bug_table section.
  */
 
 #ifdef CONFIG_BUG
 #define HAVE_ARCH_BUG
+
+struct bug_entry {
+	unsigned long bug_addr;
+#ifdef CONFIG_DEBUG_BUGVERBOSE
+	const char *file, *function;
+	unsigned short line;
+#endif
+} __attribute__((packed));
+
+static inline int is_warning_bug(const struct bug_entry *b)
+{
+	return 0;
+}
+
 #ifdef CONFIG_DEBUG_BUGVERBOSE
-#define BUG()				\
- __asm__ __volatile__(	"ud2\n"		\
-			"\t.word %c0\n"	\
-			"\t.long %c1\n"	\
-			 : : "i" (__LINE__), "i" (__FILE__))
+#define BUG()						\
+	asm volatile("1:ud2\n"				\
+		     ".pushsection __bug_table,\"a\"\n"	\
+		     "\t.long 1b, %c0, %c1\n"		\
+		     "\t.word %c2\n"			\
+		     ".popsection"			\
+		     : : "i" (__FILE__), "i" (__FUNCTION__), "i" (__LINE__))
+
+static inline const char *bug_get_file(const struct bug_entry *bug)
+{
+	return bug->file;
+}
+
+static inline const char *bug_get_function(const struct bug_entry *bug)
+{
+	return bug->function;
+}
+
+static inline unsigned bug_get_line(const struct bug_entry *bug)
+{
+	return bug->line;
+}
 #else
-#define BUG() __asm__ __volatile__("ud2\n")
+#define BUG()						\
+	asm volatile("1:ud2\n"				\
+		     ".section __bug_table,\"a\"\n"	\
+		     "\t.long 1b\n"			\
+		     ".previous")
+
+static inline const char *bug_get_file(const struct bug_entry *bug)
+{
+	return NULL;
+}
+
+static inline const char *bug_get_function(const struct bug_entry *bug)
+{
+	return NULL;
+}
+
+static inline unsigned bug_get_line(const struct bug_entry *bug)
+{
+	return 0;
+}
 #endif
 #endif
 
_

Patches currently in -mm which might be from jeremy@xxxxxxxx are

origin.patch
x86-remove-default_ldt-and-simplify-ldt-setting.patch
generic-bug-handling.patch
use-generic-bug-for-i386.patch
use-generic-bug-for-x86-64.patch
use-generic-bug-for-powerpc.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux