efi_loader: remove memory occupied by a ramdisk from EFI memory map
authorIlias Apalodimas <ilias.apalodimas@linaro.org>
Mon, 17 Mar 2025 08:33:59 +0000 (14:03 +0530)
committerIlias Apalodimas <ilias.apalodimas@linaro.org>
Wed, 26 Mar 2025 11:28:08 +0000 (13:28 +0200)
commitfc82cf66d05f61339abb5f8e5bfc83647dbf96cf
tree3dea958f67f1cee1c37f8f966716348c1b08d75b
parentc5f6542aa8ae93b7705e27103a9fdaf8445e2915
efi_loader: remove memory occupied by a ramdisk from EFI memory map

ACPI has NFIT and NVDIMM support to provide ramdisks to the OS. Linux
and device trees have support for persistent memory(pmem) devices. The
firmware can then add a pmem node for the region of memory occupied by
the ramdisk when passing the device-tree to the OS.

It's worth noting that for linux to instantiate the /dev/pmemX device,
the memory described in the pmem node has to be omitted from the EFI
memory map we hand over to the OS if ZONE_DEVICES and SPARSEMEM is
enabled. With those enabled the pmem driver ends up calling
devm_memremap_pages() instead of devm_memremap(). The latter works
whether the memory is omitted or marked as reserved, but mapping pages
only works if the memory is omitted.

On top of that, depending on how the kernel is configured, that memory
area must be page aligned or 2MiB aligned. PowerPC is an exception here
and requires 16MiB alignment, but since we don't have EFI support for
it, limit the alignment to 2MiB.

Ensure that the ISO image is 2MiB aligned and remove the region
occupied by the image from the EFI memory map.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
lib/efi_loader/efi_bootmgr.c