diff mbox

[V3,10/41] xen/mm: Align virtual address on PAGE_SIZE in iounmap

Message ID 1368152307-598-11-git-send-email-julien.grall@linaro.org
State Superseded, archived
Headers show

Commit Message

Julien Grall May 10, 2013, 2:17 a.m. UTC
ioremap function can unlikely return an unaligned virtual address if
the physical address itself is unaligned on a page size.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
CC: JBeulich@suse.com
CC: keir@xen.org
---
 xen/include/xen/vmap.h |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jan Beulich May 10, 2013, 8:23 a.m. UTC | #1
>>> On 10.05.13 at 04:17, Julien Grall <julien.grall@linaro.org> wrote:
> ioremap function can unlikely return an unaligned virtual address if
> the physical address itself is unaligned on a page size.
> 
> Signed-off-by: Julien Grall <julien.grall@linaro.org>

If you used "unsigned long" instead of "vaddr_t" (I don't think this
would build on x86 without doing so, as vaddr-t appear to be ARM
specific):

Acked-by: Jan Beulich <jbeulich@suse.com>

> --- a/xen/include/xen/vmap.h
> +++ b/xen/include/xen/vmap.h
> @@ -15,7 +15,9 @@ void __iomem *ioremap(paddr_t, size_t);
>  
>  static inline void iounmap(void __iomem *va)
>  {
> -    vunmap((void __force *)va);
> +    vaddr_t addr = (vaddr_t)(void __force *)va;
> +
> +    vunmap((void *)(addr & PAGE_MASK));
>  }
>  
>  void vm_init(void);
Julien Grall May 10, 2013, 12:40 p.m. UTC | #2
On 05/10/2013 09:23 AM, Jan Beulich wrote:

>>>> On 10.05.13 at 04:17, Julien Grall <julien.grall@linaro.org> wrote:
>> ioremap function can unlikely return an unaligned virtual address if
>> the physical address itself is unaligned on a page size.
>>
>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> 
> If you used "unsigned long" instead of "vaddr_t" (I don't think this
> would build on x86 without doing so, as vaddr-t appear to be ARM
> specific):

Right. I will fix it.

> Acked-by: Jan Beulich <jbeulich@suse.com>
> 
>> --- a/xen/include/xen/vmap.h
>> +++ b/xen/include/xen/vmap.h
>> @@ -15,7 +15,9 @@ void __iomem *ioremap(paddr_t, size_t);
>>  
>>  static inline void iounmap(void __iomem *va)
>>  {
>> -    vunmap((void __force *)va);
>> +    vaddr_t addr = (vaddr_t)(void __force *)va;
>> +
>> +    vunmap((void *)(addr & PAGE_MASK));
>>  }
>>  
>>  void vm_init(void);
> 
>
diff mbox

Patch

diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h
index 88e5d99..c713a43 100644
--- a/xen/include/xen/vmap.h
+++ b/xen/include/xen/vmap.h
@@ -15,7 +15,9 @@  void __iomem *ioremap(paddr_t, size_t);
 
 static inline void iounmap(void __iomem *va)
 {
-    vunmap((void __force *)va);
+    vaddr_t addr = (vaddr_t)(void __force *)va;
+
+    vunmap((void *)(addr & PAGE_MASK));
 }
 
 void vm_init(void);