target/i386: Make translator stop before the end of a page
commit950936681f322a5ba2813f83eb44dd972be2d5a3
authorIlya Leoshkevich <iii@linux.ibm.com>
Wed, 17 Aug 2022 15:05:05 +0000 (17 17:05 +0200)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 6 Sep 2022 07:04:26 +0000 (6 08:04 +0100)
tree3604bd255a8d080cbd13b901926b8e6318777ba5
parentab12c95d3f1999648d70bca54ebcc0588a07dd3e
target/i386: Make translator stop before the end of a page

Right now translator stops right *after* the end of a page, which
breaks reporting of fault locations when the last instruction of a
multi-insn translation block crosses a page boundary.

An implementation, like the one arm and s390x have, would require an
i386 length disassembler, which is burdensome to maintain. Another
alternative would be to single-step at the end of a guest page, but
this may come with a performance impact.

Fix by snapshotting disassembly state and restoring it after we figure
out we crossed a page boundary. This includes rolling back cc_op
updates and emitted ops.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1143
Message-Id: <20220817150506.592862-4-iii@linux.ibm.com>
[rth: Simplify end-of-insn cross-page checks.]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
target/i386/tcg/translate.c
tests/tcg/x86_64/Makefile.target
tests/tcg/x86_64/noexec.c [new file with mode: 0644]