[PATCH v2] memory: Fix addr/len for flatview_access_allowed()

Peter Xu posted 1 patch 2 days, 22 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250903142932.1038765-1-peterx@redhat.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>, David Hildenbrand <david@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>
system/physmem.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH v2] memory: Fix addr/len for flatview_access_allowed()
Posted by Peter Xu 2 days, 22 hours ago
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é <philmd@linaro.org>
Fixes: 3ab6fdc91b ("softmmu/physmem: Introduce MemTxAttrs::memory field and MEMTX_ACCESS_ERROR")
Signed-off-by: Peter Xu <peterx@redhat.com>
---
v2:
- Fix len as well [Phil]
---
 system/physmem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/system/physmem.c b/system/physmem.c
index f498572fc8..d1cd85abd4 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, 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, l)) {
         return MEMTX_ACCESS_ERROR;
     }
     return flatview_read_continue(fv, addr, attrs, buf, len,
-- 
2.50.1


Re: [PATCH v2] memory: Fix addr/len for flatview_access_allowed()
Posted by Philippe Mathieu-Daudé 2 days, 19 hours ago
On 3/9/25 16:29, 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é <philmd@linaro.org>
> Fixes: 3ab6fdc91b ("softmmu/physmem: Introduce MemTxAttrs::memory field and MEMTX_ACCESS_ERROR")
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> v2:
> - Fix len as well [Phil]
> ---
>   system/physmem.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


Re: [PATCH v2] memory: Fix addr/len for flatview_access_allowed()
Posted by David Hildenbrand 2 days, 21 hours ago
On 03.09.25 16:29, 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é <philmd@linaro.org>
> Fixes: 3ab6fdc91b ("softmmu/physmem: Introduce MemTxAttrs::memory field and MEMTX_ACCESS_ERROR")
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers

David / dhildenb