#27 Correct arm64 memory allocation type for +X pages.
Closed 9 months ago by nfrayer. Opened 10 months ago by jlinton.
rpms/ jlinton/grub2 fix_x13s  into  rawhide

@@ -0,0 +1,47 @@ 

+ From 71402fac6df4af0c06fea69aec6cf4907a1234e0 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

+ 

+ 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 <luzmaximilian@gmail.com>

+ ---

+  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 419f2201d..a3a193c25 100644

+ --- a/grub-core/loader/arm64/linux.c

+ +++ b/grub-core/loader/arm64/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/linux.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.41.0

+ 

file modified
+1
@@ -332,3 +332,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-arm64-Use-proper-memory-type-for-kernel-allocation.patch

Various arm devices (x13s, ms surface, etc) no longer are
setting the execute bit on pages allocated as data, nor do they
have the protocol to update page permissions. This results
in boot failures on these machines when grub jumps to the
kernel and the page isn't marked as executable.

Resolves: #2149020
Signed-off-by: Jeremy Linton jeremy.linton@arm.com

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/aa84edee87fb47a1a92410d0a190bef2

@jlinton thanks, both this PR and https://github.com/rhboot/grub2/pull/101 looks good to me but I would like @pjones to comment. If he agrees, I'm happy to merge both and kick a new build.

@nfrayer could you please take a look to this PR ?

Hi, this is on my todo list. I was on PTO until last week.

@jlinton @javierm Both this and the PR look good to me. Thanks for the submission.

@jlinton Can you please rebase and we can merge it. Thanks.

rebased onto e361a020245f77c809efcd0d4778d6e7d142b711

10 months ago

rebased onto ccc6137

10 months ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/6c22846b5382407fa8b757720b23f2eb

Closing this PR as it's been merged in rhboot/grub2.git

Pull-Request has been closed by nfrayer

9 months ago