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; }