Skip to content

Commit 827a438

Browse files
Vincent Chenpalmer-dabbelt
authored andcommitted
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>
1 parent 757331d commit 827a438

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/riscv/mm/ioremap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void __iomem *__ioremap_caller(phys_addr_t addr, size_t size,
4242

4343
/* Page-align mappings */
4444
offset = addr & (~PAGE_MASK);
45-
addr &= PAGE_MASK;
45+
addr -= offset;
4646
size = PAGE_ALIGN(size + offset);
4747

4848
area = get_vm_area_caller(size, VM_IOREMAP, caller);

0 commit comments

Comments
 (0)