From: Conor Dooley <conor.dooley@microchip.com>
To: Changbin Du <changbin.du@huawei.com>
Cc: Conor Dooley <conor@kernel.org>, <palmer@dabbelt.com>,
Palmer Dabbelt <palmerdabbelt@google.com>,
<linux-riscv@lists.infradead.org>,
Steven Rostedt <rostedt@goodmis.org>,
Changbin Du <changbin.du@gmail.com>,
Palmer Dabbelt <palmer@rivosinc.com>,
Hui Wang <hw.huiwang@huawei.com>
Subject: Re: [PATCH v3] RISC-V: Don't check text_mutex during stop_machine
Date: Fri, 24 Feb 2023 13:46:38 +0000 [thread overview]
Message-ID: <Y/i/vkcX5AEQ6qAm@wendy> (raw)
In-Reply-To: <20230224125857.dbsaj7mv2by66wm3@M910t>
[-- Attachment #1.1: Type: text/plain, Size: 1849 bytes --]
On Fri, Feb 24, 2023 at 08:58:57PM +0800, Changbin Du wrote:
> On Fri, Feb 24, 2023 at 11:07:42AM +0000, Conor Dooley wrote:
> > > > - lockdep_assert_held(&text_mutex);
> > > > + if (!riscv_ftrace_in_stop_machine)
> > > > + lockdep_assert_held(&text_mutex);
> > > >
> > > > if (across_pages)
> > > > patch_map(addr + len, FIX_TEXT_POKE1);
> > > This misses this function.
> > >
> > > int patch_text(void *addr, u32 insn)
> >
> > So, with a corresponding rename to the symbol, does the following look
> > okay to you?
> >
> > diff --git a/arch/riscv/kernel/probes/kprobes.c b/arch/riscv/kernel/probes/kprobes.c
> > index f21592d20306..433b454e693f 100644
> > --- a/arch/riscv/kernel/probes/kprobes.c
> > +++ b/arch/riscv/kernel/probes/kprobes.c
> > @@ -27,9 +27,15 @@ static void __kprobes arch_prepare_ss_slot(struct kprobe *p)
> >
> > p->ainsn.api.restore = (unsigned long)p->addr + offset;
> >
> > + /*
> > + * kprobes takes text_mutex, but patch_text() calls stop_machine and
> > + * lockdep gets confused by the context in which the lock is taken.
> > + */
> > + riscv_patch_in_stop_machine = true;
> > patch_text(p->ainsn.api.insn, p->opcode);
> > patch_text((void *)((unsigned long)(p->ainsn.api.insn) + offset),
> > __BUG_INSN_32);
> > + riscv_patch_in_stop_machine = false;
> > }
> hmm, why not just put 'riscv_patch_in_stop_machine' into patch_text()? Then you
> just need to modify that function.
Right, I intentionally didn't do that as `riscv_patch_in_stop_machine`
skips the lockdep check, which we only want to do for codepaths we know
the lock will be held for.
I didn't want to put it in patch_text() so if users of patch_text() that
do not take the lock are added, they will be caught.
I'm probably just erring on the paranoid/conservative side of things!
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 161 bytes --]
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2023-02-24 13:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-15 16:43 [PATCH v3] RISC-V: Don't check text_mutex during stop_machine Conor Dooley
2023-02-16 11:31 ` Changbin Du
2023-02-24 11:07 ` Conor Dooley
2023-02-24 12:58 ` Changbin Du
2023-02-24 13:46 ` Conor Dooley [this message]
2023-02-25 1:50 ` Changbin Du
2023-02-25 13:45 ` Conor Dooley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y/i/vkcX5AEQ6qAm@wendy \
--to=conor.dooley@microchip.com \
--cc=changbin.du@gmail.com \
--cc=changbin.du@huawei.com \
--cc=conor@kernel.org \
--cc=hw.huiwang@huawei.com \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=palmer@rivosinc.com \
--cc=palmerdabbelt@google.com \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox