linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: Use generic BUG() handler
@ 2011-03-16 20:27 Simon Glass
  2011-03-17 14:57 ` Questions about this patch: " anish kumar
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Simon Glass @ 2011-03-16 20:27 UTC (permalink / raw)
  To: linux-arm-kernel

From: Simon Glass <sjg@google.com>

ARM uses its own BUG() handler which makes its output slightly different
from other archtectures.

One of the problems is that the ARM implementation doesn't report the function
with the BUG() in it, but always reports the PC being in __bug(). The generic
implementation doesn't have this problem.

Currently we get something like:

kernel BUG at fs/proc/breakme.c:35!
Unable to handle kernel NULL pointer dereference at virtual address 00000000
...
PC is at __bug+0x20/0x2c

With this patch it displays:

kernel BUG at fs/proc/breakme.c:35!
Internal error: Oops - undefined instruction: 0 [#1] PREEMPT SMP
...
PC is at write_breakme+0xd0/0x1b4

This implementation uses an undefined instruction to implement BUG, and sets up
a bug table containing the relevant information. Many version of gcc do not
support %c properly for ARM (inserting a # when they shouldn't) so we work
around this using distasteful macro magic.

Also the backtrace the message now appears even when CONFIG_ARM_UNWIND is
defined.

You can fall back to the previous BUG implementation by making GENERIC_BUG
default to n in arch/arm/Kconfig.

Change-Id: I07d77c832e816f5ad2390e25f466ddf750adecf4

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 arch/arm/Kconfig              |    4 +++
 arch/arm/include/asm/bug.h    |   57 +++++++++++++++++++++++++++++++++++++++++
 arch/arm/kernel/traps.c       |   24 +++++++++++++++++
 arch/arm/kernel/vmlinux.lds.S |   12 ++++++++
 4 files changed, 97 insertions(+), 0 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 166efa2..7c8f11c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -191,6 +191,10 @@ config VECTORS_BASE
 	help
 	  The base address of exception vectors.
 
+config GENERIC_BUG
+	def_bool y
+	depends on BUG
+
 source "init/Kconfig"
 
 source "kernel/Kconfig.freezer"
diff --git a/arch/arm/include/asm/bug.h b/arch/arm/include/asm/bug.h
index 4d88425..3f8a798 100644
--- a/arch/arm/include/asm/bug.h
+++ b/arch/arm/include/asm/bug.h
@@ -3,6 +3,61 @@
 
 
 #ifdef CONFIG_BUG
+
+#ifdef CONFIG_GENERIC_BUG
+
+/*
+ * Use a suitable undefined instruction to use for ARM/Thumb2 bug handling.
+ * We need to be careful not to conflict with those used by other modules and
+ * the register_undef_hook() system.
+ */
+#ifdef CONFIG_THUMB2_KERNEL
+#define BUG_INSTR_VALUE 0xde02
+#define BUG_INSTR_TYPE ".hword "
+#else
+#define BUG_INSTR_VALUE 0xe7f001f2
+#define BUG_INSTR_TYPE ".word "
+#endif
+
+
+#define BUG() _BUG(__FILE__, __LINE__, BUG_INSTR_VALUE)
+#define _BUG(file, line, value) __BUG(file, line, value)
+
+#ifdef CONFIG_DEBUG_BUGVERBOSE
+
+/*
+ * The extra indirection is to ensure that the __FILE__ string comes through
+ * OK. Many version of gcc do not support the asm %c parameter which would be
+ * preferable to this unpleasantness. We use mergeable string sections to
+ * avoid multiple copies of the string appearing in the kernel image.
+ */
+
+#define __BUG(__file, __line, __value)				\
+do {								\
+	BUILD_BUG_ON(sizeof(struct bug_entry) != 12);		\
+	asm volatile("1:\t" BUG_INSTR_TYPE #__value "\n"	\
+		".pushsection .rodata.str, \"aMS\", 1\n"	\
+		"2:\t.asciz " #__file "\n" 			\
+		".popsection\n" 				\
+		".pushsection __bug_table,\"a\"\n"		\
+		"3:\t.word 1b, 2b\n"				\
+		"\t.hword " #__line ", 0\n"			\
+		".popsection");					\
+	unreachable();						\
+} while (0)
+
+#else  /* not CONFIG_DEBUG_BUGVERBOSE */
+
+#define __BUG(__file, __line, __value)				\
+do {								\
+	asm volatile(BUG_INSTR_TYPE #__value);			\
+	unreachable();						\
+} while (0)
+#endif  /* CONFIG_DEBUG_BUGVERBOSE */
+
+
+#else  /* not CONFIG_GENERIC_BUG */
+
 #ifdef CONFIG_DEBUG_BUGVERBOSE
 extern void __bug(const char *file, int line) __attribute__((noreturn));
 
@@ -16,6 +71,8 @@ extern void __bug(const char *file, int line) __attribute__((noreturn));
 
 #endif
 
+#endif  /* CONFIG_GENERIC_BUG */
+
 #define HAVE_ARCH_BUG
 #endif
 
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index ee57640..1199cfe 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -21,6 +21,7 @@
 #include <linux/kdebug.h>
 #include <linux/module.h>
 #include <linux/kexec.h>
+#include <linux/bug.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 
@@ -163,6 +164,7 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)
 #ifdef CONFIG_ARM_UNWIND
 static inline void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
 {
+	printk("Backtrace: ");
 	unwind_backtrace(regs, tsk);
 }
 #else
@@ -271,6 +273,8 @@ void die(const char *str, struct pt_regs *regs, int err)
 	spin_lock_irq(&die_lock);
 	console_verbose();
 	bust_spinlocks(1);
+	if (!user_mode(regs))
+		report_bug(regs->ARM_pc, regs);
 	ret = __die(str, err, thread, regs);
 
 	if (regs && kexec_should_crash(thread->task))
@@ -302,6 +306,26 @@ void arm_notify_die(const char *str, struct pt_regs *regs,
 	}
 }
 
+#ifdef CONFIG_GENERIC_BUG
+
+int is_valid_bugaddr(unsigned long pc)
+{
+#ifdef CONFIG_THUMB2_KERNEL
+	unsigned short bkpt;
+#else
+	unsigned long bkpt;
+#endif
+
+	if (pc < PAGE_OFFSET)
+		return 0;
+	if (probe_kernel_address((unsigned *)pc, bkpt))
+		return 0;
+
+	return bkpt == BUG_INSTR_VALUE;
+}
+
+#endif
+
 static LIST_HEAD(undef_hook);
 static DEFINE_SPINLOCK(undef_lock);
 
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index 6146279..4f22346 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -80,6 +80,18 @@ SECTIONS
 
 	PERCPU(PAGE_SIZE)
 
+	/*
+	* .exit.text is discarded@runtime, not link time, to deal with
+	*  references from bug_table
+	*/
+	.exit.text : AT(ADDR(.exit.text)) {
+		EXIT_TEXT
+	}
+
+	.exit.data : AT(ADDR(.exit.data)) {
+		EXIT_DATA
+	}
+
 #ifndef CONFIG_XIP_KERNEL
 	. = ALIGN(PAGE_SIZE);
 	__init_end = .;
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Questions about this patch: [PATCH] ARM: Use generic BUG() handler
  2011-03-16 20:27 [PATCH] ARM: Use generic BUG() handler Simon Glass
@ 2011-03-17 14:57 ` anish kumar
  2011-03-17 16:15   ` Simon Glass
  2011-03-29 19:02 ` Simon Glass
  2011-03-29 22:24 ` Stephen Boyd
  2 siblings, 1 reply; 5+ messages in thread
From: anish kumar @ 2011-03-17 14:57 UTC (permalink / raw)
  To: linux-arm-kernel

https://lkml.org/lkml/2011/2/28/565

I have tested this patch on my system(linux 2.6.35-android) and it is 
working
perfectly fine so wanted to understand this patch.Will this patch be 
included in
mainline?

I have few question from this thread.As my understanding of assembly is
bit limited I would appreciate if someone can just say yes/no and probably 
add
bit of words.

> This implementation uses an undefined instruction to implement BUG, and 
> sets up
> a bug table containing the relevant information. Many version of gcc do 
> not
> support %c properly for ARM (inserting a # when they shouldn't) so we work
> around this using distasteful macro magic.

This undefined instruction should cause data abort ?


> +#define BUG() _BUG(__FILE__, __LINE__, BUG_INSTR_VALUE)
> +#define _BUG(file, line, value) __BUG(file, line, value)
> +#define __BUG(__file, __line, __value) \
> +do { \
> + BUILD_BUG_ON(sizeof(struct bug_entry) != 12); \
> + asm volatile("1:\t" BUG_INSTR_TYPE #__value "\n" \
> + ".pushsection .rodata.str, \"aMS\", 1\n" \
> + "2:\t.asciz " #__file "\n" \
> + ".popsection\n" \
> + ".pushsection __bug_table,\"a\"\n" \
> + "3:\t.word 1b, 2b\n" \
> + "\t.hword " #__line ", 0\n" \
> + ".popsection"); \
> + unreachable(); \
> +} while (0)

Above piece of code i couldn't understand.As i understand this should do 
same as
original BUG() definition plus it should print the function where BUG() had 
originally
happened instead of "PC at _bug".I think in this code some 
data(guess:function name
,line no) is pushed on the stack and then popped but how this data is 
printed on console?

So kindly enlighten me on this piece of code or some pointers.Is there any 
thread which
explains about kernel fault process? 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Questions about this patch: [PATCH] ARM: Use generic BUG() handler
  2011-03-17 14:57 ` Questions about this patch: " anish kumar
@ 2011-03-17 16:15   ` Simon Glass
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Glass @ 2011-03-17 16:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Mar 17, 2011 at 7:57 AM, anish kumar
<anish198519851985@gmail.com> wrote:
> https://lkml.org/lkml/2011/2/28/565
>
> I have tested this patch on my system(linux 2.6.35-android) and it is
> working
> perfectly fine so wanted to understand this patch.Will this patch be
> included in
> mainline?

That is my intent.

> I have few question from this thread.As my understanding of assembly is
> bit limited I would appreciate if someone can just say yes/no and probably
> add
> bit of words.
>
>> This implementation uses an undefined instruction to implement BUG, and
>> sets up
>> a bug table containing the relevant information. Many version of gcc do
>> not
>> support %c properly for ARM (inserting a # when they shouldn't) so we work
>> around this using distasteful macro magic.
>
> This undefined instruction should cause data abort ?

Actually it causes an undefined instruction exception (data abort is
when a data access fails).
>
>
>> +#define BUG() _BUG(__FILE__, __LINE__, BUG_INSTR_VALUE)
>> +#define _BUG(file, line, value) __BUG(file, line, value)
>> +#define __BUG(__file, __line, __value) \
>> +do { \
>> + BUILD_BUG_ON(sizeof(struct bug_entry) != 12); \
>> + asm volatile("1:\t" BUG_INSTR_TYPE #__value "\n" \
>> + ".pushsection .rodata.str, \"aMS\", 1\n" \
>> + "2:\t.asciz " #__file "\n" \
>> + ".popsection\n" \
>> + ".pushsection __bug_table,\"a\"\n" \
>> + "3:\t.word 1b, 2b\n" \
>> + "\t.hword " #__line ", 0\n" \
>> + ".popsection"); \
>> + unreachable(); \
>> +} while (0)
>
> Above piece of code i couldn't understand.As i understand this should do
> same as
> original BUG() definition plus it should print the function where BUG() had
> originally
> happened instead of "PC at _bug".I think in this code some
> data(guess:function name
> ,line no) is pushed on the stack and then popped but how this data is
> printed on console?

It adds an entry to the bug table, which is just data stored in a
__bug_table section. Each entry is of the format struct bug_entry -
see include/asm-generic/bug.h. We store the address of the BUG (i.e.
the undef instruction), a pointer to the filename string, the line
number and some flags.

This macro adds a single instruction to the code (the undef
instruction), and then adds another 12 bytes to the bug table. The
linker collects all the bug table data into one place. Another piece
of code - report_bug() in lib/bug.c - does the actual bug reporting.
It searches the bug table until it finds the relevant address, and
prints out the filename and number.

We could store the bug information actually in the code - in a sense
this is what the current ARM implementation does. It just calls the
__bug() function with appropriate arguments. The advantage of the
table approach is that this debugging / verbose info doesn't bloat the
code, and can in principle be removed at link time if not needed,
without losing the bug reporting. I suspect on most architectures
there is an overall kernel size reduction - sizeof(1 instruction + 12
bytes) < sizeof(marshalling 3 args and calling a function) - but on
ARM this may come out even depending on the line number.

There is probably a better explanation of this somewhere.

Regards,
Simon

>
> So kindly enlighten me on this piece of code or some pointers.Is there any
> thread which
> explains about kernel fault process?
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ARM: Use generic BUG() handler
  2011-03-16 20:27 [PATCH] ARM: Use generic BUG() handler Simon Glass
  2011-03-17 14:57 ` Questions about this patch: " anish kumar
@ 2011-03-29 19:02 ` Simon Glass
  2011-03-29 22:24 ` Stephen Boyd
  2 siblings, 0 replies; 5+ messages in thread
From: Simon Glass @ 2011-03-29 19:02 UTC (permalink / raw)
  To: linux-arm-kernel

Hi, does anyone have any more comments on this? Has anyone tried it
apart from anish kumar? Thanks, Simon

On Wed, Mar 16, 2011 at 1:27 PM, Simon Glass <sjg@chromium.org> wrote:
> From: Simon Glass <sjg@google.com>
>
> ARM uses its own BUG() handler which makes its output slightly different
> from other archtectures.
>
> One of the problems is that the ARM implementation doesn't report the function
> with the BUG() in it, but always reports the PC being in __bug(). The generic
> implementation doesn't have this problem.
>
> Currently we get something like:
>
> kernel BUG at fs/proc/breakme.c:35!
> Unable to handle kernel NULL pointer dereference at virtual address 00000000
> ...
> PC is at __bug+0x20/0x2c
>
> With this patch it displays:
>
> kernel BUG at fs/proc/breakme.c:35!
> Internal error: Oops - undefined instruction: 0 [#1] PREEMPT SMP
> ...
> PC is at write_breakme+0xd0/0x1b4
>
> This implementation uses an undefined instruction to implement BUG, and sets up
> a bug table containing the relevant information. Many version of gcc do not
> support %c properly for ARM (inserting a # when they shouldn't) so we work
> around this using distasteful macro magic.
>
> Also the backtrace the message now appears even when CONFIG_ARM_UNWIND is
> defined.
>
> You can fall back to the previous BUG implementation by making GENERIC_BUG
> default to n in arch/arm/Kconfig.
>
> Change-Id: I07d77c832e816f5ad2390e25f466ddf750adecf4
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> ?arch/arm/Kconfig ? ? ? ? ? ? ?| ? ?4 +++
> ?arch/arm/include/asm/bug.h ? ?| ? 57 +++++++++++++++++++++++++++++++++++++++++
> ?arch/arm/kernel/traps.c ? ? ? | ? 24 +++++++++++++++++
> ?arch/arm/kernel/vmlinux.lds.S | ? 12 ++++++++
> ?4 files changed, 97 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 166efa2..7c8f11c 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -191,6 +191,10 @@ config VECTORS_BASE
> ? ? ? ?help
> ? ? ? ? ?The base address of exception vectors.
>
> +config GENERIC_BUG
> + ? ? ? def_bool y
> + ? ? ? depends on BUG
> +
> ?source "init/Kconfig"
>
> ?source "kernel/Kconfig.freezer"
> diff --git a/arch/arm/include/asm/bug.h b/arch/arm/include/asm/bug.h
> index 4d88425..3f8a798 100644
> --- a/arch/arm/include/asm/bug.h
> +++ b/arch/arm/include/asm/bug.h
> @@ -3,6 +3,61 @@
>
>
> ?#ifdef CONFIG_BUG
> +
> +#ifdef CONFIG_GENERIC_BUG
> +
> +/*
> + * Use a suitable undefined instruction to use for ARM/Thumb2 bug handling.
> + * We need to be careful not to conflict with those used by other modules and
> + * the register_undef_hook() system.
> + */
> +#ifdef CONFIG_THUMB2_KERNEL
> +#define BUG_INSTR_VALUE 0xde02
> +#define BUG_INSTR_TYPE ".hword "
> +#else
> +#define BUG_INSTR_VALUE 0xe7f001f2
> +#define BUG_INSTR_TYPE ".word "
> +#endif
> +
> +
> +#define BUG() _BUG(__FILE__, __LINE__, BUG_INSTR_VALUE)
> +#define _BUG(file, line, value) __BUG(file, line, value)
> +
> +#ifdef CONFIG_DEBUG_BUGVERBOSE
> +
> +/*
> + * The extra indirection is to ensure that the __FILE__ string comes through
> + * OK. Many version of gcc do not support the asm %c parameter which would be
> + * preferable to this unpleasantness. We use mergeable string sections to
> + * avoid multiple copies of the string appearing in the kernel image.
> + */
> +
> +#define __BUG(__file, __line, __value) ? ? ? ? ? ? ? ? ? ? ? ? \
> +do { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> + ? ? ? BUILD_BUG_ON(sizeof(struct bug_entry) != 12); ? ? ? ? ? \
> + ? ? ? asm volatile("1:\t" BUG_INSTR_TYPE #__value "\n" ? ? ? ?\
> + ? ? ? ? ? ? ? ".pushsection .rodata.str, \"aMS\", 1\n" ? ? ? ?\
> + ? ? ? ? ? ? ? "2:\t.asciz " #__file "\n" ? ? ? ? ? ? ? ? ? ? ?\
> + ? ? ? ? ? ? ? ".popsection\n" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> + ? ? ? ? ? ? ? ".pushsection __bug_table,\"a\"\n" ? ? ? ? ? ? ?\
> + ? ? ? ? ? ? ? "3:\t.word 1b, 2b\n" ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> + ? ? ? ? ? ? ? "\t.hword " #__line ", 0\n" ? ? ? ? ? ? ? ? ? ? \
> + ? ? ? ? ? ? ? ".popsection"); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> + ? ? ? unreachable(); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> +} while (0)
> +
> +#else ?/* not CONFIG_DEBUG_BUGVERBOSE */
> +
> +#define __BUG(__file, __line, __value) ? ? ? ? ? ? ? ? ? ? ? ? \
> +do { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> + ? ? ? asm volatile(BUG_INSTR_TYPE #__value); ? ? ? ? ? ? ? ? ?\
> + ? ? ? unreachable(); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> +} while (0)
> +#endif ?/* CONFIG_DEBUG_BUGVERBOSE */
> +
> +
> +#else ?/* not CONFIG_GENERIC_BUG */
> +
> ?#ifdef CONFIG_DEBUG_BUGVERBOSE
> ?extern void __bug(const char *file, int line) __attribute__((noreturn));
>
> @@ -16,6 +71,8 @@ extern void __bug(const char *file, int line) __attribute__((noreturn));
>
> ?#endif
>
> +#endif ?/* CONFIG_GENERIC_BUG */
> +
> ?#define HAVE_ARCH_BUG
> ?#endif
>
> diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
> index ee57640..1199cfe 100644
> --- a/arch/arm/kernel/traps.c
> +++ b/arch/arm/kernel/traps.c
> @@ -21,6 +21,7 @@
> ?#include <linux/kdebug.h>
> ?#include <linux/module.h>
> ?#include <linux/kexec.h>
> +#include <linux/bug.h>
> ?#include <linux/delay.h>
> ?#include <linux/init.h>
>
> @@ -163,6 +164,7 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)
> ?#ifdef CONFIG_ARM_UNWIND
> ?static inline void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
> ?{
> + ? ? ? printk("Backtrace: ");
> ? ? ? ?unwind_backtrace(regs, tsk);
> ?}
> ?#else
> @@ -271,6 +273,8 @@ void die(const char *str, struct pt_regs *regs, int err)
> ? ? ? ?spin_lock_irq(&die_lock);
> ? ? ? ?console_verbose();
> ? ? ? ?bust_spinlocks(1);
> + ? ? ? if (!user_mode(regs))
> + ? ? ? ? ? ? ? report_bug(regs->ARM_pc, regs);
> ? ? ? ?ret = __die(str, err, thread, regs);
>
> ? ? ? ?if (regs && kexec_should_crash(thread->task))
> @@ -302,6 +306,26 @@ void arm_notify_die(const char *str, struct pt_regs *regs,
> ? ? ? ?}
> ?}
>
> +#ifdef CONFIG_GENERIC_BUG
> +
> +int is_valid_bugaddr(unsigned long pc)
> +{
> +#ifdef CONFIG_THUMB2_KERNEL
> + ? ? ? unsigned short bkpt;
> +#else
> + ? ? ? unsigned long bkpt;
> +#endif
> +
> + ? ? ? if (pc < PAGE_OFFSET)
> + ? ? ? ? ? ? ? return 0;
> + ? ? ? if (probe_kernel_address((unsigned *)pc, bkpt))
> + ? ? ? ? ? ? ? return 0;
> +
> + ? ? ? return bkpt == BUG_INSTR_VALUE;
> +}
> +
> +#endif
> +
> ?static LIST_HEAD(undef_hook);
> ?static DEFINE_SPINLOCK(undef_lock);
>
> diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
> index 6146279..4f22346 100644
> --- a/arch/arm/kernel/vmlinux.lds.S
> +++ b/arch/arm/kernel/vmlinux.lds.S
> @@ -80,6 +80,18 @@ SECTIONS
>
> ? ? ? ?PERCPU(PAGE_SIZE)
>
> + ? ? ? /*
> + ? ? ? * .exit.text is discarded at runtime, not link time, to deal with
> + ? ? ? * ?references from bug_table
> + ? ? ? */
> + ? ? ? .exit.text : AT(ADDR(.exit.text)) {
> + ? ? ? ? ? ? ? EXIT_TEXT
> + ? ? ? }
> +
> + ? ? ? .exit.data : AT(ADDR(.exit.data)) {
> + ? ? ? ? ? ? ? EXIT_DATA
> + ? ? ? }
> +
> ?#ifndef CONFIG_XIP_KERNEL
> ? ? ? ?. = ALIGN(PAGE_SIZE);
> ? ? ? ?__init_end = .;
> --
> 1.7.3.1
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ARM: Use generic BUG() handler
  2011-03-16 20:27 [PATCH] ARM: Use generic BUG() handler Simon Glass
  2011-03-17 14:57 ` Questions about this patch: " anish kumar
  2011-03-29 19:02 ` Simon Glass
@ 2011-03-29 22:24 ` Stephen Boyd
  2 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2011-03-29 22:24 UTC (permalink / raw)
  To: linux-arm-kernel

On 3/16/2011 1:27 PM, Simon Glass wrote:
> diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
> index 6146279..4f22346 100644
> --- a/arch/arm/kernel/vmlinux.lds.S
> +++ b/arch/arm/kernel/vmlinux.lds.S
> @@ -80,6 +80,18 @@ SECTIONS
>  
>  	PERCPU(PAGE_SIZE)
>  
> +	/*
> +	* .exit.text is discarded at runtime, not link time, to deal with
> +	*  references from bug_table
> +	*/
> +	.exit.text : AT(ADDR(.exit.text)) {
> +		EXIT_TEXT
> +	}
> +
> +	.exit.data : AT(ADDR(.exit.data)) {
> +		EXIT_DATA
> +	}
> +
>  #ifndef CONFIG_XIP_KERNEL
>  	. = ALIGN(PAGE_SIZE);
>  	__init_end = .;

Should this be using the ARM_EXIT_KEEP macro instead? It seems like you
could add another condition to that macro like:

#if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || defined(CONFIG_GENERIC_BUG)
#define ARM_EXIT_KEEP(x)        x
#else
#define ARM_EXIT_KEEP(x)
#endif


and then drop this hunk here. Plus, this might be better because if you
have BUG=n and SMP_ON_UP=n you can drop the exit sections at link time
still, but with your patch they get dropped at runtime, right?

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-03-29 22:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-16 20:27 [PATCH] ARM: Use generic BUG() handler Simon Glass
2011-03-17 14:57 ` Questions about this patch: " anish kumar
2011-03-17 16:15   ` Simon Glass
2011-03-29 19:02 ` Simon Glass
2011-03-29 22:24 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).