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
88 * disable irqs for the duration. Note - these functions are almost88 * disable irqs for the duration. Note - these functions are almost
89 * entirely coded in assembly.89 * entirely coded in assembly.
90 */90 */
91void __attribute__((naked)) set_fiq_regs(struct pt_regs *regs)91void __naked set_fiq_regs(struct pt_regs *regs)
92{92{
93 register unsigned long tmp;93 register unsigned long tmp;
94 asm volatile (94 asm volatile (
@@ -106,7 +106,7 @@ void __attribute__((naked)) set_fiq_regs(struct pt_regs *regs) · 11 unmodified lines
106 : "r" (&regs->ARM_r8), "I" (PSR_I_BIT | PSR_F_BIT | FIQ_MODE));106 : "r" (&regs->ARM_r8), "I" (PSR_I_BIT | PSR_F_BIT | FIQ_MODE));
107}107}
108 108
109void __attribute__((naked)) get_fiq_regs(struct pt_regs *regs)109void __naked get_fiq_regs(struct pt_regs *regs)
110{110{
111 register unsigned long tmp;111 register unsigned long tmp;
112 asm volatile (112 asm volatile (
arch/arm/mm/copypage-feroceon.c+1−1
@@ -13,7 +13,7 @@ · 12 unmodified lines
13#include <linux/init.h>13#include <linux/init.h>
14#include <linux/highmem.h>14#include <linux/highmem.h>
15 15
16static void __attribute__((naked))16static void __naked
17feroceon_copy_user_page(void *kto, const void *kfrom)17feroceon_copy_user_page(void *kto, const void *kfrom)
18{18{
19 asm("\19 asm("\
arch/arm/mm/copypage-v3.c+1−1
@@ -15,7 +15,7 @@ · 14 unmodified lines
15 *15 *
16 * FIXME: do we need to handle cache stuff...16 * FIXME: do we need to handle cache stuff...
17 */17 */
18static void __attribute__((naked))18static void __naked
19v3_copy_user_page(void *kto, const void *kfrom)19v3_copy_user_page(void *kto, const void *kfrom)
20{20{
21 asm("\n\21 asm("\n\
arch/arm/mm/copypage-v4mc.c+1−1
@@ -44,7 +44,7 @@ static DEFINE_SPINLOCK(minicache_lock); · 43 unmodified lines
44 * instruction. If your processor does not supply this, you have to write your44 * instruction. If your processor does not supply this, you have to write your
45 * own copy_user_highpage that does the right thing.45 * own copy_user_highpage that does the right thing.
46 */46 */
47static void __attribute__((naked))47static void __naked
48mc_copy_user_page(void *from, void *to)48mc_copy_user_page(void *from, void *to)
49{49{
50 asm volatile(50 asm volatile(
arch/arm/mm/copypage-v4wb.c+1−1
@@ -22,7 +22,7 @@ · 21 unmodified lines
22 * instruction. If your processor does not supply this, you have to write your22 * instruction. If your processor does not supply this, you have to write your
23 * own copy_user_highpage that does the right thing.23 * own copy_user_highpage that does the right thing.
24 */24 */
25static void __attribute__((naked))25static void __naked
26v4wb_copy_user_page(void *kto, const void *kfrom)26v4wb_copy_user_page(void *kto, const void *kfrom)
27{27{
28 asm("\28 asm("\
arch/arm/mm/copypage-v4wt.c+1−1
@@ -20,7 +20,7 @@ · 19 unmodified lines
20 * dirty data in the cache. However, we do have to ensure that20 * dirty data in the cache. However, we do have to ensure that
21 * subsequent reads are up to date.21 * subsequent reads are up to date.
22 */22 */
23static void __attribute__((naked))23static void __naked
24v4wt_copy_user_page(void *kto, const void *kfrom)24v4wt_copy_user_page(void *kto, const void *kfrom)
25{25{
26 asm("\26 asm("\
arch/arm/mm/copypage-xsc3.c+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
29 * if we eventually end up using our copied page.29 * if we eventually end up using our copied page.
30 *30 *
31 */31 */
32static void __attribute__((naked))32static void __naked
33xsc3_mc_copy_user_page(void *kto, const void *kfrom)33xsc3_mc_copy_user_page(void *kto, const void *kfrom)
34{34{
35 asm("\35 asm("\
arch/arm/mm/copypage-xscale.c+1−1
@@ -42,7 +42,7 @@ static DEFINE_SPINLOCK(minicache_lock); · 41 unmodified lines
42 * Dcache aliasing issue. The writes will be forwarded to the write buffer,42 * Dcache aliasing issue. The writes will be forwarded to the write buffer,
43 * and merged as appropriate.43 * and merged as appropriate.
44 */44 */
45static void __attribute__((naked))45static void __naked
46mc_copy_user_page(void *from, void *to)46mc_copy_user_page(void *from, void *to)
47{47{
48 /*48 /*
include/linux/compiler-gcc.h+9−1
@@ -52,7 +52,15 @@ · 51 unmodified lines
52#define __deprecated __attribute__((deprecated))52#define __deprecated __attribute__((deprecated))
53#define __packed __attribute__((packed))53#define __packed __attribute__((packed))
54#define __weak __attribute__((weak))54#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
56#define __noreturn __attribute__((noreturn))64#define __noreturn __attribute__((noreturn))
57 65
58/*66/*