From: Will Deacon <will.deacon@arm.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>,
"Wang, Yalin" <Yalin.Wang@sonymobile.com>,
"'linux-mm@kvack.org'" <linux-mm@kvack.org>,
"'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>,
"'linux-arm-kernel@lists.infradead.org'"
<linux-arm-kernel@lists.infradead.org>,
"'linux-arm-msm@vger.kernel.org'" <linux-arm-msm@vger.kernel.org>,
Peter Maydell <Peter.Maydell@arm.com>
Subject: Re: [RFC v2] arm:extend the reserved mrmory for initrd to be page aligned
Date: Fri, 5 Dec 2014 12:05:06 +0000 [thread overview]
Message-ID: <20141205120506.GH1630@arm.com> (raw)
In-Reply-To: <20141204120305.GC17783@e104818-lin.cambridge.arm.com>
On Thu, Dec 04, 2014 at 12:03:05PM +0000, Catalin Marinas wrote:
> On Mon, Sep 15, 2014 at 12:33:25PM +0100, Russell King - ARM Linux wrote:
> > On Mon, Sep 15, 2014 at 07:07:20PM +0800, Wang, Yalin wrote:
> > > @@ -636,6 +646,11 @@ static int keep_initrd;
> > > void free_initrd_mem(unsigned long start, unsigned long end)
> > > {
> > > if (!keep_initrd) {
> > > + if (start == initrd_start)
> > > + start = round_down(start, PAGE_SIZE);
> > > + if (end == initrd_end)
> > > + end = round_up(end, PAGE_SIZE);
> > > +
> > > poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
> > > free_reserved_area((void *)start, (void *)end, -1, "initrd");
> > > }
> >
> > is the only bit of code you likely need to achieve your goal.
> >
> > Thinking about this, I think that you are quite right to align these.
> > The memory around the initrd is defined to be system memory, and we
> > already free the pages around it, so it *is* wrong not to free the
> > partial initrd pages.
>
> Actually, I think we have a problem, at least on arm64 (raised by Peter
> Maydell). There is no guarantee that the page around start/end of initrd
> is free, it may contain the dtb for example. This is even more obvious
> when we have a 64KB page kernel (the boot loader doesn't know the page
> size that the kernel is going to use).
>
> The bug was there before as we had poison_init_mem() already (not it
> disappeared since free_reserved_area does the poisoning).
>
> So as a quick fix I think we need the rounding the other way (and in the
> general case we probably lose a page at the end of initrd):
>
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index 494297c698ca..39fd080683e7 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -335,9 +335,9 @@ void free_initrd_mem(unsigned long start, unsigned long end)
> {
> if (!keep_initrd) {
> if (start == initrd_start)
> - start = round_down(start, PAGE_SIZE);
> + start = round_up(start, PAGE_SIZE);
> if (end == initrd_end)
> - end = round_up(end, PAGE_SIZE);
> + end = round_down(end, PAGE_SIZE);
>
> free_reserved_area((void *)start, (void *)end, 0, "initrd");
> }
>
> A better fix would be to check what else is around the start/end of
> initrd.
Care to submit this as a proper patch? We should at least fix Peter's issue
before doing things like extending headers, which won't work for older
kernels anyway.
Will
WARNING: multiple messages have this Message-ID (diff)
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC v2] arm:extend the reserved mrmory for initrd to be page aligned
Date: Fri, 5 Dec 2014 12:05:06 +0000 [thread overview]
Message-ID: <20141205120506.GH1630@arm.com> (raw)
In-Reply-To: <20141204120305.GC17783@e104818-lin.cambridge.arm.com>
On Thu, Dec 04, 2014 at 12:03:05PM +0000, Catalin Marinas wrote:
> On Mon, Sep 15, 2014 at 12:33:25PM +0100, Russell King - ARM Linux wrote:
> > On Mon, Sep 15, 2014 at 07:07:20PM +0800, Wang, Yalin wrote:
> > > @@ -636,6 +646,11 @@ static int keep_initrd;
> > > void free_initrd_mem(unsigned long start, unsigned long end)
> > > {
> > > if (!keep_initrd) {
> > > + if (start == initrd_start)
> > > + start = round_down(start, PAGE_SIZE);
> > > + if (end == initrd_end)
> > > + end = round_up(end, PAGE_SIZE);
> > > +
> > > poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
> > > free_reserved_area((void *)start, (void *)end, -1, "initrd");
> > > }
> >
> > is the only bit of code you likely need to achieve your goal.
> >
> > Thinking about this, I think that you are quite right to align these.
> > The memory around the initrd is defined to be system memory, and we
> > already free the pages around it, so it *is* wrong not to free the
> > partial initrd pages.
>
> Actually, I think we have a problem, at least on arm64 (raised by Peter
> Maydell). There is no guarantee that the page around start/end of initrd
> is free, it may contain the dtb for example. This is even more obvious
> when we have a 64KB page kernel (the boot loader doesn't know the page
> size that the kernel is going to use).
>
> The bug was there before as we had poison_init_mem() already (not it
> disappeared since free_reserved_area does the poisoning).
>
> So as a quick fix I think we need the rounding the other way (and in the
> general case we probably lose a page at the end of initrd):
>
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index 494297c698ca..39fd080683e7 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -335,9 +335,9 @@ void free_initrd_mem(unsigned long start, unsigned long end)
> {
> if (!keep_initrd) {
> if (start == initrd_start)
> - start = round_down(start, PAGE_SIZE);
> + start = round_up(start, PAGE_SIZE);
> if (end == initrd_end)
> - end = round_up(end, PAGE_SIZE);
> + end = round_down(end, PAGE_SIZE);
>
> free_reserved_area((void *)start, (void *)end, 0, "initrd");
> }
>
> A better fix would be to check what else is around the start/end of
> initrd.
Care to submit this as a proper patch? We should at least fix Peter's issue
before doing things like extending headers, which won't work for older
kernels anyway.
Will
WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will.deacon@arm.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>,
"Wang, Yalin" <Yalin.Wang@sonymobile.com>,
"'linux-mm@kvack.org'" <linux-mm@kvack.org>,
"'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>,
"'linux-arm-kernel@lists.infradead.org'"
<linux-arm-kernel@lists.infradead.org>,
"'linux-arm-msm@vger.kernel.org'" <linux-arm-msm@vger.kernel.org>,
Peter Maydell <Peter.Maydell@arm.com>
Subject: Re: [RFC v2] arm:extend the reserved mrmory for initrd to be page aligned
Date: Fri, 5 Dec 2014 12:05:06 +0000 [thread overview]
Message-ID: <20141205120506.GH1630@arm.com> (raw)
In-Reply-To: <20141204120305.GC17783@e104818-lin.cambridge.arm.com>
On Thu, Dec 04, 2014 at 12:03:05PM +0000, Catalin Marinas wrote:
> On Mon, Sep 15, 2014 at 12:33:25PM +0100, Russell King - ARM Linux wrote:
> > On Mon, Sep 15, 2014 at 07:07:20PM +0800, Wang, Yalin wrote:
> > > @@ -636,6 +646,11 @@ static int keep_initrd;
> > > void free_initrd_mem(unsigned long start, unsigned long end)
> > > {
> > > if (!keep_initrd) {
> > > + if (start == initrd_start)
> > > + start = round_down(start, PAGE_SIZE);
> > > + if (end == initrd_end)
> > > + end = round_up(end, PAGE_SIZE);
> > > +
> > > poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
> > > free_reserved_area((void *)start, (void *)end, -1, "initrd");
> > > }
> >
> > is the only bit of code you likely need to achieve your goal.
> >
> > Thinking about this, I think that you are quite right to align these.
> > The memory around the initrd is defined to be system memory, and we
> > already free the pages around it, so it *is* wrong not to free the
> > partial initrd pages.
>
> Actually, I think we have a problem, at least on arm64 (raised by Peter
> Maydell). There is no guarantee that the page around start/end of initrd
> is free, it may contain the dtb for example. This is even more obvious
> when we have a 64KB page kernel (the boot loader doesn't know the page
> size that the kernel is going to use).
>
> The bug was there before as we had poison_init_mem() already (not it
> disappeared since free_reserved_area does the poisoning).
>
> So as a quick fix I think we need the rounding the other way (and in the
> general case we probably lose a page at the end of initrd):
>
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index 494297c698ca..39fd080683e7 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -335,9 +335,9 @@ void free_initrd_mem(unsigned long start, unsigned long end)
> {
> if (!keep_initrd) {
> if (start == initrd_start)
> - start = round_down(start, PAGE_SIZE);
> + start = round_up(start, PAGE_SIZE);
> if (end == initrd_end)
> - end = round_up(end, PAGE_SIZE);
> + end = round_down(end, PAGE_SIZE);
>
> free_reserved_area((void *)start, (void *)end, 0, "initrd");
> }
>
> A better fix would be to check what else is around the start/end of
> initrd.
Care to submit this as a proper patch? We should at least fix Peter's issue
before doing things like extending headers, which won't work for older
kernels anyway.
Will
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2014-12-05 12:05 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-15 11:07 [RFC v2] arm:extend the reserved mrmory for initrd to be page aligned Wang, Yalin
2014-09-15 11:07 ` Wang, Yalin
2014-09-15 11:07 ` Wang, Yalin
2014-09-15 11:33 ` Russell King - ARM Linux
2014-09-15 11:33 ` Russell King - ARM Linux
2014-09-15 11:33 ` Russell King - ARM Linux
2014-09-15 14:20 ` Wang, Yalin
2014-09-15 14:20 ` Wang, Yalin
2014-09-15 14:20 ` Wang, Yalin
2014-09-15 14:20 ` Wang, Yalin
2014-12-04 12:03 ` Catalin Marinas
2014-12-04 12:03 ` Catalin Marinas
2014-12-04 12:03 ` Catalin Marinas
2014-12-05 2:35 ` Wang, Yalin
2014-12-05 2:35 ` Wang, Yalin
2014-12-05 2:35 ` Wang, Yalin
2014-12-05 14:41 ` Catalin Marinas
2014-12-05 14:41 ` Catalin Marinas
2014-12-05 14:41 ` Catalin Marinas
2014-12-05 12:05 ` Will Deacon [this message]
2014-12-05 12:05 ` Will Deacon
2014-12-05 12:05 ` Will Deacon
2014-12-05 17:07 ` Catalin Marinas
2014-12-05 17:07 ` Catalin Marinas
2014-12-05 17:07 ` Catalin Marinas
2014-12-05 17:27 ` Russell King - ARM Linux
2014-12-05 17:27 ` Russell King - ARM Linux
2014-12-05 17:52 ` Peter Maydell
2014-12-05 17:52 ` Peter Maydell
2014-12-05 17:52 ` Peter Maydell
2014-12-05 18:44 ` Catalin Marinas
2014-12-05 18:44 ` Catalin Marinas
2014-12-05 18:44 ` Catalin Marinas
2014-12-05 18:59 ` Peter Maydell
2014-12-05 18:59 ` Peter Maydell
2014-12-05 18:59 ` Peter Maydell
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=20141205120506.GH1630@arm.com \
--to=will.deacon@arm.com \
--cc=Peter.Maydell@arm.com \
--cc=Yalin.Wang@sonymobile.com \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@arm.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.