mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-11-28 07:44:52 +00:00
aa64: support pe/coff decompressor
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
This commit is contained in:
parent
db229abffb
commit
c50cc54b88
4 changed files with 144 additions and 1 deletions
|
@ -0,0 +1,43 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Thu, 11 Aug 2022 16:51:57 +0200
|
||||
Subject: [PATCH] loader/arm64/linux: Remove magic number header field check
|
||||
|
||||
The "ARM\x64" magic number in the file header identifies an image as one
|
||||
that implements the bare metal boot protocol, allowing the loader to
|
||||
simply move the file to a suitably aligned address in memory, with
|
||||
sufficient headroom for the trailing .bss segment (the required memory
|
||||
size is described in the header as well).
|
||||
|
||||
Note of this matters for GRUB, as it only supports EFI boot. EFI does
|
||||
not care about this magic number, and nor should GRUB: this prevents us
|
||||
from booting other PE linux images, such as the generic EFI zboot
|
||||
decompressor, which is a pure PE/COFF image, and does not implement the
|
||||
bare metal boot protocol.
|
||||
|
||||
So drop the magic number check.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
Resolves: rhbz#2125069
|
||||
Signed-off-by: Jeremy Linton <jlinton@redhat.com>
|
||||
(cherry-picked from commit 69edb31205602c29293a8c6e67363bba2a4a1e66)
|
||||
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
|
||||
---
|
||||
grub-core/loader/arm64/linux.c | 3 ---
|
||||
1 file changed, 3 deletions(-)
|
||||
|
||||
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
|
||||
index de85583487..489d0c7173 100644
|
||||
--- a/grub-core/loader/arm64/linux.c
|
||||
+++ b/grub-core/loader/arm64/linux.c
|
||||
@@ -55,9 +55,6 @@ static grub_addr_t initrd_end;
|
||||
grub_err_t
|
||||
grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh)
|
||||
{
|
||||
- if (lh->magic != GRUB_LINUX_ARMXX_MAGIC_SIGNATURE)
|
||||
- return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
|
||||
-
|
||||
if ((lh->code0 & 0xffff) != GRUB_DOS_MAGIC)
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled"));
|
95
0282-Correct-BSS-zeroing-on-aarch64.patch
Normal file
95
0282-Correct-BSS-zeroing-on-aarch64.patch
Normal file
|
@ -0,0 +1,95 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jeremy Linton <jeremy.linton@arm.com>
|
||||
Date: Tue, 6 Sep 2022 15:33:03 -0500
|
||||
Subject: [PATCH] Correct BSS zeroing on aarch64
|
||||
|
||||
The aarch64 loader doesn't use efi bootservices, and
|
||||
therefor it has a very minimal loader which makes a lot
|
||||
of assumptions about the kernel layout. With the ZBOOT
|
||||
changes, the layout has changed a bit and we not should
|
||||
really be parsing the PE sections to determine how much
|
||||
data to copy, otherwise the BSS won't be setup properly.
|
||||
|
||||
This code still makes a lot of assumptions about the
|
||||
the kernel layout, so its far from ideal, but it works.
|
||||
|
||||
Resolves: rhbz#2125069
|
||||
|
||||
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
|
||||
---
|
||||
grub-core/loader/arm64/linux.c | 27 ++++++++++++++++++++++-----
|
||||
1 file changed, 22 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c
|
||||
index 489d0c7173..419f2201df 100644
|
||||
--- a/grub-core/loader/arm64/linux.c
|
||||
+++ b/grub-core/loader/arm64/linux.c
|
||||
@@ -316,10 +316,12 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
||||
static grub_err_t
|
||||
parse_pe_header (void *kernel, grub_uint64_t *total_size,
|
||||
grub_uint32_t *entry_offset,
|
||||
- grub_uint32_t *alignment)
|
||||
+ grub_uint32_t *alignment,grub_uint32_t *code_size)
|
||||
{
|
||||
struct linux_arch_kernel_header *lh = kernel;
|
||||
struct grub_armxx_linux_pe_header *pe;
|
||||
+ grub_uint16_t i;
|
||||
+ struct grub_pe32_section_table *sections;
|
||||
|
||||
pe = (void *)((unsigned long)kernel + lh->hdr_offset);
|
||||
|
||||
@@ -329,6 +331,19 @@ parse_pe_header (void *kernel, grub_uint64_t *total_size,
|
||||
*total_size = pe->opt.image_size;
|
||||
*entry_offset = pe->opt.entry_addr;
|
||||
*alignment = pe->opt.section_alignment;
|
||||
+ *code_size = pe->opt.section_alignment;
|
||||
+
|
||||
+ sections = (struct grub_pe32_section_table *) ((char *)&pe->opt +
|
||||
+ pe->coff.optional_header_size);
|
||||
+ grub_dprintf ("linux", "num_sections : %d\n", pe->coff.num_sections );
|
||||
+ for (i = 0 ; i < pe->coff.num_sections; i++)
|
||||
+ {
|
||||
+ grub_dprintf ("linux", "raw_size : %lld\n",
|
||||
+ (long long) sections[i].raw_data_size);
|
||||
+ grub_dprintf ("linux", "virt_size : %lld\n",
|
||||
+ (long long) sections[i].virtual_size);
|
||||
+ *code_size += sections[i].raw_data_size;
|
||||
+ }
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
@@ -341,6 +356,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
grub_err_t err;
|
||||
grub_off_t filelen;
|
||||
grub_uint32_t align;
|
||||
+ grub_uint32_t code_size;
|
||||
void *kernel = NULL;
|
||||
int nx_supported = 1;
|
||||
|
||||
@@ -373,11 +389,12 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
|
||||
if (grub_arch_efi_linux_check_image (kernel) != GRUB_ERR_NONE)
|
||||
goto fail;
|
||||
- if (parse_pe_header (kernel, &kernel_size, &handover_offset, &align) != GRUB_ERR_NONE)
|
||||
+ if (parse_pe_header (kernel, &kernel_size, &handover_offset, &align, &code_size) != GRUB_ERR_NONE)
|
||||
goto fail;
|
||||
grub_dprintf ("linux", "kernel mem size : %lld\n", (long long) kernel_size);
|
||||
grub_dprintf ("linux", "kernel entry offset : %d\n", handover_offset);
|
||||
grub_dprintf ("linux", "kernel alignment : 0x%x\n", align);
|
||||
+ grub_dprintf ("linux", "kernel size : 0x%x\n", code_size);
|
||||
|
||||
err = grub_efi_check_nx_image_support((grub_addr_t)kernel, filelen, &nx_supported);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
@@ -396,9 +413,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
||||
kernel_addr = (void *)ALIGN_UP((grub_uint64_t)kernel_alloc_addr, align);
|
||||
|
||||
grub_dprintf ("linux", "kernel @ %p\n", kernel_addr);
|
||||
- grub_memcpy (kernel_addr, kernel, grub_min(filelen, kernel_size));
|
||||
- if (kernel_size > filelen)
|
||||
- grub_memset ((char *)kernel_addr + filelen, 0, kernel_size - filelen);
|
||||
+ grub_memcpy (kernel_addr, kernel, grub_min(code_size, kernel_size));
|
||||
+ if (kernel_size > code_size)
|
||||
+ grub_memset ((char *)kernel_addr + code_size, 0, kernel_size - code_size);
|
||||
grub_free(kernel);
|
||||
kernel = NULL;
|
||||
|
|
@ -278,3 +278,5 @@ Patch0277: 0277-squish-give-up-on-rhgb-quiet.patch
|
|||
Patch0278: 0278-squish-BLS-only-write-etc-kernel-cmdline-if-writable.patch
|
||||
Patch0279: 0279-ieee1275-implement-vec5-for-cas-negotiation.patch
|
||||
Patch0280: 0280-blscfg-Don-t-root-device-in-emu-builds.patch
|
||||
Patch0281: 0281-loader-arm64-linux-Remove-magic-number-header-field-.patch
|
||||
Patch0282: 0282-Correct-BSS-zeroing-on-aarch64.patch
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
Name: grub2
|
||||
Epoch: 1
|
||||
Version: 2.06
|
||||
Release: 56%{?dist}
|
||||
Release: 57%{?dist}
|
||||
Summary: Bootloader with support for Linux, Multiboot and more
|
||||
License: GPLv3+
|
||||
URL: http://www.gnu.org/software/grub/
|
||||
|
@ -530,6 +530,9 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg
|
|||
%endif
|
||||
|
||||
%changelog
|
||||
* Thu Sep 08 2022 Robbie Harwood <rharwood@redhat.com> - 2.06-57
|
||||
- aa64: support pe/coff decompressor
|
||||
|
||||
* Wed Sep 07 2022 Robbie Harwood <rharwood@redhat.com> - 2.06-56
|
||||
- Revert patches to claim more memory for the arena
|
||||
|
||||
|
|
Loading…
Reference in a new issue