From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUwum-0005J1-JM for qemu-devel@nongnu.org; Wed, 24 Apr 2013 06:27:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUwuk-0002CO-VW for qemu-devel@nongnu.org; Wed, 24 Apr 2013 06:27:04 -0400 Received: from mail-wg0-x22f.google.com ([2a00:1450:400c:c00::22f]:44930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUwuk-0002CH-PE for qemu-devel@nongnu.org; Wed, 24 Apr 2013 06:27:02 -0400 Received: by mail-wg0-f47.google.com with SMTP id j13so754726wgh.2 for ; Wed, 24 Apr 2013 03:27:02 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <5177B368.4080708@redhat.com> Date: Wed, 24 Apr 2013 12:26:48 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1366798928-14418-1-git-send-email-pbonzini@redhat.com> In-Reply-To: <1366798928-14418-1-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 17/21] introduce memory_region_get_address() and use it in kvm/ioapic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "kwolf@redhat.com" , peter.maydell@linaro.org, "aliguori@us.ibm.com" , "ehabkost@redhat.com" , "gleb@redhat.com" , "mst@redhat.com" , Jan Kiszka , "quintela@redhat.com" , claudio.fontana@huawei.com, "qemu-devel@nongnu.org" , "aderumier@odiso.com" , "lcapitulino@redhat.com" , "blauwirbel@gmail.com" , "anthony.perard@citrix.com" , "alex.williamson@redhat.com" , "kraxel@redhat.com" , "yang.z.zhang@intel.com" , "stefano.stabellini@eu.citrix.com" , "armbru@redhat.com" , "rth@twiddle.net" 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