Skip to content

Commit 5a73558

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
arm/ftrace: Use __patch_text()
Instead of flipping text protection, use the patch_text infrastructure that uses a fixmap alias where required. This removes the last user of set_all_modules_text_*(). Tested-by: Will Deacon <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 5c02ece commit 5a73558

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

arch/arm/kernel/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ obj-$(CONFIG_HAVE_ARM_SCU) += smp_scu.o
4949
obj-$(CONFIG_HAVE_ARM_TWD) += smp_twd.o
5050
obj-$(CONFIG_ARM_ARCH_TIMER) += arch_timer.o
5151
obj-$(CONFIG_FUNCTION_TRACER) += entry-ftrace.o
52-
obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o insn.o
53-
obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o insn.o
52+
obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o insn.o patch.o
53+
obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o insn.o patch.o
5454
obj-$(CONFIG_JUMP_LABEL) += jump_label.o insn.o patch.o
5555
obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
5656
# Main staffs in KPROBES are in arch/arm/probes/ .

arch/arm/kernel/ftrace.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <asm/ftrace.h>
2323
#include <asm/insn.h>
2424
#include <asm/set_memory.h>
25+
#include <asm/patch.h>
2526

2627
#ifdef CONFIG_THUMB2_KERNEL
2728
#define NOP 0xf85deb04 /* pop.w {lr} */
@@ -35,9 +36,7 @@ static int __ftrace_modify_code(void *data)
3536
{
3637
int *command = data;
3738

38-
set_kernel_text_rw();
3939
ftrace_modify_all_code(*command);
40-
set_kernel_text_ro();
4140

4241
return 0;
4342
}
@@ -59,13 +58,11 @@ static unsigned long adjust_address(struct dyn_ftrace *rec, unsigned long addr)
5958

6059
int ftrace_arch_code_modify_prepare(void)
6160
{
62-
set_all_modules_text_rw();
6361
return 0;
6462
}
6563

6664
int ftrace_arch_code_modify_post_process(void)
6765
{
68-
set_all_modules_text_ro();
6966
/* Make sure any TLB misses during machine stop are cleared. */
7067
flush_tlb_all();
7168
return 0;
@@ -97,10 +94,7 @@ static int ftrace_modify_code(unsigned long pc, unsigned long old,
9794
return -EINVAL;
9895
}
9996

100-
if (probe_kernel_write((void *)pc, &new, MCOUNT_INSN_SIZE))
101-
return -EPERM;
102-
103-
flush_icache_range(pc, pc + MCOUNT_INSN_SIZE);
97+
__patch_text((void *)pc, new);
10498

10599
return 0;
106100
}

0 commit comments

Comments
 (0)