grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 0/3] introduce "mmunlimited" to allocate higher memories.


From: Jeremy Szu
Subject: [PATCH 0/3] introduce "mmunlimited" to allocate higher memories.
Date: Tue, 6 Dec 2022 15:35:18 +0800

In some recent EFI firwmare implmentation, the Loader-Data, Loader-Code
and Conventional memory regions (grub loader prefer to use) are located
under 1G (for example some HP platforms). Which causes there are only
~700MB on a 8G HP platform. (There are other 4G+ memories available above
0x100000000)

In HP case:
Type       Start            End              # Pages          Attributes
Available  0000000000000000-0000000000086FFF 0000000000000087 000000000000000F
BS_Data    0000000000087000-0000000000087FFF 0000000000000001 000000000000000F
Available  0000000000088000-000000000009EFFF 0000000000000017 000000000000000F
Reserved   000000000009F000-000000000009FFFF 0000000000000001 000000000000000F
Available  0000000000100000-0000000000FFFFFF 0000000000000F00 000000000000000F
LoaderCode 0000000001000000-0000000001021FFF 0000000000000022 000000000000000F
Available  0000000001022000-00000000238A7FFF 0000000000022886 000000000000000F
BS_Data    00000000238A8000-0000000023927FFF 0000000000000080 000000000000000F
Available  0000000023928000-0000000028860FFF 0000000000004F39 000000000000000F
BS_Data    0000000028861000-000000002AB09FFF 00000000000022A9 000000000000000F
LoaderCode 000000002AB0A000-000000002ACF8FFF 00000000000001EF 000000000000000F
BS_Data    000000002ACF9000-000000002B2FAFFF 0000000000000602 000000000000000F
Available  000000002B2FB000-000000002B611FFF 0000000000000317 000000000000000F
BS_Data    000000002B612000-000000002B630FFF 000000000000001F 000000000000000F
Available  000000002B631000-000000002B632FFF 0000000000000002 000000000000000F
BS_Data    000000002B633000-000000002B63CFFF 000000000000000A 000000000000000F
Available  000000002B63D000-000000002B649FFF 000000000000000D 000000000000000F
BS_Data    000000002B64A000-000000002B64EFFF 0000000000000005 000000000000000F
Available  000000002B64F000-000000002B666FFF 0000000000000018 000000000000000F
BS_Data    000000002B667000-000000002D8D5FFF 000000000000226F 000000000000000F
LoaderCode 000000002D8D6000-000000002D8E9FFF 0000000000000014 000000000000000F
BS_Data    000000002D8EA000-000000002D925FFF 000000000000003C 000000000000000F
LoaderCode 000000002D926000-000000002D932FFF 000000000000000D 000000000000000F
BS_Data    000000002D933000-000000002D969FFF 0000000000000037 000000000000000F
BS_Code    000000002D96A000-000000002D973FFF 000000000000000A 000000000000000F
BS_Data    000000002D974000-000000002E377FFF 0000000000000A04 000000000000000F
Available  000000002E378000-000000002E37AFFF 0000000000000003 000000000000000F
...
Reserved   000000003C08B000-000000004192FFFF 00000000000058A5 000000000000000F
ACPI_NVS   0000000041930000-0000000041B2FFFF 0000000000000200 000000000000000F
ACPI_Recl  0000000041B30000-0000000041BFEFFF 00000000000000CF 000000000000000F
BS_Data    0000000041BFF000-0000000041BFFFFF 0000000000000001 000000000000000F
Available  0000000100000000-00000002AB7FFFFF 00000000001AB800 000000000000000F
Reserved   00000000000A0000-00000000000FFFFF 0000000000000060 0000000000000000
Reserved   0000000041C00000-0000000043FFFFFF 0000000000002400 0000000000000000
Reserved   0000000044000000-0000000047FFFFFF 0000000000004000 000000000000000F
Reserved   0000000049400000-00000000495FFFFF 0000000000000200 000000000000000F
Reserved   000000004C000000-000000004FFFFFFF 0000000000004000 0000000000000009
Reserved   0000000050000000-00000000547FFFFF 0000000000004800 0000000000000000
MMIO       00000000C0000000-00000000CFFFFFFF 0000000000010000 8000000000000001
Reserved   00000000FED20000-00000000FED7FFFF 0000000000000060 0000000000000000
MMIO       00000000FF800000-00000000FFFFFFFF 0000000000000800 8000000000001000
...
  LoaderCode:            562 Pages (2,301,952 Bytes)
  LoaderData:              0 Pages (0 Bytes)
...
  Available :      1,917,598 Pages (7,854,481,408 Bytes)

When verifier enabled (e.g. tpm), it allocates verified->buf to store
initrd for verification when grub_initrd_init().
Also, grub_relocator_alloc_chunk_align() allocates the other memory
region for loading initrd by kernel which needs to respect
initrd_addr_max from kernel protocol (but verifier).
Thus, grub_initrd_load() read the file to loadable address after
verification.
However, above steps consume double size of initrd.

In some cases, the OS put many modules in initrd (e.g. kernel drivers,
installation stuff, and for some reasons, not able to compress initrd)
which growth the initrd.

Based on the dump of memory map, there are ~700M memory for major grub
functions (e.g. module/kernel/initrd).

After read some discussion before (e.g. "Grub2: add UEFI support for accessing
memory address above 4GB."), some firmware are buggy on some legacy platforms.
Therefore, to prevent impact legacy platforms, I would like to introduce a new
envirnoment "mmunlimited" which ignore some limitations (seems for some legacy
platforms) and allow to allocate memory above 4G (if supported).

Jeremy Su (1):
  grub-core/kern/efi/mm.c fix warning message

Jeremy Szu (2):
  include/grub/i386/linux.h support xloadflags
  kern/efi/mm: introduce 'mmunlimited' for allocates on higher memories.

 grub-core/kern/efi/mm.c          |  39 +++++++++---
 grub-core/loader/i386/linux.c    | 105 +++++++++++++++++++++++++++++--
 include/grub/efi/api.h           |   2 +
 include/grub/i386/linux.h        |  36 +++++++++--
 include/grub/x86_64/efi/memory.h |   8 ++-
 5 files changed, 170 insertions(+), 20 deletions(-)

-- 
2.38.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]