]> git.ipfire.org Git - thirdparty/qemu.git/commit
target/loongarch: Fix the CSRRD CPUID instruction on big endian hosts
authorThomas Huth <thuth@redhat.com>
Thu, 20 Jul 2023 17:53:07 +0000 (19:53 +0200)
committerMichael Tokarev <mjt@tls.msk.ru>
Mon, 31 Jul 2023 06:12:06 +0000 (09:12 +0300)
commit0c8e6ac989581666b0fe4e0c8502000194152611
tree8b16283ddf5d203f617e63c5a133033d62c82b88
parentc1bdd3cdc4636adb150b17f490da5dc5c15689b6
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>
(cherry picked from commit c34ad459926f6c600a55fe6782a27edfa405d60b)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
target/loongarch/cpu.h
target/loongarch/csr_helper.c
target/loongarch/helper.h
target/loongarch/insn_trans/trans_privileged.c.inc