arm64: Catch non-emulated semihosting calls
authorSean Anderson <sean.anderson@seco.com>
Tue, 22 Mar 2022 20:59:31 +0000 (16:59 -0400)
committerTom Rini <trini@konsulko.com>
Fri, 1 Apr 2022 20:56:53 +0000 (16:56 -0400)
commitbbe310cdaf459b0ee69534584128ed6e057568db
treeedbe519a7ce112aee71f90b4d1b2f6b7926942ae
parent385d69d76b4216c10083f908005983d0c62e159c
arm64: Catch non-emulated semihosting calls

If a debugger is not attached to U-Boot, semihosting calls will raise a
synchronous abort exception. Try to catch this and disable semihosting
so we can e.g. use another uart if one is available. In the immediate
case, we return an error, since it is not always possible to check for
semihosting beforehand (debug uart, user-initiated load command, etc.)

We handle all possible semihosting instructions, which is probably
overkill. However, we do need to keep track of what instruction set
we're using so that we don't suppress an actual error.

A future enhancement could try to determine semihosting capability by
inspecting the processor state.  There's an example of this at [1] for
RISC-V. The equivalent for ARM would inspect the monitor modei
enable/select bits of the DSCR. However, as the article notes, an
exception handler is still helpful in order to catch disconnected
debuggers.

[1] https://tomverbeure.github.io/2021/12/30/Semihosting-on-RISCV.html#avoiding-hangs-when-a-debugger-is-not-connected

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
arch/arm/lib/interrupts_64.c
include/semihosting.h