Linux-EFI Archive mirror
 help / color / mirror / Atom feed
From: Andrew Bresticker <abrestic@rivosinc.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	 Albert Ou <aou@eecs.berkeley.edu>,
	linux-efi@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-riscv@lists.infradead.org
Subject: Re: [PATCH 2/2] efi: Don't add memblocks for unusable memory
Date: Fri, 2 Feb 2024 12:41:04 -0500	[thread overview]
Message-ID: <CALE4mHq4KhfBd+n2waUpHt48fTRXdBWZyiEJf5a3=hfUA_ue3Q@mail.gmail.com> (raw)
In-Reply-To: <CAMj1kXH7=9-Ww_z6a4Z5K8MrbH8x17Y3EzYk9Qf-3PL-JgMcww@mail.gmail.com>

On Fri, Feb 2, 2024 at 11:45 AM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Fri, 2 Feb 2024 at 17:34, Andrew Bresticker <abrestic@rivosinc.com> wrote:
> >
> > Adding memblocks (even if nomap) for such regions unnecessarily consumes
> > resources by creating struct pages for memory that may never be used or,
> > in the case of soft-reserved regions, prevents the memory from later
> > being hotplugged in by dax_kmem. This is also consistent with how x86
> > handles unusable memory found in the EFI memory map.
> >
>
> x86 doesn't care as much about memory vs device semantics as ARM does.
>
> This affects the output of memblock_is_[region_]memory(), so we'd have
> to double check that none of those uses get broken by this.
>
> If the soft reserved regions need to be omitted from memblock, we can
> deal with that separately perhaps, but changing it at this level seems
> inappropriate to me.

Sure, I can constrain this to just the soft-reserved regions.

-Andrew

>
>
> > Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com>
> > ---
> >  drivers/firmware/efi/efi-init.c | 12 +-----------
> >  1 file changed, 1 insertion(+), 11 deletions(-)
> >
> > diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c
> > index d4987d013080..f05bacac89b7 100644
> > --- a/drivers/firmware/efi/efi-init.c
> > +++ b/drivers/firmware/efi/efi-init.c
> > @@ -24,13 +24,6 @@
> >
> >  unsigned long __initdata screen_info_table = EFI_INVALID_TABLE_ADDR;
> >
> > -static int __init is_memory(efi_memory_desc_t *md)
> > -{
> > -       if (md->attribute & (EFI_MEMORY_WB|EFI_MEMORY_WT|EFI_MEMORY_WC))
> > -               return 1;
> > -       return 0;
> > -}
> > -
> >  /*
> >   * Translate a EFI virtual address into a physical address: this is necessary,
> >   * as some data members of the EFI system table are virtually remapped after
> > @@ -195,12 +188,9 @@ static __init void reserve_regions(void)
> >                 memrange_efi_to_native(&paddr, &npages);
> >                 size = npages << PAGE_SHIFT;
> >
> > -               if (is_memory(md)) {
> > +               if (is_usable_memory(md)) {
> >                         early_init_dt_add_memory_arch(paddr, size);
> >
> > -                       if (!is_usable_memory(md))
> > -                               memblock_mark_nomap(paddr, size);
> > -
> >                         /* keep ACPI reclaim memory intact for kexec etc. */
> >                         if (md->type == EFI_ACPI_RECLAIM_MEMORY)
> >                                 memblock_reserve(paddr, size);
> > --
> > 2.34.1
> >

      reply	other threads:[~2024-02-02 17:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02 16:34 [PATCH 0/2] efi: Fixes for EFI_MEMORY_SP memory on RISC-V and ARM64 Andrew Bresticker
2024-02-02 16:34 ` [PATCH 1/2] efi: runtime: Fix potential overflow of soft-reserved region size Andrew Bresticker
2024-02-02 16:37   ` Ard Biesheuvel
2024-02-02 16:34 ` [PATCH 2/2] efi: Don't add memblocks for unusable memory Andrew Bresticker
2024-02-02 16:45   ` Ard Biesheuvel
2024-02-02 17:41     ` Andrew Bresticker [this message]

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='CALE4mHq4KhfBd+n2waUpHt48fTRXdBWZyiEJf5a3=hfUA_ue3Q@mail.gmail.com' \
    --to=abrestic@rivosinc.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=ardb@kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.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 read-only IMAP folder(s) and NNTP newsgroup(s).