From nobody Fri Oct 31 11:33:44 2025 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=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1750775258; cv=none; d=zohomail.com; s=zohoarc; b=gwytsrV1QQ5GmUdpQWcAoqCYCMS0sghy8jSxZzlQZqt3tuoUag30CaWMSJmwxqv0FogHgJgzWDzumuRIqtNRdKUxtbP31pAvrx7ho84OohiaE4SPm6KjrDuf1q7o5ePHpHegkMV69nNFpJzq88DOxX0NhhQjtGMHIxL0h0vhyS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750775258; h=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=zvSWfU3vS+cIfE2UVvh70sxlin2NyiKeV2rfWj9rRaM=; b=YFWakaYVPgsiaCdslBrlIpPvFTZ3tR9sOks5QH4FRSnTb22spG3HWvozF78eK5ABog535zN903kzzgap/fHEbkKHsvBFo0M0NWyjb6Yk3MRXPXPmA78W4iRrzFqMH/6+Sz7An6JP9bpR5N33CjsBwb1jN6dJ19roAwjb7Nkpp98= 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1750775258829300.5726809772698; Tue, 24 Jun 2025 07:27:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1023774.1399828 (Exim 4.92) (envelope-from ) id 1uU4cL-0006Yj-TE; Tue, 24 Jun 2025 14:27:21 +0000 Received: by outflank-mailman (output) from mailman id 1023774.1399828; Tue, 24 Jun 2025 14:27:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uU4cL-0006Yc-QS; Tue, 24 Jun 2025 14:27:21 +0000 Received: by outflank-mailman (input) for mailman id 1023774; Tue, 24 Jun 2025 14:27:21 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uU4cL-0006YQ-De for xen-devel@lists.xenproject.org; Tue, 24 Jun 2025 14:27:21 +0000 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [2a00:1450:4864:20::32d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 561e875a-5107-11f0-a30f-13f23c93f187; Tue, 24 Jun 2025 16:27:20 +0200 (CEST) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-453608ed113so47946965e9.0 for ; Tue, 24 Jun 2025 07:27:20 -0700 (PDT) Received: from localhost.localdomain (253.226.6.51.dyn.plus.net. [51.6.226.253]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45380705351sm4602115e9.0.2025.06.24.07.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jun 2025 07:27:18 -0700 (PDT) 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" X-Inumbo-ID: 561e875a-5107-11f0-a30f-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1750775239; x=1751380039; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zvSWfU3vS+cIfE2UVvh70sxlin2NyiKeV2rfWj9rRaM=; b=hUjxIUesXR7KB+0kFJ5Y+qlyjrPUfgZB+PBb7/YrlLRi9rXMNz8TJYpBUcjmsJjjKa QNVgUnxqDp8PkRbOs0yRXoGp/Lhd4pGxqEHv39d2+Y2VKtNWotOu8iq9Ur/I07nktpie 7fQl4HrEbZU0zwXrllCqRncp7vvpd0yuTH90E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750775239; x=1751380039; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zvSWfU3vS+cIfE2UVvh70sxlin2NyiKeV2rfWj9rRaM=; b=cUKbWtaSgLtEzKmw+hFkcUj+Fd9vxD+4rtnfm5016z2YPENYpZq06n1TNHW1Tgtp0x 5IDXloa+54RxHuElgKkfYhWWsBXtQpusTUcWrNvVqJeCH5iVcSBOIoymlp+98B0MD7ZI FGilG2fkeGcaDlquBjMBHAS4wx8+tS884qdMccrylRutZJJJG4QhYUB4HJFmaS1iuNeU K7WSd3dV5Hy3ntmlg9p5iJJG/aicwd2qf0yIs1qAdKXm1PuwuWCr9ub9FDO9RTs/J9l8 lO377SMgEJHcM2bIaFFLqYKRBskndIUeJapU3zYa67mA2MLKXMBUBgWsnR4FSgKesmH7 cVrQ== X-Gm-Message-State: AOJu0YwEJv/bLQJASrBezgfHlfdqSIYhS1hFoC1bJCnN51R+vNwkO32S xpOKmsQuQNFsvXTLBUKHTANHfMgQcHf7FMwW0xeD0xvJKFEFkx9nnZSK76T7JHdD1wLIqtPtkRg e8xlOCEdEzA== X-Gm-Gg: ASbGnctMDc3gOLH5aeJhminwc+AcwN49vaoQUrdmbDw20+VGEGbwLxnC+oyiHF+T2Op mlvG4Yll3yX7L8z5ekPknZNDEUZxJEGyG/rXhb6FTuDtCH9XAUQW2iYK+pFNsiodf+A/PgkkvUq Rsr9yIZZ13PuNtiearYgKBV8/XVUV69gN17jus3s0b9sT0SYs0NaITidk1rXqyKYyLzQaZQBJ3q Xc8HjyCdSMzcS+Vi0nouZUT4k+eXqGDIAa0+FC1VrwZKI69NR85d6EahnH/xK1T863Uyz+xeDNz j6eh6ZYqH1MkIk+QLaRMEgfgUNdEVmDlIjgikAc/hgnbN8MD6TFaliNeYACnoRZ6J2rxorhOM1R ub3qrJhws2ivhbkg8LoudAd3EouRWdA== X-Google-Smtp-Source: AGHT+IGed5CPjvOm2EqjTNPtlDK3NJOxPCE24eAzf5yW8bJSP56J1fQACDEGP8alWi51zx4L7c8xGw== X-Received: by 2002:a05:600c:3d8d:b0:441:b3eb:574e with SMTP id 5b1f17b1804b1-453659c48cemr157512105e9.5.1750775239213; Tue, 24 Jun 2025 07:27:19 -0700 (PDT) From: Frediano Ziglio To: xen-devel@lists.xenproject.org Cc: Frediano Ziglio , "Daniel P. Smith" , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Jan Beulich Subject: [PATCH v2 1/2] xen/efi: Handle cases where file didn't come from ESP Date: Tue, 24 Jun 2025 15:27:08 +0100 Message-ID: <20250624142711.54925-2-frediano.ziglio@cloud.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250624142711.54925-1-frediano.ziglio@cloud.com> References: <20250624142711.54925-1-frediano.ziglio@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1750775260272116600 Content-Type: text/plain; charset="utf-8" A boot loader can load files from outside ESP. In these cases device could be not provided or path could be something not supported. In these cases allows to boot anyway, all information could be provided using UKI or using other boot loader features. Signed-off-by: Frediano Ziglio Acked-by: Marek Marczykowski-G=C3=B3recki --- Changes since v1: - set "leaf" to NULL instead of a buffer with an empty string; - keep read_file fatal if cannot load file (except configuration). --- xen/common/efi/boot.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index 1a9b4e7dae..b18af2f1f4 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -443,6 +443,18 @@ static EFI_FILE_HANDLE __init get_parent_handle(const = EFI_LOADED_IMAGE *loaded_i CHAR16 *pathend, *ptr; EFI_STATUS ret; =20 + /* + * In some cases the image could not come from a specific device. + * For instance this can happen if Xen was loaded using GRUB2 "linux" + * command. + */ + *leaf =3D NULL; + if ( !loaded_image->DeviceHandle ) + { + PrintStr(L"Xen image loaded without providing a device\r\n"); + return NULL; + } + do { EFI_FILE_IO_INTERFACE *fio; =20 @@ -466,7 +478,15 @@ static EFI_FILE_HANDLE __init get_parent_handle(const = EFI_LOADED_IMAGE *loaded_i =20 if ( DevicePathType(dp) !=3D MEDIA_DEVICE_PATH || DevicePathSubType(dp) !=3D MEDIA_FILEPATH_DP ) - blexit(L"Unsupported device path component"); + { + /* + * The image could come from an unsupported device. + * For instance this can happen if Xen was loaded using GRUB2 + * "chainloader" command and the file was not from ESP. + */ + PrintStr(L"Unsupported device path component\r\n"); + return NULL; + } =20 if ( *buffer ) { @@ -772,8 +792,11 @@ static bool __init read_file(EFI_FILE_HANDLE dir_handl= e, CHAR16 *name, =20 if ( !name ) PrintErrMesg(L"No filename", EFI_OUT_OF_RESOURCES); - ret =3D dir_handle->Open(dir_handle, &FileHandle, name, - EFI_FILE_MODE_READ, 0); + if ( dir_handle ) + ret =3D dir_handle->Open(dir_handle, &FileHandle, name, + EFI_FILE_MODE_READ, 0); + else + ret =3D EFI_NOT_FOUND; if ( file =3D=3D &cfg && ret =3D=3D EFI_NOT_FOUND ) return false; if ( EFI_ERROR(ret) ) @@ -1404,7 +1427,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE Imag= eHandle, /* 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 ) + else if ( !cfg_file_name && file_name) { CHAR16 *tail; =20 @@ -1515,7 +1538,8 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE Imag= eHandle, efi_bs->FreePages(cfg.addr, PFN_UP(cfg.size)); cfg.addr =3D 0; =20 - dir_handle->Close(dir_handle); + if ( dir_handle ) + dir_handle->Close(dir_handle); =20 if ( gop && !base_video ) { --=20 2.43.0