From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Keir Fraser <keir@xen.org>,
Ian Campbell <ian.campbell@citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Tim Deegan <tim@xen.org>,
Stefano Stabellini <stefano.stabellini@citrix.com>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH 2/2] xen/vmap: Convert vmap() to using mfn_t
Date: Wed, 3 Jun 2015 12:43:23 +0100 [thread overview]
Message-ID: <1433331803-1783-3-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1433331803-1783-1-git-send-email-andrew.cooper3@citrix.com>
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <JBeulich@suse.com>
CC: Tim Deegan <tim@xen.org>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Stefano Stabellini <stefano.stabellini@citrix.com>
---
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
next prev parent reply other threads:[~2015-06-03 11:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-03 11:43 [PATCH 0/2] xen/mem Common cleanup Andrew Cooper
2015-06-03 11:43 ` [PATCH 1/2] xen/mem: Expose typesafe mfns/gfns/pfns to common code Andrew Cooper
2015-06-03 11:43 ` Andrew Cooper [this message]
2015-06-04 14:00 ` [PATCH 0/2] xen/mem Common cleanup Tim Deegan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1433331803-1783-3-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=ian.campbell@citrix.com \
--cc=keir@xen.org \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).