OSDN Git Service

target/arm: Fix generated code for cpreg reads when HSTR is active
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 3 Apr 2023 15:12:30 +0000 (16:12 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 3 Apr 2023 15:12:30 +0000 (16:12 +0100)
commit782781e85decfd85a6d9b064be741fb30d4fd307
tree5eddd4cc02967b3e54d8065475ad67281d745433
parent12148d442ec3f4386c8624ffcf44c61a8b344018
target/arm: Fix generated code for cpreg reads when HSTR is active

In commit 049edada we added some code to handle HSTR_EL2 traps, which
we did as an inline "conditionally branch over a
gen_exception_insn()".  Unfortunately this fails to take account of
the fact that gen_exception_insn() will set s->base.is_jmp to
DISAS_NORETURN.  That means that at the end of the TB we won't
generate the necessary code to handle the "branched over the trap and
continued normal execution" codepath.  The result is that the TCG
main loop thinks that we stopped execution of the TB due to a
situation that only happens when icount is enabled, and hits an
assertion. Explicitly set is_jmp back to DISAS_NEXT so we generate
the correct code for when execution continues past this insn.

Note that this only happens for cpreg reads; writes will call
gen_lookup_tb() which generates a valid end-of-TB.

Fixes: 049edada ("target/arm: Make HSTR_EL2 traps take priority over UNDEF-at-EL1")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1551
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20230330101900.2320380-1-peter.maydell@linaro.org
target/arm/tcg/translate.c