Re: [PATCH v4 13/16] arm/ftrace: Use __patch_text_real()
From: Will Deacon
Date: Mon Oct 28 2019 - 12:48:08 EST
On Mon, Oct 28, 2019 at 05:34:21PM +0100, Peter Zijlstra wrote:
> On Mon, Oct 28, 2019 at 04:25:26PM +0000, Will Deacon wrote:
> > On Fri, Oct 18, 2019 at 09:35:38AM +0200, Peter Zijlstra wrote:
> > > @@ -97,10 +100,7 @@ static int ftrace_modify_code(unsigned l
> > > 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);
> > Why can't you just pass 'true' for patch_text_remap? AFAICT, the only
> > time you want to pass false is during early boot when the text is
> > assumedly still writable without the fixmap.
> Ah, it will also become true for module loading once we rework where we
> flip the module text RO,X. See this patch:
> But for that to land, there's still a few other issues to fix (KLP).
Passing 'true' would still work though, right? Just feels a bit error
prone having to maintain the state of patch_test_remap() and remember
that 'ftrace_lock' is holding the concurrency together.