summarylogtreecommitdiffstats
path: root/08-fix_wrong_image_size.patch
diff options
context:
space:
mode:
Diffstat (limited to '08-fix_wrong_image_size.patch')
-rw-r--r--08-fix_wrong_image_size.patch48
1 files changed, 48 insertions, 0 deletions
diff --git a/08-fix_wrong_image_size.patch b/08-fix_wrong_image_size.patch
new file mode 100644
index 000000000000..17989adf3f87
--- /dev/null
+++ b/08-fix_wrong_image_size.patch
@@ -0,0 +1,48 @@
+From c0e647eb0e2bd09315612446cb4d90f7f75cb44c Mon Sep 17 00:00:00 2001
+From: Javier Martinez Canillas <javierm@redhat.com>
+Date: Tue, 27 Apr 2021 12:25:08 +0200
+Subject: util/mkimage: Fix wrong PE32+ section sizes for some arches
+
+The commit f60ba9e5945 (util/mkimage: Refactor section setup to use a helper)
+added a helper function to setup PE sections. But it also changed how the
+raw data offsets were calculated since all the section sizes are aligned.
+However, for some platforms, i.e ia64-efi and arm64-efi, the kernel image
+size is not aligned using the section alignment. This leads to the situation
+in which the mods section offset in its PE section header does not match its
+real placement in the PE file. So, finally the GRUB is not able to locate
+and load built-in modules.
+
+The problem surfaces on ia64-efi and arm64-efi because both platforms
+require additional relocation data which is added behind .bss section.
+So, we have to add some padding behind this extra data to make the
+beginning of mods section properly aligned in the PE file. Fix it by
+aligning the kernel_size to the section alignment. That makes the sizes
+and offsets in the PE section headers to match relevant sections in the
+PE32+ binary file.
+
+Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
+Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
+Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
+Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
+---
+ util/grub-mkimagexx.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
+index 00f49ccaa..d78fa3e53 100644
+--- a/util/grub-mkimagexx.c
++++ b/util/grub-mkimagexx.c
+@@ -2388,6 +2388,10 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path,
+ layout->kernel_size += ALIGN_UP (layout->got_size, 16);
+ }
+ #endif
++
++ if (image_target->id == IMAGE_EFI)
++ layout->kernel_size = ALIGN_UP (layout->kernel_size,
++ GRUB_PE32_FILE_ALIGNMENT);
+ }
+ else
+ {
+--
+cgit v1.2.1
+