Accepting request 1110320 from home:clin:branches:X13S

- Correct the type of allocated EFI pages for ARM64 kernel from EFI_LOADER_DATA to EFI_LOADER_CODE since some Qualcomm CPUs do not allow kernel code execution on EFI_LOADER_DATA pages. (bsc#1215151)

OBS-URL: https://build.opensuse.org/request/show/1110320
OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=460
This commit is contained in:
Michael Chang 2023-09-12 02:11:11 +00:00 committed by Git OBS Bridge
parent 71f10698a2
commit 71fc1bf8e1
3 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,51 @@
From 4f9d3f4f8d7866c69e52ba7d81562daea38b22e6 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Tue, 28 Jun 2022 23:06:46 +0200
Subject: [PATCH] arm64: Use proper memory type for kernel allocation
References: bsc#1215151
Patch-Mainline: no, it's a downstream fix based on Fedora/openSUSE grub2
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.
Link: https://github.com/rhboot/grub2/commit/4f9d3f4f8d7866c69e52ba7d81562daea38b22e6
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Signed-off-by: Chester Lin <clin@suse.com>
---
grub-core/loader/arm64/linux.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/grub-core/loader/arm64/efi/linux.c b/grub-core/loader/arm64/efi/linux.c
index 419f2201d..a3a193c25 100644
--- a/grub-core/loader/arm64/efi/linux.c
+++ b/grub-core/loader/arm64/efi/linux.c
@@ -26,7 +26,9 @@
#include <grub/mm.h>
#include <grub/types.h>
#include <grub/cpu/linux.h>
+#include <grub/efi/api.h>
#include <grub/efi/efi.h>
+#include <grub/cpu/efi/memory.h>
#include <grub/efi/fdtload.h>
#include <grub/efi/memory.h>
#include <grub/efi/pe32.h>
@@ -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)
{
--
2.40.0

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Mon Sep 11 13:17:20 UTC 2023 - Chester Lin <clin@suse.com>
- Correct the type of allocated EFI pages for ARM64 kernel (bsc#1215151)
-------------------------------------------------------------------
Thu Aug 31 19:09:33 UTC 2023 - Andreas Schwab <schwab@suse.de>

View File

@ -374,6 +374,7 @@ Patch186: 0002-cryptodisk-Fallback-to-passphrase.patch
Patch187: 0003-cryptodisk-wipe-out-the-cached-keys-from-protectors.patch
Patch188: 0004-diskfilter-look-up-cryptodisk-devices-first.patch
Patch189: grub2-mkconfig-riscv64.patch
Patch190: arm64-Use-proper-memory-type-for-kernel-allocation.patch
Requires: gettext-runtime
%if 0%{?suse_version} >= 1140