From: Masahiro Yamada <yamada.m@jp.panasonic.com>
To: linux-arm-kernel@lists.infradead.org
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Russell King - ARM Linux <linux@arm.linux.org.uk>,
Masahiro Yamada <yamada.m@jp.panasonic.com>,
Santosh Shilimkar <santosh.shilimkar@ti.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Will Deacon <will.deacon@arm.com>,
Olof Johansson <olof@lixom.net>,
Laura Abbott <lauraa@codeaurora.org>,
Daniel Thompson <daniel.thompson@linaro.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH v2] ARM: mm: fix size rounding-down of arm_add_memory() function
Date: Mon, 22 Dec 2014 12:17:29 +0900 [thread overview]
Message-ID: <1419218249-5744-1-git-send-email-yamada.m@jp.panasonic.com> (raw)
The current rounding of "size" is wrong:
- If "start" is sufficiently near the next page boundary, "size"
is decremented by more than enough and the last page is lost.
- If "size" is sufficiently small, it is wrapped around and gets
a bogus value.
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Changes in v2:
- Avoid wrap around of "size"
arch/arm/kernel/setup.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index f9c8639..d13f185 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -657,10 +657,13 @@ int __init arm_add_memory(u64 start, u64 size)
/*
* Ensure that start/size are aligned to a page boundary.
- * Size is appropriately rounded down, start is rounded up.
+ * Size is rounded down, start is rounded up.
*/
- size -= start & ~PAGE_MASK;
aligned_start = PAGE_ALIGN(start);
+ if (aligned_start > start + size)
+ size = 0;
+ else
+ size -= aligned_start - start;
#ifndef CONFIG_ARCH_PHYS_ADDR_T_64BIT
if (aligned_start > ULONG_MAX) {
--
1.9.1
next reply other threads:[~2014-12-22 3:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-22 3:17 Masahiro Yamada [this message]
2014-12-22 9:09 ` Ard Biesheuvel
2015-01-14 2:53 ` Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1419218249-5744-1-git-send-email-yamada.m@jp.panasonic.com \
--to=yamada.m@jp.panasonic.com \
--cc=akpm@linux-foundation.org \
--cc=ard.biesheuvel@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=daniel.thompson@linaro.org \
--cc=geert@linux-m68k.org \
--cc=lauraa@codeaurora.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=olof@lixom.net \
--cc=santosh.shilimkar@ti.com \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®