[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 1/1] target/riscv: fix endless translation loop on big endian
From: |
Ziqiao Kong |
Subject: |
[PATCH v2 1/1] target/riscv: fix endless translation loop on big endian systems |
Date: |
Mon, 14 Apr 2025 11:46:26 +0800 |
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.
Signed-off-by: Ziqiao Kong <ziqiaokong@gmail.com>
---
target/riscv/cpu_helper.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
index 6c4391d96b..bc146771c8 100644
--- a/target/riscv/cpu_helper.c
+++ b/target/riscv/cpu_helper.c
@@ -1662,9 +1662,9 @@ static int get_physical_address(CPURISCVState *env,
hwaddr *physical,
target_ulong *pte_pa = qemu_map_ram_ptr(mr->ram_block, addr1);
target_ulong old_pte;
if (riscv_cpu_sxl(env) == MXL_RV32) {
- old_pte = qatomic_cmpxchg((uint32_t *)pte_pa, pte,
updated_pte);
+ old_pte = qatomic_cmpxchg((uint32_t *)pte_pa,
cpu_to_le32(pte), cpu_to_le32(updated_pte));
} else {
- old_pte = qatomic_cmpxchg(pte_pa, pte, updated_pte);
+ old_pte = qatomic_cmpxchg(pte_pa, cpu_to_le64(pte),
cpu_to_le64(updated_pte));
}
if (old_pte != pte) {
goto restart;
--
2.34.1
- [PATCH v2 0/1] Fix endless translation loop of riscv, Ziqiao Kong, 2025/04/13
- [PATCH v2 1/1] target/riscv: fix endless translation loop on big endian systems,
Ziqiao Kong <=
- Re: [PATCH v2 1/1] target/riscv: fix endless translation loop on big endian systems, Philippe Mathieu-Daudé, 2025/04/14
- Re: [PATCH v2 1/1] target/riscv: fix endless translation loop on big endian systems, Ziqiao Kong, 2025/04/14
- Re: [PATCH v2 1/1] target/riscv: fix endless translation loop on big endian systems, Ziqiao Kong, 2025/04/14
- Re: [PATCH v2 1/1] target/riscv: fix endless translation loop on big endian systems, Philippe Mathieu-Daudé, 2025/04/14
- Message not available
- Re: [PATCH v2 1/1] target/riscv: fix endless translation loop on big endian systems, Ziqiao Kong, 2025/04/15
- Re: [PATCH v2 1/1] target/riscv: fix endless translation loop on big endian systems, Philippe Mathieu-Daudé, 2025/04/15
- Re: [PATCH v2 1/1] target/riscv: fix endless translation loop on big endian systems, Ziqiao Kong, 2025/04/15
- Re: [PATCH v2 1/1] target/riscv: fix endless translation loop on big endian systems, Ziqiao Kong, 2025/04/15
- Re: [PATCH v2 1/1] target/riscv: fix endless translation loop on big endian systems, Ziqiao Kong, 2025/04/15