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 501CFC433F5 for ; Thu, 12 May 2022 09:13:03 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 57DC0840AD; Thu, 12 May 2022 11:13:00 +0200 (CEST) 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="tWD7WAPk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 082A684216; Thu, 12 May 2022 11:12:59 +0200 (CEST) Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) (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 B12D983B19 for ; Thu, 12 May 2022 11:12:54 +0200 (CEST) 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-pf1-x42e.google.com with SMTP id i24so4241274pfa.7 for ; Thu, 12 May 2022 02:12:54 -0700 (PDT) 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=ATEHLvvnddWnfwd90IGtqOlqBSJELLtVeJOYG7Ot5Eo=; b=tWD7WAPkmmsfyUW7RtKoiURxbsX9TOVGTPCqmL6Mf7lWf+IkQO+H4EPK+2hrsWettV U5qxW2Y07Y1yxmZ4XisAaVQCKtob6lr1fFRlKR4s5CHWVsMrHGZf4tAIi0Y/ICem6Y0H jI6YCGTpLdXOuYqqG4VOwdBrcUH/Fts/g0lSmtvoKynazp8SSS/vAkK1N1Dzl0DLXRL6 u1wB83UAgpWFe7GzNkYAIv5eaNhYMZy0ZOm7+drClnfSD1WsRadMXnQWuKLl+cgNI4/0 B5c9fQ8r6pQQl0Nm6OvAzGYwtv+jCLtBQ2khCRJRPhHuhofPuR3urV9jDNFwDwi2/FOH jkwQ== 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=ATEHLvvnddWnfwd90IGtqOlqBSJELLtVeJOYG7Ot5Eo=; b=bZa6MnIoP+RpElPJCCpWRkNjXaXRyaamrm3qqgAtLAZy/gLuwqdvXGISbR7Il+tJRc QKkPLzkJqAI7INynC3i34gc3HA5awMEjuQrrugkWThdRJd+k500rjoktj8cORpK1yFqK 6qcuWd1FFsj38wXIUPkCaZnwPhbXTpXE5E6R0QNq6pjHUZFzYKyX1+yJQ1Mf83f46VMM BWEhRen1m3OSJBVhywzbFQ09QIutG5NeHV4bEi0Um2rtPD4n/XrOp0jN3HdZjEUgwTPb b53WO/qGIfCq99fCsK/tAiIGOEqqpR/pnlXsyMuQCe9lNH+EUU7RPmalRUHQ+b2KJkvQ x2kw== X-Gm-Message-State: AOAM530b37WjCJGrUxJu2XlCGgF54YWBHeXRaGQlfEJwTcAN5b9LuD4h bHwdgHosE1rsCm3deGjdIPQPRg== X-Google-Smtp-Source: ABdhPJwtz3UjAVXgFQmaMqjPiuoqGXFsUXfTJwaapuTyKY+PyhhYqDSApA2/DbI4IHKW63x7Yp9b3A== X-Received: by 2002:a63:200e:0:b0:3db:4f23:2abd with SMTP id g14-20020a63200e000000b003db4f232abdmr4003694pgg.366.1652346773084; Thu, 12 May 2022 02:12:53 -0700 (PDT) Received: from laputa (p914133-ipoe.ipoe.ocn.ne.jp. [153.243.15.132]) by smtp.gmail.com with ESMTPSA id t6-20020a1709028c8600b0015e8d4eb2d1sm3324307plo.283.2022.05.12.02.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 02:12:52 -0700 (PDT) Date: Thu, 12 May 2022 18:12:47 +0900 From: AKASHI Takahiro To: xypron.glpk@gmx.de 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: Re: [PATCH v5 06/17] efi_loader: bootmgr: add booting from removable media Message-ID: <20220512091247.GB90900@laputa> Mail-Followup-To: AKASHI Takahiro , xypron.glpk@gmx.de, 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 References: <20220428080950.23509-1-masahisa.kojima@linaro.org> <20220428080950.23509-7-masahisa.kojima@linaro.org> <2175cecb-a392-5107-b932-b099ec21d62c@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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 > > > > > Date: Fri, 29 Apr 2022 19:03:22 +0200 > > > From: Heinrich Schuchardt > > > > > > On 4/28/22 10:09, Masahisa Kojima wrote: > > > > From: AKASHI Takahiro > > > > > > > > Under the current implementation, booting from removable 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 > > > > > > > > To avoid build error for sandbox, default file name "BOOTSANDBOX.efi" > > > > is defined even if it is out of scope of UEFI specification. > > > > > > > > Signed-off-by: AKASHI Takahiro > > > > Signed-off-by: Masahisa Kojima > > > > --- > > > > Changes in v5: > > > > - add default file name definition for SANDBOX to avoid build error > > > > > > > > Changes from original version: > > > > - create new include file "efi_default_filename.h" to > > > > avoid conflict with config_distro_bootcmd.h > > > > - modify the target pointer of efi_free_pool(), expand_media_path() should > > > > only free the pointer allocated by efi_dp_from_file() function. > > > > include/config_distro_bootcmd.h | 14 +-------- > > > > include/efi_default_filename.h | 33 ++++++++++++++++++++++ > > > > lib/efi_loader/efi_bootmgr.c | 50 ++++++++++++++++++++++++++++++++- > > > > 3 files changed, 83 insertions(+), 14 deletions(-) > > > > create mode 100644 include/efi_default_filename.h > > > > > > > > diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h > > > > index c55023889c..6a3110f27b 100644 > > > > --- a/include/config_distro_bootcmd.h > > > > +++ b/include/config_distro_bootcmd.h > > > > @@ -91,19 +91,7 @@ > > > > #endif > > > > > > > > #ifdef CONFIG_EFI_LOADER > > > > -#if defined(CONFIG_ARM64) > > > > -#define BOOTEFI_NAME "bootaa64.efi" > > > > -#elif defined(CONFIG_ARM) > > > > -#define BOOTEFI_NAME "bootarm.efi" > > > > -#elif defined(CONFIG_X86_RUN_32BIT) > > > > -#define BOOTEFI_NAME "bootia32.efi" > > > > -#elif defined(CONFIG_X86_RUN_64BIT) > > > > -#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" > > > > -#endif > > > > +#include > > > > #endif > > > > > > > > #ifdef BOOTEFI_NAME > > > > diff --git a/include/efi_default_filename.h b/include/efi_default_filename.h > > > > new file mode 100644 > > > > index 0000000000..cb2ef9e131 > > > > --- /dev/null > > > > +++ b/include/efi_default_filename.h > > > > @@ -0,0 +1,33 @@ > > > > +/* SPDX-License-Identifier: GPL-2.0+ */ > > > > +/* > > > > + * Default boot file name when none is present in the FilePath. > > > > + * This is defined in the UEFI specification. > > > > + * > > > > + * Copyright (c) 2022, Linaro Limited > > > > + */ > > > > +#ifndef _EFI_DEFAULT_FILENAME_H > > > > +#define _EFI_DEFAULT_FILENAME_H > > > > + > > > > +#if defined(CONFIG_ARM64) > > > > +#define BOOTEFI_NAME "BOOTAA64.EFI" > > > > +#elif defined(CONFIG_ARM) > > > > +#define BOOTEFI_NAME "BOOTARM.EFI" > > > > +#elif defined(CONFIG_X86_64) > > > > +#define BOOTEFI_NAME "BOOTX64.EFI" > > > > +#elif defined(CONFIG_X86) > > > > +#define BOOTEFI_NAME "BOOTIA32.EFI" > > > > +#elif defined(CONFIG_ARCH_RV32I) > > > > +#define BOOTEFI_NAME "BOOTRISCV32.EFI" > > > > +#elif defined(CONFIG_ARCH_RV64I) > > > > +#define BOOTEFI_NAME "BOOTRISCV64.EFI" > > > > +#elif defined(CONFIG_SANDBOX) > > > > +/* > > > > + * SANDBOX is not defined in UEFI specification, but > > > > + * this definition avoids build failure for SANDBOX. > > > > + */ > > > > +#define BOOTEFI_NAME "BOOTSANDBOX.EFI" > > > > > > The sandbox should boot the default binary for the host architecture: > > > > > > #ifndef _EFI_DEFAULT_FILENAME_H > > > #define _EFI_DEFAULT_FILENAME_H > > > > > > #include > > > > > > #undef BOOTEFI_NAME > > > > > > #if HOST_ARCH == HOST_ARCH_X86_64 > > > #define BOOTEFI_NAME "BOOTX64.EFI" > > > #endif > > > > > > #if HOST_ARCH == HOST_ARCH_X86 > > > #define BOOTEFI_NAME "BOOTIA32.EFI" > > > #endif > > > > > > #if HOST_ARCH == HOST_ARCH_AARCH64 > > > #define BOOTEFI_NAME "BOOTAA64.EFI" > > > #endif > > > > > > #if HOST_ARCH == HOST_ARCH_ARM > > > #define BOOTEFI_NAME "BOOTARM.EFI" > > > #endif > > > > > > #if HOST_ARCH == HOST_ARCH_RISCV32 > > > #define BOOTEFI_NAME "BOOTRISCV32.EFI" > > > #endif > > > > > > #if HOST_ARCH == HOST_ARCH_RISCV64 > > > #define BOOTEFI_NAME "BOOTRISCV64.EFI" > > > #endif > > > > > > #ifndef BOOTEFI_NAME > > > #error Unsupported UEFI architecture > > > #endif > > > > > > #endif > > > > Maybe sanbox is special, but using the host architecture for actual > > boards makes no sense. 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: > > > > $ strings ./lib/efi_loader/efi_bootmgr.o | grep BOOT > > /EFI/BOOT/BOOTX64.EFI > > > > The original diff that used CONFIG_ARM64, CONFIG_ARM, etc, did this > > right. > > Hmm, forget about that. The problem is in the sed expression in the > toplevel Makefile that is used to MK_ARCH that ends up setting > HOST_ARCH incorrectly. Using a variable named HOST_ARCH to hold the > target architecture doesn't help understanding what's going wrong here > of course... I can nod to Mark's comment here. Even though HOST_ARCH might work, it's quite confusing. Apparently it looks wrong as Mark said. Please address this comment properly as you modified my patch. What I basically recommend is: * In (top-dir)/Makefile - s/HOST_ARCH/MK_ARCH/g - add if (CONFIG_SANDBOX) HOST_ARCH = $(MK_ARCH) - remove "undefine MK_ARCH" * In efi_default_filename.h - s/HOST_ARCH/MK_ARCH/g This way, HOST_ARCH is only used in sandbox-related code. -Takahiro Akashi