]> git.proxmox.com Git - mirror_qemu.git/commit - cpu-exec.c
cpu-exec: wrap tcg_qemu_tb_exec() in a fn to restore the PC
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 22 Feb 2013 18:10:02 +0000 (18:10 +0000)
committerBlue Swirl <blauwirbel@gmail.com>
Sun, 3 Mar 2013 14:28:37 +0000 (14:28 +0000)
commit77211379d73ea0c89c0b5bb6eee74b17cb06f9a8
treefefbdb43a06725304a1d8854bdd5ca1abca81bd6
parentfadf982584b040527aeee0ede270a4d01463d293
cpu-exec: wrap tcg_qemu_tb_exec() in a fn to restore the PC

If tcg_qemu_tb_exec() returns a value whose low bits don't indicate a
link to an indexed next TB, this means that the TB execution never
started (eg because the instruction counter hit zero).  In this case the
guest PC has to be reset to the address of the start of the TB.
Refactor the cpu-exec code to make all tcg_qemu_tb_exec() calls pass
through a wrapper function which does this restoration if necessary.

Note that the apparent change in cpu_exec_nocache() from calling
cpu_pc_from_tb() with the old TB to calling it with the TB returned by
do_tcg_qemu_tb_exec() is safe, because in the nocache case we can
guarantee that the TB we try to execute is not linked to any others,
so the only possible returned TB is the one we started at. That is,
we should arguably previously have included in cpu_exec_nocache() an
assert(next_tb & ~TB_EXIT_MASK) == tb), since the API requires restore
from next_tb but we were using tb.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
cpu-exec.c