target/mips: Fix handling of LL/SC instructions after 7dd547e5ab
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Sun, 2 Feb 2020 15:34:09 +0000 (15:34 +0000)
committerAleksandar Markovic <amarkovic@wavecomp.com>
Tue, 4 Feb 2020 07:51:41 +0000 (08:51 +0100)
commitec860426dfbebe0c9995e12cd82935a94fde5215
tree9130b31cfa03a5e183ca3ef9adddc21e77dd4fb4
parentf31160c7d1b89cfb4dd4001a23575b42141cb0ec
target/mips: Fix handling of LL/SC instructions after 7dd547e5ab

After 7dd547e5ab6b31e7a0cfc182d3ad131dd55a948f the env->llval value
is loaded as an unsigned value (instead of sign-extended as before).
Therefore, the CMPXCHG in gen_st_cond() in translate.c fails if the
sign bit is set in the loaded value.

Fix this by sign-extending the llval value for the 32-bit case.

I discovered this issue because FreeBSD MIPS64 was looping forever
in an atomic helper function when trying to start /sbin/init.

Signed-off-by: Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Fixes: 7dd547e5ab ("target/mips: Use cpu_*_mmuidx_ra instead of MMU_MODE*_SUFFIX")
Buglink: https://bugs.launchpad.net/qemu/+bug/1861605
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Aleksandar Markovic <amarkovic@wavecomp.com>
Cc: Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20200202153409.28534-1-jrtc27@jrtc27.com>
target/mips/op_helper.c