linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] arm64: IPI each CPU after invalidating the I-cache for kernel mappings
Date: Tue, 19 Jun 2018 17:50:19 +0100	[thread overview]
Message-ID: <20180619165019.GU13984@arm.com> (raw)
In-Reply-To: <20180619135528.4rxgluvroybxgxem@lakrids.cambridge.arm.com>

On Tue, Jun 19, 2018 at 02:55:28PM +0100, Mark Rutland wrote:
> On Tue, Jun 19, 2018 at 01:48:15PM +0100, Will Deacon wrote:
> > diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c
> > index 816d03c4c913..4cc41864f277 100644
> > --- a/arch/arm64/kernel/insn.c
> > +++ b/arch/arm64/kernel/insn.c
> > @@ -249,7 +249,6 @@ static int __kprobes aarch64_insn_patch_text_cb(void *arg)
> >  	} else {
> >  		while (atomic_read(&pp->cpu_count) <= num_online_cpus())
> >  			cpu_relax();
> > -		isb();
> >  	}
> 
> Something seems amiss here. 
> 
> We call __apply_alternatives_multi_stop() via stop_machine(), and I
> thought that ensured that all CPUs had IRQs masked.
> 
> If so, the IPI from flush_icache_range() will deadlock.
> 
> If not, we can take IRQs, and execute potentially patched code.

Yes, I think you're right, and I think this only applies to kprobes (since
it patches arbitrary instructions and requires the stop_machine()). However,
I think that highlights another issue, which is that the "nosync" patching
cases as used by things like jump_labels are still going to want this IPI,
so actually the fastpath stuff can all be ripped out. ftrace can probably
be left as-is, since I doubt it's critical that new CPUs immediately see
dynamic tracepoints.

I'll cook a patch sorting this out and include it in v2.

> I think there's also an existing problem here. Even if with have IRQs
> masked, we could take SDEI events (or GICv3 psudeo-NMIs, once we have
> those). I don't know how we can manage those.

I guess there are just some places where we can't deal with an SDEI event.
That said, it's fine as long as the SDEI path is careful about what it runs
(and SDEI is masked until the worst of the patching is over during boot).

James?

Will

  parent reply	other threads:[~2018-06-19 16:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19 12:48 [PATCH 0/3] I-side fixes Will Deacon
2018-06-19 12:48 ` [PATCH 1/3] arm64: Avoid flush_icache_range() in alternatives patching code Will Deacon
2018-06-19 13:33   ` Mark Rutland
2018-06-19 12:48 ` [PATCH 2/3] arm64: Remove unnecessary ISBs from set_{pte,pmd,pud} Will Deacon
2018-06-19 13:34   ` [PATCH 2/3] arm64: Remove unnecessary ISBs from set_{pte, pmd, pud} Mark Rutland
2018-06-20 15:32   ` Catalin Marinas
2018-06-19 12:48 ` [PATCH 3/3] arm64: IPI each CPU after invalidating the I-cache for kernel mappings Will Deacon
2018-06-19 13:55   ` Mark Rutland
2018-06-19 13:59     ` Mark Rutland
2018-06-19 16:50     ` Will Deacon [this message]
2018-06-21 10:24       ` James Morse
2018-06-20 16:01   ` Alexander Van Brunt
2018-06-20 17:01     ` Will Deacon

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=20180619165019.GU13984@arm.com \
    --to=will.deacon@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).