On 2/6/26 21:08, Daniel Henrique Barboza wrote:
memory_region_dispatch_read|write, when dealing with an invalid memory
region, default to MEMTX_DECODE_ERROR error code. This happens because
memory_region_access_valid() until recently would just report true/false
and nothing else.
We now have access to the internal reason why memory_region_access_valid()
would fail. In particular, we can now receive a MEMTX_ACCESS_ERROR when
the mr->ops->valid.accepts() callback fails.
Make both functions return the actual error reason in case
memory_region_access_valid fails, allowing more precise error handling
throughout the code.
Signed-off-by: Daniel Henrique Barboza <[email protected]>
---
system/memory.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/system/memory.c b/system/memory.c
index 48348edb96..7d38b9774e 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -1492,9 +1492,9 @@ MemTxResult memory_region_dispatch_read(MemoryRegion *mr,
mr->alias_offset + addr,
pval, op, attrs);
}
- if (!memory_region_access_valid(mr, addr, size, false, attrs, NULL)) {
+ if (!memory_region_access_valid(mr, addr, size, false, attrs, &r)) {
Now I see you propagate MemTxResult (my comment from previous patch).
Maybe clearer is 1st patch add the MemTxResult argument keeping current
behavior and 2nd patch update to your current patch #1 change?
*pval = unassigned_mem_read(mr, addr, size);
- return MEMTX_DECODE_ERROR;
+ return r;
}