linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxim Uvarov <maxim.uvarov@linaro.org>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ard Biesheuvel <ardb@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	Arvind Sankar <nivedita@alum.mit.edu>,
	linux-efi@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Jens Wiklander <jens.wiklander@linaro.org>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>
Subject: Re: [PATCH 1/1] efi/libstub: DRAM base calculation
Date: Mon, 7 Sep 2020 18:42:34 +0300	[thread overview]
Message-ID: <CAD8XO3a+TtYciQR4UmprvxHcN8E9wNABEVdt0JsN-GDhJeZJzA@mail.gmail.com> (raw)
In-Reply-To: <CAD8XO3YGKwqbt6cYZQgauioeywLFg56tm+PFM6_nGhuJwSk4Jg@mail.gmail.com>

Tested both original and (md->type == EFI_CONVENTIONAL_MEMORY)
versions - they fix qemu v7 boot under qemu. I think the second
version is more correct.

Regards,
Maxim.

On Mon, 7 Sep 2020 at 13:21, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
>
> On Mon, 7 Sep 2020 at 11:31, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> >
> > On 07.09.20 09:00, Maxim Uvarov wrote:
> > > On Fri, 4 Sep 2020 at 18:50, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> > >>
> > >> In the memory map the regions with the lowest addresses may be of type
> > >> EFI_RESERVED_TYPE. The reserved areas may be discontinuous relative to the
> > >> rest of the memory. So for calculating the maximum loading address for the
> > >> device tree and the initial ramdisk image these reserved areas should not
> > >> be taken into account.
> > >>
> > >> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> > >> ---
> > >>  drivers/firmware/efi/libstub/efi-stub.c | 3 ++-
> > >>  1 file changed, 2 insertions(+), 1 deletion(-)
> > >>
> > >> diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
> > >> index c2484bf75c5d..13058ac75765 100644
> > >> --- a/drivers/firmware/efi/libstub/efi-stub.c
> > >> +++ b/drivers/firmware/efi/libstub/efi-stub.c
> > >> @@ -106,7 +106,8 @@ static unsigned long get_dram_base(void)
> > >>         map.map_end = map.map + map_size;
> > >>
> > >>         for_each_efi_memory_desc_in_map(&map, md) {
> > >> -               if (md->attribute & EFI_MEMORY_WB) {
> > >> +               if (md->attribute & EFI_MEMORY_WB &&
> > >> +                   md->type != EFI_RESERVED_TYPE) {
> > >
> > > shouldn't the type here be CONVENTIONAL?
> >
> > In 32bit ARM reserve_kernel_base() the following are considered:
> >
> > * EFI_LOADER_CODE
> > * EFI_LOADER_DATA
> > * EFI_BOOT_SERVICES_CODE
> > * EFI_BOOT_SERVICES_DATA
> > * EFI_CONVENTIONAL_MEMORY
> >
> > What I have not yet fully understood is why Linux on ARM 32bit tries to
> > put the kernel into the first 128 MiB. Cf. handle_kernel_image() in
> > drivers/firmware/efi/libstub/arm32-stub.c.
> >
>
> Are you looking to the latest kernel?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/firmware/efi/libstub/arm32-stub.c?h=v5.9-rc4#n211
> efi_bs_call(allocate_pages,..) is only for EFI_CONVENTIONAL_MEMORY.
>
> > According to the comments this is due to some implementation detail in
> > the Linux zImage decompressor and not required by UEFI or the hardware:
> >
> >          Verify that the DRAM base address is compatible with the ARM
> >          boot protocol, which determines the base of DRAM by masking
> >          off the low 27 bits of the address at which the zImage is
> >          loaded. These assumptions are made by the decompressor,
> >          before any memory map is available.
>
> I think that is also fixed with:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/firmware/efi/libstub/arm32-stub.c?h=v5.9-rc4&id=d0f9ca9be11f25ef4151195eab7ea36d136084f6
>
> Maxim.
>
> >
> > Best regards
> >
> > Heinrich
> >
> > >
> > >>                         if (membase > md->phys_addr)
> > >>                                 membase = md->phys_addr;
> > >>                 }
> > >> --
> > >> 2.28.0
> > >>
> >

  reply	other threads:[~2020-09-07 15:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04 15:50 [PATCH 1/1] efi/libstub: DRAM base calculation Heinrich Schuchardt
2020-09-07  7:00 ` Maxim Uvarov
2020-09-07  8:30   ` Heinrich Schuchardt
2020-09-07 10:21     ` Maxim Uvarov
2020-09-07 15:42       ` Maxim Uvarov [this message]
2020-09-09  8:17 ` Ard Biesheuvel
2020-09-09 10:43   ` Maxim Uvarov
2020-09-09 10:46     ` Ard Biesheuvel
2020-09-09 11:04       ` Maxim Uvarov
2020-09-09 20:36   ` Atish Patra
2020-09-10 10:03     ` 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=CAD8XO3a+TtYciQR4UmprvxHcN8E9wNABEVdt0JsN-GDhJeZJzA@mail.gmail.com \
    --to=maxim.uvarov@linaro.org \
    --cc=ardb@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jens.wiklander@linaro.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=nivedita@alum.mit.edu \
    --cc=xypron.glpk@gmx.de \
    /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).