提交 fd153abb 编写于 作者: N Nicolas Pitre

[ARM] Orion: fix ioremap() optimization

The ioremap() optimization used for internal register didn't cope
with the fact that paddr + size can wrap to zero if the area extends
to the end of the physical address space.

Issue isolated by Sylver Bruneau <sylver.bruneau@googlemail.com>.
Signed-off-by: NNicolas Pitre <nico@marvell.com>
上级 c5a1e8f7
...@@ -20,11 +20,10 @@ static inline void __iomem * ...@@ -20,11 +20,10 @@ static inline void __iomem *
__arch_ioremap(unsigned long paddr, size_t size, unsigned int mtype) __arch_ioremap(unsigned long paddr, size_t size, unsigned int mtype)
{ {
void __iomem *retval; void __iomem *retval;
unsigned long offs = paddr - ORION5X_REGS_PHYS_BASE;
if (mtype == MT_DEVICE && size && paddr >= ORION5X_REGS_PHYS_BASE && if (mtype == MT_DEVICE && size && offs < ORION5X_REGS_SIZE &&
paddr + size <= ORION5X_REGS_PHYS_BASE + ORION5X_REGS_SIZE) { size <= ORION5X_REGS_SIZE && offs + size <= ORION5X_REGS_SIZE) {
retval = (void __iomem *)ORION5X_REGS_VIRT_BASE + retval = (void __iomem *)ORION5X_REGS_VIRT_BASE + offs;
(paddr - ORION5X_REGS_PHYS_BASE);
} else { } else {
retval = __arm_ioremap(paddr, size, mtype); retval = __arm_ioremap(paddr, size, mtype);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册