From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: ignore memory outside of the linear range
Date: Mon, 17 Aug 2015 12:11:30 +0100 [thread overview]
Message-ID: <20150817111130.GG1688@arm.com> (raw)
In-Reply-To: <CAKv+Gu__o9ZFyx_nnQWm2zfacVvN7B6W-DUhLqfW8xrMeFJp_Q@mail.gmail.com>
On Mon, Aug 17, 2015 at 11:55:33AM +0100, Ard Biesheuvel wrote:
> On 17 August 2015 at 12:53, Will Deacon <will.deacon@arm.com> wrote:
> > On Mon, Aug 17, 2015 at 11:35:46AM +0100, Ard Biesheuvel wrote:
> >> On 17 August 2015 at 11:43, Will Deacon <will.deacon@arm.com> wrote:
> >> > On Sat, Aug 15, 2015 at 01:13:44PM +0100, Ard Biesheuvel wrote:
> >> >> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> >> >> index ad87ce826cce..c65e57d4c3e7 100644
> >> >> --- a/arch/arm64/mm/init.c
> >> >> +++ b/arch/arm64/mm/init.c
> >> >> @@ -158,6 +158,19 @@ early_param("mem", early_mem);
> >> >>
> >> >> void __init arm64_memblock_init(void)
> >> >> {
> >> >> + /*
> >> >> + * Remove the memory that we will not be able to cover
> >> >> + * with the linear mapping.
> >> >> + */
> >> >> + const s64 linear_region_size = -(s64)PAGE_OFFSET;
> >> >> +
> >> >> + if (memstart_addr + linear_region_size < memblock_end_of_DRAM()) {
> >> >> + pr_warn("Ignoring memory outside of linear range (0x%012llx - 0x%012llx)\n",
> >> >> + memstart_addr + linear_region_size,
> >> >> + (u64)memblock_end_of_DRAM() - 1);
> >> >> + memblock_remove(memstart_addr + linear_region_size, ULLONG_MAX);
> >> >> + }
> >> >> +
> >> >
> >> > I think this will interact badly with Mark Salter's patches to relocate
> >> > the initrd if it falls outside of the linear mapping (which relies on the
> >> > memblocks remaining intact after paging_init):
> >> >
> >> > https://lkml.org/lkml/2015/8/16/75
> >> >
> >>
> >> Are you sure? By the looks of it, these patches combined would
> >> correctly address the case where no mem= is passed, but the initial
> >> ramdisk is loaded past the end of the linear region.
> >>
> >> I.e., memblock_end_of_DRAM() will return the clipped value, which
> >> would be smaller than orig_end, triggering the relocation machinery
> >> which moves it inside the linear region.
> >
> > Ok. I was trying to consider the case where the initrd is outside of the
> > linear mapping not because of a restrictive "mem=", but because its out
> > of range of our page tables. AFAICT, we'll end up attempting to memcpy
> > the thing back down (but I appreciate that things won't work without
> > your patch too).
> >
>
> But isn't the whole point of Mark's patches that the source initrd is
> memremap()'d and copied to a destination that is covered by the kernel
> direct mapping? I.e., mem= is enforced in the exact same place where
> this code is added, and so the initrd will not be mapped if it is
> outside of mem=
Yes, you're right. I'd somehow confused myself with the to_free case,
but it all falls out in the wash and we'll map what we need to map
before copying the initrd down.
Will
next prev parent reply other threads:[~2015-08-17 11:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-15 12:13 [PATCH] arm64: ignore memory outside of the linear range Ard Biesheuvel
2015-08-17 9:43 ` Will Deacon
2015-08-17 10:35 ` Ard Biesheuvel
2015-08-17 10:53 ` Will Deacon
2015-08-17 10:55 ` Ard Biesheuvel
2015-08-17 11:11 ` Will Deacon [this message]
2015-08-17 10:40 ` Catalin Marinas
2015-08-17 10:44 ` Ard Biesheuvel
2015-08-17 11:04 ` Catalin Marinas
2015-08-17 11:06 ` Ard Biesheuvel
2015-08-17 12:07 ` Catalin Marinas
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=20150817111130.GG1688@arm.com \
--to=will.deacon@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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.