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

[Xen-devel] [PATCH 2/2] xen/vmap: Convert vmap() to using mfn_t



No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CC: Keir Fraser <keir@xxxxxxx>
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Tim Deegan <tim@xxxxxxx>
CC: Ian Campbell <ian.campbell@xxxxxxxxxx>
CC: Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>

---
Compile tested on all architecutres, functionally tested on x86.
---
 xen/arch/arm/mm.c              |    8 +++++---
 xen/arch/x86/domain_page.c     |    3 ++-
 xen/arch/x86/mm.c              |    6 +++---
 xen/arch/x86/mm/shadow/multi.c |    6 +++---
 xen/common/vmap.c              |   14 +++++++-------
 xen/drivers/acpi/osl.c         |    5 +++--
 xen/include/xen/vmap.h         |    6 +++---
 7 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index a91ea77..feabe34 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -273,7 +273,9 @@ void clear_fixmap(unsigned map)
 #ifdef CONFIG_DOMAIN_PAGE
 void *map_domain_page_global(unsigned long mfn)
 {
-    return vmap(&mfn, 1);
+    mfn_t m = _mfn(mfn);
+
+    return vmap(&m, 1);
 }
 
 void unmap_domain_page_global(const void *va)
@@ -794,10 +796,10 @@ void *__init arch_vmap_virt_end(void)
  */
 void *ioremap_attr(paddr_t pa, size_t len, unsigned int attributes)
 {
-    unsigned long pfn = PFN_DOWN(pa);
+    mfn_t mfn = _mfn(PFN_DOWN(pa));
     unsigned int offs = pa & (PAGE_SIZE - 1);
     unsigned int nr = PFN_UP(offs + len);
-    void *ptr = __vmap(&pfn, nr, 1, 1, attributes);
+    void *ptr = __vmap(&mfn, nr, 1, 1, attributes);
 
     if ( ptr == NULL )
         return NULL;
diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c
index 7954998..8f3217b 100644
--- a/xen/arch/x86/domain_page.c
+++ b/xen/arch/x86/domain_page.c
@@ -322,6 +322,7 @@ int mapcache_vcpu_init(struct vcpu *v)
 
 void *map_domain_page_global(unsigned long mfn)
 {
+    mfn_t m = _mfn(mfn);
     ASSERT(!in_irq() && local_irq_is_enabled());
 
 #ifdef NDEBUG
@@ -329,7 +330,7 @@ void *map_domain_page_global(unsigned long mfn)
         return mfn_to_virt(mfn);
 #endif
 
-    return vmap(&mfn, 1);
+    return vmap(&m, 1);
 }
 
 void unmap_domain_page_global(const void *ptr)
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 7a7a854..1c0783f 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5883,10 +5883,10 @@ void *__init arch_vmap_virt_end(void)
 
 void __iomem *ioremap(paddr_t pa, size_t len)
 {
-    unsigned long pfn = PFN_DOWN(pa);
+    mfn_t mfn = _mfn(PFN_DOWN(pa));
     void *va;
 
-    WARN_ON(page_is_ram_type(pfn, RAM_TYPE_CONVENTIONAL));
+    WARN_ON(page_is_ram_type(mfn_x(mfn), RAM_TYPE_CONVENTIONAL));
 
     /* The low first Mb is always mapped. */
     if ( !((pa + len - 1) >> 20) )
@@ -5896,7 +5896,7 @@ void __iomem *ioremap(paddr_t pa, size_t len)
         unsigned int offs = pa & (PAGE_SIZE - 1);
         unsigned int nr = PFN_UP(offs + len);
 
-        va = __vmap(&pfn, nr, 1, 1, PAGE_HYPERVISOR_NOCACHE) + offs;
+        va = __vmap(&mfn, nr, 1, 1, PAGE_HYPERVISOR_NOCACHE) + offs;
     }
 
     return (void __force __iomem *)va;
diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
index 43e70d8..6edac71 100644
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -4670,7 +4670,7 @@ static void *emulate_map_dest(struct vcpu *v,
     }
     else
     {
-        unsigned long mfns[2];
+        mfn_t mfns[2];
 
         /* Cross-page emulated writes are only supported for HVM guests;
          * PV guests ought to know better */
@@ -4689,8 +4689,8 @@ static void *emulate_map_dest(struct vcpu *v,
         /* Cross-page writes mean probably not a pagetable */
         sh_remove_shadows(d, sh_ctxt->mfn2, 0, 0 /* Slow, can fail */ );
 
-        mfns[0] = mfn_x(sh_ctxt->mfn1);
-        mfns[1] = mfn_x(sh_ctxt->mfn2);
+        mfns[0] = sh_ctxt->mfn1;
+        mfns[1] = sh_ctxt->mfn2;
         map = vmap(mfns, 2);
         if ( !map )
             return MAPPING_UNHANDLEABLE;
diff --git a/xen/common/vmap.c b/xen/common/vmap.c
index ac66a8c..c57239f 100644
--- a/xen/common/vmap.c
+++ b/xen/common/vmap.c
@@ -181,7 +181,7 @@ void vm_free(const void *va)
     spin_unlock(&vm_lock);
 }
 
-void *__vmap(const unsigned long *mfn, unsigned int granularity,
+void *__vmap(const mfn_t *mfn, unsigned int granularity,
              unsigned int nr, unsigned int align, unsigned int flags)
 {
     void *va = vm_alloc(nr * granularity, align);
@@ -189,7 +189,7 @@ void *__vmap(const unsigned long *mfn, unsigned int 
granularity,
 
     for ( ; va && nr--; ++mfn, cur += PAGE_SIZE * granularity )
     {
-        if ( map_pages_to_xen(cur, *mfn, granularity, flags) )
+        if ( map_pages_to_xen(cur, mfn_x(*mfn), granularity, flags) )
         {
             vunmap(va);
             va = NULL;
@@ -199,7 +199,7 @@ void *__vmap(const unsigned long *mfn, unsigned int 
granularity,
     return va;
 }
 
-void *vmap(const unsigned long *mfn, unsigned int nr)
+void *vmap(const mfn_t *mfn, unsigned int nr)
 {
     return __vmap(mfn, 1, nr, 1, PAGE_HYPERVISOR);
 }
@@ -218,7 +218,7 @@ void vunmap(const void *va)
 
 void *vmalloc(size_t size)
 {
-    unsigned long *mfn;
+    mfn_t *mfn;
     size_t pages, i;
     struct page_info *pg;
     void *va;
@@ -226,7 +226,7 @@ void *vmalloc(size_t size)
     ASSERT(size);
 
     pages = PFN_UP(size);
-    mfn = xmalloc_array(unsigned long, pages);
+    mfn = xmalloc_array(mfn_t, pages);
     if ( mfn == NULL )
         return NULL;
 
@@ -235,7 +235,7 @@ void *vmalloc(size_t size)
         pg = alloc_domheap_page(NULL, 0);
         if ( pg == NULL )
             goto error;
-        mfn[i] = page_to_mfn(pg);
+        mfn[i] = _mfn(page_to_mfn(pg));
     }
 
     va = vmap(mfn, pages);
@@ -247,7 +247,7 @@ void *vmalloc(size_t size)
 
  error:
     while ( i-- )
-         free_domheap_page(mfn_to_page(mfn[i]));
+        free_domheap_page(mfn_to_page(mfn_x(mfn[i])));
     xfree(mfn);
     return NULL;
 }
diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
index 93c983c..4c09859 100644
--- a/xen/drivers/acpi/osl.c
+++ b/xen/drivers/acpi/osl.c
@@ -88,13 +88,14 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
 acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
 {
        if (system_state >= SYS_STATE_active) {
-               unsigned long pfn = PFN_DOWN(phys);
+               mfn_t mfn = _mfn(PFN_DOWN(phys));
                unsigned int offs = phys & (PAGE_SIZE - 1);
 
                /* The low first Mb is always mapped. */
                if ( !((phys + size - 1) >> 20) )
                        return __va(phys);
-               return __vmap(&pfn, PFN_UP(offs + size), 1, 1, 
PAGE_HYPERVISOR_NOCACHE) + offs;
+               return __vmap(&mfn, PFN_UP(offs + size), 1, 1,
+                             PAGE_HYPERVISOR_NOCACHE) + offs;
        }
        return __acpi_map_table(phys, size);
 }
diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h
index a13591d..5671ac8 100644
--- a/xen/include/xen/vmap.h
+++ b/xen/include/xen/vmap.h
@@ -1,15 +1,15 @@
 #if !defined(__XEN_VMAP_H__) && defined(VMAP_VIRT_START)
 #define __XEN_VMAP_H__
 
-#include <xen/types.h>
+#include <xen/mm.h>
 #include <asm/page.h>
 
 void *vm_alloc(unsigned int nr, unsigned int align);
 void vm_free(const void *);
 
-void *__vmap(const unsigned long *mfn, unsigned int granularity,
+void *__vmap(const mfn_t *mfn, unsigned int granularity,
              unsigned int nr, unsigned int align, unsigned int flags);
-void *vmap(const unsigned long *mfn, unsigned int nr);
+void *vmap(const mfn_t *mfn, unsigned int nr);
 void vunmap(const void *);
 void *vmalloc(size_t size);
 void *vzalloc(size_t size);
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.