qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] memory: Do not allow subregion out of the parent region rang


From: Paolo Bonzini
Subject: Re: [PATCH] memory: Do not allow subregion out of the parent region range
Date: Mon, 16 Dec 2019 14:08:17 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1

On 14/12/19 17:02, Philippe Mathieu-Daudé wrote:
> If a subregion is mapped out of the parent region range, it
> will never get accessed. Since this is a bug, abort to help
> the developer notice the mistake.
> 
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> ---
>  memory.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/memory.c b/memory.c
> index 06484c2bff..61f355dcd5 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -2390,6 +2390,7 @@ static void 
> memory_region_add_subregion_common(MemoryRegion *mr,
>  {
>      assert(!subregion->container);
>      subregion->container = mr;
> +    assert(offset + memory_region_size(subregion) <= memory_region_size(mr));
>      subregion->addr = offset;
>      memory_region_update_container_subregions(subregion);
>  }
> 

I think in some cases this could be intentional, for example if you have
different models with different BAR sizes and you organize this with the
same tree of MemoryRegion and different sizes for the parent.  I'm not
saying this happens in the current devices we support, I'm just
wondering if it should be a reason not to apply the patch.  I suppose
you did spend some time debugging something where the patch would have
been useful; what was that something?

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]