qemu/target/arm
Peter Maydell 5e5584c89f target/arm: Don't abort on M-profile exception return in linux-user mode
An attempt to do an exception-return (branch to one of the magic
addresses) in linux-user mode for M-profile should behave like
a normal branch, because linux-user mode is always going to be
in 'handler' mode. This used to work, but we broke it when we added
support for the M-profile security extension in commit d02a8698d7.

In that commit we allowed even handler-mode calls to magic return
values to be checked for and dealt with by causing an
EXCP_EXCEPTION_EXIT exception to be taken, because this is
needed for the FNC_RETURN return-from-non-secure-function-call
handling. For system mode we added a check in do_v7m_exception_exit()
to make any spurious calls from Handler mode behave correctly, but
forgot that linux-user mode would also be affected.

How an attempted return-from-non-secure-function-call in linux-user
mode should be handled is not clear -- on real hardware it would
result in return to secure code (not to the Linux kernel) which
could then handle the error in any way it chose. For QEMU we take
the simple approach of treating this erroneous return the same way
it would be handled on a CPU without the security extensions --
treat it as a normal branch.

The upshot of all this is that for linux-user mode we should never
do any of the bx_excret magic, so the code change is simple.

This ought to be a weird corner case that only affects broken guest
code (because Linux user processes should never be attempting to do
exception returns or NS function returns), except that the code that
assigns addresses in RAM for the process and stack in our linux-user
code does not attempt to avoid this magic address range, so
legitimate code attempting to return to a trampoline routine on the
stack can fall into this case. This change fixes those programs,
but we should also look at restricting the range of memory we
use for M-profile linux-user guests to the area that would be
real RAM in hardware.

Cc: qemu-stable@nongnu.org
Reported-by: Christophe Lyon <christophe.lyon@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20190822131534.16602-1-peter.maydell@linaro.org
Fixes: https://bugs.launchpad.net/qemu/+bug/1840922
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2019-09-03 16:20:35 +01:00
..
arch_dump.c target/arm: Add aa{32, 64}_vfp_{dreg, qreg} helpers 2018-01-25 11:45:29 +00:00
arm-powerctl.c target/arm/arm-powerctl: Add new arm_set_cpu_on_and_reset() 2019-02-28 11:03:04 +00:00
arm-powerctl.h target/arm/arm-powerctl: Add new arm_set_cpu_on_and_reset() 2019-02-28 11:03:04 +00:00
arm-semi.c semihosting: split console_out into string and char versions 2019-06-12 17:53:22 +01:00
arm_ldst.h target: Do not include "exec/exec-all.h" if it is not necessary 2018-06-01 14:15:10 +02:00
cpu-param.h tcg: Split out target/arch/cpu-param.h 2019-06-10 07:03:34 -07:00
cpu-qom.h hw/core: Move cpu.c, cpu.h from qom/ to hw/core/ 2019-08-21 13:24:01 +02:00
cpu.c target/arm/cpu: Ensure we can use the pmu with kvm 2019-08-16 14:02:51 +01:00
cpu.h target/arm: Allow ARMCPRegInfo read/write functions to throw exceptions 2019-09-03 16:20:34 +01:00
cpu64.c target-arm queue: 2019-08-16 17:21:40 +01:00
crypto_helper.c target: Do not include "exec/exec-all.h" if it is not necessary 2018-06-01 14:15:10 +02:00
debug_helper.c target/arm: Move debug routines to debug_helper.c 2019-07-04 17:14:43 +01:00
gdbstub.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
gdbstub64.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
helper-a64.c Clean up inclusion of sysemu/sysemu.h 2019-08-16 13:31:53 +02:00
helper-a64.h target/arm: Split helper_msr_i_pstate into 3 2019-03-05 15:55:08 +00:00
helper-sve.h target/arm: Rewrite vector gather first-fault loads 2018-10-08 14:55:03 +01:00
helper.c target/arm: Take exceptions on ATS instructions when needed 2019-09-03 16:20:34 +01:00
helper.h target/arm: Remove helper_double_saturate 2019-08-16 14:02:50 +01:00
idau.h qom: make interface types abstract 2018-12-11 15:45:22 -02:00
internals.h target/arm: Declare some M-profile functions publicly 2019-07-01 17:29:01 +01:00
iwmmxt_helper.c target/arm: Untabify iwmmxt_helper.c 2018-08-24 13:17:48 +01:00
kvm-consts.h arm: add trailing ; after MISMATCH_CHECK 2017-02-01 03:37:18 +02:00
kvm-stub.c Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
kvm.c target-arm queue: 2019-08-16 17:21:40 +01:00
kvm32.c Clean up inclusion of sysemu/sysemu.h 2019-08-16 13:31:53 +02:00
kvm64.c target-arm queue: 2019-08-16 17:21:40 +01:00
kvm_arm.h target/arm/cpu: Ensure we can use the pmu with kvm 2019-08-16 14:02:51 +01:00
m_helper.c Clean up inclusion of sysemu/sysemu.h 2019-08-16 13:31:53 +02:00
machine.c Include hw/boards.h a bit less 2019-08-16 13:31:53 +02:00
Makefile.objs target/arm/helper: Move M profile routines to m_helper.c 2019-07-04 17:14:43 +01:00
monitor.c Include hw/boards.h a bit less 2019-08-16 13:31:53 +02:00
neon_helper.c target/arm: Use tcg_gen_abs_i64 and tcg_gen_gvec_abs 2019-05-13 22:52:08 +00:00
op_addsub.h
op_helper.c target/arm: Remove helper_double_saturate 2019-08-16 14:02:50 +01:00
pauth_helper.c target/arm: Fix output of PAuth Auth 2019-06-13 15:14:03 +01:00
psci.c sysemu: Split sysemu/runstate.h off sysemu/sysemu.h 2019-08-16 13:37:36 +02:00
sve.decode target/arm: SVE brk[ab] merging does not have s bit 2019-01-07 15:23:45 +00:00
sve_helper.c tcg: Introduce set/clear_helper_retaddr 2019-07-14 12:19:00 +02:00
tlb_helper.c target/arm: Move TLB related routines to tlb_helper.c 2019-07-01 17:29:01 +01:00
trace-events trace-events: Shorten file names in comments 2019-03-22 16:18:07 +00:00
translate-a64.c target/arm: Allow ARMCPRegInfo read/write functions to throw exceptions 2019-09-03 16:20:34 +01:00
translate-a64.h Revert "target/arm: Use unallocated_encoding for aarch32" 2019-09-03 16:20:34 +01:00
translate-sve.c tcg: Specify optional vector requirements with a list 2019-05-13 14:44:03 -07:00
translate-vfp.inc.c target/arm: Free TCG temps in trans_VMOV_64_sp() 2019-09-03 16:20:35 +01:00
translate.c target/arm: Don't abort on M-profile exception return in linux-user mode 2019-09-03 16:20:35 +01:00
translate.h Revert "target/arm: Use unallocated_encoding for aarch32" 2019-09-03 16:20:34 +01:00
vec_helper.c target/arm: Add helpers for FMLAL 2019-02-28 11:03:05 +00:00
vfp-uncond.decode target/arm: Convert VCVTA/VCVTN/VCVTP/VCVTM to decodetree 2019-06-13 15:14:04 +01:00
vfp.decode target/arm: Use vfp_expand_imm() for AArch32 VFP VMOV_imm 2019-06-17 15:14:19 +01:00
vfp_helper.c target/arm/vfp_helper: Call set_fpscr_to_host before updating to FPSCR 2019-07-08 14:11:31 +01:00