Skip to content

Commit 39503fc

Browse files
Ming Wangchenhuacai
authored andcommitted
LoongArch: Reserve the EFI memory map region
The EFI memory map at 'boot_memmap' is crucial for kdump to understand the primary kernel's memory layout. This memory region, typically part of EFI Boot Services (BS) data, can be overwritten after ExitBootServices if not explicitly preserved by the kernel. This commit addresses this by: 1. Calling memblock_reserve() to reserve the entire physical region occupied by the EFI memory map (header + descriptors). This prevents the primary kernel from reallocating and corrupting this area. 2. Setting the EFI_PRESERVE_BS_REGIONS flag in efi.flags. This indicates that efforts have been made to preserve critical BS code/data regions which can be useful for other kernel subsystems or debugging. These changes ensure the original EFI memory map data remains intact, improving kdump reliability and potentially aiding other EFI-related functionalities that might rely on preserved BS code/data. Signed-off-by: Ming Wang <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 7d69294 commit 39503fc

File tree

1 file changed

+12
-0
lines changed
  • arch/loongarch/kernel

1 file changed

+12
-0
lines changed

arch/loongarch/kernel/efi.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@ void __init efi_init(void)
144144
if (efi_memmap_init_early(&data) < 0)
145145
panic("Unable to map EFI memory map.\n");
146146

147+
/*
148+
* Reserve the physical memory region occupied by the EFI
149+
* memory map table (header + descriptors). This is crucial
150+
* for kdump, as the kdump kernel relies on this original
151+
* memmap passed by the bootloader. Without reservation,
152+
* this region could be overwritten by the primary kernel.
153+
* Also, set the EFI_PRESERVE_BS_REGIONS flag to indicate that
154+
* critical boot services code/data regions like this are preserved.
155+
*/
156+
memblock_reserve((phys_addr_t)boot_memmap, sizeof(*tbl) + data.size);
157+
set_bit(EFI_PRESERVE_BS_REGIONS, &efi.flags);
158+
147159
early_memunmap(tbl, sizeof(*tbl));
148160
}
149161

0 commit comments

Comments
 (0)