[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/7] target/sparc: Handle bus errors in mmu_probe()
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PATCH 5/7] target/sparc: Handle bus errors in mmu_probe() |
Date: |
Thu, 1 Aug 2019 19:30:10 +0100 |
Convert the mmu_probe() function to using address_space_ldl()
rather than ldl_phys(), so we can explicitly detect memory
transaction failures.
This makes no practical difference at the moment, because
ldl_phys() will return 0 on a transaction failure, and we
treat transaction failures and 0 PDEs identically. However
the spec says that MMU probe operations are supposed to
update the fault status registers, and if we ever implement
that we'll want to distinguish the difference. For the
moment, just add a TODO comment about the bug.
Signed-off-by: Peter Maydell <address@hidden>
---
target/sparc/mmu_helper.c | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c
index 351055a09b1..d90aabfa4d2 100644
--- a/target/sparc/mmu_helper.c
+++ b/target/sparc/mmu_helper.c
@@ -287,11 +287,20 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong
address, int mmulev)
CPUState *cs = env_cpu(env);
hwaddr pde_ptr;
uint32_t pde;
+ MemTxResult result;
+
+ /*
+ * TODO: MMU probe operations are supposed to set the fault
+ * status registers, but we don't do this.
+ */
/* Context base + context number */
pde_ptr = (hwaddr)(env->mmuregs[1] << 4) +
(env->mmuregs[2] << 2);
- pde = ldl_phys(cs->as, pde_ptr);
+ pde = address_space_ldl(cs->as, pde_ptr, MEMTXATTRS_UNSPECIFIED, &result);
+ if (result != MEMTX_OK) {
+ return 0;
+ }
switch (pde & PTE_ENTRYTYPE_MASK) {
default:
@@ -304,7 +313,11 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong
address, int mmulev)
return pde;
}
pde_ptr = ((address >> 22) & ~3) + ((pde & ~3) << 4);
- pde = ldl_phys(cs->as, pde_ptr);
+ pde = address_space_ldl(cs->as, pde_ptr,
+ MEMTXATTRS_UNSPECIFIED, &result);
+ if (result != MEMTX_OK) {
+ return 0;
+ }
switch (pde & PTE_ENTRYTYPE_MASK) {
default:
@@ -318,7 +331,11 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong
address, int mmulev)
return pde;
}
pde_ptr = ((address & 0xfc0000) >> 16) + ((pde & ~3) << 4);
- pde = ldl_phys(cs->as, pde_ptr);
+ pde = address_space_ldl(cs->as, pde_ptr,
+ MEMTXATTRS_UNSPECIFIED, &result);
+ if (result != MEMTX_OK) {
+ return 0;
+ }
switch (pde & PTE_ENTRYTYPE_MASK) {
default:
@@ -332,7 +349,11 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong
address, int mmulev)
return pde;
}
pde_ptr = ((address & 0x3f000) >> 10) + ((pde & ~3) << 4);
- pde = ldl_phys(cs->as, pde_ptr);
+ pde = address_space_ldl(cs->as, pde_ptr,
+ MEMTXATTRS_UNSPECIFIED, &result);
+ if (result != MEMTX_OK) {
+ return 0;
+ }
switch (pde & PTE_ENTRYTYPE_MASK) {
default:
--
2.20.1
- [Qemu-devel] [PATCH 0/7] target/sparc: Convert to do_transaction_failed hook, Peter Maydell, 2019/08/01
- [Qemu-devel] [PATCH 6/7] target/sparc: Remove unused ldl_phys from dump_mmu(), Peter Maydell, 2019/08/01
- [Qemu-devel] [PATCH 5/7] target/sparc: Handle bus errors in mmu_probe(),
Peter Maydell <=
- [Qemu-devel] [PATCH 3/7] target/sparc: Check for transaction failures in MXCC stream ASI accesses, Peter Maydell, 2019/08/01
- [Qemu-devel] [PATCH 2/7] target/sparc: Check for transaction failures in MMU passthrough ASIs, Peter Maydell, 2019/08/01
- [Qemu-devel] [PATCH 4/7] target/sparc: Correctly handle bus errors in page table walks, Peter Maydell, 2019/08/01
- [Qemu-devel] [PATCH 7/7] target/sparc: Switch to do_transaction_failed() hook, Peter Maydell, 2019/08/01
- [Qemu-devel] [PATCH 1/7] target/sparc: Factor out the body of sparc_cpu_unassigned_access(), Peter Maydell, 2019/08/01