target/loongarch: Fix the CSRRD CPUID instruction on big endian hosts
commitc34ad459926f6c600a55fe6782a27edfa405d60b
authorThomas Huth <thuth@redhat.com>
Thu, 20 Jul 2023 17:53:07 +0000 (20 19:53 +0200)
committerThomas Huth <thuth@redhat.com>
Mon, 24 Jul 2023 16:44:48 +0000 (24 18:44 +0200)
tree76adf6aa58a092635c4b63e27b89be87fcddd1ef
parent71a00a5baea0e291a59ae639cbecf54d8cd70abb
target/loongarch: Fix the CSRRD CPUID instruction on big endian hosts

The test in tests/avocado/machine_loongarch.py is currently failing
on big endian hosts like s390x. By comparing the traces between running
the QEMU_EFI.fd bios on a s390x and on a x86 host, it's quickly obvious
that the CSRRD instruction for the CPUID is behaving differently. And
indeed: The code currently does a long read (i.e. 64 bit) from the
address that points to the CPUState->cpu_index field (with tcg_gen_ld_tl()
in the trans_csrrd() function). But this cpu_index field is only an "int"
(i.e. 32 bit). While this dirty pointer magic works on little endian hosts,
it of course fails on big endian hosts. Fix it by using a proper helper
function instead.

Message-Id: <20230720175307.854460-1-thuth@redhat.com>
Reviewed-by: Song Gao <gaosong@loongson.cn>
Signed-off-by: Thomas Huth <thuth@redhat.com>
target/loongarch/cpu.h
target/loongarch/csr_helper.c
target/loongarch/helper.h
target/loongarch/insn_trans/trans_privileged.c.inc