mirror-linux/drivers/firmware/efi
Ard Biesheuvel ba69e0750b efi: Avoid cold plugged memory for placing the kernel
UEFI 2.11 introduced EFI_MEMORY_HOT_PLUGGABLE to annotate system memory
regions that are 'cold plugged' at boot, i.e., hot pluggable memory that
is available from early boot, and described as system RAM by the
firmware.

Existing loaders and EFI applications running in the boot context will
happily use this memory for allocating data structures that cannot be
freed or moved at runtime, and this prevents the memory from being
unplugged. Going forward, the new EFI_MEMORY_HOT_PLUGGABLE attribute
should be tested, and memory annotated as such should be avoided for
such allocations.

In the EFI stub, there are a couple of occurrences where, instead of the
high-level AllocatePages() UEFI boot service, a low-level code sequence
is used that traverses the EFI memory map and carves out the requested
number of pages from a free region. This is needed, e.g., for allocating
as low as possible, or for allocating pages at random.

While AllocatePages() should presumably avoid special purpose memory and
cold plugged regions, this manual approach needs to incorporate this
logic itself, in order to prevent the kernel itself from ending up in a
hot unpluggable region, preventing it from being unplugged.

So add the EFI_MEMORY_HOTPLUGGABLE macro definition, and check for it
where appropriate.

Cc: stable@vger.kernel.org
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2025-02-04 14:08:22 +01:00
..
libstub efi: Avoid cold plugged memory for placing the kernel 2025-02-04 14:08:22 +01:00
stmm efi: Add tee-based EFI variable driver 2023-12-11 11:19:18 +01:00
test [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
Kconfig efi/zboot: Limit compression options to GZIP and ZSTD 2024-12-06 16:59:56 +01:00
Makefile efi: Add tee-based EFI variable driver 2023-12-11 11:19:18 +01:00
apple-properties.c
arm-runtime.c efi: runtime: Fix potential overflow of soft-reserved region size 2024-02-02 19:31:24 +01:00
capsule-loader.c [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
capsule.c
cper-arm.c
cper-x86.c
cper.c efi/cper: Print correctable AER information 2024-08-27 12:23:19 +02:00
cper_cxl.c
cper_cxl.h
dev-path-parser.c driver core: Constify API device_find_child() and adapt for various usages 2025-01-03 11:19:35 +01:00
earlycon.c fbcon: Increase maximum font width x height to 64 x 128 2024-03-16 08:29:48 +01:00
efi-bgrt.c
efi-init.c efi: Don't add memblocks for soft-reserved memory 2024-02-02 19:31:24 +01:00
efi-pstore.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
efi.c efi: Avoid cold plugged memory for placing the kernel 2025-02-04 14:08:22 +01:00
efibc.c
embedded-firmware.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
esrt.c efi/esrt: remove esre_attribute::store() 2024-12-13 08:43:58 +01:00
fdtparams.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
memattr.c efi/memattr: Ignore table if the size is clearly bogus 2024-11-15 12:03:29 +01:00
memmap.c efi/x86: Free EFI memory map only when installing a new one. 2024-06-15 10:25:02 +02:00
mokvar-table.c
rci2-table.c treewide: Use sysfs_bin_attr_simple_read() helper 2024-04-11 16:02:25 +02:00
reboot.c
riscv-runtime.c riscv: dmi: Add SMBIOS/DMI support 2024-06-26 08:02:33 -07:00
runtime-wrappers.c efi: Add missing __nocfi annotations to runtime wrappers 2024-06-05 10:18:58 +02:00
sysfb_efi.c efi: sysfb_efi: fix W=1 warnings when EFI is not set 2025-01-14 08:35:28 +01:00
tpm.c tpm: fix unsigned/signed mismatch errors related to __calc_tpm2_event_size 2024-10-15 20:27:29 +02:00
unaccepted_memory.c mm: rework accept memory helpers 2024-09-01 20:26:07 -07:00
vars.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00