cpu-exec: Exit exclusive region on longjmp from step_atomic
commit426eeecdf5d9cf1695a53c08f46394f8e5351750
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 2 Nov 2017 16:35:36 +0000 (2 16:35 +0000)
committerRichard Henderson <richard.henderson@linaro.org>
Fri, 3 Nov 2017 08:34:21 +0000 (3 09:34 +0100)
tree0198f704b55d7ffece0be6e30787a30db1420ac1
parentba2c747992f8c315c2fbddba196ce9137430d61d
cpu-exec: Exit exclusive region on longjmp from step_atomic

Commit ac03ee5331612e44be narrowed the scope of the exclusive
region so it only covers when we're executing the TB, not when
we're generating it. However it missed that there is more than
one execution path out of cpu_tb_exec -- if the atomic insn
causes an exception then the code will longjmp out, skipping
the code to end the exclusive region. This causes QEMU to hang
the next time the CPU calls start_exclusive(), waiting for
itself to exit the region.

Move the "end the region" code out to the end of the
function so that it is run for both normal exit and also
for exit-via-longjmp. We have to use a volatile bool flag
to decide whether we need to end the region, because we
can longjump out of the codegen as well as the execution.

(For some reason this only reproduces for me with a clang
optimized build, not a gcc debug build.)

Reviewed-by: Emilio G. Cota <cota@braap.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Fixes: ac03ee5331612e44beb393df2b578c951d27dc0d
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <1509640536-32160-1-git-send-email-peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
accel/tcg/cpu-exec.c