Patchwork [19/30] memory: Introduce address_space_lookup_region

login
register
mail settings
Submitter Paolo Bonzini
Date May 21, 2013, 10:57 a.m.
Message ID <1369133851-1894-20-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/245270/
State New
Headers show

Comments

Paolo Bonzini - May 21, 2013, 10:57 a.m.
From: Jan Kiszka <jan.kiszka@siemens.com>

This introduces a wrapper for phys_page_find (before we complicate
address_space_translate with IOMMU translation).  This function will
also encapsulate locking and reference counting when we introduce
BQL-free dispatching.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 exec.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Peter Maydell - May 23, 2013, 6:19 p.m.
On 21 May 2013 11:57, Paolo Bonzini <pbonzini@redhat.com> wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> This introduces a wrapper for phys_page_find (before we complicate
> address_space_translate with IOMMU translation).  This function will
> also encapsulate locking and reference counting when we introduce
> BQL-free dispatching.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM

Patch

diff --git a/exec.c b/exec.c
index 4cc5ecb..a29dec5 100644
--- a/exec.c
+++ b/exec.c
@@ -198,13 +198,19 @@  static MemoryRegionSection *phys_page_find(AddressSpaceDispatch *d, hwaddr index
     return &phys_sections[lp.ptr];
 }
 
+static MemoryRegionSection *address_space_lookup_region(AddressSpace *as,
+                                                        hwaddr addr)
+{
+    return phys_page_find(as->dispatch, addr >> TARGET_PAGE_BITS);
+}
+
 MemoryRegionSection *address_space_translate(AddressSpace *as, hwaddr addr,
                                              hwaddr *xlat, hwaddr *plen,
                                              bool is_write)
 {
     MemoryRegionSection *section;
 
-    section = phys_page_find(as->dispatch, addr >> TARGET_PAGE_BITS);
+    section = address_space_lookup_region(as, addr);
     /* Compute offset within MemoryRegionSection */
     addr -= section->offset_within_address_space;
     *plen = MIN(section->size - addr, *plen);