History

[ARM] 5421/1: ftrace: fix crash due to tracing of __naked functions

This is a fix for the following crash observed in 2.6.29-rc3: http://lkml.org/lkml/2009/1/29/150 On ARM it doesn't make sense to trace a naked function because then mcount is called without stack and frame pointer being set up and there is no chance to restore the lr register to the value before mcount was called. Reported-by: Matthias Kaehlcke <matthias@kaehlcke.net> Tested-by: Matthias Kaehlcke <matthias@kaehlcke.net>

Uwe Kleine-König committed 17 years ago

Commit 446c92b1 parent 9311c599 files · +18 −10Browse files

Unified · Split

9 files
  1. arch/arm/kernel/fiq.c +2 −2
  2. arch/arm/mm/copypage-feroceon.c +1 −1
  3. arch/arm/mm/copypage-v3.c +1 −1
  4. arch/arm/mm/copypage-v4mc.c +1 −1
  5. arch/arm/mm/copypage-v4wb.c +1 −1
  6. arch/arm/mm/copypage-v4wt.c +1 −1
  7. arch/arm/mm/copypage-xsc3.c +1 −1
  8. arch/arm/mm/copypage-xscale.c +1 −1
  9. include/linux/compiler-gcc.h +9 −1
arch/arm/kernel/fiq.c+2−2
@@ -88,7 +88,7 @@ void set_fiq_handler(void *start, unsigned int length) · 87 unmodified lines
8888 * disable irqs for the duration. Note - these functions are almost
8989 * entirely coded in assembly.
9090 */
91−void __attribute__((naked)) set_fiq_regs(struct pt_regs *regs)
91+void __naked set_fiq_regs(struct pt_regs *regs)
9292 {
9393 register unsigned long tmp;
9494 asm volatile (
@@ -106,7 +106,7 @@ void __attribute__((naked)) set_fiq_regs(struct pt_regs *regs) · 11 unmodified lines
106106 : "r" (&regs->ARM_r8), "I" (PSR_I_BIT | PSR_F_BIT | FIQ_MODE));
107107 }
108108
109−void __attribute__((naked)) get_fiq_regs(struct pt_regs *regs)
109+void __naked get_fiq_regs(struct pt_regs *regs)
110110 {
111111 register unsigned long tmp;
112112 asm volatile (
arch/arm/mm/copypage-feroceon.c+1−1
@@ -13,7 +13,7 @@ · 12 unmodified lines
1313 #include <linux/init.h>
1414 #include <linux/highmem.h>
1515
16−static void __attribute__((naked))
16+static void __naked
1717 feroceon_copy_user_page(void *kto, const void *kfrom)
1818 {
1919 asm("\
arch/arm/mm/copypage-v3.c+1−1
@@ -15,7 +15,7 @@ · 14 unmodified lines
1515 *
1616 * FIXME: do we need to handle cache stuff...
1717 */
18−static void __attribute__((naked))
18+static void __naked
1919 v3_copy_user_page(void *kto, const void *kfrom)
2020 {
2121 asm("\n\
arch/arm/mm/copypage-v4mc.c+1−1
@@ -44,7 +44,7 @@ static DEFINE_SPINLOCK(minicache_lock); · 43 unmodified lines
4444 * instruction. If your processor does not supply this, you have to write your
4545 * own copy_user_highpage that does the right thing.
4646 */
47−static void __attribute__((naked))
47+static void __naked
4848 mc_copy_user_page(void *from, void *to)
4949 {
5050 asm volatile(
arch/arm/mm/copypage-v4wb.c+1−1
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 * instruction. If your processor does not supply this, you have to write your
2323 * own copy_user_highpage that does the right thing.
2424 */
25−static void __attribute__((naked))
25+static void __naked
2626 v4wb_copy_user_page(void *kto, const void *kfrom)
2727 {
2828 asm("\
arch/arm/mm/copypage-v4wt.c+1−1
@@ -20,7 +20,7 @@ · 19 unmodified lines
2020 * dirty data in the cache. However, we do have to ensure that
2121 * subsequent reads are up to date.
2222 */
23−static void __attribute__((naked))
23+static void __naked
2424 v4wt_copy_user_page(void *kto, const void *kfrom)
2525 {
2626 asm("\
arch/arm/mm/copypage-xsc3.c+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929 * if we eventually end up using our copied page.
3030 *
3131 */
32−static void __attribute__((naked))
32+static void __naked
3333 xsc3_mc_copy_user_page(void *kto, const void *kfrom)
3434 {
3535 asm("\
arch/arm/mm/copypage-xscale.c+1−1
@@ -42,7 +42,7 @@ static DEFINE_SPINLOCK(minicache_lock); · 41 unmodified lines
4242 * Dcache aliasing issue. The writes will be forwarded to the write buffer,
4343 * and merged as appropriate.
4444 */
45−static void __attribute__((naked))
45+static void __naked
4646 mc_copy_user_page(void *from, void *to)
4747 {
4848 /*
include/linux/compiler-gcc.h+9−1
@@ -52,7 +52,15 @@ · 51 unmodified lines
5252 #define __deprecated __attribute__((deprecated))
5353 #define __packed __attribute__((packed))
5454 #define __weak __attribute__((weak))
55−#define __naked __attribute__((naked))
55+
56+/*
57+ * it doesn't make sense on ARM (currently the only user of __naked) to trace
58+ * naked functions because then mcount is called without stack and frame pointer
59+ * being set up and there is no chance to restore the lr register to the value
60+ * before mcount was called.
61+ */
62+#define __naked __attribute__((naked)) notrace
63+
5664 #define __noreturn __attribute__((noreturn))
5765
5866 /*