summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorKristian Klausen <kristian@klausen.dk>2021-09-28 14:44:16 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-04 15:03:53 +0100
commitb8c0f073f6a282f89fba7711ec168d0638749300 (patch)
treee5ab029e59753092968248f5d339d3b0dda83f1f /meta
parent75b79d5c056b5abb44c546af773e3431d4c09476 (diff)
downloadpoky-b8c0f073f6a282f89fba7711ec168d0638749300.tar.gz
wic/bootimg-efi: Add Unified Kernel Image option
"A unified kernel image is a single EFI PE executable combining an EFI stub loader, a kernel image, an initramfs image, and the kernel command line. [...] Images of this type have the advantage that all metadata and payload that makes up the boot entry is monopolized in a single PE file that can be signed cryptographically as one for the purpose of EFI SecureBoot."[1] This commit adds a create-unified-kernel-image=true option to the bootimg-efi plugin for creating a Unified Kernel Image[1] and installing it into $BOOT/EFI/Linux/ with a .efi extension per the the Boot Loader Specification[1][2]. This is useful for implementing Secure Boot. systemd-boot is the only mainstream bootloader implementing the specification, but GRUB should be able to boot the EFI binary, this commit however doesn't implement the necessary changes to the GRUB config generation logic to boot the Unified Kernel Image. [1] https://systemd.io/BOOT_LOADER_SPECIFICATION/#type-2-efi-unified-kernel-images [2] https://systemd.io/BOOT_LOADER_SPECIFICATION/ (From OE-Core rev: b0573f240525df561ddef6e47cb285b217d38487) Signed-off-by: Kristian Klausen <kristian@klausen.dk> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/image_types_wic.bbclass5
-rw-r--r--meta/lib/oeqa/selftest/cases/wic.py29
2 files changed, 32 insertions, 2 deletions
diff --git a/meta/classes/image_types_wic.bbclass b/meta/classes/image_types_wic.bbclass
index d561fb2636..e3863c88a9 100644
--- a/meta/classes/image_types_wic.bbclass
+++ b/meta/classes/image_types_wic.bbclass
@@ -27,6 +27,7 @@ WICVARS ?= "\
27 ROOTFS_SIZE \ 27 ROOTFS_SIZE \
28 STAGING_DATADIR \ 28 STAGING_DATADIR \
29 STAGING_DIR \ 29 STAGING_DIR \
30 STAGING_DIR_HOST \
30 STAGING_LIBDIR \ 31 STAGING_LIBDIR \
31 TARGET_SYS \ 32 TARGET_SYS \
32" 33"
@@ -84,8 +85,8 @@ do_image_wic[deptask] += "do_image_complete"
84WKS_FILE_DEPENDS_DEFAULT = '${@bb.utils.contains_any("BUILD_ARCH", [ 'x86_64', 'i686' ], "syslinux-native", "",d)}' 85WKS_FILE_DEPENDS_DEFAULT = '${@bb.utils.contains_any("BUILD_ARCH", [ 'x86_64', 'i686' ], "syslinux-native", "",d)}'
85WKS_FILE_DEPENDS_DEFAULT += "bmap-tools-native cdrtools-native btrfs-tools-native squashfs-tools-native e2fsprogs-native" 86WKS_FILE_DEPENDS_DEFAULT += "bmap-tools-native cdrtools-native btrfs-tools-native squashfs-tools-native e2fsprogs-native"
86WKS_FILE_DEPENDS_BOOTLOADERS = "" 87WKS_FILE_DEPENDS_BOOTLOADERS = ""
87WKS_FILE_DEPENDS_BOOTLOADERS:x86 = "syslinux grub-efi systemd-boot" 88WKS_FILE_DEPENDS_BOOTLOADERS:x86 = "syslinux grub-efi systemd-boot os-release"
88WKS_FILE_DEPENDS_BOOTLOADERS:x86-64 = "syslinux grub-efi systemd-boot" 89WKS_FILE_DEPENDS_BOOTLOADERS:x86-64 = "syslinux grub-efi systemd-boot os-release"
89WKS_FILE_DEPENDS_BOOTLOADERS:x86-x32 = "syslinux grub-efi" 90WKS_FILE_DEPENDS_BOOTLOADERS:x86-x32 = "syslinux grub-efi"
90 91
91WKS_FILE_DEPENDS ??= "${WKS_FILE_DEPENDS_DEFAULT} ${WKS_FILE_DEPENDS_BOOTLOADERS}" 92WKS_FILE_DEPENDS ??= "${WKS_FILE_DEPENDS_DEFAULT} ${WKS_FILE_DEPENDS_BOOTLOADERS}"
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index dc7b9e637e..5fc8e65142 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -1158,6 +1158,35 @@ class Wic2(WicTestCase):
1158 out = glob(self.resultdir + "%s-*.direct" % wksname) 1158 out = glob(self.resultdir + "%s-*.direct" % wksname)
1159 self.assertEqual(1, len(out)) 1159 self.assertEqual(1, len(out))
1160 1160
1161 @only_for_arch(['i586', 'i686', 'x86_64'])
1162 def test_efi_plugin_unified_kernel_image_qemu(self):
1163 """Test efi plugin's Unified Kernel Image feature in qemu"""
1164 config = 'IMAGE_FSTYPES = "wic"\n'\
1165 'INITRAMFS_IMAGE = "core-image-minimal-initramfs"\n'\
1166 'WKS_FILE = "test_efi_plugin.wks"\n'\
1167 'MACHINE_FEATURES:append = " efi"\n'
1168 self.append_config(config)
1169 self.assertEqual(0, bitbake('core-image-minimal core-image-minimal-initramfs ovmf').status)
1170 self.remove_config(config)
1171
1172 with runqemu('core-image-minimal', ssh=False,
1173 runqemuparams='ovmf', image_fstype='wic') as qemu:
1174 # Check that /boot has EFI bootx64.efi (required for EFI)
1175 cmd = "ls /boot/EFI/BOOT/bootx64.efi | wc -l"
1176 status, output = qemu.run_serial(cmd)
1177 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
1178 self.assertEqual(output, '1')
1179 # Check that /boot has EFI/Linux/linux.efi (required for Unified Kernel Images auto detection)
1180 cmd = "ls /boot/EFI/Linux/linux.efi | wc -l"
1181 status, output = qemu.run_serial(cmd)
1182 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
1183 self.assertEqual(output, '1')
1184 # Check that /boot doesn't have loader/entries/boot.conf (Unified Kernel Images are auto detected by the bootloader)
1185 cmd = "ls /boot/loader/entries/boot.conf 2&>/dev/null | wc -l"
1186 status, output = qemu.run_serial(cmd)
1187 self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
1188 self.assertEqual(output, '0')
1189
1161 def test_fs_types(self): 1190 def test_fs_types(self):
1162 """Test filesystem types for empty and not empty partitions""" 1191 """Test filesystem types for empty and not empty partitions"""
1163 img = 'core-image-minimal' 1192 img = 'core-image-minimal'