- use-generic-bug-for-powerpc.patch removed from -mm tree

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

 



The patch titled

     Use generic BUG for powerpc

has been removed from the -mm tree.  Its filename is

     use-generic-bug-for-powerpc.patch

This patch was dropped because an updated version was merged

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

This makes powerpc use the generic BUG machinery.  Since the generic BUG
machinery is just the old powerpc code repurposed, there are no functional
changes.

There is an overall reduction of code, since module_32/64 duplicated several
functions.

BTW, powerpc doesn't seem to be using BUG_OPCODE or BUG_ILLEGAL_INSTRUCTION
for actual BUGs any more (I presume they were once used).  There are still a
couple of uses of those macros elsewhere (kernel/prom_init.c and
kernel/head_64.S); should be converted to "twi 31,0,0" as well?

[akpm@xxxxxxxx: build fixes]
Signed-off-by: Jeremy Fitzhardinge <jeremy@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/powerpc/Kconfig              |    5 +++
 arch/powerpc/kernel/module_32.c   |   43 +-------------------------
 arch/powerpc/kernel/module_64.c   |   43 +-------------------------
 arch/powerpc/kernel/traps.c       |   45 +++-------------------------
 arch/powerpc/kernel/vmlinux.lds.S |    6 ---
 arch/powerpc/xmon/xmon.c          |   11 +++---
 include/asm-powerpc/bug.h         |   22 ++++++++++++-
 include/asm-powerpc/module.h      |    2 -
 include/linux/bug.h               |    2 +
 lib/bug.c                         |    2 -
 10 files changed, 47 insertions(+), 134 deletions(-)

diff -puN arch/powerpc/Kconfig~use-generic-bug-for-powerpc arch/powerpc/Kconfig
--- a/arch/powerpc/Kconfig~use-generic-bug-for-powerpc
+++ a/arch/powerpc/Kconfig
@@ -99,6 +99,11 @@ config AUDIT_ARCH
 	bool
 	default y
 
+config GENERIC_BUG
+	bool
+	default y
+	depends on BUG
+
 config DEFAULT_UIMAGE
 	bool
 	help
diff -puN arch/powerpc/kernel/module_32.c~use-generic-bug-for-powerpc arch/powerpc/kernel/module_32.c
--- a/arch/powerpc/kernel/module_32.c~use-generic-bug-for-powerpc
+++ a/arch/powerpc/kernel/module_32.c
@@ -23,6 +23,7 @@
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/cache.h>
+#include <linux/bug.h>
 
 #if 0
 #define DEBUGP printk
@@ -273,48 +274,10 @@ int module_finalize(const Elf_Ehdr *hdr,
 		    const Elf_Shdr *sechdrs,
 		    struct module *me)
 {
-	char *secstrings;
-	unsigned int i;
-
-	me->arch.bug_table = NULL;
-	me->arch.num_bugs = 0;
-
-	/* Find the __bug_table section, if present */
-	secstrings = (char *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
-	for (i = 1; i < hdr->e_shnum; i++) {
-		if (strcmp(secstrings+sechdrs[i].sh_name, "__bug_table"))
-			continue;
-		me->arch.bug_table = (void *) sechdrs[i].sh_addr;
-		me->arch.num_bugs = sechdrs[i].sh_size / sizeof(struct bug_entry);
-		break;
-	}
-
-	/*
-	 * Strictly speaking this should have a spinlock to protect against
-	 * traversals, but since we only traverse on BUG()s, a spinlock
-	 * could potentially lead to deadlock and thus be counter-productive.
-	 */
-	list_add(&me->arch.bug_list, &module_bug_list);
-
-	return 0;
+	return module_bug_finalize(hdr, sechdrs, me);
 }
 
 void module_arch_cleanup(struct module *mod)
 {
-	list_del(&mod->arch.bug_list);
-}
-
-struct bug_entry *module_find_bug(unsigned long bugaddr)
-{
-	struct mod_arch_specific *mod;
-	unsigned int i;
-	struct bug_entry *bug;
-
-	list_for_each_entry(mod, &module_bug_list, bug_list) {
-		bug = mod->bug_table;
-		for (i = 0; i < mod->num_bugs; ++i, ++bug)
-			if (bugaddr == bug->bug_addr)
-				return bug;
-	}
-	return NULL;
+	module_bug_cleanup(mod);
 }
diff -puN arch/powerpc/kernel/module_64.c~use-generic-bug-for-powerpc arch/powerpc/kernel/module_64.c
--- a/arch/powerpc/kernel/module_64.c~use-generic-bug-for-powerpc
+++ a/arch/powerpc/kernel/module_64.c
@@ -20,6 +20,7 @@
 #include <linux/moduleloader.h>
 #include <linux/err.h>
 #include <linux/vmalloc.h>
+#include <linux/bug.h>
 #include <asm/module.h>
 #include <asm/uaccess.h>
 
@@ -416,48 +417,10 @@ LIST_HEAD(module_bug_list);
 int module_finalize(const Elf_Ehdr *hdr,
 		const Elf_Shdr *sechdrs, struct module *me)
 {
-	char *secstrings;
-	unsigned int i;
-
-	me->arch.bug_table = NULL;
-	me->arch.num_bugs = 0;
-
-	/* Find the __bug_table section, if present */
-	secstrings = (char *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
-	for (i = 1; i < hdr->e_shnum; i++) {
-		if (strcmp(secstrings+sechdrs[i].sh_name, "__bug_table"))
-			continue;
-		me->arch.bug_table = (void *) sechdrs[i].sh_addr;
-		me->arch.num_bugs = sechdrs[i].sh_size / sizeof(struct bug_entry);
-		break;
-	}
-
-	/*
-	 * Strictly speaking this should have a spinlock to protect against
-	 * traversals, but since we only traverse on BUG()s, a spinlock
-	 * could potentially lead to deadlock and thus be counter-productive.
-	 */
-	list_add(&me->arch.bug_list, &module_bug_list);
-
-	return 0;
+	return module_bug_finalize(hdr, sechdrs, me);
 }
 
 void module_arch_cleanup(struct module *mod)
 {
-	list_del(&mod->arch.bug_list);
-}
-
-struct bug_entry *module_find_bug(unsigned long bugaddr)
-{
-	struct mod_arch_specific *mod;
-	unsigned int i;
-	struct bug_entry *bug;
-
-	list_for_each_entry(mod, &module_bug_list, bug_list) {
-		bug = mod->bug_table;
-		for (i = 0; i < mod->num_bugs; ++i, ++bug)
-			if (bugaddr == bug->bug_addr)
-				return bug;
-	}
-	return NULL;
+	module_bug_cleanup(mod);
 }
diff -puN arch/powerpc/kernel/traps.c~use-generic-bug-for-powerpc arch/powerpc/kernel/traps.c
--- a/arch/powerpc/kernel/traps.c~use-generic-bug-for-powerpc
+++ a/arch/powerpc/kernel/traps.c
@@ -32,6 +32,7 @@
 #include <linux/kprobes.h>
 #include <linux/kexec.h>
 #include <linux/backlight.h>
+#include <linux/bug.h>
 
 #include <asm/kdebug.h>
 #include <asm/pgtable.h>
@@ -740,45 +741,9 @@ static int emulate_instruction(struct pt
  */
 extern struct bug_entry __start___bug_table[], __stop___bug_table[];
 
-#ifndef CONFIG_MODULES
-#define module_find_bug(x)	NULL
-#endif
-
-struct bug_entry *find_bug(unsigned long bugaddr)
+int is_valid_bugaddr(unsigned long addr)
 {
-	struct bug_entry *bug;
-
-	for (bug = __start___bug_table; bug < __stop___bug_table; ++bug)
-		if (bugaddr == bug->bug_addr)
-			return bug;
-	return module_find_bug(bugaddr);
-}
-
-static int check_bug_trap(struct pt_regs *regs)
-{
-	struct bug_entry *bug;
-	unsigned long addr;
-
-	if (regs->msr & MSR_PR)
-		return 0;	/* not in kernel */
-	addr = regs->nip;	/* address of trap instruction */
-	if (addr < PAGE_OFFSET)
-		return 0;
-	bug = find_bug(regs->nip);
-	if (bug == NULL)
-		return 0;
-	if (bug->line & BUG_WARNING_TRAP) {
-		/* this is a WARN_ON rather than BUG/BUG_ON */
-		printk(KERN_ERR "Badness in %s at %s:%ld\n",
-		       bug->function, bug->file,
-		       bug->line & ~BUG_WARNING_TRAP);
-		dump_stack();
-		return 1;
-	}
-	printk(KERN_CRIT "kernel BUG in %s at %s:%ld!\n",
-	       bug->function, bug->file, bug->line);
-
-	return 0;
+	return addr >= PAGE_OFFSET;
 }
 
 void __kprobes program_check_exception(struct pt_regs *regs)
@@ -812,7 +777,9 @@ void __kprobes program_check_exception(s
 			return;
 		if (debugger_bpt(regs))
 			return;
-		if (check_bug_trap(regs)) {
+
+		if (!(regs->msr & MSR_PR) &&  /* not user-mode */
+		    report_bug(regs->nip)) {
 			regs->nip += 4;
 			return;
 		}
diff -puN arch/powerpc/kernel/vmlinux.lds.S~use-generic-bug-for-powerpc arch/powerpc/kernel/vmlinux.lds.S
--- a/arch/powerpc/kernel/vmlinux.lds.S~use-generic-bug-for-powerpc
+++ a/arch/powerpc/kernel/vmlinux.lds.S
@@ -61,11 +61,7 @@ SECTIONS
 		__stop___ex_table = .;
 	}
 
-	__bug_table : {
-		__start___bug_table = .;
-		*(__bug_table)
-		__stop___bug_table = .;
-	}
+	BUG_TABLE
 
 /*
  * Init sections discarded at runtime
diff -puN include/asm-powerpc/bug.h~use-generic-bug-for-powerpc include/asm-powerpc/bug.h
--- a/include/asm-powerpc/bug.h~use-generic-bug-for-powerpc
+++ a/include/asm-powerpc/bug.h
@@ -20,8 +20,6 @@ struct bug_entry {
 	const char	*function;
 };
 
-struct bug_entry *find_bug(unsigned long bugaddr);
-
 /*
  * If this bit is set in the line number it means that the trap
  * is for WARN_ON rather than BUG or BUG_ON.
@@ -30,6 +28,26 @@ struct bug_entry *find_bug(unsigned long
 
 #ifdef CONFIG_BUG
 
+static inline int is_warning_bug(const struct bug_entry *bug)
+{
+	return bug->line & BUG_WARNING_TRAP;
+}
+
+static inline const char *bug_get_function(const struct bug_entry *bug)
+{
+	return bug->function;
+}
+
+static inline const char *bug_get_file(const struct bug_entry *bug)
+{
+	return bug->file;
+}
+
+static inline unsigned bug_get_line(const struct bug_entry *bug)
+{
+	return (unsigned)(bug->line & ~BUG_WARNING_TRAP);
+}
+
 /*
  * BUG_ON() and WARN_ON() do their best to cooperate with compile-time
  * optimisations. However depending on the complexity of the condition
diff -puN include/linux/bug.h~use-generic-bug-for-powerpc include/linux/bug.h
--- a/include/linux/bug.h~use-generic-bug-for-powerpc
+++ a/include/linux/bug.h
@@ -6,6 +6,8 @@
 #ifdef CONFIG_GENERIC_BUG
 #include <linux/module.h>
 
+const struct bug_entry *find_bug(unsigned long bugaddr);
+
 int report_bug(unsigned long bug_addr);
 
 int  module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
diff -puN arch/powerpc/xmon/xmon.c~use-generic-bug-for-powerpc arch/powerpc/xmon/xmon.c
--- a/arch/powerpc/xmon/xmon.c~use-generic-bug-for-powerpc
+++ a/arch/powerpc/xmon/xmon.c
@@ -19,6 +19,7 @@
 #include <linux/module.h>
 #include <linux/sysrq.h>
 #include <linux/interrupt.h>
+#include <linux/bug.h>
 
 #include <asm/ptrace.h>
 #include <asm/string.h>
@@ -32,7 +33,6 @@
 #include <asm/cputable.h>
 #include <asm/rtas.h>
 #include <asm/sstep.h>
-#include <asm/bug.h>
 
 #ifdef CONFIG_PPC64
 #include <asm/hvcall.h>
@@ -1329,7 +1329,7 @@ static void backtrace(struct pt_regs *ex
 
 static void print_bug_trap(struct pt_regs *regs)
 {
-	struct bug_entry *bug;
+	const struct bug_entry *bug;
 	unsigned long addr;
 
 	if (regs->msr & MSR_PR)
@@ -1340,11 +1340,12 @@ static void print_bug_trap(struct pt_reg
 	bug = find_bug(regs->nip);
 	if (bug == NULL)
 		return;
-	if (bug->line & BUG_WARNING_TRAP)
+	if (is_warning_bug(bug))
 		return;
 
-	printf("kernel BUG in %s at %s:%d!\n",
-	       bug->function, bug->file, (unsigned int)bug->line);
+	printf("kernel BUG in %s at %s:%u!\n",
+		bug_get_function(bug), bug_get_file(bug),
+		bug_get_line(bug));
 }
 
 void excprint(struct pt_regs *fp)
diff -puN include/asm-powerpc/module.h~use-generic-bug-for-powerpc include/asm-powerpc/module.h
--- a/include/asm-powerpc/module.h~use-generic-bug-for-powerpc
+++ a/include/asm-powerpc/module.h
@@ -46,8 +46,6 @@ struct mod_arch_specific {
 	unsigned int num_bugs;
 };
 
-extern struct bug_entry *module_find_bug(unsigned long bugaddr);
-
 /*
  * Select ELF headers.
  * Make empty section for module_frob_arch_sections to expand.
diff -puN lib/bug.c~use-generic-bug-for-powerpc lib/bug.c
--- a/lib/bug.c~use-generic-bug-for-powerpc
+++ a/lib/bug.c
@@ -64,7 +64,7 @@ static inline const struct bug_entry *mo
 }
 #endif
 
-static const struct bug_entry *find_bug(unsigned long bugaddr)
+const struct bug_entry *find_bug(unsigned long bugaddr)
 {
 	const struct bug_entry *bug;
 
_

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

origin.patch
x86-remove-default_ldt-and-simplify-ldt-setting.patch
use-generic-bug-for-powerpc.patch
use-generic-bug-for-powerpc-fix-2.patch
bug-test-1.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