[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 2/2] accel/tcg: Call tcg_tb_insert() for one-insn TBs
From: |
Alex Bennée |
Subject: |
Re: [PATCH v2 2/2] accel/tcg: Call tcg_tb_insert() for one-insn TBs |
Date: |
Fri, 17 Jan 2025 10:38:19 +0000 |
User-agent: |
mu4e 1.12.8; emacs 29.4 |
Ilya Leoshkevich <iii@linux.ibm.com> writes:
> Currently one-insn TBs created from I/O memory are not added to
> region_trees. Therefore, when they generate exceptions, they are not
> handled by cpu_restore_state_from_tb().
>
> For x86 this is not a problem, because x86_restore_state_to_opc() only
> restores pc and cc, which already have the correct values if the first
> TB instruction causes an exception. However, on several other
> architectures, restore_state_to_opc() is not stricly limited to state
> restoration and affects some exception-related registers, where guests
> can notice incorrect values, for example:
>
> - arm's exception.syndrome;
> - hppa's unwind_breg;
> - riscv's excp_uw2;
> - s390x's int_pgm_ilen.
>
> Fix by always calling tcg_tb_insert(). This may increase the size of
> region_trees, but tcg_region_reset_all() clears it once code_gen_buffer
> fills up, so it will not grow uncontrollably.
>
> Do not call tb_link_page(), which would add such TBs to the QHT, to
> prevent tb_lookup() from finding them. These TBs are single-use, since
> subsequent reads from I/O memory may return different values; they are
> not removed from code_gen_buffer only in order to keep things simple.
>
> Co-developed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro