Above 4 GiB is never suitable for 32-bit platforms. 64-bit platforms need
tests and/or analysis. I prefer increasing max address rather than having a
fallback to any_pages. In parallel threads there is already a discussion of
memory allocations on riscv64 and aarch64.

The summary:
i386_efi, arm_efi, riscv32_efi: max address is set to 4GiB-1 and can't be
increased. Any pages is not suitable.
x86_64_efi: currently either 2GiB-1 or 4GiB-1. To increase it we need to
both force mcmodel=large and solve mapping problem
ia64_efi: currently set at 4GiB-1. Probably can be increased
arm64_efi: currently at 256TiB-1. Without D128 it's the highest mappable
address on arm64. There is a report that this value causes problem on some
Lenovo systems.
riscv64_efi: value is the same as arm64. I didn't check how MMU works on
riscv64 so can't say if this matches the real limitation or just a
copy-paste mistake. In either case this value already causes some problems
and we need to force mcmodel=large first.
loongarch64_efi: 16TiB-1. No idea why. No complaints for it either.

In an ideal world we should use any_pages on all 64-bit systems but as you
can see compiler aspects, MMU limits and firmware bugs limit its usefulness

Regards

Le mar. 22 avr. 2025, 23:34, Paymon MARANDI <pay...@encs.concordia.ca> a
écrit :

> earlier version of this didn't count for other archs and actually
> mapping the unmapped memory above 4GB.
>
> this builds on top of the previous patch (by phcoder) in the series and
> hopefully will do all of the above.
>
> Signed-off-by: Paymon MARANDI <pay...@encs.concordia.ca>
> ---
>  grub-core/kern/efi/mm.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
> index 60ac7ed00..34615826d 100644
> --- a/grub-core/kern/efi/mm.c
> +++ b/grub-core/kern/efi/mm.c
> @@ -178,9 +178,18 @@ grub_efi_allocate_pages_real
> (grub_efi_physical_address_t address,
>  void *
>  grub_efi_allocate_any_pages (grub_efi_uintn_t pages)
>  {
> -  return grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS,
> -                                      pages,
> GRUB_EFI_ALLOCATE_MAX_ADDRESS,
> -                                      GRUB_EFI_LOADER_DATA);
> +  void *ret;
> +  ret = grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS, pages,
> +                                      GRUB_EFI_ALLOCATE_MAX_ADDRESS,
> +                                      GRUB_EFI_LOADER_DATA);
> +  if (ret == NULL)
> +    {
> +      grub_errno = GRUB_ERR_NONE;
> +      ret = grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS,
> +                                         pages,
> GRUB_EFI_ALLOCATE_ANY_PAGES,
> +                                         GRUB_EFI_LOADER_DATA);
> +    }
> +  return ret;
>  }
>
>  void *
> --
> 2.49.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to