From c4218f0de98c4a5c84e830424b5582b1a4747a7b Mon Sep 17 00:00:00 2001 From: Nicolas Frayer Date: Wed, 13 Sep 2023 00:10:53 +0200 Subject: [PATCH] arm64: Use proper memory type for kernel allocation Resolves: #2149020 Signed-off-by: Nicolas Frayer --- ...er-memory-type-for-kernel-allocation.patch | 44 +++++++++++++++++++ grub.patches | 1 + grub2.spec | 6 ++- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 0336-arm64-Use-proper-memory-type-for-kernel-allocation.patch diff --git a/0336-arm64-Use-proper-memory-type-for-kernel-allocation.patch b/0336-arm64-Use-proper-memory-type-for-kernel-allocation.patch new file mode 100644 index 0000000..e77fcbf --- /dev/null +++ b/0336-arm64-Use-proper-memory-type-for-kernel-allocation.patch @@ -0,0 +1,44 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Maximilian Luz +Date: Tue, 28 Jun 2022 23:06:46 +0200 +Subject: [PATCH] arm64: Use proper memory type for kernel allocation + +Currently, the kernel pages are allocated with type EFI_LOADER_DATA. +While the vast majority of systems will happily execute code from those +pages (i.e. don't care about memory protection), the Microsoft Surface +Pro X stalls, as this memory is not designated as "executable". + +Therefore, allocate the kernel pages as EFI_LOADER_CODE to request +memory that is actually executable. + +Signed-off-by: Maximilian Luz +--- + grub-core/loader/arm64/linux.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c +index 419f2201df8b..a3a193c255e9 100644 +--- a/grub-core/loader/arm64/linux.c ++++ b/grub-core/loader/arm64/linux.c +@@ -26,7 +26,9 @@ + #include + #include + #include ++#include + #include ++#include + #include + #include + #include +@@ -403,7 +405,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + grub_loader_unset(); + + kernel_alloc_pages = GRUB_EFI_BYTES_TO_PAGES (kernel_size + align - 1); +- kernel_alloc_addr = grub_efi_allocate_any_pages (kernel_alloc_pages); ++ kernel_alloc_addr = grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS, ++ kernel_alloc_pages, ++ GRUB_EFI_ALLOCATE_MAX_ADDRESS, ++ GRUB_EFI_LOADER_CODE); + grub_dprintf ("linux", "kernel numpages: %d\n", kernel_alloc_pages); + if (!kernel_alloc_addr) + { diff --git a/grub.patches b/grub.patches index 4761637..b870cef 100644 --- a/grub.patches +++ b/grub.patches @@ -333,3 +333,4 @@ Patch0332: 0332-emu-Add-switch-root-to-grub-emu.patch Patch0333: 0333-util-Enable-default-kernel-for-updates.patch Patch0334: 0334-efi-http-change-uint32_t-to-uintn_t.patch Patch0335: 0335-Add-Install-section-to-aux-systemd-units.patch +Patch0336: 0336-arm64-Use-proper-memory-type-for-kernel-allocation.patch diff --git a/grub2.spec b/grub2.spec index 8fd1e44..65f5915 100644 --- a/grub2.spec +++ b/grub2.spec @@ -17,7 +17,7 @@ Name: grub2 Epoch: 1 Version: 2.06 -Release: 99%{?dist} +Release: 100%{?dist} Summary: Bootloader with support for Linux, Multiboot and more License: GPLv3+ URL: http://www.gnu.org/software/grub/ @@ -548,6 +548,10 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg %endif %changelog +* Wed Sep 13 2023 Nicolas Frayer - 2.06-100 +- arm64: Use proper memory type for kernel allocation +- Resolves: #2149020 + * Fri Sep 01 2023 Christian Glombek - 2.06-99 - spec: Use systemd presets and macros for units in tools package - Resolves: #2230575