fb89b0c9e2
- Fix arm64 kernel image not aligned on 64k boundary (bsc#1192522) * 0001-arm64-Fix-EFI-loader-kernel-image-allocation.patch * 0002-Arm-check-for-the-PE-magic-for-the-compiled-arch.patch OBS-URL: https://build.opensuse.org/request/show/931473 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=397
67 lines
2.5 KiB
Diff
67 lines
2.5 KiB
Diff
From 337b3d963d28b3544e8817428fb68ca559613a39 Mon Sep 17 00:00:00 2001
|
|
From: Peter Jones <pjones@redhat.com>
|
|
Date: Thu, 9 Sep 2021 10:59:28 -0400
|
|
Subject: [PATCH 2/2] Arm: check for the PE magic for the compiled arch
|
|
|
|
In "arm64: Fix EFI loader kernel image allocation", Ben fixed the kernel
|
|
alignment to match the alignment given in the PE header. In doing so, a
|
|
check for valid PE magic was added, which was hard-coded to the value
|
|
seen on Aarch64 (GRUB_PE32_PE64_MAGIC).
|
|
|
|
Unfortunately, this code is shared between 64-bit and 32-bit, and so
|
|
that value broke 32-bit Arm systems.
|
|
|
|
This patch adds a constant definition for GRUB_PE32_PEXX_MAGIC, which is
|
|
either GRUB_PE32_PE64_MAGIC or GRUB_PE32_PE32_MAGIC, depending on which
|
|
platform is being built, and uses it in the header magic check.
|
|
|
|
Resolves: rhbz#2000756
|
|
|
|
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
---
|
|
grub-core/loader/arm64/efi/linux.c | 2 +-
|
|
include/grub/arm/linux.h | 1 +
|
|
include/grub/arm64/linux.h | 1 +
|
|
3 files changed, 3 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/grub-core/loader/arm64/efi/linux.c b/grub-core/loader/arm64/efi/linux.c
|
|
index 4da49a182..87cb2f97c 100644
|
|
--- a/grub-core/loader/arm64/efi/linux.c
|
|
+++ b/grub-core/loader/arm64/efi/linux.c
|
|
@@ -376,7 +376,7 @@ parse_pe_header (void *kernel, grub_uint64_t *total_size,
|
|
|
|
pe = (void *)((unsigned long)kernel + lh->hdr_offset);
|
|
|
|
- if (pe->opt.magic != GRUB_PE32_PE64_MAGIC)
|
|
+ if (pe->opt.magic != GRUB_PE32_PEXX_MAGIC)
|
|
return grub_error(GRUB_ERR_BAD_OS, "Invalid PE optional header magic");
|
|
|
|
*total_size = pe->opt.image_size;
|
|
diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
|
|
index b582f67f6..966a5074f 100644
|
|
--- a/include/grub/arm/linux.h
|
|
+++ b/include/grub/arm/linux.h
|
|
@@ -44,6 +44,7 @@ struct grub_arm_linux_pe_header
|
|
|
|
#if defined(__arm__)
|
|
# define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM_MAGIC_SIGNATURE
|
|
+# define GRUB_PE32_PEXX_MAGIC GRUB_PE32_PE32_MAGIC
|
|
# define linux_arch_kernel_header linux_arm_kernel_header
|
|
# define grub_armxx_linux_pe_header grub_arm_linux_pe_header
|
|
#endif
|
|
diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h
|
|
index de99d39c0..b4b91473a 100644
|
|
--- a/include/grub/arm64/linux.h
|
|
+++ b/include/grub/arm64/linux.h
|
|
@@ -48,6 +48,7 @@ struct grub_arm64_linux_pe_header
|
|
|
|
#if defined(__aarch64__)
|
|
# define GRUB_LINUX_ARMXX_MAGIC_SIGNATURE GRUB_LINUX_ARM64_MAGIC_SIGNATURE
|
|
+# define GRUB_PE32_PEXX_MAGIC GRUB_PE32_PE64_MAGIC
|
|
# define linux_arch_kernel_header linux_arm64_kernel_header
|
|
# define grub_armxx_linux_pe_header grub_arm64_linux_pe_header
|
|
#endif
|
|
--
|
|
2.31.1
|
|
|