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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CC83BC433EF for ; Thu, 12 May 2022 10:38:08 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A21CA83EF0; Thu, 12 May 2022 12:38:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="RxHy3OrQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D73A38432D; Thu, 12 May 2022 12:38:02 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5296783B74 for ; Thu, 12 May 2022 12:37:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1652351877; bh=9WEwj9SK4a3m47CPD+ycVTwydQUoJTUG3lpzsAg9L4w=; h=X-UI-Sender-Class:Date:From:To:CC:Subject:In-Reply-To:References; b=RxHy3OrQT2xphF9zi3+ZrfcjqCPB6VmaFEbSVlxwBgVPKjAE8Kj6h++U/kO3Sbn/F xO/taLQG0o5uLW0ZUXHB9OMRL3ejFjcFjYRoQJ0aEYLn8j9jSMGBF9YhC5uM/ziN3Q biGkjVWqeJGT/EM/I+VKnJYPAp6ygJBwtQv/PUBE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [127.0.0.1] ([62.143.94.109]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M6Db0-1niWdR0QFE-006jIO; Thu, 12 May 2022 12:37:57 +0200 Date: Thu, 12 May 2022 12:34:41 +0200 From: Heinrich Schuchardt To: AKASHI Takahiro CC: Mark Kettenis , masahisa.kojima@linaro.org, ilias.apalodimas@linaro.org, sjg@chromium.org, francois.ozog@linaro.org, kettenis@openbsd.org, Peter.Hoyes@arm.com, narmstrong@baylibre.com, andre.przywara@arm.com, u-boot@lists.denx.de Subject: =?US-ASCII?Q?Re=3A_=5BPATCH_v5_06/17=5D_efi=5Floader=3A_boot?= =?US-ASCII?Q?mgr=3A_add_booting_from_removable_media?= User-Agent: K-9 Mail for Android In-Reply-To: <20220512091247.GB90900@laputa> References: <20220428080950.23509-1-masahisa.kojima@linaro.org> <20220428080950.23509-7-masahisa.kojima@linaro.org> <2175cecb-a392-5107-b932-b099ec21d62c@gmx.de> <20220512091247.GB90900@laputa> Message-ID: <6A7C6ACC-9AB8-4FF5-BFDE-9BFD2A593852@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:dAKyMDnVarXb9S7SMwHGRFDLcqi58/hN4q+YbVQ/FodiT3aKZOD Veh85vvmmvTDFTtfOqMzFDT++7Aae1h9nHSf+/EZSmgD0vIeJhS0ibcO4HI8kInLqI2VT+0 pTpIkjOfZqw6dDxC7k8PrVQwoOa2ED2VSxgnKYoCYtSJNsEDfHoqzc8gMqp9h7nts3Vi2fG jnMvX8q7rstMZihMv/gPw== X-UI-Out-Filterresults: notjunk:1;V03:K0:RDe1TPF7P9Y=:Zoybgjie7ezGE95+mJl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GK/VzPqMr7IUUUdSdugwcystxDFdzjL2MOt DNSRyVzeIiY7X0= X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.5 at phobos.denx.de X-Virus-Status: Clean Am 12=2E Mai 2022 11:12:47 MESZ schrieb AKASHI Takahiro : >Heinrich, > >On Thu, May 05, 2022 at 02:47:35PM +0200, Mark Kettenis wrote: >> > Date: Thu, 5 May 2022 14:05:04 +0200 (CEST) >> > From: Mark Kettenis >> >=20 >> > > Date: Fri, 29 Apr 2022 19:03:22 +0200 >> > > From: Heinrich Schuchardt >> > >=20 >> > > On 4/28/22 10:09, Masahisa Kojima wrote: >> > > > From: AKASHI Takahiro >> > > > >> > > > Under the current implementation, booting from removable media us= ing >> > > > a architecture-specific default image name, say BOOTAA64=2EEFI, i= s >> > > > supported only in distro_bootcmd script=2E See the commit 74522c8= 98b35 >> > > > ("efi_loader: Add distro boot script for removable media")=2E >> > > > >> > > > 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=2E5=2E1 Boot via the Simple File Protocol >> > > > When booting via the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, the File= Path will >> > > > start with a device path that points to the device that implem= ents the >> > > > EFI_SIMPLE_FILE_SYSTEM_PROTOCOL or the EFI_BLOCK_IO_PROTOCOL= =2E The next >> > > > part of the FilePath may point to the file name, including >> > > > subdirectories, which contain the bootable image=2E If the fil= e name is >> > > > a null device path, the file name must be generated from the r= ules >> > > > defined below=2E >> > > > =2E=2E=2E >> > > > 3=2E5=2E1=2E1 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}=2EEFI =2E=2E=2E >> > > > >> > > > 2) So (1) entails the hehavior that the user's preference of boot= media >> > > > order should be determined by Boot#### and BootOrder variable= s=2E >> > > > >> > > > With this patch, the semantics mentioned above is fully implement= ed=2E >> > > > 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 de= vice >> > > > (without any file path/name) >> > > > * define Boot0002 which contains only a device path to the SCSI d= evice, >> > > > and >> > > > * set BootOrder to Boot0001:Boot0002 >> > > > >> > > > To avoid build error for sandbox, default file name "BOOTSANDBOX= =2Eefi" >> > > > is defined even if it is out of scope of UEFI specification=2E >> > > > >> > > > Signed-off-by: AKASHI Takahiro >> > > > Signed-off-by: Masahisa Kojima >> > > > --- >> > > > Changes in v5: >> > > > - add default file name definition for SANDBOX to avoid build err= or >> > > > >> > > > Changes from original version: >> > > > - create new include file "efi_default_filename=2Eh" to >> > > > avoid conflict with config_distro_bootcmd=2Eh >> > > > - modify the target pointer of efi_free_pool(), expand_media_path= () should >> > > > only free the pointer allocated by efi_dp_from_file() function= =2E >> > > > include/config_distro_bootcmd=2Eh | 14 +-------- >> > > > include/efi_default_filename=2Eh | 33 ++++++++++++++++++++++ >> > > > lib/efi_loader/efi_bootmgr=2Ec | 50 ++++++++++++++++++++++++= ++++++++- >> > > > 3 files changed, 83 insertions(+), 14 deletions(-) >> > > > create mode 100644 include/efi_default_filename=2Eh >> > > > >> > > > diff --git a/include/config_distro_bootcmd=2Eh b/include/config_d= istro_bootcmd=2Eh >> > > > index c55023889c=2E=2E6a3110f27b 100644 >> > > > --- a/include/config_distro_bootcmd=2Eh >> > > > +++ b/include/config_distro_bootcmd=2Eh >> > > > @@ -91,19 +91,7 @@ >> > > > #endif >> > > > >> > > > #ifdef CONFIG_EFI_LOADER >> > > > -#if defined(CONFIG_ARM64) >> > > > -#define BOOTEFI_NAME "bootaa64=2Eefi" >> > > > -#elif defined(CONFIG_ARM) >> > > > -#define BOOTEFI_NAME "bootarm=2Eefi" >> > > > -#elif defined(CONFIG_X86_RUN_32BIT) >> > > > -#define BOOTEFI_NAME "bootia32=2Eefi" >> > > > -#elif defined(CONFIG_X86_RUN_64BIT) >> > > > -#define BOOTEFI_NAME "bootx64=2Eefi" >> > > > -#elif defined(CONFIG_ARCH_RV32I) >> > > > -#define BOOTEFI_NAME "bootriscv32=2Eefi" >> > > > -#elif defined(CONFIG_ARCH_RV64I) >> > > > -#define BOOTEFI_NAME "bootriscv64=2Eefi" >> > > > -#endif >> > > > +#include >> > > > #endif >> > > > >> > > > #ifdef BOOTEFI_NAME >> > > > diff --git a/include/efi_default_filename=2Eh b/include/efi_defau= lt_filename=2Eh >> > > > new file mode 100644 >> > > > index 0000000000=2E=2Ecb2ef9e131 >> > > > --- /dev/null >> > > > +++ b/include/efi_default_filename=2Eh >> > > > @@ -0,0 +1,33 @@ >> > > > +/* SPDX-License-Identifier: GPL-2=2E0+ */ >> > > > +/* >> > > > + * Default boot file name when none is present in the FilePath= =2E >> > > > + * This is defined in the UEFI specification=2E >> > > > + * >> > > > + * Copyright (c) 2022, Linaro Limited >> > > > + */ >> > > > +#ifndef _EFI_DEFAULT_FILENAME_H >> > > > +#define _EFI_DEFAULT_FILENAME_H >> > > > + >> > > > +#if defined(CONFIG_ARM64) >> > > > +#define BOOTEFI_NAME "BOOTAA64=2EEFI" >> > > > +#elif defined(CONFIG_ARM) >> > > > +#define BOOTEFI_NAME "BOOTARM=2EEFI" >> > > > +#elif defined(CONFIG_X86_64) >> > > > +#define BOOTEFI_NAME "BOOTX64=2EEFI" >> > > > +#elif defined(CONFIG_X86) >> > > > +#define BOOTEFI_NAME "BOOTIA32=2EEFI" >> > > > +#elif defined(CONFIG_ARCH_RV32I) >> > > > +#define BOOTEFI_NAME "BOOTRISCV32=2EEFI" >> > > > +#elif defined(CONFIG_ARCH_RV64I) >> > > > +#define BOOTEFI_NAME "BOOTRISCV64=2EEFI" >> > > > +#elif defined(CONFIG_SANDBOX) >> > > > +/* >> > > > + * SANDBOX is not defined in UEFI specification, but >> > > > + * this definition avoids build failure for SANDBOX=2E >> > > > + */ >> > > > +#define BOOTEFI_NAME "BOOTSANDBOX=2EEFI" >> > >=20 >> > > The sandbox should boot the default binary for the host architectur= e: >> > >=20 >> > > #ifndef _EFI_DEFAULT_FILENAME_H >> > > #define _EFI_DEFAULT_FILENAME_H >> > >=20 >> > > #include >> > >=20 >> > > #undef BOOTEFI_NAME >> > >=20 >> > > #if HOST_ARCH =3D=3D HOST_ARCH_X86_64 >> > > #define BOOTEFI_NAME "BOOTX64=2EEFI" >> > > #endif >> > >=20 >> > > #if HOST_ARCH =3D=3D HOST_ARCH_X86 >> > > #define BOOTEFI_NAME "BOOTIA32=2EEFI" >> > > #endif >> > >=20 >> > > #if HOST_ARCH =3D=3D HOST_ARCH_AARCH64 >> > > #define BOOTEFI_NAME "BOOTAA64=2EEFI" >> > > #endif >> > >=20 >> > > #if HOST_ARCH =3D=3D HOST_ARCH_ARM >> > > #define BOOTEFI_NAME "BOOTARM=2EEFI" >> > > #endif >> > >=20 >> > > #if HOST_ARCH =3D=3D HOST_ARCH_RISCV32 >> > > #define BOOTEFI_NAME "BOOTRISCV32=2EEFI" >> > > #endif >> > >=20 >> > > #if HOST_ARCH =3D=3D HOST_ARCH_RISCV64 >> > > #define BOOTEFI_NAME "BOOTRISCV64=2EEFI" >> > > #endif >> > >=20 >> > > #ifndef BOOTEFI_NAME >> > > #error Unsupported UEFI architecture >> > > #endif >> > >=20 >> > > #endif >> >=20 >> > Maybe sanbox is special, but using the host architecture for actual >> > boards makes no sense=2E I see this has made its way into master >> > already, but when I cross-build for apple_m1_defconfig on an amd64 >> > machine I end up with: >> >=20 >> > $ strings =2E/lib/efi_loader/efi_bootmgr=2Eo | grep BOOT >> > /EFI/BOOT/BOOTX64=2EEFI >> >=20 >> > The original diff that used CONFIG_ARM64, CONFIG_ARM, etc, did this >> > right=2E >>=20 >> Hmm, forget about that=2E The problem is in the sed expression in the >> toplevel Makefile that is used to MK_ARCH that ends up setting >> HOST_ARCH incorrectly=2E Using a variable named HOST_ARCH to hold the >> target architecture doesn't help understanding what's going wrong here >> of course=2E=2E=2E > >I can nod to Mark's comment here=2E >Even though HOST_ARCH might work, it's quite confusing=2E >Apparently it looks wrong as Mark said=2E > >Please address this comment properly as you modified my patch=2E > >What I basically recommend is: >* In (top-dir)/Makefile > - s/HOST_ARCH/MK_ARCH/g > - add > if (CONFIG_SANDBOX) > HOST_ARCH =3D $(MK_ARCH) > - remove "undefine MK_ARCH" >* In efi_default_filename=2Eh > - s/HOST_ARCH/MK_ARCH/g > >This way, HOST_ARCH is only used in sandbox-related code=2E TARGET_ARCH would be a better variable name=2E Best regards Heinrich > >-Takahiro Akashi