qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 17/21] introduce memory_region_get_address() and


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 17/21] introduce memory_region_get_address() and use it in kvm/ioapic
Date: Wed, 24 Apr 2013 12:26:48 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4

Il 24/04/2013 12:22, Paolo Bonzini ha scritto:
> diff --git a/memory.c b/memory.c
> index c82bd12..dba0a4b 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1451,15 +1451,24 @@ static FlatRange *address_space_lookup(AddressSpace 
> *as, AddrRange addr)
>                     sizeof(FlatRange), cmp_flatrange_addr);
>  }
>  
> -MemoryRegionSection memory_region_find(MemoryRegion *address_space,
> +MemoryRegionSection memory_region_find(MemoryRegion *mr,
>                                         hwaddr addr, uint64_t size)
>  {
> -    AddressSpace *as = memory_region_to_address_space(address_space);
> -    AddrRange range = addrrange_make(int128_make64(addr),
> -                                     int128_make64(size));
> -    FlatRange *fr = address_space_lookup(as, range);
>      MemoryRegionSection ret = { .mr = NULL, .size = 0 };
> +    MemoryRegion *root;
> +    AddressSpace *as;
> +    AddrRange range;
> +    FlatRange *fr;
> +
> +    addr += mr->addr;
> +    for (root = mr; root->parent; ) {
> +        root = root->parent;
> +        addr += root->addr;
> +    }
>  
> +    as = memory_region_to_address_space(root);
> +    range = addrrange_make(int128_make64(addr), int128_make64(size));
> +    fr = address_space_lookup(as, range);
>      if (!fr) {
>          return ret;
>      }
> 

Looking at the code again, mrs.address_space is not filled in.  This should
be squashed in too for completeness.

diff --git a/memory.c b/memory.c
index dba0a4b..1916937 100644
--- a/memory.c
+++ b/memory.c
@@ -1479,6 +1479,7 @@ MemoryRegionSection memory_region_find(MemoryRegion *mr,
     }
 
     ret.mr = fr->mr;
+    ret.address_space = as;
     range = addrrange_intersection(range, fr->addr);
     ret.offset_within_region = fr->offset_in_region;
     ret.offset_within_region += int128_get64(int128_sub(range.start,

Paolo



reply via email to

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