unicorn/qemu/target-arm
Kirill Batuzov d45ea1ba3b
target-arm: check that LSB <= MSB in BFI instruction
The documentation states that if LSB > MSB in BFI instruction behaviour
is unpredictable. Currently QEMU crashes because of assertion failure in
this case:

tcg/tcg-op.h:2061: tcg_gen_deposit_i32: Assertion `len <= 32' failed.

While assertion failure may meet the "unpredictable" definition this
behaviour is undesirable because it allows an unprivileged guest program
to crash the emulator with the OS and other programs.

This patch addresses the issue by throwing illegal instruction exception
if LSB > MSB. Only ARM decoder is affected because Thumb decoder already
has this check in place.

To reproduce issue run the following program

int main(void) {
asm volatile (".long 0x07c00c12" :: );
return 0;
}

compiled with
gcc -marm -static badop_arm.c -o badop_arm

Backports commit 45140a57675ecb4b0daee71bf145c24dbdf9429c from qemu
2018-02-12 11:06:12 -05:00
..
arm_ldst.h import 2015-08-21 15:04:50 +08:00
cpu-qom.h target-arm: Add ARMCPU secure property 2018-02-12 10:40:52 -05:00
cpu.c target-arm: Change reset to highest available EL 2018-02-12 10:40:53 -05:00
cpu.h target-arm: Split NO_MIGRATE into ALIAS and NO_RAW 2018-02-12 10:59:36 -05:00
cpu64.c target-arm: add CPREG secure state support 2018-02-11 18:29:35 -05:00
crypto_helper.c target-arm: crypto: fix BE host support 2018-02-12 10:40:52 -05:00
helper-a64.c target-arm: Squash input denormals in FRECPS and FRSQRTS 2018-02-12 11:04:28 -05:00
helper-a64.h import 2015-08-21 15:04:50 +08:00
helper.c target-arm: Add checks that cpreg raw accesses are handled 2018-02-12 11:02:00 -05:00
helper.h rework code/block tracing 2016-01-22 19:07:50 -08:00
internals.h target-arm: make TTBCR banked 2018-02-11 19:59:03 -05:00
iwmmxt_helper.c import 2015-08-21 15:04:50 +08:00
kvm-consts.h import 2015-08-21 15:04:50 +08:00
Makefile.objs delete sparc32_dma.h & arm-semi.c 2017-01-19 15:10:41 +08:00
neon_helper.c Arm support ported. (#736) 2017-01-23 23:30:57 +08:00
op_addsub.h import 2015-08-21 15:04:50 +08:00
op_helper.c target-arm: make c13 cp regs banked (FCSEIDR, ...) 2018-02-12 10:40:51 -05:00
psci.c import 2015-08-21 15:04:50 +08:00
translate-a64.c target-arm: Add condexec state to insn_start 2018-02-11 15:13:40 -05:00
translate.c target-arm: check that LSB <= MSB in BFI instruction 2018-02-12 11:06:12 -05:00
translate.h target-arm: add non-secure Translation Block flag 2018-02-11 17:50:46 -05:00
unicorn.h arm64eb: add support for ARM64 big endian. 2017-04-24 23:30:01 +08:00
unicorn_aarch64.c target-arm: make c13 cp regs banked (FCSEIDR, ...) 2018-02-12 10:40:51 -05:00
unicorn_arm.c fix conflicts 2017-03-30 12:23:24 +08:00