[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191127203123.912390742@linuxfoundation.org>
Date: Wed, 27 Nov 2019 21:29:30 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Vincent Chen <vincentc@...estech.com>,
Christoph Hellwig <hch@....de>,
Palmer Dabbelt <palmer@...ive.com>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH 4.19 120/306] RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap
From: Vincent Chen <vincentc@...estech.com>
[ 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: Vincent Chen <vincentc@...estech.com>
Reviewed-by: Christoph Hellwig <hch@....de>
Signed-off-by: Palmer Dabbelt <palmer@...ive.com>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
arch/riscv/mm/ioremap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/mm/ioremap.c b/arch/riscv/mm/ioremap.c
index 70ef2724cdf61..bd2f2db557cc5 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);
--
2.20.1
Powered by blists - more mailing lists