From patchwork Thu Jun 1 12:06:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 687703 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp307801wru; Thu, 1 Jun 2023 05:06:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7MlHRWUXMOhM5l3lA+pN7AWjr5o0h553qg6/2Cj6RmVhpbagmiAnuTvS84W10jjUzn3z0G X-Received: by 2002:a05:6a00:3923:b0:64d:42f6:4c7b with SMTP id fh35-20020a056a00392300b0064d42f64c7bmr9961229pfb.27.1685621200625; Thu, 01 Jun 2023 05:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685621200; cv=none; d=google.com; s=arc-20160816; b=AYHMInZhd3tbUMDKWsqFBPtB2tu8l1UmUGMBvtb1Hya9DwZM9sWdJCE6tKTTQLMvWI ipy2L6A7DUfhA6FD0p0AE4l/4FCFxckI+tcPkErCL9xVdJsiUg1WXquqzmuWIulD4vzV JX2iN9SRxKGWOuhbKfwb7Tt0SDu1y0teVym61oUqDdKjgYlMBHwZW1cG+LQsjYnMnRe1 bP2SGy1J5eYvMcbHLyC7CwRCcSFbalKl65bAO0flg1bUUPo7TLIZ+p07Wuv4c3l4x8HW gyobVHabr92t9mqNRZkmd9410tdlzTvfwLzDonDSFPckK14VIM3/ymChlDzeX2J4zliU Xglw== 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=Lad3KiEH3JnoFsFx/7Ht/jIf2smrLTvkWs6hcocEV9A=; b=Ajfb2S53OlwCpvc6IAXtb7Gy6x3VIXS8izFePHcX7cs8meBiwdJ25EhGpgCbgFHW41 /jcLe6NivEeIrSOEWzP/8GMmvJp7TJIG/k3QPXPooQicWxUQig17OnA3z3ECDm/R2NSB grvgico/DKjXkbbjSL6g1IkESvqOFq3/ygWdxvSxkthh3cBDNPE9v5ZO2ECz+LhfrHLn xWk86BxD3n3e5lV68rasXaaesgquW3IYt74lFPz9TqjwTxOo7jAyzSYIfNOja8B3l8T5 5cHIMdP+g0M7JM95lvGzshx+f4KYNLTyElhX2xOkG4qEuBlQA+eHEHForx2GWS4uAczv Jdgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CmUffJ1Q; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id h16-20020a633850000000b00530b3b98fc5si1604691pgn.417.2023.06.01.05.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 05:06:40 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CmUffJ1Q; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 35925862D1; Thu, 1 Jun 2023 14:06:33 +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="CmUffJ1Q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 24F5B862F7; Thu, 1 Jun 2023 14:06:31 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450: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 919CD8627B for ; Thu, 1 Jun 2023 14:06:28 +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-wr1-x42e.google.com with SMTP id ffacd0b85a97d-30c4775d05bso276078f8f.2 for ; Thu, 01 Jun 2023 05:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685621188; x=1688213188; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Lad3KiEH3JnoFsFx/7Ht/jIf2smrLTvkWs6hcocEV9A=; b=CmUffJ1QAqCdFwZPXJg9Y/5DooZsYZvg95LVki9h2Nig3cVHEq8wO87yyel9/84n6V QSKaRuLkZ3SQHvVIG2IRaxBz8TUYibtWM/7SqilG/5L0B8GyT5DeiEMGGHuGpQ0SvsVN AqmfIGN24Yir5imOeEV10dvjVvOm2Bxg+5efsJL5eWDDM/YywH6XAmhVqKopRTjEDqhh PMe9CwV+xE71XVWjpLpm4txMV2adpcgUjhaEped4ed/p+ITUCtiGk6bzYl/lh3juqUHU ukjncUztMA8da0DoNKRFTUk23Uc5w9WierrphCD3vk0TkA+bDDcCQYHHv+VM45ZJ2sdO mg4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685621188; x=1688213188; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Lad3KiEH3JnoFsFx/7Ht/jIf2smrLTvkWs6hcocEV9A=; b=VFLAv6MpTyl8I+SY9+v8uiP4TsO5kUDhulmyOTCs3bvzcZy1exkcxyJnpQpm1FBFRB 5SwFQzZjiHt3XStWc85AcmYQuS7IQDmXlLejN/ZYDy5vo82R/khxKRnTgcTbbAgT8OXN A/G1VukhsYivBvyRX74FS9jtiTdDlytA3L+Q4IjEGC8+coJiOkDdM0i/MfaPsLhsArgC b9tnbC3VPxHSygSvJ0TBXeYAFVEBWpza7w49ShSrCVublkzPY4x9hICKM/tlA82qMxpu PH3EcVIdCjaAtzcFkh68B6Tc/RH/8LuzevaRmXRTKSds8WL3p2xFO7PCjuHV52ogI13a eaYQ== X-Gm-Message-State: AC+VfDyPUEmgXJsCu917niRfutpbNvazih1q8nGSI4YhvI9IVz0D7BlE wQqQP49FAlQTgBmlpOlLK5//TRfLB2OKYrNSjUs= X-Received: by 2002:a05:6000:14b:b0:306:2fab:1f81 with SMTP id r11-20020a056000014b00b003062fab1f81mr1701851wrx.21.1685621187884; Thu, 01 Jun 2023 05:06:27 -0700 (PDT) Received: from localhost.localdomain (ppp089210114029.access.hol.gr. [89.210.114.29]) by smtp.gmail.com with ESMTPSA id i14-20020adfe48e000000b0030ae499da59sm10097004wrm.111.2023.06.01.05.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 05:06:27 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt Subject: [PATCH 1/2] efi_loader: delete handle from events when a protocol is uninstalled Date: Thu, 1 Jun 2023 15:06:23 +0300 Message-Id: <20230601120625.1843555-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.39.2 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.8 at phobos.denx.de X-Virus-Status: Clean When a notification event is registered for a protocol the handle of the protocol is added in our event notification list. When all the protocols of the handle are uninstalled we delete the handle but we do not remove it from the event notification list. Clean up the protocol removal functions and add a wrapper which - Removes the to-be deleted handle from any lists it participates - Remove the handle if no more protocols are present It's worth noting that all our variants of efi_uninstall_protocol_*() and uninstall_multiple_protocol_*() end up calling efi_uninstall_protocol(). We could add the cleanup in that function only, however efi_reinstall_protocol_interface() expects the handle not to be removed. Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_boottime.c | 45 +++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index d5065f296aee..450524ddca2f 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -197,6 +197,35 @@ static bool efi_event_is_queued(struct efi_event *event) return !!event->queue_link.next; } +/** + * efi_handle_cleanup() - Clean the deleted handle from the various lists + * @handle: handle to remove + * @force: force removal even if protocols are still installed on the handle + * + * Return: status code + */ +static void efi_handle_cleanup(efi_handle_t handle, bool force) +{ + struct efi_register_notify_event *item, *next; + + if (!list_empty(&handle->protocols) || force) + return; + /* The handle is about to be freed. Remove it from events */ + list_for_each_entry_safe(item, next, &efi_register_notify_events, link) { + struct efi_protocol_notification *hitem, *hnext; + + list_for_each_entry_safe(hitem, hnext, &item->handles, link) { + if (handle == hitem->handle) { + list_del(&hitem->link); + free(hitem); + } + } + } + /* The last protocol has been removed, delete the handle. */ + list_del(&handle->link); + free(handle); +} + /** * efi_process_event_queue() - process event queue */ @@ -627,8 +656,7 @@ void efi_delete_handle(efi_handle_t handle) return; } - list_del(&handle->link); - free(handle); + efi_handle_cleanup(handle, true); } /** @@ -1396,11 +1424,8 @@ static efi_status_t EFIAPI efi_uninstall_protocol_interface if (ret != EFI_SUCCESS) goto out; - /* If the last protocol has been removed, delete the handle. */ - if (list_empty(&handle->protocols)) { - list_del(&handle->link); - free(handle); - } + /* Check if we have to purge the handle from various lists */ + efi_handle_cleanup(handle, false); out: return EFI_EXIT(ret); } @@ -2777,11 +2802,7 @@ efi_uninstall_multiple_protocol_interfaces_int(efi_handle_t handle, i++; } if (ret == EFI_SUCCESS) { - /* If the last protocol has been removed, delete the handle. */ - if (list_empty(&handle->protocols)) { - list_del(&handle->link); - free(handle); - } + efi_handle_cleanup(handle, false); goto out; } From patchwork Thu Jun 1 12:06:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 687704 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp307959wru; Thu, 1 Jun 2023 05:06:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5lb8QkP5wbyFpat82fTFYvY/gXW0SUktOTBan6P7kaAB4KHLSqueM7jZ9vUhvOj1VSUAG+ X-Received: by 2002:a17:90a:e385:b0:255:5b1a:be04 with SMTP id b5-20020a17090ae38500b002555b1abe04mr8887423pjz.4.1685621217035; Thu, 01 Jun 2023 05:06:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685621217; cv=none; d=google.com; s=arc-20160816; b=Pu0Ziqr38owe4esGqOF0W+srMDTyyYcuQdtarW3wZogvxuvRE8oOcQv1uBWG3Eg1d0 aPK8FaVmYmONT00qiEantrSgpGKPTtTq5FJ3AxQnVHz50O7RGWH/GCrNpPBo57h4CdKl ER9plQYjYKcKhMt5oCnoloQWBHikvOS2y6aRYHa9bTZYYA5Yq0M7QY2k+j86Ir+aJ8Z8 IiCF6kHEbZ0ej2imZFzBLbYGlCfxXXj7TuCz+H5GyTSS5gpi1t3ERKNn6WBkM9zqOAuo he5vuuZwxKmGTIqO6JviArS6rtFD65fr5TEaFAnrMsbIeS3To69xCNKNyfNgUL6EB8pk sf6A== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dG+/fsnZ9+jCpYIYtjcD2442Qwe4hOf13Uklbp4LF0E=; b=AdKjhq5XldV01a2gg4LLHxXB2O+iVWn8bGc+Nqx5/LCeWjz04h0m2GFjGWl7jkvqow g4wGfc/vClAi4cXEbTZlGanIHKsaGPFxh2c6n89qWQkHSAJCRbYcVYxAkzPvfr8oAM2A Osc4b4GbH9cnau20GO5J3EjWY1KOLVuCHM6sLkB23jwFTK2KuUBTaHcJpH3IwJtNWuOc p2tl68x0v2susFln+Gx4vEe5aI+VyHrfez4/qdIWyuvQnyVaG6gzrH06R/5PGj7pzUS9 He9eG63GVUyd3TIykycTbXrZN6yNC6+QV8lbBVogkaNCO0pCIWis9up0DqvvOwi8JPVS fy0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g1PDQM7Y; 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 u9-20020a17090a2b8900b0024c1ddfa1bfsi987445pjd.92.2023.06.01.05.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 05:06:56 -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=g1PDQM7Y; 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 BA945862FB; Thu, 1 Jun 2023 14:06:35 +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="g1PDQM7Y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9EE118627B; Thu, 1 Jun 2023 14:06:32 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) (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 BC81C862F2 for ; Thu, 1 Jun 2023 14:06: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=ilias.apalodimas@linaro.org Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4f3b4ed6fdeso830555e87.3 for ; Thu, 01 Jun 2023 05:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685621189; x=1688213189; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dG+/fsnZ9+jCpYIYtjcD2442Qwe4hOf13Uklbp4LF0E=; b=g1PDQM7YVHYLMBl2n3N+HAkfQ9CM5hEDlu1mZbTO4IjT2RHvsF9skp4FJNWg61Ijik OmQrgO7jrdInDjZPiKQOQ9mjixVhV6dYsGOS93cB9nhvXI5VWcuPzP7MsURxusPk/AdR /7AJiqc6b4HXvFSdnPltuiN9dNMdlUU9FX0bxQiZyJLedRKDaw5YktUBOrU6CJxpgNx6 u+/1oQro+Dx77SZBxiBwRoWhdTCgE9p1Zpa1el9+528kHbPRlR+xGxqQFAcHSnaRRABy TAOlvTkSGBbgkMO0sqkGhawgkhnkUVU77OvUdKQhb4jp7BtZDsAPn8xdmUNfoUf77oTo uydg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685621189; x=1688213189; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dG+/fsnZ9+jCpYIYtjcD2442Qwe4hOf13Uklbp4LF0E=; b=gG4WSbjnvrPpl7pp0cLhuIFqofzHRFr/pqSxfdmKEnT9ppVeaF4ITlntEiGHJX1stW LvQNge5Ak50oPEy0VnusdLaD7Vwy9weiFL15C79VnEJlqtBQFRmygyak3DjCKP/2k6mA eWTobGpQY4Fh/rmeFzii1OCyXzVAYXCsnPgCNrV4UXXRm4Jsk+Nsrym8tti6eC/DcOXr G3jkXyPrjXcb3zdg+y/4xq8GIdFGmJQiidiOBWyp6fSdqU+WXxtddzaFkVdV0VIEwxjZ Q7lCtLXk/Lizs6AQ4OiFE/j8ZUNmZYB3wYyg4BSDS3oT69/6mpGMKM9/0pvz3Tr0HtmC BySQ== X-Gm-Message-State: AC+VfDyT8LnIwtkSZkKiIxTL6GvAH4kmomGxCUTSInkPUYQ73CCWwKSn A54JOJnqQPohVPmejkrnSB7wfkkoWHS/rGjzC3g= X-Received: by 2002:ac2:434e:0:b0:4ef:f1f4:14db with SMTP id o14-20020ac2434e000000b004eff1f414dbmr1161820lfl.16.1685621188867; Thu, 01 Jun 2023 05:06:28 -0700 (PDT) Received: from localhost.localdomain (ppp089210114029.access.hol.gr. [89.210.114.29]) by smtp.gmail.com with ESMTPSA id i14-20020adfe48e000000b0030ae499da59sm10097004wrm.111.2023.06.01.05.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 05:06:28 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt Subject: [PATCH 2/2] efi_selftest: check for deleted handles in the event notification list Date: Thu, 1 Jun 2023 15:06:24 +0300 Message-Id: <20230601120625.1843555-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230601120625.1843555-1-ilias.apalodimas@linaro.org> References: <20230601120625.1843555-1-ilias.apalodimas@linaro.org> 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.8 at phobos.denx.de X-Virus-Status: Clean A previous patch is fixing a problem where handles were added in an event notification list, but were never deleted when the handle got deleted. Add a test case which calls - RegisterProtocolNotify - IstallMultipleProtocolInterface - UnIstallMultipleProtocolInterface - LocateHandleBuffer(ByRegisterNotify) The last call should return EFI_NOT_FOUND Signed-off-by: Ilias Apalodimas --- Heinrich this is not rebased on top of https://lore.kernel.org/u-boot/20230601070609.14977-1-heinrich.schuchardt@canonical.com/ .../efi_selftest_register_notify.c | 61 ++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) -- 2.39.2 diff --git a/lib/efi_selftest/efi_selftest_register_notify.c b/lib/efi_selftest/efi_selftest_register_notify.c index ad763dd6cb8b..d133c7c50b71 100644 --- a/lib/efi_selftest/efi_selftest_register_notify.c +++ b/lib/efi_selftest/efi_selftest_register_notify.c @@ -33,8 +33,14 @@ static efi_guid_t guid1 = static efi_guid_t guid2 = EFI_GUID(0xf909f2bb, 0x90a8, 0x0d77, 0x94, 0x0c, 0x3e, 0xa8, 0xea, 0x38, 0xd6, 0x6f); +static efi_guid_t guid3 = + EFI_GUID(0xfa09f2cb, 0x70a8, 0x0d77, + 0x9a, 0x2c, 0x31, 0x18, 0xca, 0x41, 0xa6, 0x6e); + static struct context context; static struct efi_event *event; +static struct efi_event *test_uninstall_event; +static void *test_uninstall_key; /* * Notification function, increments the notification count if parameter @@ -63,6 +69,17 @@ static void EFIAPI notify(struct efi_event *event, void *context) } } +/* + * Notification function, does nothing and is used to test UninstallProtocol + * + * @event notified event + * @context pointer to the notification count + */ +static void EFIAPI test_uninstall_notify(struct efi_event *event, void *context) +{ + return; +} + /* * Setup unit test. * @@ -91,6 +108,21 @@ static int setup(const efi_handle_t img_handle, return EFI_ST_FAILURE; } + ret = boottime->create_event(EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, test_uninstall_notify, NULL, + &test_uninstall_event); + if (ret != EFI_SUCCESS) { + efi_st_error("could not create event\n"); + return EFI_ST_FAILURE; + } + + ret = boottime->register_protocol_notify(&guid3, test_uninstall_event, + &test_uninstall_key); + if (ret != EFI_SUCCESS) { + efi_st_error("could not register event\n"); + return EFI_ST_FAILURE; + } + return EFI_ST_SUCCESS; } @@ -121,8 +153,10 @@ static int teardown(void) static int execute(void) { efi_status_t ret; - efi_handle_t handle1 = NULL, handle2 = NULL; - struct interface interface1, interface2; + efi_handle_t handle1 = NULL, handle2 = NULL, handle3 = NULL; + struct interface interface1, interface2, interface3; + efi_uintn_t handle_count; + efi_handle_t *handles; ret = boottime->install_protocol_interface(&handle1, &guid1, EFI_NATIVE_INTERFACE, @@ -224,6 +258,29 @@ static int execute(void) return EFI_ST_FAILURE; } + ret = boottime->install_protocol_interface(&handle3, &guid3, + EFI_NATIVE_INTERFACE, + &interface3); + if (ret != EFI_SUCCESS) { + efi_st_error("could not install interface\n"); + return EFI_ST_FAILURE; + } + + ret = boottime->uninstall_multiple_protocol_interfaces + (handle3, &guid3, &interface3, NULL); + if (ret != EFI_SUCCESS) { + efi_st_error("UninstallMultipleProtocolInterfaces failed\n"); + return EFI_ST_FAILURE; + } + + ret = boottime->locate_handle_buffer(BY_REGISTER_NOTIFY, NULL, + test_uninstall_key, + &handle_count, &handles); + if (ret != EFI_NOT_FOUND) { + efi_st_error("UninstallMultipleProtocolInterfaces failed to delete event handles\n"); + return EFI_ST_FAILURE; + } + return EFI_ST_SUCCESS; }