Re: [PATCH] arm64: cacheflush: Fix KGDB trap detection

From: Doug Anderson
Date: Fri May 01 2020 - 14:15:49 EST


Hi,

On Fri, May 1, 2020 at 9:20 AM Daniel Thompson
<daniel.thompson@xxxxxxxxxx> wrote:
>
> flush_icache_range() contains a bodge to avoid issuing IPIs when the kgdb
> trap handler is running because issuing IPIs is unsafe (and unnecessary)
> in this exection context. However the current test is flawed: it both

s/exection/execution/

> over-matches (could skip the IPI when the kgdb trap is not running) and
> under-matches (does not skip the IPI for all kgdb cache operations).

Maybe explain why? I believe this is because "kgdb_connected"
signifies that a host "gdb" is connected.

* If we're sitting at the kdb prompt "kgdb_connected" won't be set but
we might still try to do something with a breakpoint with interrupts
off.

* If we are currently _not_ stopped in the debugger but the host "gdb"
is connected then "kgdb_connected" will continue to be set. In this
context we will exit early if any other callers happen to try to cache
flush with interrupts disabled.


> Fix by replacing the ad-hoc check with the proper kgdb macro. This also
> allows us to drop the #ifdef wrapper.
>
> Fixes: 3b8c9f1cdfc5 ("arm64: IPI each CPU after invalidating the I-cache for kernel mappings")
> Signed-off-by: Daniel Thompson <daniel.thompson@xxxxxxxxxx>
> ---
> arch/arm64/include/asm/cacheflush.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)

Other than the suggestions to the commit message:

Reviewed-by: Douglas Anderson <dianders@xxxxxxxxxxxx>