2018-10-02 08:59:55

by Zong Li

[permalink] [raw]
Subject: [PATCH v3 5/5] RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap

From: Vincent Chen <[email protected]>

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 <[email protected]>
---
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 70ef272..bd2f2db 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.7.4



2018-10-02 14:52:25

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v3 5/5] RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap

On Tue, Oct 02, 2018 at 04:52:31PM +0800, Zong Li wrote:
> From: Vincent Chen <[email protected]>
>
> 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 <[email protected]>

Looks good,

Reviewed-by: Christoph Hellwig <[email protected]>

(and I'm pretty sure I reviewed this before..)

2018-10-03 03:27:15

by Zong Li

[permalink] [raw]
Subject: Re: [PATCH v3 5/5] RISC-V: Avoid corrupting the upper 32-bit of phys_addr_t in ioremap

Christoph Hellwig <[email protected]> 於 2018年10月2日 週二 下午10:51寫道:
>
> On Tue, Oct 02, 2018 at 04:52:31PM +0800, Zong Li wrote:
> > From: Vincent Chen <[email protected]>
> >
> > 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 <[email protected]>
>
> Looks good,
>
> Reviewed-by: Christoph Hellwig <[email protected]>
>
> (and I'm pretty sure I reviewed this before..)

Hi Christoph,

Very sorry about that. I didn't notice I lose these review tags. Could
you please help to review again in version 4 patches? Thank you.

Regards,
Zong