From 8dbc390581f7bf64c0a99007a1d68c147ab87581 Mon Sep 17 00:00:00 2001 From: Benno Rice Date: Fri, 23 Mar 2018 20:56:18 +0000 Subject: [PATCH] Allow makefs to properly tag UEFI El Torito boot images. Use them in amd64 ISOs. UEFI booting requires an EFI System Partition (ESP). On most storage devices this will be in a specific partition type. To allow booting from CD/ISO filesystems, UEFI will look for an ESP in the form of a FAT filesystem image embedded in the image. Historically FreeBSD has added one of these to its amd64 ISO images but marked it as simply another i386 boot image. Luckily for us most UEFI implementations are rather forgiving and work this out for us. This change adds the ability to mark a boot image as being a UEFI image. It also modifies our ISO generation to use this marking for the UEFI image we embed. Reported by: Thomas Schmitt Reviewed by: emaste, imp MFC after: 1 week Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D14809 --- release/amd64/mkisoimages.sh | 2 +- usr.sbin/makefs/cd9660/cd9660_eltorito.c | 12 +++++++++--- usr.sbin/makefs/cd9660/cd9660_eltorito.h | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/release/amd64/mkisoimages.sh b/release/amd64/mkisoimages.sh index ca94018e2f9b..66f7c945c6cd 100644 --- a/release/amd64/mkisoimages.sh +++ b/release/amd64/mkisoimages.sh @@ -38,7 +38,7 @@ if [ "$1" = "-b" ]; then umount efi rmdir efi mdconfig -d -u $device - bootable="-o bootimage=i386;efiboot.img -o no-emul-boot $bootable" + bootable="-o bootimage=efi;efiboot.img -o no-emul-boot $bootable" shift else diff --git a/usr.sbin/makefs/cd9660/cd9660_eltorito.c b/usr.sbin/makefs/cd9660/cd9660_eltorito.c index 33300646208c..303f51819e58 100644 --- a/usr.sbin/makefs/cd9660/cd9660_eltorito.c +++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.c @@ -104,9 +104,12 @@ cd9660_add_boot_disk(iso9660_disk *diskStructure, const char *boot_info) else if (strcmp(sysname, "macppc") == 0 || strcmp(sysname, "mac68k") == 0) new_image->system = ET_SYS_MAC; + else if (strcmp(sysname, "efi") == 0 || + strcmp(sysname, "uefi") == 0) + new_image->system = ET_SYS_UEFI; else { warnx("boot disk system must be " - "i386, powerpc, macppc, or mac68k"); + "efi, i386, powerpc, macppc, mac68k"); free(temp); free(new_image); return 0; @@ -338,12 +341,12 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int first_sector) int used_sectors; int num_entries = 0; int catalog_sectors; - struct boot_catalog_entry *x86_head, *mac_head, *ppc_head, + struct boot_catalog_entry *x86_head, *mac_head, *ppc_head, *uefi_head, *valid_entry, *default_entry, *temp, *head, **headp, *next; struct cd9660_boot_image *tmp_disk; headp = NULL; - x86_head = mac_head = ppc_head = NULL; + x86_head = mac_head = ppc_head = uefi_head = NULL; /* If there are no boot disks, don't bother building boot information */ if (TAILQ_EMPTY(&diskStructure->boot_images)) @@ -422,6 +425,9 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int first_sector) case ET_SYS_MAC: headp = &mac_head; break; + case ET_SYS_UEFI: + headp = &uefi_head; + break; default: warnx("%s: internal error: unknown system type", __func__); diff --git a/usr.sbin/makefs/cd9660/cd9660_eltorito.h b/usr.sbin/makefs/cd9660/cd9660_eltorito.h index 976dd989e74d..e4569daf9219 100644 --- a/usr.sbin/makefs/cd9660/cd9660_eltorito.h +++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.h @@ -44,6 +44,7 @@ #define ET_SYS_X86 0 #define ET_SYS_PPC 1 #define ET_SYS_MAC 2 +#define ET_SYS_UEFI 0xef #define ET_BOOT_ENTRY_SIZE 0x20