efi: honour memory reservations passed via a linux specific config table
In order to allow the OS to reserve memory persistently across a kexec, introduce a Linux-specific UEFI configuration table that points to the head of a linked list in memory, allowing each kernel to add list items describing memory regions that the next kernel should treat as reserved. This is useful, e.g., for GICv3 based ARM systems that cannot disable DMA access to the LPI tables, forcing them to reuse the same memory region again after a kexec reboot. Tested-by: Jeremy Linton <jeremy.linton@arm.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
This commit is contained in:
@@ -52,7 +52,8 @@ struct efi __read_mostly efi = {
|
||||
.properties_table = EFI_INVALID_TABLE_ADDR,
|
||||
.mem_attr_table = EFI_INVALID_TABLE_ADDR,
|
||||
.rng_seed = EFI_INVALID_TABLE_ADDR,
|
||||
.tpm_log = EFI_INVALID_TABLE_ADDR
|
||||
.tpm_log = EFI_INVALID_TABLE_ADDR,
|
||||
.mem_reserve = EFI_INVALID_TABLE_ADDR,
|
||||
};
|
||||
EXPORT_SYMBOL(efi);
|
||||
|
||||
@@ -484,6 +485,7 @@ static __initdata efi_config_table_type_t common_tables[] = {
|
||||
{EFI_MEMORY_ATTRIBUTES_TABLE_GUID, "MEMATTR", &efi.mem_attr_table},
|
||||
{LINUX_EFI_RANDOM_SEED_TABLE_GUID, "RNG", &efi.rng_seed},
|
||||
{LINUX_EFI_TPM_EVENT_LOG_GUID, "TPMEventLog", &efi.tpm_log},
|
||||
{LINUX_EFI_MEMRESERVE_TABLE_GUID, "MEMRESERVE", &efi.mem_reserve},
|
||||
{NULL_GUID, NULL, NULL},
|
||||
};
|
||||
|
||||
@@ -591,6 +593,29 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz,
|
||||
early_memunmap(tbl, sizeof(*tbl));
|
||||
}
|
||||
|
||||
if (efi.mem_reserve != EFI_INVALID_TABLE_ADDR) {
|
||||
unsigned long prsv = efi.mem_reserve;
|
||||
|
||||
while (prsv) {
|
||||
struct linux_efi_memreserve *rsv;
|
||||
|
||||
/* reserve the entry itself */
|
||||
memblock_reserve(prsv, sizeof(*rsv));
|
||||
|
||||
rsv = early_memremap(prsv, sizeof(*rsv));
|
||||
if (rsv == NULL) {
|
||||
pr_err("Could not map UEFI memreserve entry!\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (rsv->size)
|
||||
memblock_reserve(rsv->base, rsv->size);
|
||||
|
||||
prsv = rsv->next;
|
||||
early_memunmap(rsv, sizeof(*rsv));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user