]> git.ipfire.org Git - thirdparty/qemu.git/commit
target/riscv: fix endless translation loop on big endian systems
authorZiqiao Kong <ziqiaokong@gmail.com>
Tue, 15 Apr 2025 08:02:54 +0000 (16:02 +0800)
committerMichael Tokarev <mjt@tls.msk.ru>
Tue, 20 May 2025 06:55:46 +0000 (09:55 +0300)
commit156321d18ebf86a21c487f995ce077d7c602d456
tree049fd12ea4c696e9caa7e0e7dd71bb286a882ff2
parentb76d4a5657129785c037a8689804caedbb045333
target/riscv: fix endless translation loop on big endian systems

On big endian systems, pte and updated_pte hold big endian host data
while pte_pa points to little endian target data. This means the branch
at cpu_helper.c:1669 will be always satisfied and restart translation,
causing an endless translation loop.

The correctness of this patch can be deduced by:

old_pte will hold value either from cpu_to_le32/64(pte) or
cpu_to_le32/64(updated_pte), both of wich is litte endian. After that,
an in-place conversion by le32/64_to_cpu(old_pte) ensures that old_pte
now is in native endian, same with pte. Therefore, the endianness of the
both side of if (old_pte != pte) is correct.

Signed-off-by: Ziqiao Kong <ziqiaokong@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250415080254.3667878-2-ziqiaokong@gmail.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Cc: qemu-stable@nongnu.org
(cherry picked from commit ad63158bdb33dab5704ea1cf740d2ea0387175df)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
target/riscv/cpu_helper.c