summaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2022-09-17 22:35:23 +0200
committerJan Janssen <medhefgo@web.de>2022-09-20 12:54:53 +0200
commit757d6c916d7248090aee5cc36ee2fdb5cf44d69e (patch)
tree500413edb86278bcd24b5bd3aabce1e23a6308d8 /src/boot
parent6944c611634ddca985fe54966469d8844fc34fb3 (diff)
downloadsystemd-757d6c916d7248090aee5cc36ee2fdb5cf44d69e.tar.gz
stub: Refuse operation if kernel lacks EFI handover support
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/efi/linux_x86.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/boot/efi/linux_x86.c b/src/boot/efi/linux_x86.c
index eeb3c7abc6..1174aa3ece 100644
--- a/src/boot/efi/linux_x86.c
+++ b/src/boot/efi/linux_x86.c
@@ -28,6 +28,13 @@
enum {
XLF_KERNEL_64 = 1 << 0,
XLF_CAN_BE_LOADED_ABOVE_4G = 1 << 1,
+ XLF_EFI_HANDOVER_32 = 1 << 2,
+ XLF_EFI_HANDOVER_64 = 1 << 3,
+#ifdef __x86_64__
+ XLF_EFI_HANDOVER = XLF_EFI_HANDOVER_64,
+#else
+ XLF_EFI_HANDOVER = XLF_EFI_HANDOVER_32,
+#endif
};
typedef struct {
@@ -138,6 +145,12 @@ EFI_STATUS linux_exec(
if (!image_params->hdr.relocatable_kernel)
return log_error_status_stall(EFI_UNSUPPORTED, u"Kernel is not relocatable.");
+ /* The xloadflags were added in version 2.12+ of the boot protocol but the handover support predates
+ * that, so we cannot safety-check this for 2.11. */
+ if (image_params->hdr.version >= SETUP_VERSION_2_12 &&
+ !FLAGS_SET(image_params->hdr.xloadflags, XLF_EFI_HANDOVER))
+ return log_error_status_stall(EFI_UNSUPPORTED, u"Kernel does not support EFI handover protocol.");
+
bool can_4g = image_params->hdr.version >= SETUP_VERSION_2_12 &&
FLAGS_SET(image_params->hdr.xloadflags, XLF_CAN_BE_LOADED_ABOVE_4G);