From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97639C433EF for ; Wed, 10 Nov 2021 05:38:20 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 93352611F2 for ; Wed, 10 Nov 2021 05:38:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 93352611F2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 533E5836BB; Wed, 10 Nov 2021 06:38:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="yx25/58m"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DCEBA836D1; Wed, 10 Nov 2021 06:38:14 +0100 (CET) Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8CF52836B8 for ; Wed, 10 Nov 2021 06:38:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pl1-x62d.google.com with SMTP id u11so2106631plf.3 for ; Tue, 09 Nov 2021 21:38:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=RcNZOr/XJhyZb1qTy85Uug56oKKg+u6YumFdnF/ZfWM=; b=yx25/58mCwhrKweT4XfY5tUFFVBVQjwCObC0vPMBWiaSSubg6kQKeTNA7AA69C6u3Q bUk9OA7ILGGDIy6QRqIq++cl8Rh8+mE7dOawMFQZjUko03NLVbn1RVkLP9eGOc740ORW sLHBlD8cdUJxJR//X0Y5sQjCJ29kQt6lfZ5C45lSa0bUD1nodnhl8/5jU0Hhj2R5RTCF eZi/m2nhsel4k3jqPc5ZRDPlkpMVWLTSLZOLGgfEDlaBq3kTrqfXodY+s+LctVaSWN2Y 8Escw5Q9P0ktKIRnudwd+fHPL58+VkHHemw8q0+P+3qKn/6pSjO7fpVKNY0WezLsVnIt A77Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=RcNZOr/XJhyZb1qTy85Uug56oKKg+u6YumFdnF/ZfWM=; b=P0z+xETqe3uNGboSdZ7b9uOWywDrYF2kEZ5IVu57KuEMfAm7jbCh9ACCzLtfynovpE ghKZeQ52zFGNDAfcJdK9r0FWawY2K5bEWl1HZat9WEmXcWI0tvJeiQwBluSMcC0/LHBp F0erMdR34XDcagZ8rtAgdL1hNJu83Ps6e+rshy5BuZoPTWXek5wimjIKm88WENea7cE0 q0YZ2pTb3I7qpF2zTPlYUs72OJnq7VHhxqVK/Rb63R+go+fjQF/Fw/rKj0/EcQ835hUp 0p1D0IQPEWYz3u/oyIcqkyGSLERWnFUtk0J4aNJ61O9tJ+s8Uu/evVTDXy1fXI1gH0f1 7Eig== X-Gm-Message-State: AOAM5308efVa/etzEYo+jTC0SsnSyKecP4WdqcdwBDO9H6EEUfu5fgGl 9yK7Ipzn3h/n2Rchk96IemF6Aw== X-Google-Smtp-Source: ABdhPJwcAZgmB7zTxOF9j/Nmn0xV34HlO4C8FRpVo+D0JABpKDNp1/zTA5uJbAd6vlVvFkpj65LLEg== X-Received: by 2002:a17:902:8544:b0:142:66e7:afbb with SMTP id d4-20020a170902854400b0014266e7afbbmr12955546plo.62.1636522685632; Tue, 09 Nov 2021 21:38:05 -0800 (PST) Received: from laputa ([2400:4050:c3e1:100:d4ad:badd:7539:9f5a]) by smtp.gmail.com with ESMTPSA id w13sm16711568pgm.3.2021.11.09.21.38.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 21:38:05 -0800 (PST) Date: Wed, 10 Nov 2021 14:38:01 +0900 From: AKASHI Takahiro To: Heinrich Schuchardt Cc: agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org, u-boot@lists.denx.de Subject: Re: [RFC 2/3] efi_loader: bootmgr: add booting from removable media Message-ID: <20211110053801.GA54635@laputa> Mail-Followup-To: AKASHI Takahiro , Heinrich Schuchardt , agraf@csgraf.de, sjg@chromium.org, ilias.apalodimas@linaro.org, u-boot@lists.denx.de References: <20211109013233.72902-1-takahiro.akashi@linaro.org> <20211109013233.72902-3-takahiro.akashi@linaro.org> <1c97bf92-418b-1604-ad0f-a873a5770cd2@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1c97bf92-418b-1604-ad0f-a873a5770cd2@canonical.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Heinrich, Overall, do you agree to add this feature? On Tue, Nov 09, 2021 at 10:14:47AM +0100, Heinrich Schuchardt wrote: > > > On 11/9/21 02:32, AKASHI Takahiro wrote: > > Under the current implementation, booting from removal media using > > a architecture-specific default image name, say BOOTAA64.EFI, is > > supported only in distro_bootcmd script. See the commit 74522c898b35 > > ("efi_loader: Add distro boot script for removable media"). > > > > This is, however, half-baked implementation because > > 1) UEFI specification requires this feature to be implemented as part > > of Boot Manager's responsibility: > > > > 3 - Boot Manager > > 3.5.1 Boot via the Simple File Protocol > > When booting via the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, the FilePath will > > start with a device path that points to the device that implements the > > EFI_SIMPLE_FILE_SYSTEM_PROTOCOL or the EFI_BLOCK_IO_PROTOCOL. The next > > part of the FilePath may point to the file name, including > > subdirectories, which contain the bootable image. If the file name is > > a null device path, the file name must be generated from the rules > > defined below. > > ... > > 3.5.1.1 Removable Media Boot Behavior > > To generate a file name when none is present in the FilePath, the > > firmware must append a default file name in the form > > \EFI\BOOT\BOOT{machine type short-name}.EFI ... > > > > 2) So (1) entails the hehavior that the user's preference of boot media > > order should be determined by Boot#### and BootOrder variables. > > > > With this patch, the semantics mentioned above is fully implemented. > > For example, if you want to boot the system from USB and SCSI in this > > order, > > * define Boot0001 which contains only a device path to the USB device > > (without any file path/name) > > * define Boot0002 which contains only a device path to the SCSI device, > > and > > * set BootOrder to Boot0001:Boot0002 > > > > Signed-off-by: AKASHI Takahiro > > --- > > lib/efi_loader/efi_bootmgr.c | 65 +++++++++++++++++++++++++++++++++++- > > 1 file changed, 64 insertions(+), 1 deletion(-) > > > > diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c > > index 1fe19237f9a6..1d9d5858561f 100644 > > --- a/lib/efi_loader/efi_bootmgr.c > > +++ b/lib/efi_loader/efi_bootmgr.c > > @@ -30,6 +30,66 @@ static const struct efi_runtime_services *rs; > > * should do normal or recovery boot. > > */ > > +#if defined(CONFIG_ARM64) > > +#define BOOTEFI_NAME "bootaa64.efi" > > +#elif defined(CONFIG_ARM) > > +#define BOOTEFI_NAME "bootarm.efi" > > +#elif defined(CONFIG_X86_RUN_32BIT) > > CONFIG_X86. Check it after CONFIG_X86_64. > > > +#define BOOTEFI_NAME "bootia32.efi" > > +#elif defined(CONFIG_X86_RUN_64BIT) > > %s/X86_RUN_64BIT/X86_64/ > > Check this before CONFIG_X86 OK, so #elif defined(CONFIG_X86_64) ... #elif defined(CONFIG_X86) ... > > +#define BOOTEFI_NAME "bootx64.efi" > > +#elif defined(CONFIG_ARCH_RV32I) > > +#define BOOTEFI_NAME "bootriscv32.efi" > > +#elif defined(CONFIG_ARCH_RV64I) > > +#define BOOTEFI_NAME "bootriscv64.efi" > > +#else > > +#define BOOTEFI_NAME "dummy.efi" > > This should result in a build error. > > #error Unsupported UEFI architecture OK. > > +#endif > > I think this belongs into an include file. OK, but the only drawback is that this will make efi_api.h, which I would like to move those definitions to, target-dependent. As we have discussed somewhere else[1], if we want to use those include files, we should remove sich dependencies. Can you also make your comment on this thread[1], please? [1] https://lists.denx.de/pipermail/u-boot/2021-November/466465.html > According to the UEFI specification the file names are capitalized. OK. > > + > > +/** > > + * expand_media_path() - expand a device path for default file name > > + * @device_path: device path to check against > > + * > > + * If @device_path is a media or disk partition which houses a file > > + * system, this function returns a full device path which contains > > + * an architecture-specific default file name for removable media. > > + * > > + * Return: a newly allocated device path > > + */ > > +static > > +struct efi_device_path *expand_media_path(struct efi_device_path *device_path) > > +{ > > + struct efi_device_path *dp, *full_path; > > + efi_handle_t handle; > > + efi_status_t ret; > > + > > + if (!device_path) > > + return NULL; > > + > > + /* > > + * If device_path is a (removable) media or partition which provides > > + * simple file system protocol, append a default file name to support > > + * booting from removable media. > > + */ > > + dp = device_path; > > + ret = efi_locate_device_path(&efi_simple_file_system_protocol_guid, > > + &dp, &handle); > > + if (ret == EFI_SUCCESS) { > > + if (dp->type == DEVICE_PATH_TYPE_END) { > > + dp = efi_dp_from_file(NULL, 0, > > + "/efi/boot/" BOOTEFI_NAME); > > capitalized: > /EFI/BOOT/ OK -Takahiro Akashi > Best regards > > Heinrich > > > + full_path = efi_dp_append(device_path, dp); > > + } else { > > + full_path = efi_dp_dup(device_path); > > + } > > + efi_free_pool(dp); > > + } else { > > + full_path = efi_dp_dup(device_path); > > + } > > + > > + return full_path; > > +} > > + > > /** > > * try_load_entry() - try to load image for boot option > > * > > @@ -68,13 +128,16 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, > > } > > if (lo.attributes & LOAD_OPTION_ACTIVE) { > > + struct efi_device_path *file_path; > > u32 attributes; > > log_debug("%s: trying to load \"%ls\" from %pD\n", > > __func__, lo.label, lo.file_path); > > - ret = EFI_CALL(efi_load_image(true, efi_root, lo.file_path, > > + file_path = expand_media_path(lo.file_path); > > + ret = EFI_CALL(efi_load_image(true, efi_root, file_path, > > NULL, 0, handle)); > > + efi_free_pool(file_path); > > if (ret != EFI_SUCCESS) { > > log_warning("Loading %ls '%ls' failed\n", > > varname, lo.label); > >