RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap

For 32bit, the upper 32-bit of phys_addr_t will be flushed to zero
after AND with PAGE_MASK because the data type of PAGE_MASK is
unsigned long. To fix this problem, the page alignment is done by
subtracting the page offset instead of AND with PAGE_MASK.

Signed-off-by: Vincent Chen <vincentc@andestech.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
This commit is contained in:
Vincent Chen 2018-10-02 16:52:31 +08:00 committed by Palmer Dabbelt
parent 757331db92
commit 827a438156
No known key found for this signature in database
GPG Key ID: EF4CA1502CCBAB41
1 changed files with 1 additions and 1 deletions

View File

@ -42,7 +42,7 @@ static void __iomem *__ioremap_caller(phys_addr_t addr, size_t size,
/* Page-align mappings */
offset = addr & (~PAGE_MASK);
addr &= PAGE_MASK;
addr -= offset;
size = PAGE_ALIGN(size + offset);
area = get_vm_area_caller(size, VM_IOREMAP, caller);