unicorn/qemu/target/arm
Luc Michel 1ae9d988c6
target/arm: fix smc incorrectly trapping to EL3 when secure is off
This commit fixes a case where the CPU would try to go to EL3 when
executing an smc instruction, even though ARM_FEATURE_EL3 is false. This
case is raised when the PSCI conduit is set to smc, but the smc
instruction does not lead to a valid PSCI call.

QEMU crashes with an assertion failure latter on because of incoherent
mmu_idx.

This commit refactors the pre_smc helper by enumerating all the possible
way of handling an scm instruction, and covering the previously missing
case leading to the crash.

The following minimal test would crash before this commit:

.global _start
.text
_start:
ldr x0, =0xdeadbeef ; invalid PSCI call
smc #0

run with the following command line:

aarch64-linux-gnu-gcc -nostdinc -nostdlib -Wl,-Ttext=40000000 \
-o test test.s

qemu-system-aarch64 -M virt,virtualization=on,secure=off \
-cpu cortex-a57 -kernel test

Backports commit 7760da729ac88f112f98f36395ac3b55fc9e4211 from qemu
2018-11-23 18:57:23 -05:00
..
arm_ldst.h
arm-powerctl.c target-arm: powerctl: Enable HVC when starting CPUs to EL2 2018-10-23 12:53:40 -04:00
arm-powerctl.h
cpu64.c target/arm: Convert v8.2-fp16 from feature bit to aa64pfr0 test 2018-11-10 08:34:32 -05:00
cpu-qom.h
cpu.c target/arm/cpu: Give Cortex-A15 and -A7 the EL2 feature 2018-11-16 21:59:55 -05:00
cpu.h target/arm: Track the state of our irq lines from the GIC explicitly 2018-11-16 21:47:59 -05:00
crypto_helper.c
helper-a64.c target/arm: Check HAVE_CMPXCHG128 at translate time 2018-10-23 15:29:46 -04:00
helper-a64.h
helper-sve.h target/arm: Rewrite vector gather first-fault loads 2018-10-08 14:15:15 -04:00
helper.c target/arm: Hyp mode R14 is shared with User and System 2018-11-16 21:58:29 -05:00
helper.h target/arm: Add v8M stack checks on ADD/SUB/MOV of SP 2018-10-08 14:15:15 -04:00
internals.h target/arm: Hyp mode R14 is shared with User and System 2018-11-16 21:58:29 -05:00
iwmmxt_helper.c
kvm-consts.h
Makefile.objs
neon_helper.c
op_addsub.h
op_helper.c target/arm: fix smc incorrectly trapping to EL3 when secure is off 2018-11-23 18:57:23 -05:00
psci.c
sve_helper.c sve_helper: Use the QEMU_FLATTEN macro instead of the compiler attribute directly 2018-10-23 13:05:02 -04:00
sve.decode
translate-a64.c target/arm: Remove can't-happen if() from handle_vec_simd_shli() 2018-11-11 08:37:16 -05:00
translate-a64.h
translate-sve.c decodetree: Remove insn argument from trans_* expanders 2018-11-11 08:27:01 -05:00
translate.c target/arm: Reorg NEON VLD/VST single element to one lane 2018-11-10 11:24:37 -05:00
translate.h target/arm: Use gvec for NEON_3R_VTST_VCEQ, NEON_3R_VCGT, NEON_3R_VCGE 2018-11-10 11:03:42 -05:00
unicorn_aarch64.c
unicorn_arm.c
unicorn.h
vec_helper.c