qemu/target/i386/tcg
Richard Henderson 5b2fd6cf37 target/i386: Fix 32-bit wrapping of pc/eip computation
In 32-bit mode, pc = eip + cs_base is also 32-bit, and must wrap.
Failure to do so results in incorrect memory exceptions to the guest.
Before 732d548732, this was implicitly done via truncation to
target_ulong but only in qemu-system-i386, not qemu-system-x86_64.

To fix this, we must add conditional zero-extensions.
Since we have to test for 32 vs 64-bit anyway, note that cs_base
is always zero in 64-bit mode.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2022
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20231212172510.103305-1-richard.henderson@linaro.org>
(cherry picked from commit b5e0d5d22fbffc3d8f7d3e86d7a2d05a1a974e27)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: context fix in target/i386/tcg/tcg-cpu.c for v8.1.0-1190-gb77af26e97
 "accel/tcg: Replace CPUState.env_ptr with cpu_env()")
2023-12-14 11:25:31 +03:00
..
sysemu target/i386: raise FERR interrupt with iothread locked 2023-09-21 19:35:19 +03:00
user target/i386: implement SYSCALL/SYSRET in 32-bit emulators 2023-06-26 10:23:56 +02:00
bpt_helper.c
cc_helper.c target/i386: Rename helper template headers as '.h.inc' 2023-06-13 11:28:58 +02:00
cc_helper_template.h.inc target/i386: Rename helper template headers as '.h.inc' 2023-06-13 11:28:58 +02:00
decode-new.c.inc target/i386: fix memory operand size for CVTPS2PD 2023-10-04 17:34:46 +03:00
decode-new.h target/i386: generalize operand size "ph" for use in CVTPS2PD 2023-10-04 17:34:30 +03:00
emit.c.inc target/i386: fix memory operand size for CVTPS2PD 2023-10-04 17:34:46 +03:00
excp_helper.c
fpu_helper.c
helper-tcg.h
int_helper.c target/i386: Rename helper template headers as '.h.inc' 2023-06-13 11:28:58 +02:00
mem_helper.c
meson.build
misc_helper.c target/i386: implement RDPID in TCG 2023-06-26 10:23:56 +02:00
mpx_helper.c
ops_sse_header.h.inc target/i386: Rename helper template headers as '.h.inc' 2023-06-13 11:28:58 +02:00
seg_helper.c target/i386: implement SYSCALL/SYSRET in 32-bit emulators 2023-06-26 10:23:56 +02:00
seg_helper.h
shift_helper_template.h.inc target/i386: Rename helper template headers as '.h.inc' 2023-06-13 11:28:58 +02:00
tcg-cpu.c target/i386: Fix 32-bit wrapping of pc/eip computation 2023-12-14 11:25:31 +03:00
tcg-cpu.h
tcg-stub.c
translate.c target/i386: Fix 32-bit wrapping of pc/eip computation 2023-12-14 11:25:31 +03:00