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 E63DBC433F5 for ; Wed, 2 Mar 2022 09:44:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BDC3583C64; Wed, 2 Mar 2022 10:44:37 +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="uiTrCEdW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6523283C6C; Wed, 2 Mar 2022 10:44:36 +0100 (CET) Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) (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 4A0DF83C60 for ; Wed, 2 Mar 2022 10:44:32 +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-pf1-x42f.google.com with SMTP id t5so1440342pfg.4 for ; Wed, 02 Mar 2022 01:44:32 -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=sh9TUsGRC4Jl+Mn8FcchaTQhlAD4b6tSz8UHhiY+Eug=; b=uiTrCEdWQ1FNdx6N4AE7CVTjWC+H9+ftjE2aT5rcj6OWlyuHyIiVhlYO5y+/fKgoc5 I8rH0jjkO/OZHSKm9b4+Dmzb5ZSyekXSmgzOZKsR92mNeYHl0m3r0bzg2N5KBfhx/wTF cCZ4XBt2ncmyE0USeUv313bTi5Wq1zk1xo0kvU+MnCOVuzTLfVk/i4L1gulPnBCB4W0q Y24DTEAjMyIUE1tJme87UifAeuimxAYu1O8hnElKMj/RbswxWvH1964mCdge7BNJn5+p RhHiB+4FTWd4uPd/U45Kom+J3hGWb15KlLP2t2p7gu/dykocyLw1HxKFR6pFcHsdgAIA T+Cw== 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=sh9TUsGRC4Jl+Mn8FcchaTQhlAD4b6tSz8UHhiY+Eug=; b=6JjJBj0TxIvrouoOO3xXmVRSu1n8sTTm7nHZbPv5fUXVeMflLwT4llTHUCvjC9lGlR ZMhk9YEy0lONOJ72O7AaJf6h38RPZ61Gn+lPxn3tNyKsWI67TXujKT8p5tRX3SkTLd1E 4QVdNMkW7Zox0PkVsgWwrg7YM8bq4RUEwgxgel9f8DqfWuOjlEvlnxdPH6zNMJMvK+tW /Zlnsgvg56aGBgzj9INb2c2cWkXy2twxA+cZ6vn937ZMAg3VEALKvi6Axs7s0PrDi7nB hkupzaWaS3qP6dsMwz572s/2xDx7t3iu3YP7BtqDN3zAhBENMcSq1kiK1YF+3YDFbgla uYqQ== X-Gm-Message-State: AOAM532oVvkXAbU9YnV/inpQ5kPFm7AxJoo0sZglI+PNVfS64e3uEHAO FbRZfWsEOIN20zrgFXItYDvPzg== X-Google-Smtp-Source: ABdhPJydUDndZ35HGkHokjPRKu6vq2/qSkvDn2s/OGFprJ005H9B6K/i0hc9mBQsCWmTXItykE55Eg== X-Received: by 2002:a05:6a00:805:b0:4f0:fea7:d3c7 with SMTP id m5-20020a056a00080500b004f0fea7d3c7mr31599469pfk.54.1646214270493; Wed, 02 Mar 2022 01:44:30 -0800 (PST) Received: from laputa ([2400:4050:c3e1:100:4d0e:aea6:76ea:b3fa]) by smtp.gmail.com with ESMTPSA id h17-20020a056a001a5100b004f0edf683dfsm20382708pfv.168.2022.03.02.01.44.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 01:44:30 -0800 (PST) Date: Wed, 2 Mar 2022 18:44:26 +0900 From: AKASHI Takahiro To: Heinrich Schuchardt Cc: u-boot@lists.denx.de, Ilias Apalodimas Subject: Re: [PATCH 2/2] efi_loader: use short-form DP for load options Message-ID: <20220302094426.GA48479@laputa> Mail-Followup-To: AKASHI Takahiro , Heinrich Schuchardt , u-boot@lists.denx.de, Ilias Apalodimas References: <20220226115651.117246-1-xypron.glpk@gmx.de> <20220226115651.117246-3-xypron.glpk@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220226115651.117246-3-xypron.glpk@gmx.de> 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 On Sat, Feb 26, 2022 at 12:56:51PM +0100, Heinrich Schuchardt wrote: > The GUID of partitions is sufficient for identification and will stay > constant in the lifetime of a boot option. The preceding path of the > device-path may change due to changes in the enumeration of devices. > Therefore it is preferable to use the short-form of device-paths in load > options. Adjust the 'efidebug boot add' command accordingly. Since a "long" device path is still valid, I think that a user should be allowed to use a long device path especially if he or she wants to limit an interface for loading any image. Please add an option to efidebug to select a short or long path. Furthermore, I would like to ask you to add a test, as you always require me to do so, for loading from a short path. Otherwise, the feature will never be exercised in CI loop. -Takahiro Akashi > Signed-off-by: Heinrich Schuchardt > --- > cmd/efidebug.c | 15 +++++++++++---- > include/efi_loader.h | 3 ++- > lib/efi_loader/efi_device_path.c | 21 +++++++++++++-------- > 3 files changed, 26 insertions(+), 13 deletions(-) > > diff --git a/cmd/efidebug.c b/cmd/efidebug.c > index 401d13cc4c..f62a4345fd 100644 > --- a/cmd/efidebug.c > +++ b/cmd/efidebug.c > @@ -747,7 +747,7 @@ struct efi_device_path *create_initrd_dp(const char *dev, const char *part, > const char *file) > > { > - struct efi_device_path *tmp_dp = NULL, *tmp_fp = NULL; > + struct efi_device_path *tmp_dp = NULL, *tmp_fp = NULL, *short_fp; > struct efi_device_path *initrd_dp = NULL; > efi_status_t ret; > const struct efi_initrd_dp id_dp = { > @@ -771,9 +771,12 @@ struct efi_device_path *create_initrd_dp(const char *dev, const char *part, > printf("Cannot create device path for \"%s %s\"\n", part, file); > goto out; > } > + short_fp = efi_dp_shorten(tmp_fp); > + if (!short_fp) > + short_fp = tmp_fp; > > initrd_dp = efi_dp_append((const struct efi_device_path *)&id_dp, > - tmp_fp); > + short_fp); > > out: > efi_free_pool(tmp_dp); > @@ -807,6 +810,7 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, > size_t label_len, label_len16; > u16 *label; > struct efi_device_path *device_path = NULL, *file_path = NULL; > + struct efi_device_path *fp_free = NULL; > struct efi_device_path *final_fp = NULL; > struct efi_device_path *initrd_dp = NULL; > struct efi_load_option lo; > @@ -849,13 +853,16 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, > > /* file path */ > ret = efi_dp_from_name(argv[3], argv[4], argv[5], > - &device_path, &file_path); > + &device_path, &fp_free); > if (ret != EFI_SUCCESS) { > printf("Cannot create device path for \"%s %s\"\n", > argv[3], argv[4]); > r = CMD_RET_FAILURE; > goto out; > } > + file_path = efi_dp_shorten(fp_free); > + if (!file_path) > + file_path = fp_free; > fp_size += efi_dp_size(file_path) + > sizeof(struct efi_device_path); > argc -= 5; > @@ -927,7 +934,7 @@ out: > efi_free_pool(final_fp); > efi_free_pool(initrd_dp); > efi_free_pool(device_path); > - efi_free_pool(file_path); > + efi_free_pool(fp_free); > free(lo.label); > > return r; > diff --git a/include/efi_loader.h b/include/efi_loader.h > index e390d323a9..c7d6b7c7f3 100644 > --- a/include/efi_loader.h > +++ b/include/efi_loader.h > @@ -725,7 +725,8 @@ extern void *efi_bounce_buffer; > #define EFI_LOADER_BOUNCE_BUFFER_SIZE (64 * 1024 * 1024) > #endif > > - > +/* shorten device path */ > +struct efi_device_path *efi_dp_shorten(struct efi_device_path *dp); > struct efi_device_path *efi_dp_next(const struct efi_device_path *dp); > int efi_dp_match(const struct efi_device_path *a, > const struct efi_device_path *b); > diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c > index dc787b4d3d..ddd5f132ec 100644 > --- a/lib/efi_loader/efi_device_path.c > +++ b/lib/efi_loader/efi_device_path.c > @@ -122,20 +122,25 @@ int efi_dp_match(const struct efi_device_path *a, > } > } > > -/* > +/** > + * efi_dp_shorten() - shorten device-path > + * > * We can have device paths that start with a USB WWID or a USB Class node, > * and a few other cases which don't encode the full device path with bus > * hierarchy: > * > - * - MESSAGING:USB_WWID > - * - MESSAGING:USB_CLASS > - * - MEDIA:FILE_PATH > - * - MEDIA:HARD_DRIVE > - * - MESSAGING:URI > + * * MESSAGING:USB_WWID > + * * MESSAGING:USB_CLASS > + * * MEDIA:FILE_PATH > + * * MEDIA:HARD_DRIVE > + * * MESSAGING:URI > * > * See UEFI spec (section 3.1.2, about short-form device-paths) > + * > + * @dp: original devie-path > + * @Return: shortened device-path or NULL > */ > -static struct efi_device_path *shorten_path(struct efi_device_path *dp) > +struct efi_device_path *efi_dp_shorten(struct efi_device_path *dp) > { > while (dp) { > /* > @@ -189,7 +194,7 @@ static struct efi_object *find_obj(struct efi_device_path *dp, bool short_path, > } > } > > - obj_dp = shorten_path(efi_dp_next(obj_dp)); > + obj_dp = efi_dp_shorten(efi_dp_next(obj_dp)); > } while (short_path && obj_dp); > } > > -- > 2.34.1 >