linux-user/arm: BKPT should cause SIGTRAP, not be a syscall
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 20 Apr 2020 21:22:03 +0000 (22:22 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 21 May 2020 19:00:18 +0000 (20:00 +0100)
commit13a0c21e64bddf1a3659d30b2b6e95529f9047ed
treebf15cde0ed27ac2128e26e6cd7eb972c4f244a48
parent9f8f640eae8a875fa302d64748985bf21dc7f907
linux-user/arm: BKPT should cause SIGTRAP, not be a syscall

In linux-user/arm/cpu-loop.c we incorrectly treat EXCP_BKPT similarly
to EXCP_SWI, which means that if the guest executes a BKPT insn then
QEMU will perform a syscall for it (which syscall depends on what
value happens to be in r7...). The correct behaviour is that the
guest process should take a SIGTRAP.

This code has been like this (more or less) since commit
06c949e62a098f in 2006 which added BKPT in the first place.  This is
probably because at the time the same code path was used to handle
both Linux syscalls and semihosting calls, and (on M profile) BKPT
with a suitable magic number is used for semihosting calls.  But
these days we've moved handling of semihosting out to an entirely
different codepath, so we can fix this bug by simply removing this
handling of EXCP_BKPT and instead making it deliver a SIGTRAP like
EXCP_DEBUG (as we do already on aarch64).

Reported-by: <omerg681@gmail.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20200420212206.12776-2-peter.maydell@linaro.org
Fixes: https://bugs.launchpad.net/qemu/+bug/1873898
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
linux-user/arm/cpu_loop.c