Skip to contentSkip to conversation

memory: Fix addr for flatview_access_allowed()

PATCH Superseded Peter Xu 3 participants 4 messages Sep 2, 2025 – Sep 3, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Peter Xu

author
#0 lore raw

PATCH 1/1 memory: Fix addr for flatview_access_allowed()

flatview_access_allowed() should pass in the address offset of the memory region, rather than the global address space.

Shouldn't be a major issue yet, since the addr is only used in an error log.

Cc Philippe Mathieu-Daudé <[email protected]>
Fixes 3ab6fdc91b ("softmmu/physmem: Introduce MemTxAttrs::memory field and MEMTX_ACCESS_ERROR")
---
 system/physmem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
system/physmem.c +2 -2
index f498572fc8..019118cf75 100644
@@ -3027,7 +3027,7 @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
 
     l = len;
     mr = flatview_translate(fv, addr, &mr_addr, &l, true, attrs);
-    if (!flatview_access_allowed(mr, attrs, addr, len)) {
+    if (!flatview_access_allowed(mr, attrs, mr_addr, len)) {
         return MEMTX_ACCESS_ERROR;
     }
     return flatview_write_continue(fv, addr, attrs, buf, len,
@@ -3118,7 +3118,7 @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr,
 
     l = len;
     mr = flatview_translate(fv, addr, &mr_addr, &l, false, attrs);
-    if (!flatview_access_allowed(mr, attrs, addr, len)) {
+    if (!flatview_access_allowed(mr, attrs, mr_addr, len)) {
         return MEMTX_ACCESS_ERROR;
     }
     return flatview_read_continue(fv, addr, attrs, buf, len,
Signature · 1 line
2.50.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Peter Xu

flatview_access_allowed() should pass in the address offset of the memory region, rather than the global address space.

Shouldn't be a major issue yet, since the addr is only used in an error log.

Cc Philippe Mathieu-Daudé <[email protected]>
Fixes 3ab6fdc91b ("softmmu/physmem: Introduce MemTxAttrs::memory field and MEMTX_ACCESS_ERROR")

---

Signature · 3 lines
Cheers

David / dhildenb
#2 lore raw
In reply to Peter Xu
Quoted 18 lines · Peter Xu

flatview_access_allowed() should pass in the address offset of the memory region, rather than the global address space.

Shouldn't be a major issue yet, since the addr is only used in an error log.

Cc Philippe Mathieu-Daudé <[email protected]>
Fixes 3ab6fdc91b ("softmmu/physmem: Introduce MemTxAttrs::memory field and MEMTX_ACCESS_ERROR")
---
  system/physmem.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
system/physmem.c +0 -0
index f498572fc8..019118cf75 100644

system/physmem.c static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, · line 3030

Quoted 5 lines
system/physmem.c +1 -1
@@ -3027,7 +3027,7 @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
 
      l = len;
      mr = flatview_translate(fv, addr, &mr_addr, &l, true, attrs);
-    if (!flatview_access_allowed(mr, attrs, addr, len)) {
+    if (!flatview_access_allowed(mr, attrs, mr_addr, len)) {

Right, but shouldn't we also use the translated length?

       if (!flatview_access_allowed(mr, attrs, mr_addr, l)) {

system/physmem.c static MemTxResult flatview_read(FlatView *fv, hwaddr addr, · line 3121

Quoted 9 lines
system/physmem.c +1 -1
          return MEMTX_ACCESS_ERROR;
      }
      return flatview_write_continue(fv, addr, attrs, buf, len,
@@ -3118,7 +3118,7 @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr,
 
      l = len;
      mr = flatview_translate(fv, addr, &mr_addr, &l, false, attrs);
-    if (!flatview_access_allowed(mr, attrs, addr, len)) {
+    if (!flatview_access_allowed(mr, attrs, mr_addr, len)) {

Ditto.

Quoted 3 lines
system/physmem.c +0 -0
          return MEMTX_ACCESS_ERROR;
      }
      return flatview_read_continue(fv, addr, attrs, buf, len,
author
#3 lore raw
Quoted 26 lines · Philippe Mathieu-Daudé
Quoted 18 lines · Peter Xu

flatview_access_allowed() should pass in the address offset of the memory region, rather than the global address space.

Shouldn't be a major issue yet, since the addr is only used in an error log.

Cc Philippe Mathieu-Daudé <[email protected]>
Fixes 3ab6fdc91b ("softmmu/physmem: Introduce MemTxAttrs::memory field and MEMTX_ACCESS_ERROR")
---
  system/physmem.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
system/physmem.c +0 -0
index f498572fc8..019118cf75 100644

system/physmem.c static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, · line 3029

Quoted 4 lines
system/physmem.c +1 -1
@@ -3027,7 +3027,7 @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
      l = len;
      mr = flatview_translate(fv, addr, &mr_addr, &l, true, attrs);
-    if (!flatview_access_allowed(mr, attrs, addr, len)) {
+    if (!flatview_access_allowed(mr, attrs, mr_addr, len)) {

Right, but shouldn't we also use the translated length?

Quoted 1 line
       if (!flatview_access_allowed(mr, attrs, mr_addr, l)) {

Yes.. I'll repost, thanks. :)

Quoted 16 lines

system/physmem.c static MemTxResult flatview_read(FlatView *fv, hwaddr addr, · line 3120

Quoted 9 lines
system/physmem.c +1 -1
          return MEMTX_ACCESS_ERROR;
      }
      return flatview_write_continue(fv, addr, attrs, buf, len,
@@ -3118,7 +3118,7 @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr,
      l = len;
      mr = flatview_translate(fv, addr, &mr_addr, &l, false, attrs);
-    if (!flatview_access_allowed(mr, attrs, addr, len)) {
+    if (!flatview_access_allowed(mr, attrs, mr_addr, len)) {

Ditto.

Quoted 3 lines
system/physmem.c +0 -0
          return MEMTX_ACCESS_ERROR;
      }
      return flatview_read_continue(fv, addr, attrs, buf, len,
Signature · 1 line
Peter Xu