]> git.proxmox.com Git - mirror_qemu.git/commit - target-arm/translate.c
target-arm: check that LSB <= MSB in BFI instruction
authorKirill Batuzov <batuzovk@ispras.ru>
Thu, 5 Feb 2015 13:37:22 +0000 (13:37 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 5 Feb 2015 13:37:22 +0000 (13:37 +0000)
commit45140a57675ecb4b0daee71bf145c24dbdf9429c
tree2d53ceff6ba8454498c177d3ee38e910c285ac87
parenta8eb6e19991d1a7a6a7b04ac447548d30d75eb4a
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

Signed-off-by: Kirill Batuzov <batuzovk@ispras.ru>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
target-arm/translate.c