[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191015144258.GQ2359@hirez.programming.kicks-ass.net>
Date: Tue, 15 Oct 2019 16:42:58 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Jessica Yu <jeyu@...nel.org>
Cc: Steven Rostedt <rostedt@...dmis.org>, x86@...nel.org,
linux-kernel@...r.kernel.org, mhiramat@...nel.org,
bristot@...hat.com, jbaron@...mai.com,
torvalds@...ux-foundation.org, tglx@...utronix.de,
mingo@...nel.org, namit@...are.com, hpa@...or.com, luto@...nel.org,
ard.biesheuvel@...aro.org, jpoimboe@...hat.com, rabin@....in,
Mark Rutland <mark.rutland@....com>,
Will Deacon <will@...nel.org>, james.morse@....com
Subject: Re: [PATCH v3 5/6] x86/ftrace: Use text_poke()
On Tue, Oct 15, 2019 at 03:56:34PM +0200, Peter Zijlstra wrote:
> Right, the problem is set_all_modules_text_*(), that relies on COMING
> having made the protection changes.
>
> After the x86 changes, there's only 2 more architectures that use that
> function. I'll work on getting those converted and then we can delete
> that function and worry no more about it.
Here's a possible patch for arch/arm, which only leaves arch/nds32/.
---
arch/arm/kernel/ftrace.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
index bda949fd84e8..c87e68e4ccf7 100644
--- a/arch/arm/kernel/ftrace.c
+++ b/arch/arm/kernel/ftrace.c
@@ -22,6 +22,7 @@
#include <asm/ftrace.h>
#include <asm/insn.h>
#include <asm/set_memory.h>
+#include <asm/patch.h>
#ifdef CONFIG_THUMB2_KERNEL
#define NOP 0xf85deb04 /* pop.w {lr} */
@@ -31,13 +32,15 @@
#ifdef CONFIG_DYNAMIC_FTRACE
+static int patch_text_remap = 0;
+
static int __ftrace_modify_code(void *data)
{
int *command = data;
- set_kernel_text_rw();
+ patch_text_remap = 1;
ftrace_modify_all_code(*command);
- set_kernel_text_ro();
+ patch_text_remap = 0;
return 0;
}
@@ -59,13 +62,13 @@ static unsigned long adjust_address(struct dyn_ftrace *rec, unsigned long addr)
int ftrace_arch_code_modify_prepare(void)
{
- set_all_modules_text_rw();
+ patch_text_remap = 1;
return 0;
}
int ftrace_arch_code_modify_post_process(void)
{
- set_all_modules_text_ro();
+ patch_text_remap = 0;
/* Make sure any TLB misses during machine stop are cleared. */
flush_tlb_all();
return 0;
@@ -97,10 +100,7 @@ static int ftrace_modify_code(unsigned long pc, unsigned long old,
return -EINVAL;
}
- if (probe_kernel_write((void *)pc, &new, MCOUNT_INSN_SIZE))
- return -EPERM;
-
- flush_icache_range(pc, pc + MCOUNT_INSN_SIZE);
+ __patch_text_real((void *)pc, new, patch_text_remap);
return 0;
}
Powered by blists - more mailing lists