qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memory: Forbid memory_region_set_address() on AS root
@ 2021-04-17 12:53 Philippe Mathieu-Daudé
  2021-04-17 12:59 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-17 12:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Philippe Mathieu-Daudé, Peter Xu

To be sure an AddressSpace is zero-based, forbid changing
base address of MemoryRegion used as AddressSpace container.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
Based-on: <20210417103028.601124-1-f4bug@amsat.org>
---
 softmmu/memory.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/softmmu/memory.c b/softmmu/memory.c
index 409bcaec7f5..73c0e6f84f5 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -2522,6 +2522,7 @@ static void memory_region_readd_subregion(MemoryRegion *mr)
 
 void memory_region_set_address(MemoryRegion *mr, hwaddr addr)
 {
+    assert(!mr->is_root_mr);
     if (addr != mr->addr) {
         mr->addr = addr;
         memory_region_readd_subregion(mr);
-- 
2.26.3



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] memory: Forbid memory_region_set_address() on AS root
  2021-04-17 12:53 [PATCH] memory: Forbid memory_region_set_address() on AS root Philippe Mathieu-Daudé
@ 2021-04-17 12:59 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-04-17 12:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Peter Xu

On 4/17/21 2:53 PM, Philippe Mathieu-Daudé wrote:
> To be sure an AddressSpace is zero-based, forbid changing
> base address of MemoryRegion used as AddressSpace container.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> Based-on: <20210417103028.601124-1-f4bug@amsat.org>
> ---
>  softmmu/memory.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/softmmu/memory.c b/softmmu/memory.c
> index 409bcaec7f5..73c0e6f84f5 100644
> --- a/softmmu/memory.c
> +++ b/softmmu/memory.c
> @@ -2522,6 +2522,7 @@ static void memory_region_readd_subregion(MemoryRegion *mr)
>  
>  void memory_region_set_address(MemoryRegion *mr, hwaddr addr)
>  {
> +    assert(!mr->is_root_mr);

Hmm to not discriminate the API usage, maybe safer as:

       assert(!(addr && mr->is_root_mr));

>      if (addr != mr->addr) {
>          mr->addr = addr;
>          memory_region_readd_subregion(mr);
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-17 13:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-17 12:53 [PATCH] memory: Forbid memory_region_set_address() on AS root Philippe Mathieu-Daudé
2021-04-17 12:59 ` Philippe Mathieu-Daudé

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).