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 31C9AC433F5 for ; Thu, 19 May 2022 00:35:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C971E82105; Thu, 19 May 2022 02:35:11 +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="Qvf2KGn/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D83F682114; Thu, 19 May 2022 02:35:09 +0200 (CEST) Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) (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 496FA81E79 for ; Thu, 19 May 2022 02:35:06 +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-pl1-x634.google.com with SMTP id i8so3317670plr.13 for ; Wed, 18 May 2022 17:35:06 -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=SeKP4S1FybIFVngAu07Wsyd0lgiNLOlPEmpiroeyoaA=; b=Qvf2KGn/VP41IzgmifcyLpfP8kB5cWLMzBBLzbWz+S/QPxqNyBB+WEsMsOIqF5AOqq QeudF7+pzXMVud+xQBaZr7NrnxEn7VZsA0UWzoCGH33Z2eLYQig1ZespAno+57LUdHpR mHeaNA9nCG21Ufp7FTc9cP3ha9thVAKRIdup/yaWvXqsfA1XOHBITUTGOrWYBeYQM3pj ZIVym3YwKYr799ZdZfUiVslT8TMz92hp7EV4WvhYFd9ZM8mLrUmdygMZ054xmgU31k6e NbarNuC/1sob4jxNtSycjMS/fdZCLc9fWQHotORWFLg8rsu/SwoHhn62uoM/7afI1XpE fgUg== 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=SeKP4S1FybIFVngAu07Wsyd0lgiNLOlPEmpiroeyoaA=; b=KiYYR4EvS1GXXeRRlllwCt2wPs+O+spem4eo0Y4RvSuDEbq1Jq4iwxZMiqOmG5wdHD d/b4LoGJWAPDn5d1UybazACGmBqUyVtsrQt1V7tZ4M6AjW1382MbgiNAlLHOFt1YPHWy X79t1I4SszgkmC5U91sRmSqfrJA7FQxi13qcY2567L9l51p0gRSOawXVyJCY1l46c9wq VI4sLUNdLbJt5SOfg4ed5XIwRLIvxuqxGBxFnJVbPq5OxZFiJ809NAA4VVJmxsZySlTy yIVwzVymjRFB8/vw/QmKHgmyLacA7nkTj1mFF73lzNBNJIjuhWxoIocYr5Le+eYFD4vr r0BQ== X-Gm-Message-State: AOAM533ZvbhhAi7gXazk2vylxs3/+TAFy/5AwAziW4BnnkIFHO+LqQue FCFA3SBVF2L4bBPaugrjxsOkog== X-Google-Smtp-Source: ABdhPJzn0NBMK99AsE86OPYzH8La1B5HnE9ni9p7CSLKohccQPG51y+fehmSPR+uWvJVf6wPMF37Xg== X-Received: by 2002:a17:902:eb90:b0:15e:b55f:d9c5 with SMTP id q16-20020a170902eb9000b0015eb55fd9c5mr2273780plg.33.1652920504492; Wed, 18 May 2022 17:35:04 -0700 (PDT) Received: from laputa ([2400:4050:c3e1:100:395d:8f58:fd1d:448b]) by smtp.gmail.com with ESMTPSA id w2-20020a1709026f0200b0015e8d4eb287sm2266216plk.209.2022.05.18.17.35.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 17:35:03 -0700 (PDT) Date: Thu, 19 May 2022 09:35:00 +0900 From: AKASHI Takahiro To: kevans@FreeBSD.org, Heinrich Schuchardt Cc: u-boot@lists.denx.de Subject: Re: [PATCH v2] cmd: bootefi: restore ability to boot arbitrary blob Message-ID: <20220519003500.GA37304@laputa> Mail-Followup-To: AKASHI Takahiro , kevans@FreeBSD.org, Heinrich Schuchardt , u-boot@lists.denx.de References: <20220410210555.88818-1-kevans@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220410210555.88818-1-kevans@FreeBSD.org> 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 I thought I had sent out my comment when this patch was submitted first time, but it seems that it has never reached out to ML. On Sun, Apr 10, 2022 at 04:05:55PM -0500, kevans@FreeBSD.org wrote: > From: Kyle Evans > > Up until commit 5f59518a7b1ae ("efi_loader: setting boot device"), we > could boot an arbitrary blob with bootefi. Indeed, efi_run_image() even > has a special case for missing device paths indicating a payload that > was directly loaded via JTAG, for example. > > Restore the ability to inject a UEFI payload into memory and `bootefi` > it. If the address passed isn't the last PE-COFF loaded, then we'll > wipe out the pre-existing DP/Image information and let efi_run_image() > synthesize a memory device path. > > An image size is required if we're booting an arbitrary payload, and > the FDT argument has been changed to accept `-`. The size could be > deduced from the image header, but it's required anyways as an explicit > acknowledgment that one's trying to boot an arbitrary payload rather > than accidentally using the wrong address in the single-addr form. The syntax seems to be odd and I don't think it is user-friendly " [fdt address [image size]]\n" as an image-related parameter,, doesn't follow
immediately but comes *after* . Instead, I would suggest bootefi [:] [] (or [@]) I believe that ":" notation is quite intuitive and non-misleading. Moreover, a similar syntax can be seen, for example, in booti command. -Takahiro Akashi > If the image address matches the last loaded PE_COFF, it is an error > to pass the incorrect size (but the size may be omitted). > > Signed-off-by: Kyle Evans > --- > > Changes since v1: > - Specifying an address that isn't the last-known without a size produces the > same error as in the past ("No UEFI binary known at ...") > - Specifying a size with the last known address that doesn't match the last > recorded size will get: Size does not match known UEFI binary at %s > > cmd/bootefi.c | 42 ++++++++++++++++++++++++++++++++++-------- > 1 file changed, 34 insertions(+), 8 deletions(-) > > diff --git a/cmd/bootefi.c b/cmd/bootefi.c > index 53d9f0e0dc..0d3aecb2a1 100644 > --- a/cmd/bootefi.c > +++ b/cmd/bootefi.c > @@ -425,7 +425,7 @@ static int do_efibootmgr(void) > * @image_opt: string of image start address > * Return: status code > */ > -static int do_bootefi_image(const char *image_opt) > +static int do_bootefi_image(const char *image_opt, const char *size_opt) > { > void *image_buf; > unsigned long addr, size; > @@ -444,13 +444,35 @@ static int do_bootefi_image(const char *image_opt) > if (!addr) > return CMD_RET_USAGE; > > + size = 0; > + if (size_opt) { > + size = strtoul(size_opt, NULL, 16); > + /* Check that a numeric value was passed */ > + if (!size) > + return CMD_RET_USAGE; > + } > + > image_buf = map_sysmem(addr, 0); > > if (image_buf != image_addr) { > - log_err("No UEFI binary known at %s\n", image_opt); > - return CMD_RET_FAILURE; > + /* Fake device path -- we must have a size. */ > + > + if (size == 0) { > + printf("No UEFI binary known at %s\n", image_opt); > + return CMD_RET_FAILURE; > + } > + > + if (image_addr) > + efi_clear_bootdev(); > + } else { > + if (size != 0 && size != image_size) { > + printf("Size does not match known UEFI binary at %s\n", > + image_opt); > + return CMD_RET_FAILURE; > + } > + > + size = image_size; > } > - size = image_size; > } > ret = efi_run_image(image_buf, size); > > @@ -654,7 +676,7 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, > return CMD_RET_FAILURE; > } > > - if (argc > 2) { > + if (argc > 2 && strcmp(argv[2], "-") != 0) { > uintptr_t fdt_addr; > > fdt_addr = hextoul(argv[2], NULL); > @@ -677,15 +699,19 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, > return do_efi_selftest(); > #endif > > - return do_bootefi_image(argv[1]); > + return do_bootefi_image(argv[1], argc > 3 ? argv[3] : NULL); > } > > #ifdef CONFIG_SYS_LONGHELP > static char bootefi_help_text[] = > - " [fdt address]\n" > + " [fdt address [image size]]\n" > " - boot EFI payload stored at address .\n" > " If specified, the device tree located at gets\n" > " exposed as EFI configuration table.\n" > + " The image size is required if this is not a preloaded image, but\n" > + " it must be omitted if the image was preloaded.\n" > + " The parameter accepts '-' to indicate FDT already\n" > + " installed or pre-specified in fdt_addr or fdtcontroladdr.\n" > #ifdef CONFIG_CMD_BOOTEFI_HELLO > "bootefi hello\n" > " - boot a sample Hello World application stored within U-Boot\n" > @@ -707,7 +733,7 @@ static char bootefi_help_text[] = > #endif > > U_BOOT_CMD( > - bootefi, 3, 0, do_bootefi, > + bootefi, 4, 0, do_bootefi, > "Boots an EFI payload from memory", > bootefi_help_text > ); > -- > 2.33.0 >