Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bb925b9b authored by Vincent Chen's avatar Vincent Chen Committed by Greg Kroah-Hartman
Browse files

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



[ Upstream commit 827a438156e4c423b6875a092e272933952a2910 ]

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: default avatarVincent Chen <vincentc@andestech.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarPalmer Dabbelt <palmer@sifive.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 829aa617
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);