[PATCH] efi_loader: Don't allocate from Special purpose memory
Heinrich Schuchardt
xypron.glpk at gmx.de
Wed Oct 16 18:51:53 CEST 2024
On 17.09.24 11:02, Ilias Apalodimas wrote:
> The EFI spec defines special-purpose memory in §7.2. That memory
> serves as a hint to the OS to avoid allocating this memory for core
> OS data or code that can not be relocated. So let's ignore it when
> allocating from conventional memory.
>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> ---
> lib/efi_loader/efi_memory.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
> index c6f1dd09456e..74732e37f8aa 100644
> --- a/lib/efi_loader/efi_memory.c
> +++ b/lib/efi_loader/efi_memory.c
> @@ -422,7 +422,8 @@ static efi_status_t efi_check_allocated(u64 addr, bool must_be_allocated)
>
> if (addr >= start && addr < end) {
> if (must_be_allocated ^
> - (item->desc.type == EFI_CONVENTIONAL_MEMORY))
> + (item->desc.type == EFI_CONVENTIONAL_MEMORY) &&
> + !(item->desc.attribute & EFI_MEMORY_SP))
> return EFI_SUCCESS;
> else
> return EFI_NOT_FOUND;
> @@ -460,6 +461,9 @@ static uint64_t efi_find_free_memory(uint64_t len, uint64_t max_addr)
Now that Sushosh's LMB patches are merged this function does not exist
anymore.
I think we should next move the EFI memory map to LMB to avoid double
book keeping.
Best regards
Heinrich
> if (desc->type != EFI_CONVENTIONAL_MEMORY)
> continue;
>
> + if (desc->attribute & EFI_MEMORY_SP)
> + continue;
> +
> /* Out of bounds for max_addr */
> if ((ret + len) > max_addr)
> continue;
More information about the U-Boot
mailing list