From: Daniel Thompson <daniel.thompson@linaro.org>
To: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Douglas Anderson <dianders@chromium.org>,
Jason Wessel <jason.wessel@windriver.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, patches@linaro.org
Subject: Re: [PATCH v2] arm64: cacheflush: Fix KGDB trap detection
Date: Wed, 6 May 2020 16:06:09 +0100 [thread overview]
Message-ID: <20200506150609.kya3nygfvdwvimad@holly.lan> (raw)
In-Reply-To: <20200505150916.GC24239@willie-the-truck>
On Tue, May 05, 2020 at 04:09:16PM +0100, Will Deacon wrote:
> On Tue, May 05, 2020 at 03:15:29PM +0100, Daniel Thompson wrote:
> > On Mon, May 04, 2020 at 09:48:04PM +0100, Will Deacon wrote:
> > > On Mon, May 04, 2020 at 06:05:18PM +0100, Daniel Thompson wrote:
> > > > diff --git a/arch/arm64/include/asm/cacheflush.h b/arch/arm64/include/asm/cacheflush.h
> > > > index e6cca3d4acf7..ce50c1f1f1ea 100644
> > > > --- a/arch/arm64/include/asm/cacheflush.h
> > > > +++ b/arch/arm64/include/asm/cacheflush.h
> > > > @@ -79,7 +79,7 @@ static inline void flush_icache_range(unsigned long start, unsigned long end)
> > > > * IPI all online CPUs so that they undergo a context synchronization
> > > > * event and are forced to refetch the new instructions.
> > > > */
> > > > -#ifdef CONFIG_KGDB
> > > > +
> > > > /*
> > > > * KGDB performs cache maintenance with interrupts disabled, so we
> > > > * will deadlock trying to IPI the secondary CPUs. In theory, we can
> > > > @@ -89,9 +89,9 @@ static inline void flush_icache_range(unsigned long start, unsigned long end)
> > > > * the patching operation, so we don't need extra IPIs here anyway.
> > > > * In which case, add a KGDB-specific bodge and return early.
> > > > */
> > > > - if (kgdb_connected && irqs_disabled())
> > > > + if (in_dbg_master())
> > >
> > > Does this imply that irqs are disabled?
> >
> > Yes.
Except for bugs...
> >
> > Assuming CONFIG_KGDB is enabled then in_dbg_master() expands to:
> >
> > (raw_smp_processor_id() == atomic_read(&kgdb_active))
>
> Aha, so this can drop the raw_ prefix and call smp_processor_id() instead?
We need to allow in_dbg_master() to be called from preemptible contexts
(because its job it to disclose information about our executions
context) but given irqs are always disabled when we in_dbg_master()
then I think we can make this and rely on short-circuit eval to
avoid PREEMPT_DEBUG errors:
(irqs_disabled() && (smp_processor_id() == atomic_read(&kgdb_active)))
> I can queue the arm64 patch regardless.
I don't want to hide anything... when I looked closer I realized
that the above change also eliminates a small window where the original
macro can spuriously evaluate to true.
Specifically if we migrate to a new core after reading the processor
id and the previous core takes a breakpoint then we would evaluate
true if we read kgdb_active before we get the IPI to bring us to halt.
Sorry for overlooking this in my reply yesterday! I'll have a patch out
for this shortly.
Daniel.
next prev parent reply other threads:[~2020-05-06 15:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-04 17:05 [PATCH v2] arm64: cacheflush: Fix KGDB trap detection Daniel Thompson
2020-05-04 20:48 ` Will Deacon
2020-05-05 14:15 ` Daniel Thompson
2020-05-05 15:09 ` Will Deacon
2020-05-06 15:06 ` Daniel Thompson [this message]
2020-05-05 16:13 ` 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=20200506150609.kya3nygfvdwvimad@holly.lan \
--to=daniel.thompson@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=dianders@chromium.org \
--cc=jason.wessel@windriver.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@linaro.org \
--cc=will@kernel.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).