qemu/target/i386
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
..
hax exec/memory: Add symbolic value for memory listener priority for accel 2023-06-28 14:27:59 +02:00
hvf accel: Rename HVF 'struct hvf_vcpu_state' -> AccelCPUState 2023-06-28 14:14:22 +02:00
kvm hw/xen: select kernel mode for per-vCPU event channel upcall vector 2023-11-09 16:39:13 +03:00
nvmm exec/memory: Add symbolic value for memory listener priority for accel 2023-06-28 14:27:59 +02:00
tcg target/i386: Fix 32-bit wrapping of pc/eip computation 2023-12-14 11:25:31 +03:00
whpx exec/memory: Add symbolic value for memory listener priority for accel 2023-06-28 14:27:59 +02:00
arch_dump.c dump: Replace opaque DumpState pointer with a typed one 2022-10-06 19:30:43 +04:00
arch_memory_mapping.c
cpu-dump.c target/i386: Remove x86_cpu_dump_local_apic_state() dead stub 2023-02-27 22:29:01 +01:00
cpu-internal.h
cpu-param.h target/i386: Remove NB_MMU_MODES define 2023-03-13 06:44:37 -07:00
cpu-qom.h target/i386: Convert to 3-phase reset 2022-12-16 15:58:15 +00:00
cpu-sysemu.c KVM: remove support for kernel-irqchip=off 2023-01-06 00:51:02 +01:00
cpu.c target/i386: Add new CPU model GraniteRapids 2023-07-07 12:52:27 +02:00
cpu.h target/i386: Fix 32-bit wrapping of pc/eip computation 2023-12-14 11:25:31 +03:00
gdbstub.c gdbstub: move register helpers into standalone include 2023-03-07 20:44:08 +00:00
helper.c target/i386/helper: Shuffle do_cpu_init() 2023-06-13 11:28:58 +02:00
helper.h target/i386: implement SYSCALL/SYSRET in 32-bit emulators 2023-06-26 10:23:56 +02:00
host-cpu.c *: Add missing includes of qemu/error-report.h 2023-03-22 15:06:57 +00:00
host-cpu.h
Kconfig
machine.c i386/xen: handle PV timer hypercalls 2023-03-01 09:07:52 +00:00
meson.build meson: Replace softmmu_ss -> system_ss 2023-06-20 10:01:30 +02:00
monitor.c error: Drop superfluous #include "qapi/qmp/qerror.h" 2023-02-23 13:56:14 +01:00
ops_sse.h target/i386: Use aesdec_ISB_ISR_IMC_AK 2023-07-08 07:30:18 +01:00
sev-sysemu-stub.c error: Drop superfluous #include "qapi/qmp/qerror.h" 2023-02-23 13:56:14 +01:00
sev.c i386/sev: Update checks and information related to reduced-phys-bits 2023-04-28 12:50:34 +02:00
sev.h
svm.h
trace-events
trace.h
xsave_helper.c