summaryrefslogtreecommitdiffstats
path: root/arch/riscv
diff options
context:
space:
mode:
authorVincent Chen <vincentc@andestech.com>2018-10-02 10:52:31 +0200
committerPalmer Dabbelt <palmer@sifive.com>2018-10-23 02:02:56 +0200
commit827a438156e4c423b6875a092e272933952a2910 (patch)
treeb06c4c99ec6e728b6447a5a6c6d61bac60c84e78 /arch/riscv
parentRISC-V: Select GENERIC_LIB_UMODDI3 on RV32 (diff)
downloadlinux-827a438156e4c423b6875a092e272933952a2910.tar.xz
linux-827a438156e4c423b6875a092e272933952a2910.zip
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>
Diffstat (limited to 'arch/riscv')
-rw-r--r--arch/riscv/mm/ioremap.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/riscv/mm/ioremap.c b/arch/riscv/mm/ioremap.c
index 70ef2724cdf6..bd2f2db557cc 100644
--- a/arch/riscv/mm/ioremap.c
+++ b/arch/riscv/mm/ioremap.c
@@ -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);