From nobody Sat May 23 21:00:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=invisiblethingslab.com ARC-Seal: i=1; a=rsa-sha256; t=1779273218; cv=none; d=zohomail.com; s=zohoarc; b=A6VtD7L30tU9HAAutPbpjhK7xEp+0/xcI618hgpV3YyAeQ5VKwoGcWy+gsTzif2oaI65KH26jHao4gdnRzppKCWtWFwq4JmTxu18Ds+cwTaPoY2sdvGMWZ0zNr1w7CJy+RcZrDnTXhxi/2DI+7ij5DqzpFY/mhrhkzATnFsHXtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779273218; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZzZRd/W+twUqe2StwJ6Eyg7n9htO5E4rntWCs+841Nw=; b=JDjD4U1oEBn52PigH53A4IAW7GQ13DPh2p5zLxoTpRp0IckHQAOLiqXQVEgzuaQxVG9ULxTABrKUcXgNhTuCePFUkDnSJcYXfeYUhmALcLt/RelW2CibvPzErxyH+vyez1xzQyEPcrgsPM15Dop7TTmjqWb3QueG2HBeXEL8y7E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1779273218251386.1330637647251; Wed, 20 May 2026 03:33:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1313809.1583865 (Exim 4.92) (envelope-from ) id 1wPeEj-0001ta-RH; Wed, 20 May 2026 10:33:13 +0000 Received: by outflank-mailman (output) from mailman id 1313809.1583865; Wed, 20 May 2026 10:33:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wPeEj-0001tT-Na; Wed, 20 May 2026 10:33:13 +0000 Received: by outflank-mailman (input) for mailman id 1313809; Wed, 20 May 2026 10:33:12 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wPeEi-0001tL-H8 for xen-devel@lists.xenproject.org; Wed, 20 May 2026 10:33:12 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wPeEh-005eeI-T0 for xen-devel@lists.xenproject.org; Wed, 20 May 2026 12:33:11 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a0d8ddf-e002-0a2a0a5209dd-0a2a45058328-18 for ; Wed, 20 May 2026 12:33:11 +0200 Received: from [202.12.124.153] (helo=fhigh-b2-smtp.messagingengine.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a0d8de6-aaa8-0a2a45050019-ca0c7c99d4a1-3 for ; Wed, 20 May 2026 12:33:11 +0200 Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfhigh.stl.internal (Postfix) with ESMTP id 590A27A00E8; Wed, 20 May 2026 06:33:09 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Wed, 20 May 2026 06:33:10 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 20 May 2026 06:33:06 -0400 (EDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=fm3 header.d=invisiblethingslab.com header.i="@invisiblethingslab.com" header.h="Cc:Content-Transfer-Encoding:Content-Type:Date:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To"; dkim=pass header.s=fm3 header.d=messagingengine.com header.i="@messagingengine.com" header.h="Cc:Content-Transfer-Encoding:Content-Type:Date:Feedback-ID:From:In-Reply-To:Message-ID:MIME-Version:References:Subject:To:X-ME-Proxy:X-ME-Sender" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1779273189; x=1779359589; bh=ZzZRd/W+tw Uqe2StwJ6Eyg7n9htO5E4rntWCs+841Nw=; b=kXKq/+gPIJgFYtlBGfAwJ19V5E Q0Q44XkYpupxCV3Kkppy0UNSTMXUM5/feinb25g3+AcwkCrQo2u6PXU/j/XhYNX5 glakQAO69I85vPRSWnEXY5oG7K1C9plc22VKhg9Knpgc4z+pImhheBnMvTd5uimk MOULPg2ZUcny7mV2EfaGqSHqI2YoKl+/Urwxgbm5FTRo474+WYsgiOmoDqIXzk9f LLZ3X14K5kpip8GkfzepPG623A7s3CaYePVxSc+EhN82uaOwhR0zv0MuCuRne/FR X50fE2UpOA19qr0wbxki7hhqF14MqDjyjDwtcqOGCmhuyNLQpDwV0fkVkPmQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1779273189; x= 1779359589; bh=ZzZRd/W+twUqe2StwJ6Eyg7n9htO5E4rntWCs+841Nw=; b=M 6/BMmMkQp02+XO39XlR6+3MdQKWzvCsySPhLID2T+Gve7yzmSnF85hEGcbPMszUG QmmoLJskBE9ZsRq0fO48x8gcOQRzXLOdLxXBo4Fd1uJnhum81XWXvjnLO98cPalM G3LH0jrWmkHyHiYvEA8pzTehPeTjsbnFu2Zc/9XiSQ7/AqRpgMXvaa3syoH2JEIa VvzOACS8zxI1ZAR27M9ZiF10dZmSeNWVUgBjt2mniW8BEwEP6bfxr1oDGnYD/c7c BgYdABEvNv5YfVhW8vTlYol4oJpuJv/1vfdVFSYC3h9RLHAhib8o+EqPbz4da+Xj 4UhKCUG0QNMUNqg2foyJg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgddugeeggedtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefuiiihmhho nhcutegtvggurgnkshhkihcuoegrtggtvghksehinhhvihhsihgslhgvthhhihhnghhslh grsgdrtghomheqnecuggftrfgrthhtvghrnhepheeuffeggfeuffduteelffdvtddvgfeg ffevvdetteekiefgvdekieduveeljeffnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheprggttggvkhesihhnvhhishhisghlvghthhhinhhgshhl rggsrdgtohhmpdhnsggprhgtphhtthhopedugedpmhhouggvpehsmhhtphhouhhtpdhrtg hpthhtohepgigvnhdquggvvhgvlheslhhishhtshdrgigvnhhprhhojhgvtghtrdhorhhg pdhrtghpthhtohepohhlvghkshhiihdrkhhurhhotghhkhhosehgmhgrihhlrdgtohhmpd hrtghpthhtoheprggttggvkhesihhnvhhishhisghlvghthhhinhhgshhlrggsrdgtohhm pdhrtghpthhtoheprghnughrvgifrdgtohhophgvrhefsegtihhtrhhigidrtghomhdprh gtphhtthhopehmrghrmhgrrhgvkhesihhnvhhishhisghlvghthhhinhhgshhlrggsrdgt ohhmpdhrtghpthhtohepshhsthgrsggvlhhlihhniheskhgvrhhnvghlrdhorhhgpdhrtg hpthhtohepjhhulhhivghnseigvghnrdhorhhgpdhrtghpthhtohepsggvrhhtrhgrnhgu rdhmrghrqhhuihhssegrrhhmrdgtohhmpdhrtghpthhtohepmhhitghhrghlrdhorhiivg hlsegrmhgurdgtohhm X-ME-Proxy: Feedback-ID: i792e4853:Fastmail From: =?UTF-8?q?Szymon=20Aceda=C5=84ski?= To: xen-devel@lists.xenproject.org Cc: oleksii.kurochko@gmail.com, =?UTF-8?q?Szymon=20Aceda=C5=84ski?= , Andrew Cooper , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , "Daniel P. Smith" , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Teddy Astie Subject: [PATCH v2 for-4.22] EFI: Fix boot from a device without a file system Date: Wed, 20 May 2026 12:30:26 +0200 Message-ID: <809b9976089eaf02e864684461ced4e939dbcc83.1779271357.git.accek@invisiblethingslab.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <5ee376dc0df448437f386ab2606c42d63a515ca1.1779194154.git.accek@invisiblethingslab.com> References: <5ee376dc0df448437f386ab2606c42d63a515ca1.1779194154.git.accek@invisiblethingslab.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1779273191-E2F94443-E4806041/0/0 X-purgate-type: clean X-purgate-size: 9995 X-ZohoMail-DKIM: pass (identity @invisiblethingslab.com) X-ZM-MESSAGEID: 1779273219942158500 When netbooting a unified Xen kernel image (via GRUB chainloader), the resulting loaded_image->DeviceHandle does not support SIMPLE_FILE_SYSTEM_PROTOCOL. Instead of crashing via noreturn PrintErrMesg() in get_parent_handle(), we defer calling this function until filesystem access is needed. This way when booting UKI, get_parent_handle() is not called at all. Suggested-by: Andrew Cooper Suggested-by: Marek Marczykowski-G=C3=B3recki Signed-off-by: Szymon Aceda=C5=84ski --- Changes in v2: - Restructured along the lines Andrew and Marek both suggested on v1: defer get_parent_handle() until the first call site that actually needs a file. This mirrors the existing lazy pattern in ARM's allocate_module_file() in xen/arch/arm/efi/efi-boot.h, which was also changed to use the new ensure_dir_handle() helper. Tests performed: - Same as v1: PXE-loaded GRUB chainloading UKI - failure without patch, success with patch - QEMU boot from EFI partition, with config, kernel and initrd on EFI partition too - success with and without patch (halts later in both cases due to unrelated issue) - Cross-compiling ARM64 - success xen/arch/arm/efi/efi-boot.h | 12 ++++---- xen/arch/x86/efi/efi-boot.h | 9 ++++-- xen/common/efi/boot.c | 57 ++++++++++++++++++++++++------------- 3 files changed, 50 insertions(+), 28 deletions(-) diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h index ea59de47e7..069cc68b0a 100644 --- a/xen/arch/arm/efi/efi-boot.h +++ b/xen/arch/arm/efi/efi-boot.h @@ -403,7 +403,7 @@ static void __init noreturn efi_arch_post_exit_boot(voi= d) } =20 static void __init efi_arch_cfg_file_early(const EFI_LOADED_IMAGE *image, - EFI_FILE_HANDLE dir_handle, + EFI_FILE_HANDLE *dir_handle, const char *section) { union string name; @@ -419,8 +419,11 @@ static void __init efi_arch_cfg_file_early(const EFI_L= OADED_IMAGE *image, name.s =3D get_value(&cfg, section, "dtb"); if ( name.s ) { + CHAR16 *fname; + split_string(name.s); - read_file(dir_handle, s2w(&name), &dtbfile, NULL); + ensure_dir_handle(image, dir_handle, &fname); + read_file(*dir_handle, s2w(&name), &dtbfile, NULL); efi_bs->FreePool(name.w); } } @@ -430,7 +433,7 @@ static void __init efi_arch_cfg_file_early(const EFI_LO= ADED_IMAGE *image, } =20 static void __init efi_arch_cfg_file_late(const EFI_LOADED_IMAGE *image, - EFI_FILE_HANDLE dir_handle, + EFI_FILE_HANDLE *dir_handle, const char *section) { } @@ -665,8 +668,7 @@ static int __init allocate_module_file(const EFI_LOADED= _IMAGE *loaded_image, file_info->name_len =3D name_len; =20 /* Get the file system interface. */ - if ( !*dir_handle ) - *dir_handle =3D get_parent_handle(loaded_image, &fname); + ensure_dir_handle(loaded_image, dir_handle, &fname); =20 /* Load the binary in memory */ read_file(*dir_handle, s2w(&module_name), &module_binary, NULL); diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 42a2c46b5e..d738b839ee 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -284,13 +284,13 @@ static void __init noreturn efi_arch_post_exit_boot(v= oid) } =20 static void __init efi_arch_cfg_file_early(const EFI_LOADED_IMAGE *image, - EFI_FILE_HANDLE dir_handle, + EFI_FILE_HANDLE *dir_handle, const char *section) { } =20 static void __init efi_arch_cfg_file_late(const EFI_LOADED_IMAGE *image, - EFI_FILE_HANDLE dir_handle, + EFI_FILE_HANDLE *dir_handle, const char *section) { union string name; @@ -304,9 +304,12 @@ static void __init efi_arch_cfg_file_late(const EFI_LO= ADED_IMAGE *image, name.s =3D get_value(&cfg, "global", "ucode"); if ( name.s ) { + CHAR16 *fname; + microcode_set_module(mbi.mods_count); split_string(name.s); - read_file(dir_handle, s2w(&name), &ucode, NULL); + ensure_dir_handle(image, dir_handle, &fname); + read_file(*dir_handle, s2w(&name), &ucode, NULL); efi_bs->FreePool(name.w); } } diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 9ea2183c0b..f90309624b 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -547,6 +547,17 @@ static EFI_FILE_HANDLE __init get_parent_handle(const = EFI_LOADED_IMAGE *loaded_i return dir_handle; } =20 +static void __init ensure_dir_handle(const EFI_LOADED_IMAGE *loaded_image, + EFI_FILE_HANDLE *dir_handle, + CHAR16 **file_name) +{ + if ( *dir_handle ) + return; + *dir_handle =3D get_parent_handle(loaded_image, file_name); + if ( !*dir_handle ) + blexit(L"Cannot load files without a usable file system"); +} + static CHAR16 *__init point_tail(CHAR16 *fn) { CHAR16 *tail =3D NULL; @@ -1514,7 +1525,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE Imag= eHandle, =20 if ( use_cfg_file ) { - EFI_FILE_HANDLE dir_handle; + EFI_FILE_HANDLE dir_handle =3D NULL; EFI_HANDLE gop_handle; UINTN depth, cols, rows; =20 @@ -1526,31 +1537,33 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE Im= ageHandle, =20 gop =3D efi_get_gop(&gop_handle); =20 - /* Get the file system interface. */ - dir_handle =3D get_parent_handle(loaded_image, &file_name); - /* Read and parse the config file. */ if ( read_section(loaded_image, L"config", &cfg, NULL) ) PrintStr(L"Using builtin config file\r\n"); - else if ( !cfg_file_name && file_name ) + else { - CHAR16 *tail; + ensure_dir_handle(loaded_image, &dir_handle, &file_name); =20 - while ( (tail =3D point_tail(file_name)) !=3D NULL ) + if ( !cfg_file_name ) { - wstrcpy(tail, L".cfg"); - if ( read_file(dir_handle, file_name, &cfg, NULL) ) - break; - *tail =3D 0; + CHAR16 *tail; + + while ( (tail =3D point_tail(file_name)) !=3D NULL ) + { + wstrcpy(tail, L".cfg"); + if ( read_file(dir_handle, file_name, &cfg, NULL) ) + break; + *tail =3D 0; + } + if ( !tail ) + blexit(L"No configuration file found."); + PrintStr(L"Using configuration file '"); + PrintStr(file_name); + PrintStr(L"'\r\n"); } - if ( !tail ) - blexit(L"No configuration file found."); - PrintStr(L"Using configuration file '"); - PrintStr(file_name); - PrintStr(L"'\r\n"); + else if ( !read_file(dir_handle, cfg_file_name, &cfg, NULL) ) + blexit(L"Configuration file not found."); } - else if ( !read_file(dir_handle, cfg_file_name, &cfg, NULL) ) - blexit(L"Configuration file not found."); pre_parse(&cfg); =20 if ( section.w ) @@ -1567,6 +1580,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE Imag= eHandle, if ( !name.s ) break; free_cfg(); + ensure_dir_handle(loaded_image, &dir_handle, &file_name); if ( !read_file(dir_handle, s2w(&name), &cfg, NULL) ) { PrintStr(L"Chained configuration file '"); @@ -1578,13 +1592,14 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE Im= ageHandle, efi_bs->FreePool(name.w); } =20 - efi_arch_cfg_file_early(loaded_image, dir_handle, section.s); + efi_arch_cfg_file_early(loaded_image, &dir_handle, section.s); =20 option_str =3D name.s ? split_string(name.s) : NULL; =20 if ( !read_section(loaded_image, L"kernel", &kernel, option_str) && name.s ) { + ensure_dir_handle(loaded_image, &dir_handle, &file_name); read_file(dir_handle, s2w(&name), &kernel, option_str); efi_bs->FreePool(name.w); } @@ -1599,6 +1614,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE Imag= eHandle, name.s =3D get_value(&cfg, section.s, "ramdisk"); if ( name.s ) { + ensure_dir_handle(loaded_image, &dir_handle, &file_name); read_file(dir_handle, s2w(&name), &ramdisk, NULL); efi_bs->FreePool(name.w); } @@ -1609,6 +1625,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE Imag= eHandle, name.s =3D get_value(&cfg, section.s, "xsm"); if ( name.s ) { + ensure_dir_handle(loaded_image, &dir_handle, &file_name); read_file(dir_handle, s2w(&name), &xsm, NULL); efi_bs->FreePool(name.w); } @@ -1634,7 +1651,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE Imag= eHandle, } } =20 - efi_arch_cfg_file_late(loaded_image, dir_handle, section.s); + efi_arch_cfg_file_late(loaded_image, &dir_handle, section.s); =20 free_cfg(); =20 --=20 2.53.0