From: Ard Biesheuvel <ardb@kernel.org>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>, Andy Lutomirski <luto@kernel.org>,
Dave Hansen <dave.hansen@intel.com>,
Sean Christopherson <seanjc@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Joerg Roedel <jroedel@suse.de>, Andi Kleen <ak@linux.intel.com>,
Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@linux.intel.com>,
David Rientjes <rientjes@google.com>,
Vlastimil Babka <vbabka@suse.cz>,
Tom Lendacky <thomas.lendacky@amd.com>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Ingo Molnar <mingo@redhat.com>,
Dario Faggioli <dfaggioli@suse.com>,
Mike Rapoport <rppt@kernel.org>,
David Hildenbrand <david@redhat.com>,
Mel Gorman <mgorman@techsingularity.net>,
marcelo.cerri@canonical.com, tim.gardner@canonical.com,
khalid.elmously@canonical.com, philip.cox@canonical.com,
aarcange@redhat.com, peterx@redhat.com, x86@kernel.org,
linux-mm@kvack.org, linux-coco@lists.linux.dev,
linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
Borislav Petkov <bp@suse.de>
Subject: Re: [PATCHv10 02/11] efi/x86: Get full memory map in allocate_e820()
Date: Mon, 8 May 2023 09:19:37 +0200 [thread overview]
Message-ID: <CAMj1kXFNXMmAsnQovWq18LrOnNL4=3Puamvz7p1ufynJfVEOug@mail.gmail.com> (raw)
In-Reply-To: <20230507234618.18067-3-kirill.shutemov@linux.intel.com>
On Mon, 8 May 2023 at 01:46, Kirill A. Shutemov
<kirill.shutemov@linux.intel.com> wrote:
>
> Currently allocate_e820() is only interested in the size of map and size
> of memory descriptor to determine how many e820 entries the kernel
> needs.
>
> UEFI Specification version 2.9 introduces a new memory type --
> unaccepted memory. To track unaccepted memory kernel needs to allocate
> a bitmap. The size of the bitmap is dependent on the maximum physical
> address present in the system. A full memory map is required to find
> the maximum address.
>
> Modify allocate_e820() to get a full memory map.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reviewed-by: Borislav Petkov <bp@suse.de>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> drivers/firmware/efi/libstub/x86-stub.c | 26 +++++++++++--------------
> 1 file changed, 11 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
> index a0bfd31358ba..fff81843169c 100644
> --- a/drivers/firmware/efi/libstub/x86-stub.c
> +++ b/drivers/firmware/efi/libstub/x86-stub.c
> @@ -681,28 +681,24 @@ static efi_status_t allocate_e820(struct boot_params *params,
> struct setup_data **e820ext,
> u32 *e820ext_size)
> {
> - unsigned long map_size, desc_size, map_key;
> + struct efi_boot_memmap *map;
> efi_status_t status;
> - __u32 nr_desc, desc_version;
> + __u32 nr_desc;
>
> - /* Only need the size of the mem map and size of each mem descriptor */
> - map_size = 0;
> - status = efi_bs_call(get_memory_map, &map_size, NULL, &map_key,
> - &desc_size, &desc_version);
> - if (status != EFI_BUFFER_TOO_SMALL)
> - return (status != EFI_SUCCESS) ? status : EFI_UNSUPPORTED;
> + status = efi_get_memory_map(&map, false);
> + if (status != EFI_SUCCESS)
> + return status;
>
> - nr_desc = map_size / desc_size + EFI_MMAP_NR_SLACK_SLOTS;
> -
> - if (nr_desc > ARRAY_SIZE(params->e820_table)) {
> - u32 nr_e820ext = nr_desc - ARRAY_SIZE(params->e820_table);
> + nr_desc = map->map_size / map->desc_size;
> + if (nr_desc > ARRAY_SIZE(params->e820_table) - EFI_MMAP_NR_SLACK_SLOTS) {
> + u32 nr_e820ext = nr_desc - ARRAY_SIZE(params->e820_table) +
> + EFI_MMAP_NR_SLACK_SLOTS;
>
> status = alloc_e820ext(nr_e820ext, e820ext, e820ext_size);
> - if (status != EFI_SUCCESS)
> - return status;
> }
>
> - return EFI_SUCCESS;
> + efi_bs_call(free_pool, map);
> + return status;
> }
>
> struct exit_boot_struct {
> --
> 2.39.3
>
next prev parent reply other threads:[~2023-05-08 7:19 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-07 23:46 [PATCHv10 00/11] mm, x86/cc: Implement support for unaccepted memory Kirill A. Shutemov
2023-05-07 23:46 ` [PATCHv10 01/11] mm: Add " Kirill A. Shutemov
2023-05-07 23:46 ` [PATCHv10 02/11] efi/x86: Get full memory map in allocate_e820() Kirill A. Shutemov
2023-05-08 7:19 ` Ard Biesheuvel [this message]
2023-05-07 23:46 ` [PATCHv10 03/11] x86/boot: Add infrastructure required for unaccepted memory support Kirill A. Shutemov
2023-05-07 23:46 ` [PATCHv10 04/11] efi/x86: Implement support for unaccepted memory Kirill A. Shutemov
2023-05-08 7:30 ` Ard Biesheuvel
2023-05-08 19:00 ` Kirill A. Shutemov
2023-05-08 22:11 ` Ard Biesheuvel
2023-05-09 0:56 ` Kirill A. Shutemov
2023-05-09 6:47 ` Ard Biesheuvel
2023-05-12 1:59 ` Kirill A. Shutemov
2023-05-12 7:39 ` Ard Biesheuvel
2023-05-12 10:59 ` Kirill A. Shutemov
2023-05-12 11:01 ` Ard Biesheuvel
2023-05-07 23:46 ` [PATCHv10 05/11] x86/boot/compressed: Handle " Kirill A. Shutemov
2023-05-08 7:31 ` Ard Biesheuvel
2023-05-07 23:46 ` [PATCHv10 06/11] x86/mm: Reserve unaccepted memory bitmap Kirill A. Shutemov
2023-05-07 23:46 ` [PATCHv10 07/11] x86/mm: Provide helpers for unaccepted memory Kirill A. Shutemov
2023-05-07 23:46 ` [PATCHv10 08/11] x86/mm: Avoid load_unaligned_zeropad() stepping into " Kirill A. Shutemov
2023-05-07 23:46 ` [PATCHv10 09/11] x86/tdx: Make _tdx_hypercall() and __tdx_module_call() available in boot stub Kirill A. Shutemov
2023-05-07 23:46 ` [PATCHv10 10/11] x86/tdx: Refactor try_accept_one() Kirill A. Shutemov
2023-05-07 23:46 ` [PATCHv10 11/11] x86/tdx: Add unaccepted memory support Kirill A. Shutemov
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='CAMj1kXFNXMmAsnQovWq18LrOnNL4=3Puamvz7p1ufynJfVEOug@mail.gmail.com' \
--to=ardb@kernel.org \
--cc=aarcange@redhat.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=bp@suse.de \
--cc=dave.hansen@intel.com \
--cc=david@redhat.com \
--cc=dfaggioli@suse.com \
--cc=jroedel@suse.de \
--cc=khalid.elmously@canonical.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-coco@lists.linux.dev \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=marcelo.cerri@canonical.com \
--cc=mgorman@techsingularity.net \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=peterz@infradead.org \
--cc=philip.cox@canonical.com \
--cc=rientjes@google.com \
--cc=rppt@kernel.org \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=tim.gardner@canonical.com \
--cc=vbabka@suse.cz \
--cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox