3e026f665c
- Add safety measure to pcr snapshot by checking platform and tpm status * safe_tpm_pcr_snapshot.patch - Fix installation failure due to unavailable nvram device on ppc64le (bsc#1201361) * 0001-grub-install-set-point-of-no-return-for-powerpc-ieee1275.patch - Add patches to dynamically allocate additional memory regions for EFI systems (bsc#1202438) * 0001-mm-Allow-dynamically-requesting-additional-memory-re.patch * 0002-kern-efi-mm-Always-request-a-fixed-number-of-pages-o.patch * 0003-kern-efi-mm-Extract-function-to-add-memory-regions.patch * 0004-kern-efi-mm-Pass-up-errors-from-add_memory_regions.patch * 0005-kern-efi-mm-Implement-runtime-addition-of-pages.patch - Enlarge the default heap size and defer the disk cache invalidation (bsc#1202438) * 0001-kern-efi-mm-Enlarge-the-default-heap-size.patch * 0002-mm-Defer-the-disk-cache-invalidation.patch - Add patches for ALP FDE support * 0001-devmapper-getroot-Have-devmapper-recognize-LUKS2.patch * 0002-devmapper-getroot-Set-up-cheated-LUKS2-cryptodisk-mo.patch * 0003-disk-cryptodisk-When-cheatmounting-use-the-sector-in.patch * 0004-normal-menu-Don-t-show-Booting-s-msg-when-auto-booti.patch * 0005-EFI-suppress-the-Welcome-to-GRUB-message-in-EFI-buil.patch * 0006-EFI-console-Do-not-set-colorstate-until-the-first-te.patch * 0007-EFI-console-Do-not-set-cursor-until-the-first-text-o.patch * 0008-linuxefi-Use-common-grub_initrd_load.patch * 0009-Add-crypttab_entry-to-obviate-the-need-to-input-pass.patch * 0010-templates-import-etc-crypttab-to-grub.cfg.patch OBS-URL: https://build.opensuse.org/request/show/1004537 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=419
107 lines
3.9 KiB
Diff
107 lines
3.9 KiB
Diff
From 834cb2ca9ed2d9d7a6926e598accdfe280b615da Mon Sep 17 00:00:00 2001
|
|
From: Patrick Steinhardt <ps@pks.im>
|
|
Date: Thu, 21 Apr 2022 15:24:19 +1000
|
|
Subject: [PATCH 2/5] kern/efi/mm: Always request a fixed number of pages on
|
|
init
|
|
|
|
When initializing the EFI memory subsystem, we will by default request
|
|
a quarter of the available memory, bounded by a minimum/maximum value.
|
|
Given that we're about to extend the EFI memory system to dynamically
|
|
request additional pages from the firmware as required, this scaling of
|
|
requested memory based on available memory will not make a lot of sense
|
|
anymore.
|
|
|
|
Remove this logic as a preparatory patch such that we'll instead defer
|
|
to the runtime memory allocator. Note that ideally, we'd want to change
|
|
this after dynamic requesting of pages has been implemented for the EFI
|
|
platform. But because we'll need to split up initialization of the
|
|
memory subsystem and the request of pages from the firmware, we'd have
|
|
to duplicate quite some logic at first only to remove it afterwards
|
|
again. This seems quite pointless, so we instead have patches slightly
|
|
out of order.
|
|
|
|
Signed-off-by: Patrick Steinhardt <ps@pks.im>
|
|
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
Tested-by: Patrick Steinhardt <ps@pks.im>
|
|
---
|
|
grub-core/kern/efi/mm.c | 35 +++--------------------------------
|
|
1 file changed, 3 insertions(+), 32 deletions(-)
|
|
|
|
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
|
|
index 67a691d..2874522 100644
|
|
--- a/grub-core/kern/efi/mm.c
|
|
+++ b/grub-core/kern/efi/mm.c
|
|
@@ -38,9 +38,8 @@
|
|
a multiplier of 4KB. */
|
|
#define MEMORY_MAP_SIZE 0x3000
|
|
|
|
-/* The minimum and maximum heap size for GRUB itself. */
|
|
-#define MIN_HEAP_SIZE 0x100000
|
|
-#define MAX_HEAP_SIZE (1600 * 0x100000)
|
|
+/* The default heap size for GRUB itself in bytes. */
|
|
+#define DEFAULT_HEAP_SIZE 0x100000
|
|
|
|
static void *finish_mmap_buf = 0;
|
|
static grub_efi_uintn_t finish_mmap_size = 0;
|
|
@@ -514,23 +513,6 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
|
return filtered_desc;
|
|
}
|
|
|
|
-/* Return the total number of pages. */
|
|
-static grub_efi_uint64_t
|
|
-get_total_pages (grub_efi_memory_descriptor_t *memory_map,
|
|
- grub_efi_uintn_t desc_size,
|
|
- grub_efi_memory_descriptor_t *memory_map_end)
|
|
-{
|
|
- grub_efi_memory_descriptor_t *desc;
|
|
- grub_efi_uint64_t total = 0;
|
|
-
|
|
- for (desc = memory_map;
|
|
- desc < memory_map_end;
|
|
- desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
|
|
- total += desc->num_pages;
|
|
-
|
|
- return total;
|
|
-}
|
|
-
|
|
/* Add memory regions. */
|
|
static void
|
|
add_memory_regions (grub_efi_memory_descriptor_t *memory_map,
|
|
@@ -619,8 +601,6 @@ grub_efi_mm_init (void)
|
|
grub_efi_memory_descriptor_t *filtered_memory_map_end;
|
|
grub_efi_uintn_t map_size;
|
|
grub_efi_uintn_t desc_size;
|
|
- grub_efi_uint64_t total_pages;
|
|
- grub_efi_uint64_t required_pages;
|
|
int mm_status;
|
|
|
|
/* Prepare a memory region to store two memory maps. */
|
|
@@ -660,22 +640,13 @@ grub_efi_mm_init (void)
|
|
filtered_memory_map_end = filter_memory_map (memory_map, filtered_memory_map,
|
|
desc_size, memory_map_end);
|
|
|
|
- /* By default, request a quarter of the available memory. */
|
|
- total_pages = get_total_pages (filtered_memory_map, desc_size,
|
|
- filtered_memory_map_end);
|
|
- required_pages = (total_pages >> 2);
|
|
- 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))
|
|
- required_pages = BYTES_TO_PAGES (MAX_HEAP_SIZE);
|
|
-
|
|
/* Sort the filtered descriptors, so that GRUB can allocate pages
|
|
from smaller regions. */
|
|
sort_memory_map (filtered_memory_map, desc_size, filtered_memory_map_end);
|
|
|
|
/* Allocate memory regions for GRUB's memory management. */
|
|
add_memory_regions (filtered_memory_map, desc_size,
|
|
- filtered_memory_map_end, required_pages);
|
|
+ filtered_memory_map_end, BYTES_TO_PAGES (DEFAULT_HEAP_SIZE));
|
|
|
|
#if 0
|
|
/* For debug. */
|
|
--
|
|
2.35.3
|
|
|