]> git.feebdaed.xyz Git - 0xmirror/qemu.git/commit
target/arm: Fix assert on BRA.
authorHarald van Dijk <hdijk@accesssoftek.com>
Fri, 28 Nov 2025 04:38:11 +0000 (04:38 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 1 Dec 2025 09:36:40 +0000 (09:36 +0000)
commit7248dab3c9d73fcefe609f7a3414f9d048fefcc1
tree68a533a84e49a2284a890683c9bb790dc1f421f8
parent9ef49528b5286f078061b52ac41e0ca19fa10e36
target/arm: Fix assert on BRA.

trans_BRA does

    gen_a64_set_pc(s, dst);
    set_btype_for_br(s, a->rn);

gen_a64_set_pc does

    s->pc_save = -1;

set_btype_for_br (if aa64_bti is enabled and the register is not x16 or
x17) does

    gen_pc_plus_diff(s, pc, 0);

gen_pc_plus_diff does

    assert(s->pc_save != -1);

Hence, this assert is getting hit. We need to call set_btype_for_br
before gen_a64_set_pc, and there is nothing in set_btype_for_br that
depends on gen_a64_set_pc having already been called, so this commit
simply swaps the calls.

(The commit message for 64678fc45d8f6 says that set_brtype_for_br()
must be "moved after" get_a64_set_pc(), but this is a mistake in
the commit message -- the actual changes in that commit move
set_brtype_for_br() *before* get_a64_set_pc() and this is necessary
to avoid the assert.)

Cc: qemu-stable@nongnu.org
Fixes: 64678fc45d8f6 ("target/arm: Fix BTI versus CF_PCREL")
Signed-off-by: Harald van Dijk <hdijk@accesssoftek.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: d2265ebb-84bc-41b7-a2d7-05dc9a5a2055@accesssoftek.com
[PMM: added note about 64678fc45d8f6 to commit message]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
target/arm/tcg/translate-a64.c