arm: ftrace: fix dynamic ftrace with DEBUG_RODATA and !FRAME_POINTER
Subsystems (2)
PATCH RESEND 1/1 arm: ftrace: fix dynamic ftrace with DEBUG_RODATA and !FRAME_POINTER
The support for dynamic ftrace with CONFIG_DEBUG_RODATA involves overriding the weak arch_ftrace_update_code() with a variant which makes the kernel text writable around the patching.
This override was however added under the CONFIG_OLD_MCOUNT ifdef, and CONFIG_OLD_MCOUNT is only enabled if frame pointers are enabled.
This leads to non-functional dynamic ftrace (ftrace triggers a WARN_ON()) when CONFIG_DEBUG_RODATA is enabled and CONFIG_FRAME_POINTER is not.
Move the override out of that ifdef and into the CONFIG_DYNAMIC_FTRACE ifdef where it belongs.
--- arch/arm/kernel/ftrace.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
arch/arm/kernel/ftrace.c +6 -5
@@ -29,11 +29,6 @@#endif #ifdef CONFIG_DYNAMIC_FTRACE -#ifdef CONFIG_OLD_MCOUNT -#define OLD_MCOUNT_ADDR ((unsigned long) mcount) -#define OLD_FTRACE_ADDR ((unsigned long) ftrace_caller_old) - -#define OLD_NOP 0xe1a00000 /* mov r0, r0 */static int __ftrace_modify_code (void *data) {
@@ -51,6 +46,12 @@ void arch_ftrace_update_code(int command)stop_machine (__ftrace_modify_code, &command,NULL ); } +#ifdef CONFIG_OLD_MCOUNT +#define OLD_MCOUNT_ADDR ((unsigned long) mcount) +#define OLD_FTRACE_ADDR ((unsigned long) ftrace_caller_old) + +#define OLD_NOP 0xe1a00000/* mov r0, r0 */ +static unsigned long ftrace_nop_replace (struct dyn_ftrace *rec) {return rec->arch.old_mcount ?OLD_NOP :NOP ;
Signature · 1 line
2.7.4
Quoted 14 lines · Abel Vesa
The support for dynamic ftrace with
CONFIG_DEBUG_RODATAinvolves overriding the weakarch_ftrace_update_code()with a variant which makes the kernel text writable around the patching.This override was however added under the
CONFIG_OLD_MCOUNTifdef, andCONFIG_OLD_MCOUNTis only enabled if frame pointers are enabled.This leads to non-functional dynamic ftrace (ftrace triggers a
WARN_ON()) whenCONFIG_DEBUG_RODATAis enabled andCONFIG_FRAME_POINTERis not.Move the override out of that ifdef and into the
CONFIG_DYNAMIC_FTRACEifdef where it belongs.
Quoted 6 lines
Fixes 80d6b0c2eed2a ("ARM: mm: allow text and rodata sections to be read-only")Suggested-by Nicolai Stange <[email protected]>Suggested-by Rabin Vincent <[email protected]>Signed-off-by Abel Vesa <[email protected]>Acked-by Rabin Vincent <[email protected]>
This looks fine to me. I'd send it to the ARM patch tracker since you've gotten an Ack:
http://www.arm.linux.org.uk/developer/patches/info.php
-Kees
Quoted 36 lines
--- arch/arm/kernel/ftrace.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)arch/arm/kernel/ftrace.c +6
-6@@ -29,11 +29,6 @@#endif #ifdef CONFIG_DYNAMIC_FTRACE -#ifdef CONFIG_OLD_MCOUNT -#define OLD_MCOUNT_ADDR ((unsigned long) mcount) -#define OLD_FTRACE_ADDR ((unsigned long) ftrace_caller_old) - -#define OLD_NOP 0xe1a00000 /* mov r0, r0 */static int __ftrace_modify_code (void *data) {@@ -51,6 +46,12 @@ void arch_ftrace_update_code(int command)stop_machine (__ftrace_modify_code, &command,NULL ); } +#ifdef CONFIG_OLD_MCOUNT +#define OLD_MCOUNT_ADDR ((unsigned long) mcount) +#define OLD_FTRACE_ADDR ((unsigned long) ftrace_caller_old) + +#define OLD_NOP 0xe1a00000/* mov r0, r0 */ +static unsigned long ftrace_nop_replace (struct dyn_ftrace *rec) {return rec->arch.old_mcount ?OLD_NOP :NOP ; --2.7.4
Signature · 2 lines
Kees Cook Pixel Security