On 7/17/23 11:35, Peter Maydell wrote:
In CPUSparcState we define the fprs field as uint64_t.  However we
then refer to it in translate.c via a TCGv_i32 which we set up with
tcg_global_mem_new_ptr().  This means that on a big-endian host when
the guest does something to writo te the FPRS register this value
ends up in the wrong half of the uint64_t, and the QEMU C code that
refers to env->fprs sees the wrong value.  The effect of this is that
guest code that enables the FPU crashes with spurious FPU Disabled
exceptions.  In particular, this is why
  tests/avocado/machine_sparc64_sun4u.py:Sun4uMachine.test_sparc64_sun4u
times out on an s390 host.

There are multiple ways we could fix this; since there are actually
only three bits in the FPRS register and the code in translate.c
would be a bit painful to convert to dealing with a TCGv_i64, change
the type of the CPU state struct field to match what translate.c is
expecting.

(None of the other fields referenced by the r32[] array in
sparc_tcg_init() have the wrong type.)

Signed-off-by: Peter Maydell<peter.mayd...@linaro.org>
---
Changes v1->v2:
  * drop unnecessary change to gdbstub.c
  * put the vmstate fields the correct way around

NB: I believe the vmstate changes to be correct, but sparc64
seems unable to successfully do a savevm/loadvm even before
this change due to some other bug (the guest kernel panics
immediately after the loadvm).
---
  target/sparc/cpu.h     | 2 +-
  target/sparc/cpu.c     | 4 ++--
  target/sparc/machine.c | 3 ++-
  target/sparc/monitor.c | 2 +-
  4 files changed, 6 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson <richard.hender...@linaro.org>

r~

Reply via email to