From: Mike Rapoport <rppt@linux.ibm.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Juergen Gross <JGross@suse.com>, Joey Lee <JLee@suse.com>,
"linux-efi@vger.kernel.org" <linux-efi@vger.kernel.org>,
"guillaume.gardet@arm.com" <guillaume.gardet@arm.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Russell King - ARM Linux admin <linux@armlinux.org.uk>,
Chester Lin <clin@suse.com>,
"geert@linux-m68k.org" <geert@linux-m68k.org>,
"ren_guo@c-sky.com" <ren_guo@c-sky.com>, Gary Lin <GLin@suse.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"mingo@kernel.org" <mingo@kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] efi/arm: fix allocation failure when reserving the kernel base
Date: Wed, 21 Aug 2019 11:29:28 +0300 [thread overview]
Message-ID: <20190821082927.GC26713@rapoport-lnx> (raw)
In-Reply-To: <CAKv+Gu99z3V1B68CU8qhNwwffqDxNBOM6t3Q8-V7qpbDkf-Cwg@mail.gmail.com>
On Wed, Aug 21, 2019 at 10:29:37AM +0300, Ard Biesheuvel wrote:
> On Wed, 21 Aug 2019 at 10:11, Mike Rapoport <rppt@linux.ibm.com> wrote:
> >
> > On Wed, Aug 21, 2019 at 09:35:16AM +0300, Ard Biesheuvel wrote:
> > > On Wed, 21 Aug 2019 at 09:11, Chester Lin <clin@suse.com> wrote:
> > > >
> > > > On Tue, Aug 20, 2019 at 03:28:25PM +0300, Ard Biesheuvel wrote:
> > > > > On Tue, 20 Aug 2019 at 14:56, Russell King - ARM Linux admin
> > > > > <linux@armlinux.org.uk> wrote:
> > > > > >
> > > > > > On Fri, Aug 02, 2019 at 05:38:54AM +0000, Chester Lin wrote:
> > > > > > > diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
> > > > > > > index f3ce34113f89..909b11ba48d8 100644
> > > > > > > --- a/arch/arm/mm/mmu.c
> > > > > > > +++ b/arch/arm/mm/mmu.c
> > > > > > > @@ -1184,6 +1184,9 @@ void __init adjust_lowmem_bounds(void)
> > > > > > > phys_addr_t block_start = reg->base;
> > > > > > > phys_addr_t block_end = reg->base + reg->size;
> > > > > > >
> > > > > > > + if (memblock_is_nomap(reg))
> > > > > > > + continue;
> > > > > > > +
> > > > > > > if (reg->base < vmalloc_limit) {
> > > > > > > if (block_end > lowmem_limit)
> > > > > > > /*
> > > > > >
> > > > > > I think this hunk is sane - if the memory is marked nomap, then it isn't
> > > > > > available for the kernel's use, so as far as calculating where the
> > > > > > lowmem/highmem boundary is, it effectively doesn't exist and should be
> > > > > > skipped.
> > > > > >
> > > > >
> > > > > I agree.
> > > > >
> > > > > Chester, could you explain what you need beyond this change (and my
> > > > > EFI stub change involving TEXT_OFFSET) to make things work on the
> > > > > RPi2?
> > > > >
> > > >
> > > > Hi Ard,
> > > >
> > > > In fact I am working with Guillaume to try booting zImage kernel and openSUSE
> > > > from grub2.04 + arm32-efistub so that's why we get this issue on RPi2, which is
> > > > one of the test machines we have. However we want a better solution for all
> > > > cases but not just RPi2 since we don't want to affect other platforms as well.
> > > >
> > >
> > > Thanks Chester, but that doesn't answer my question.
> > >
> > > Your fix is a single patch that changes various things that are only
> > > vaguely related. We have already identified that we need to take
> > > TEXT_OFFSET (minus some space used by the swapper page tables) into
> > > account into the EFI stub if we want to ensure compatibility with many
> > > different platforms, and as it turns out, this applies not only to
> > > RPi2 but to other platforms as well, most notably the ones that
> > > require a TEXT_OFFSET of 0x208000, since they also have reserved
> > > regions at the base of RAM.
> > >
> > > My question was what else we need beyond:
> > > - the EFI stub TEXT_OFFSET fix [0]
> > > - the change to disregard NOMAP memblocks in adjust_lowmem_bounds()
> > > - what else???
> >
> > I think the only missing part here is to ensure that non-reserved memory in
> > bank 0 starts from a PMD-aligned address. I believe this could be done if
> > EFI stub, but I'm not really familiar with it so this just a semi-educated
> > guess :)
> >
>
> Given that it is the ARM arch code that imposes this requirement, how
> about adding something like this to adjust_lowmem_bounds():
>
> if (memblock_start_of_DRAM() % PMD_SIZE)
> memblock_mark_nomap(memblock_start_of_DRAM(),
> PMD_SIZE - (memblock_start_of_DRAM() % PMD_SIZE));
memblock_start_of_DRAM() won't work here, as it returns the actual start of
the DRAM including NOMAP regions. Moreover, as we cannot mark a region
NOMAP inside for_each_memblock() this should be done beforehand.
I think something like this could work:
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 2f0f07e..f2b635b 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1178,6 +1178,19 @@ void __init adjust_lowmem_bounds(void)
*/
vmalloc_limit = (u64)(uintptr_t)vmalloc_min - PAGE_OFFSET + PHYS_OFFSET;
+ /*
+ * The first usable region must be PMD aligned. Mark its start
+ * as MEMBLOCK_NOMAP if it isn't
+ */
+ for_each_memblock(memory, reg) {
+ if (!memblock_is_nomap(reg) && (reg->base % PMD_SIZE)) {
+ phys_addr_t size = PMD_SIZE - (reg->base % PMD_SIZE);
+
+ memblock_mark_nomap(reg->base, size);
+ break;
+ }
+ }
+
for_each_memblock(memory, reg) {
phys_addr_t block_start = reg->base;
phys_addr_t block_end = reg->base + reg->size;
> (and introduce the nomap check into the loop)
--
Sincerely yours,
Mike.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-08-21 8:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-02 5:38 [PATCH] efi/arm: fix allocation failure when reserving the kernel base Chester Lin
2019-08-04 7:57 ` Ard Biesheuvel
2019-08-14 7:58 ` Guillaume Gardet
2019-08-15 7:59 ` Ard Biesheuvel
2019-08-15 11:16 ` Chester Lin
2019-08-15 11:32 ` Ard Biesheuvel
2019-08-15 13:37 ` Mike Rapoport
2019-08-19 7:56 ` Chester Lin
2019-08-19 14:56 ` Ard Biesheuvel
2019-08-20 7:33 ` Chester Lin
2019-08-20 7:49 ` Mike Rapoport
2019-08-20 10:29 ` Chester Lin
2019-08-20 11:00 ` Ard Biesheuvel
2019-08-20 11:54 ` Russell King - ARM Linux admin
2019-08-20 12:27 ` Ard Biesheuvel
2019-08-20 11:56 ` Russell King - ARM Linux admin
2019-08-20 12:28 ` Ard Biesheuvel
2019-08-21 6:10 ` Chester Lin
2019-08-21 6:35 ` Ard Biesheuvel
2019-08-21 7:11 ` Mike Rapoport
2019-08-21 7:22 ` Chester Lin
2019-08-21 7:29 ` Ard Biesheuvel
2019-08-21 8:29 ` Mike Rapoport [this message]
2019-08-21 9:42 ` Ard Biesheuvel
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=20190821082927.GC26713@rapoport-lnx \
--to=rppt@linux.ibm.com \
--cc=GLin@suse.com \
--cc=JGross@suse.com \
--cc=JLee@suse.com \
--cc=akpm@linux-foundation.org \
--cc=ard.biesheuvel@linaro.org \
--cc=clin@suse.com \
--cc=geert@linux-m68k.org \
--cc=guillaume.gardet@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mingo@kernel.org \
--cc=ren_guo@c-sky.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;
as well as URLs for NNTP newsgroup(s).