forked from pool/grub2
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
90 lines
3.3 KiB
Diff
90 lines
3.3 KiB
Diff
From 4287786dde414d9b0517d12762904b4b2be19d2a Mon Sep 17 00:00:00 2001
|
|
From: Patrick Steinhardt <ps@pks.im>
|
|
Date: Thu, 21 Apr 2022 15:24:21 +1000
|
|
Subject: [PATCH 4/5] kern/efi/mm: Pass up errors from add_memory_regions()
|
|
|
|
The function add_memory_regions() is currently only called on system
|
|
initialization to allocate a fixed amount of pages. As such, it didn't
|
|
need to return any errors: in case it failed, we cannot proceed anyway.
|
|
This will change with the upcoming support for requesting more memory
|
|
from the firmware at runtime, where it doesn't make sense anymore to
|
|
fail hard.
|
|
|
|
Refactor the function to return an error to prepare for this. Note that
|
|
this does not change the behaviour when initializing the memory system
|
|
because grub_efi_mm_init() knows to call grub_fatal() in case
|
|
grub_efi_mm_add_regions() returns an error.
|
|
|
|
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 | 22 +++++++++++++++-------
|
|
1 file changed, 15 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
|
|
index 087272f..45ea6d5 100644
|
|
--- a/grub-core/kern/efi/mm.c
|
|
+++ b/grub-core/kern/efi/mm.c
|
|
@@ -514,7 +514,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
|
|
}
|
|
|
|
/* Add memory regions. */
|
|
-static void
|
|
+static grub_err_t
|
|
add_memory_regions (grub_efi_memory_descriptor_t *memory_map,
|
|
grub_efi_uintn_t desc_size,
|
|
grub_efi_memory_descriptor_t *memory_map_end,
|
|
@@ -542,9 +542,9 @@ add_memory_regions (grub_efi_memory_descriptor_t *memory_map,
|
|
GRUB_EFI_ALLOCATE_ADDRESS,
|
|
GRUB_EFI_LOADER_CODE);
|
|
if (! addr)
|
|
- grub_fatal ("cannot allocate conventional memory %p with %u pages",
|
|
- (void *) ((grub_addr_t) start),
|
|
- (unsigned) pages);
|
|
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
|
+ "Memory starting at %p (%u pages) marked as free, but EFI would not allocate",
|
|
+ (void *) ((grub_addr_t) start), (unsigned) pages);
|
|
|
|
grub_mm_init_region (addr, PAGES_TO_BYTES (pages));
|
|
|
|
@@ -554,7 +554,11 @@ add_memory_regions (grub_efi_memory_descriptor_t *memory_map,
|
|
}
|
|
|
|
if (required_pages > 0)
|
|
- grub_fatal ("too little memory");
|
|
+ return grub_error (GRUB_ERR_OUT_OF_MEMORY,
|
|
+ "could not allocate all requested memory: %" PRIuGRUB_UINT64_T " pages still required after iterating EFI memory map",
|
|
+ required_pages);
|
|
+
|
|
+ return GRUB_ERR_NONE;
|
|
}
|
|
|
|
void
|
|
@@ -601,6 +605,7 @@ grub_efi_mm_add_regions (grub_size_t required_bytes)
|
|
grub_efi_memory_descriptor_t *filtered_memory_map_end;
|
|
grub_efi_uintn_t map_size;
|
|
grub_efi_uintn_t desc_size;
|
|
+ grub_err_t err;
|
|
int mm_status;
|
|
|
|
/* Prepare a memory region to store two memory maps. */
|
|
@@ -645,8 +650,11 @@ grub_efi_mm_add_regions (grub_size_t required_bytes)
|
|
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, BYTES_TO_PAGES (required_bytes));
|
|
+ err = add_memory_regions (filtered_memory_map, desc_size,
|
|
+ filtered_memory_map_end,
|
|
+ BYTES_TO_PAGES (required_bytes));
|
|
+ if (err != GRUB_ERR_NONE)
|
|
+ return err;
|
|
|
|
#if 0
|
|
/* For debug. */
|
|
--
|
|
2.35.3
|
|
|