From patchwork Wed Oct 5 15:26:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 612534 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp891469pvb; Wed, 5 Oct 2022 08:26:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6oY5LgfmEH7VOdA6ka7ue+6fNgSLh6KK29gSGQN1/hEgoS+IMiEiEGcFNIcKJysu4i5zWD X-Received: by 2002:a17:907:2672:b0:734:a952:439a with SMTP id ci18-20020a170907267200b00734a952439amr90237ejc.539.1664983592782; Wed, 05 Oct 2022 08:26:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664983592; cv=none; d=google.com; s=arc-20160816; b=i63v3AIbg+c4fNnbElTfVqwiD6KrYYYmIQfUZCMT5hG1/tDs4w0SWEypSBAoj4iAD7 ozvDFQ46rkntSGVeb3k9jIP+dMf6WGjFTf7SIqxSjTa3nZiPDkA/gil6jTDFLZ6/7kmK X7FfxYPKVqFbojKk7WoyeR6YcPmT+H6GVW5WWIRsB2OBgrd3ibalGFNwOu1Kw0Vhmvvw L+0z3vVr/cXTp0xU+1C/vNFqIhyWq5EgNT23IMu8DcmrIe6bGgr1o4lsSsPHZcl8rwL3 wiIr/e54TTmsG0nOHZD7kU/WS6q1gb+uybJTfb4ns+9IWEfATocv+UhnBHESj5C1Wy9R UnuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=Ibqk35fL78XwF61LwGa/eGEXz+9PF0DYHgPd7NLX7RU=; b=XLRJ18WhG7P0ZXmD0yxs/ONIAwg2AIGMD+adynPREjyckb1EkbeViRVvFF7A8efFlV mGXnkWZq6/Q292gH0xiOpjjdlj7QZaray/uJgs3AWadTphiXtgW/qWqjQ10Q8sn2rbd/ UY8QmHp5HlvcelMZHpz8zaRRwT5CHXrz2Xeq/hWbcRadhodLPILXpn6lJOa2oRQuuYkp sE+F63U/PG1XKd+h00yW2Dce1+JEPAWjHDuPSNBcLkPt2m8zHgFhU0eIMorrHDk+bOYy ykbVZOf7V9DTVLO9a4G6i54NxGxWoXUo0TOrvKNB77RKUrWs9q/STC564/ahCpv0YjLw HW6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G9ofu9Yd; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id hz5-20020a1709072ce500b007815ca78c38si13199555ejc.235.2022.10.05.08.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:26:32 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G9ofu9Yd; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 590EA84D8E; Wed, 5 Oct 2022 17:26:29 +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="G9ofu9Yd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4E38F84D96; Wed, 5 Oct 2022 17:26:27 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (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 9A88C84D79 for ; Wed, 5 Oct 2022 17:26:24 +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=ilias.apalodimas@linaro.org Received: by mail-ed1-x536.google.com with SMTP id u21so19300499edi.9 for ; Wed, 05 Oct 2022 08:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=Ibqk35fL78XwF61LwGa/eGEXz+9PF0DYHgPd7NLX7RU=; b=G9ofu9YdSE+nQ89dkh78ziZJSA71HvZ9EvCUTbrZxaGy3Q5En8kuLzo8rhvcQ+3MRg +uVp5rHj0z2Yf+5wlVuwuUKIK8UlfUWj2zUd0xyAAOtR2erGUOtfSKsKp2VeIlJ9iMiJ PCzsbMQ564mfTHRuucSHMZnaZcK62WoYQvm3vpill/PB7bDN7ZYSOazs1gsXSgQL7dwo WFt8v/XyBq3DfZ6F1uV3IRXInolz6hlY+K/nYwrXgUQHBb0Ymf3U/jmrM/p1DFpPBsRX oVggFFxFt0ZVQuNbuXeSAHhLb0kqgUheBEUwyN5cLFpR6ilqPF/XvO8csbfVmS7Fl8os Wr8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=Ibqk35fL78XwF61LwGa/eGEXz+9PF0DYHgPd7NLX7RU=; b=VuZuiiDZ4Vu6lp49BPWkP0c6aokiIjZX/MxrDWWgb1ZDsHdfDAMF6LeMhfW6/XQ85E VTGDGbw4q/ms/PIY+zo4ataen7x5uyMNz/SgTSEWmTXzFW9y/MctjNU2dzOxualb3i8I nnYp1auTzOWk7ADJXFGxN2Q8RRDlWy7+wp/JA2U7iWjyFsPPu6yaESt23tAX8jQagHA3 QMG1NMBKolYDhyV2sPAcLC3Q9jIBy0/uiyu72m/SoU5NROihX67U5JGit4v1pd4LTJxP LlEyWdO58Dnvs1shkCKEBbcMI91ED4SWmJEAJm4zT5ZvD1cKHXNRyVYs4vZa5rmchec6 9hkw== X-Gm-Message-State: ACrzQf0UskERsaO9NcSxGgitvOYfKaMPaCeZITNhpzj7jVf7OJGXmRZ7 qh32ACViO8hO0xv5is0MYgQdhA== X-Received: by 2002:a05:6402:169a:b0:458:fe61:d3b4 with SMTP id a26-20020a056402169a00b00458fe61d3b4mr305967edv.140.1664983584208; Wed, 05 Oct 2022 08:26:24 -0700 (PDT) Received: from hades.. (ppp046103015185.access.hol.gr. [46.103.15.185]) by smtp.gmail.com with ESMTPSA id n15-20020aa7c78f000000b00458d50b4a24sm3918815eds.96.2022.10.05.08.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:26:23 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: Ilias Apalodimas , u-boot@lists.denx.de Subject: [RFC PATCH 0/2] Clean up protocol installation API Date: Wed, 5 Oct 2022 18:26:00 +0300 Message-Id: <20221005152603.3085754-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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 This RFC is trying to clean up the usage of the internal functions used to manage the protocol and handle lifetimes. Currently we arbitrarily use either InstallProtocol, InstallMultipleProtocol and a combination of efi_add_protocol, efi_create_handle, efi_delete_handle(). The latter is the most problematic one since it blindly removes all protocols from a handle and finally the handle itself. This is prone to coding errors Since someone might inadvertently delete a handle while other consumers still use a protocol. InstallProtocol is also ambiguous since the EFI spec only demands InstallMultipleProtocol to test and guarantee a duplicate device path is not inadvertently installed on two different handles. So this patch series is preparing the ground in order for InstallMultipleProtocol and UnInstallMultipleProtocol to be used internally in U-Boot. There is an example on bootefi.c demonstrating how the cleanup would eventually look like. If we agree on the direction, I'll clean up the remaining callsites with InstallMultipleProtocol. Size differences between old/new binary show that eventually we will manage to reduce the overall code size by getting rid all the unneeded EFI_CALL invocations add/remove: 4/0 grow/shrink: 1/6 up/down: 1128/-892 (236) Function old new delta __efi_install_multiple_protocol_interfaces - 496 +496 __efi_uninstall_multiple_protocol_interfaces - 412 +412 efi_uninstall_multiple_protocol_interfaces_ext - 108 +108 efi_install_multiple_protocol_interfaces_ext - 108 +108 efi_run_image 288 292 +4 efi_initrd_register 220 212 -8 efi_console_register 344 336 -8 efi_disk_add_dev.part 644 632 -12 efi_root_node_register 256 240 -16 efi_uninstall_multiple_protocol_interfaces 472 84 -388 efi_install_multiple_protocol_interfaces 544 84 -460 Total: Before=547442, After=547678, chg +0.04% add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0) Data old new delta Total: Before=101061, After=101061, chg +0.00% add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0) RO Data old new delta Total: Before=42925, After=42925, chg +0.00% Ilias Apalodimas (2): efi_loader: define internal implementation of install/uninstallmultiple cmd: replace efi_create_handle/add_protocol with InstallMultipleProtocol cmd/bootefi.c | 13 ++- include/efi.h | 2 + include/efi_loader.h | 6 +- lib/efi_loader/efi_boottime.c | 180 ++++++++++++++++++++++++------- lib/efi_loader/efi_capsule.c | 15 +-- lib/efi_loader/efi_console.c | 14 +-- lib/efi_loader/efi_disk.c | 10 +- lib/efi_loader/efi_load_initrd.c | 15 ++- lib/efi_loader/efi_root_node.c | 44 ++++---- 9 files changed, 203 insertions(+), 96 deletions(-)