Skip to contentSkip to conversation

util/grub-mkrescue: use capitalised paths for removable EFI images

PATCH In review Mingcong Bai 2 participants 2 messages Jun 13, 2024 – Jun 16, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 util/grub-mkrescue: use capitalised paths for removable EFI images

Per UEFI Specification, section 3.4.1.1:

... If FilePathList[0] points to a device that supports the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, then the system firmware will attempt to boot from a removable media FilePathList[0] by adding a default file name in the form \EFI\BOOT\BOOT{machine type short-name}.EFI.

While FAT < 32 filesystems are not case sensitive (which grub-mkrescue creates as a FAT12 image via mformat with a size of 2.88MiB), it seems that some of Loongson's LoongArch-based firmware (namely those found on their latest XA61200 boards) seems to treat this file system as case-sensitive. In this case, at least the XA61200 board seems incapable of identifying /efi/boot/bootloongarch64.efi as a valid removable EFI image.

In any case, according to the UEFI Specification, all paths and image filenames should be capitalised (with the exception of BOOTx64.EFI, according to section 3.5.1.1, for some reason) to stay compliant. The Loongson case is only one example of users running into buggy firmware and unbootable GRUB ISO images.

---
 util/grub-mkrescue.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
util/grub-mkrescue.c +3 -3
index 27696e034..cfb749967 100644
@@ -769,8 +769,8 @@ main (int argc, char *argv[])
       || source_dirs[GRUB_INSTALL_PLATFORM_RISCV64_EFI])
     {
       FILE *f;
-      char *efidir_efi = grub_util_path_concat (2, iso9660_dir, "efi");
-      char *efidir_efi_boot = grub_util_path_concat (3, iso9660_dir, "efi", "boot");
+      char *efidir_efi = grub_util_path_concat (2, iso9660_dir, "EFI");
+      char *efidir_efi_boot = grub_util_path_concat (3, iso9660_dir, "EFI", "BOOT");
       char *imgname, *img32, *img64, *img_mac = NULL;
       char *efiimgfat, *iso_uuid_file, *diskdir, *diskdir_uuid;
       grub_install_mkdir_p (efidir_efi_boot);
@@ -792,39 +792,39 @@ main (int argc, char *argv[])
       free (diskdir_uuid);
       free (diskdir);
 
-      imgname = grub_util_path_concat (2, efidir_efi_boot, "bootia64.efi");
+      imgname = grub_util_path_concat (2, efidir_efi_boot, "BOOTIA64.EFI");
       make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_IA64_EFI, 
"ia64-efi", imgname);
       free (imgname);

       grub_install_push_module ("part_apple");
-      img64 = grub_util_path_concat (2, efidir_efi_boot, "bootx64.efi");
+      img64 = grub_util_path_concat (2, efidir_efi_boot, "BOOTx64.EFI");
       make_image_abs (GRUB_INSTALL_PLATFORM_X86_64_EFI, "x86_64-efi", 
img64);
       grub_install_pop_module ();

       grub_install_push_module ("part_apple");
-      img32 = grub_util_path_concat (2, efidir_efi_boot, "bootia32.efi");
+      img32 = grub_util_path_concat (2, efidir_efi_boot, "BOOTIA32.EFI");
       make_image_abs (GRUB_INSTALL_PLATFORM_I386_EFI, "i386-efi", 
img32);
       grub_install_pop_module ();

- imgname = grub_util_path_concat (2, efidir_efi_boot, "bootarm.efi");
+ imgname = grub_util_path_concat (2, efidir_efi_boot, "BOOTARM.EFI");
make_image_abs (GRUB_INSTALL_PLATFORM_ARM_EFI, "arm-efi",

imgname);
       free (imgname);

- imgname = grub_util_path_concat (2, efidir_efi_boot, "bootaa64.efi");

+      imgname = grub_util_path_concat (2, efidir_efi_boot, "BOOTAA64.EFI");
       make_image_abs (GRUB_INSTALL_PLATFORM_ARM64_EFI, "arm64-efi", 
imgname);
       free (imgname);

- imgname = grub_util_path_concat (2, efidir_efi_boot, "bootloongarch64.efi");
+ imgname = grub_util_path_concat (2, efidir_efi_boot, "BOOTLOONGARCH64.EFI");
make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_LOONGARCH64_EFI,
"loongarch64-efi",

 			     imgname);
       free (imgname);

- imgname = grub_util_path_concat (2, efidir_efi_boot, "bootriscv32.efi");
+ imgname = grub_util_path_concat (2, efidir_efi_boot, "BOOTRISCV32.EFI");
make_image_abs (GRUB_INSTALL_PLATFORM_RISCV32_EFI, "riscv32-efi",

imgname);
       free (imgname);

- imgname = grub_util_path_concat (2, efidir_efi_boot, "bootriscv64.efi");
+ imgname = grub_util_path_concat (2, efidir_efi_boot, "BOOTRISCV64.EFI");
make_image_abs (GRUB_INSTALL_PLATFORM_RISCV64_EFI, "riscv64-efi",

imgname);
       free (imgname);
Signature · 7 lines
2.43.4


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#1 lore raw

Hi,

now that i know how to test grub-mkrescue out of the git clone, i also gave your patch v2 a run.

Its mail form seems to be problematic:
- Alpine shows two leading blanks in the context lines instead of one. Empty context lines show no leading blank. Long lines show intermediate line breaks (which is a normal behavior for alpine).
- But running the blob in your raw mail body through "base64 -d" yields the same, including the surplus line breaks.
- In https://lists.gnu.org/archive/html/grub-devel/2024-06/msg00101.html
the changed -/+ line pairs are shown merged to single lines. Blanks are missing there.
- After removing the surplus blanks, inserting the missing ones, and merging lines, i still don't get the second hunk through "patch -p1 -b" until i insert

    @@ -818,11 +818,11 @@ main (int argc, char *argv[])
                                  imgname);
  after
           make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_LOONGARCH64_EFI,
                                  "loongarch64-efi",
                                  imgname);

(One may blame this on my limited patch knowledge which is inviting
witchcraft.)

Now patch works in the current git clone with these messages:
patching file util/grub-mkrescue.c
Hunk #1 succeeded at 767 (offset -2 lines).
Hunk #2 succeeded at 790 with fuzz 2 (offset -2 lines). Hunk #3 succeeded at 818 with fuzz 1.

Compiling works without complaints.

I successfully built grub-mkrescue and tested ISO production with
platform={efi,pc} x target={i386,x86_64}

The "efi" test runs used the xorriso options which would have caused a failure with the patch v1. (I tested yesterday that it indeed would happen with the ISO/HFS+ file name change if not the option was changed accordingly.)
The ISOs of all 4 runs showed the expected boot lures. I did not test whether they actually boot, though. It would not help too much, because in the end the most hunchbacked of the really existing firmwares decides about the usability of the names.

So half a "Tested-by:" for the patch ...
and a "Boooh !" towards your mail program.

Have a nice day :)

Thomas

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel