From 6d56530bd04534f038f775624e1c4942a8bf95de Mon Sep 17 00:00:00 2001 From: fengtao Date: Mon, 14 Feb 2022 16:17:15 +0800 Subject: [PATCH] double grub x86_64-efi mm pool grub2 will construct mm pool by uefi memory function for grub memory manger, grub_malloc, grub_free, etc. but we have limit memory address under x86_64 platform in commit:456eb8632e7(Try to pick better locations for kernel and initrd) so, x86_64 can only address available ram under 4GB. there comes a problem, when available memory under 4GB is not enough, and initrd is large, like 200MB~300MB. we got out of memory when verifiers use grub_malloc. Finally, we descide to double grub mm pool when we init it. And what the point is, we cannot init all of the available memory under 4GB. you can read commit:5ff84fb244b (x86-efi: Allow initrd+params+cmdline allocations above 4GB.) --- grub-core/kern/efi/mm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index f64f79e..50116a6 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -658,7 +658,11 @@ grub_efi_mm_init (void) /* By default, request a quarter of the available memory. */ total_pages = get_total_pages (filtered_memory_map, desc_size, filtered_memory_map_end); +#if defined(__x86_64__) + required_pages = (total_pages >> 1); +#else required_pages = (total_pages >> 2); +#endif if (required_pages < BYTES_TO_PAGES (MIN_HEAP_SIZE)) required_pages = BYTES_TO_PAGES (MIN_HEAP_SIZE); else if (required_pages > BYTES_TO_PAGES (MAX_HEAP_SIZE)) -- 2.27.0