* [PATCH] memory: Fix addr for flatview_access_allowed()
@ 2025-09-02 21:40 Peter Xu
2025-09-03 7:53 ` David Hildenbrand
2025-09-03 10:38 ` Philippe Mathieu-Daudé
0 siblings, 2 replies; 4+ messages in thread
From: Peter Xu @ 2025-09-02 21:40 UTC (permalink / raw)
To: qemu-devel
Cc: David Hildenbrand, peterx, Philippe Mathieu-Daudé,
Paolo Bonzini, Peter Maydell
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>
---
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)) {
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,
--
2.50.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] memory: Fix addr for flatview_access_allowed()
2025-09-02 21:40 [PATCH] memory: Fix addr for flatview_access_allowed() Peter Xu
@ 2025-09-03 7:53 ` David Hildenbrand
2025-09-03 10:38 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2025-09-03 7:53 UTC (permalink / raw)
To: Peter Xu, qemu-devel
Cc: Philippe Mathieu-Daudé, Paolo Bonzini, Peter Maydell
On 02.09.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é <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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] memory: Fix addr for flatview_access_allowed()
2025-09-02 21:40 [PATCH] memory: Fix addr for flatview_access_allowed() Peter Xu
2025-09-03 7:53 ` David Hildenbrand
@ 2025-09-03 10:38 ` Philippe Mathieu-Daudé
2025-09-03 13:09 ` Peter Xu
1 sibling, 1 reply; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-03 10:38 UTC (permalink / raw)
To: Peter Xu, qemu-devel; +Cc: David Hildenbrand, Paolo Bonzini, Peter Maydell
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é <philmd@linaro.org>
> Fixes: 3ab6fdc91b ("softmmu/physmem: Introduce MemTxAttrs::memory field and MEMTX_ACCESS_ERROR")
> Signed-off-by: Peter Xu <peterx@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,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] memory: Fix addr for flatview_access_allowed()
2025-09-03 10:38 ` Philippe Mathieu-Daudé
@ 2025-09-03 13:09 ` Peter Xu
0 siblings, 0 replies; 4+ messages in thread
From: Peter Xu @ 2025-09-03 13:09 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, David Hildenbrand, Paolo Bonzini, Peter Maydell
On Wed, Sep 03, 2025 at 12:38:19PM +0200, Philippe Mathieu-Daudé wrote:
> 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é <philmd@linaro.org>
> > Fixes: 3ab6fdc91b ("softmmu/physmem: Introduce MemTxAttrs::memory field and MEMTX_ACCESS_ERROR")
> > Signed-off-by: Peter Xu <peterx@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)) {
Yes.. I'll repost, thanks. :)
>
> > 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,
>
--
Peter Xu
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-09-03 13:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-02 21:40 [PATCH] memory: Fix addr for flatview_access_allowed() Peter Xu
2025-09-03 7:53 ` David Hildenbrand
2025-09-03 10:38 ` Philippe Mathieu-Daudé
2025-09-03 13:09 ` Peter Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).