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 5532EC433F5 for ; Thu, 6 Oct 2022 01:53:58 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3FFB584D6B; Thu, 6 Oct 2022 03:53:56 +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="vrgziiZ+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C464F84D80; Thu, 6 Oct 2022 03:53:54 +0200 (CEST) Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) (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 0E08184955 for ; Thu, 6 Oct 2022 03:53:52 +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-x635.google.com with SMTP id c24so426912plo.3 for ; Wed, 05 Oct 2022 18:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=8umPefrbAKMR5SeaH2I5ESrhYBTrislTGL67XkJlnd0=; b=vrgziiZ+b3pfq/WRRfLXAlQ9QCJ06dDKKQGm507P8p4YJ0b1sctWTdIHRrJ1fV5Kk/ RYzRs8OFOgv6oXwFvLLH6Z/kEei9kYUsKsCOeFkBxQDdmyuli1kRCBkJur/GAsvAsJYj i5EJqp5zNtUT1bW47JhajxIK5JDEu3R51BwMWnV9rIHcXGjxnrHmc6r5msENTQuOkX2w rM+fW5NXexY1wED3V/QR0j+2X8hpaIYTd1aE8evDr74yFmFsmrAvVrr+FsZb7SZWCbny ki3lJENrVmKzQ59uqzfMEvYyR7j+FZ9YoMQfZbntwQfAjCF9I9OPVjFb0pfBndb6YgTn 9TqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8umPefrbAKMR5SeaH2I5ESrhYBTrislTGL67XkJlnd0=; b=z6gIVBiWDCHn9xw35Q1RFeDo9zG2YJWbe/5Y2EdL7qQbYRcoBQyROToulM4g1jPpcU uMJWuOG5bkHLzwI9fXUcVfMlQ/i02RQ/lul7L/KQmb2KBZmTpUQV/dDafHlV/oJ698EI M8Ev3rgH7bdQT4S3/AiD67qoJR9er6C2la6+0qVU133TSLKeDBxpWjF8qG6ZelKVArOE y9gIHhCcu++Ja+VXsJruWebphEuFwofFQUa7Lb3MkWQsyGoIfN6cNZofGJOUxI2LaAUF JMfG9PHqmXxSmsHQu+XwzAgwfVhxVTKrTniYrpFim3H8YbyG7JUjt/zAdRrRx66g3O9s sIGw== X-Gm-Message-State: ACrzQf16UWAySFCCBvGW+9VWfxufW2pxrdpBFIqMQE4JBxpvGW1tb9Ex WiokbiZvKGE1eqcKK6IR1/3reA== X-Google-Smtp-Source: AMsMyM7QRr+LawGAh1DWqswLF06Ng+3TWVTaniV1Tw0YonJlpM6pHzCuz4/EUKHOP7odeumOHLJjSw== X-Received: by 2002:a17:902:82ca:b0:17f:8003:1ceb with SMTP id u10-20020a17090282ca00b0017f80031cebmr2091699plz.54.1665021230306; Wed, 05 Oct 2022 18:53:50 -0700 (PDT) Received: from laputa ([2400:4050:c3e1:100:78d2:68b8:e073:79cd]) by smtp.gmail.com with ESMTPSA id o39-20020a17090a0a2a00b001f262f6f717sm1773774pjo.3.2022.10.05.18.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 18:53:49 -0700 (PDT) Date: Thu, 6 Oct 2022 10:53:46 +0900 From: AKASHI Takahiro To: Ilias Apalodimas Cc: xypron.glpk@gmx.de, u-boot@lists.denx.de Subject: Re: [RFC PATCH 2/2] cmd: replace efi_create_handle/add_protocol with InstallMultipleProtocol Message-ID: <20221006015346.GC38245@laputa> Mail-Followup-To: AKASHI Takahiro , Ilias Apalodimas , xypron.glpk@gmx.de, u-boot@lists.denx.de References: <20221005152603.3085754-1-ilias.apalodimas@linaro.org> <20221005152603.3085754-3-ilias.apalodimas@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221005152603.3085754-3-ilias.apalodimas@linaro.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.6 at phobos.denx.de X-Virus-Status: Clean On Wed, Oct 05, 2022 at 06:26:02PM +0300, Ilias Apalodimas wrote: > In general handles should only be deleted if the last remaining protocol > is removed. Instead of explicitly calling > efi_create_handle -> efi_add_protocol -> efi_delete_handle which blindly > removes all protocols from a handle before removing it, use > InstallMultiple/UninstallMultiple which adheres to the EFI spec and only > deletes a handle if there are no additional protocols present > > Signed-off-by: Ilias Apalodimas > --- > cmd/bootefi.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > diff --git a/cmd/bootefi.c b/cmd/bootefi.c > index 3041873afbbc..4ab68868cc7e 100644 > --- a/cmd/bootefi.c > +++ b/cmd/bootefi.c > @@ -509,12 +509,9 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) > * Make sure that device for device_path exist > * in load_image(). Otherwise, shell and grub will fail. > */ > - ret = efi_create_handle(&mem_handle); > - if (ret != EFI_SUCCESS) > - goto out; > - > - ret = efi_add_protocol(mem_handle, &efi_guid_device_path, > - file_path); > + ret = efi_install_multiple_protocol_interfaces(&mem_handle, > + &efi_guid_device_path, > + file_path, NULL); nitpick: NULL -> NULL, NULL UEFI spec seems to require "A variable argument list containing pairs of protocol GUIDs and protocol interfaces" even if a protocol interface won't be used with GUID as NULL. -Takahiro Akashi > if (ret != EFI_SUCCESS) > goto out; > msg_path = file_path; > @@ -542,7 +539,9 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size) > ret = do_bootefi_exec(handle, load_options); > > out: > - efi_delete_handle(mem_handle); > + efi_uninstall_multiple_protocol_interfaces(mem_handle, > + &efi_guid_device_path, > + file_path, NULL); > efi_free_pool(file_path); > return ret; > } > -- > 2.34.1 >