]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
arm64: cacheflush: Fix KGDB trap detection
authorDaniel Thompson <daniel.thompson@linaro.org>
Mon, 4 May 2020 17:05:18 +0000 (18:05 +0100)
committerWill Deacon <will@kernel.org>
Tue, 5 May 2020 15:09:30 +0000 (16:09 +0100)
commitab8ad279ceac4fc78ae4dcf1a26326e05695e537
tree8d2198021f23edd12d20f0aed55ef2b324fb3748
parentda7bad98eebb7bedcb37cf8c34fbb0de470c2b99
arm64: cacheflush: Fix KGDB trap detection

flush_icache_range() contains a bodge to avoid issuing IPIs when the kgdb
trap handler is running because issuing IPIs is unsafe (and not needed)
in this execution context. However the current test, based on
kgdb_connected is flawed: it both over-matches and under-matches.

The over match occurs because kgdb_connected is set when gdb attaches
to the stub and remains set during normal running. This is relatively
harmelss because in almost all cases irq_disabled() will be false.

The under match is more serious. When kdb is used instead of kgdb to access
the debugger then kgdb_connected is not set in all the places that the
debug core updates sw breakpoints (and hence flushes the icache). This
can lead to deadlock.

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@linaro.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20200504170518.2959478-1-daniel.thompson@linaro.org
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/include/asm/cacheflush.h