Skip to content

Commit

Permalink
RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vincent Chen authored and Palmer Dabbelt committed Oct 23, 2018
1 parent 757331d commit 827a438
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/riscv/mm/ioremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 827a438

Please sign in to comment.