On 2/9/25 23:40, Peter Xu wrote:
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é <phi...@linaro.org>
Fixes: 3ab6fdc91b ("softmmu/physmem: Introduce MemTxAttrs::memory field and 
MEMTX_ACCESS_ERROR")
Signed-off-by: Peter Xu <pet...@redhat.com>
---
  system/physmem.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/system/physmem.c b/system/physmem.c
index f498572fc8..019118cf75 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -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)) {

          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.

          return MEMTX_ACCESS_ERROR;
      }
      return flatview_read_continue(fv, addr, attrs, buf, len,


Reply via email to