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

[Xen-devel] [PATCH] vunmap: let vunmap align virtual address by itself



From: Andrii Anisov <andrii_anisov@xxxxxxxx>

Let vunmap align passed virtual address by PAGE_SIZE.
This also makes it consistent with how {,un}map_domain_page()
currently works.

With the main change, also:
 - strip all existing vunmap() calls from prior masking
 - replace opencoded PAGE_MASK macro in vm_index()

Signed-off-by: Andrii Anisov <andrii_anisov@xxxxxxxx>
---
 xen/arch/x86/mm/shadow/hvm.c | 2 +-
 xen/common/vmap.c            | 4 ++--
 xen/drivers/acpi/osl.c       | 2 +-
 xen/include/xen/vmap.h       | 4 +---
 4 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/mm/shadow/hvm.c b/xen/arch/x86/mm/shadow/hvm.c
index c6469c8..8561a11 100644
--- a/xen/arch/x86/mm/shadow/hvm.c
+++ b/xen/arch/x86/mm/shadow/hvm.c
@@ -597,7 +597,7 @@ static void sh_emulate_unmap_dest(struct vcpu *v, void 
*addr,
     {
         paging_mark_dirty(v->domain, sh_ctxt->mfn[1]);
         put_page(mfn_to_page(sh_ctxt->mfn[1]));
-        vunmap((void *)((unsigned long)addr & PAGE_MASK));
+        vunmap(addr);
     }
     else
         unmap_domain_page(addr);
diff --git a/xen/common/vmap.c b/xen/common/vmap.c
index faebc1d..e7bd6bf 100644
--- a/xen/common/vmap.c
+++ b/xen/common/vmap.c
@@ -141,7 +141,7 @@ static void *vm_alloc(unsigned int nr, unsigned int align,
 
 static unsigned int vm_index(const void *va, enum vmap_region type)
 {
-    unsigned long addr = (unsigned long)va & ~(PAGE_SIZE - 1);
+    unsigned long addr = (unsigned long)va & PAGE_MASK;
     unsigned int idx;
     unsigned long start = (unsigned long)vm_base[type];
 
@@ -225,7 +225,7 @@ void *vmap(const mfn_t *mfn, unsigned int nr)
 
 void vunmap(const void *va)
 {
-    unsigned long addr = (unsigned long)va;
+    unsigned long addr = (unsigned long)va & PAGE_MASK;
     unsigned int pages = vm_size(va, VMAP_DEFAULT);
 
     if ( !pages )
diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
index 4c8bb78..1a91453 100644
--- a/xen/drivers/acpi/osl.c
+++ b/xen/drivers/acpi/osl.c
@@ -115,7 +115,7 @@ void acpi_os_unmap_memory(void __iomem * virt, acpi_size 
size)
        }
 
        if (system_state >= SYS_STATE_boot)
-               vunmap((void *)((unsigned long)virt & PAGE_MASK));
+               vunmap(virt);
 }
 
 acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h
index 369560e..a556d13 100644
--- a/xen/include/xen/vmap.h
+++ b/xen/include/xen/vmap.h
@@ -27,9 +27,7 @@ void __iomem *ioremap(paddr_t, size_t);
 
 static inline void iounmap(void __iomem *va)
 {
-    unsigned long addr = (unsigned long)(void __force *)va;
-
-    vunmap((void *)(addr & PAGE_MASK));
+    vunmap((void *)va);
 }
 
 void *arch_vmap_virt_end(void);
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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