From patchwork Thu Jun 15 14:39:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 693004 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d91:0:0:0:0:0 with SMTP id b17csp562186wru; Thu, 15 Jun 2023 07:39:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ76vh0SXg8wulvZwKl5bjc/8QRUyaHvosuxDkMQnP6BO2OxGHZ4VF83KXTj20ygCpnRCg1B X-Received: by 2002:a05:6a00:2da3:b0:666:7866:ece9 with SMTP id fb35-20020a056a002da300b006667866ece9mr4645456pfb.33.1686839995901; Thu, 15 Jun 2023 07:39:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686839995; cv=none; d=google.com; s=arc-20160816; b=yUrJ0zCvouh14sk5FLpkEerGWlrYA9Dr9bMqmqkr26kc914SKQcRKy8ntxt1JOaC1x KVpV9OFY2sCn7jqALI6mC0cZGgyLlqDE9yju/IDzGoPqNeHTAeR0+jl1Ocr1apTpD2HH 9oxF5ZYY2twBI1KbUNAu7oMp5F20iFxZo0384fJ/8cGGP2sXdsuShMTLajmCtSyy2hKS S6sazoYiZwA8XoVKzWQ6WToNQLH4h94ZvOU8nbHqr7QmTfw1f9tXF4KSp5cSrP1uxHg+ p54ctL16AbpnYemGIjPLBBqaEcfllb4HWXmfIBqIUmUq3N82ehWcY8dgzqGiPSIgzj9t DBFA== 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=PJ474ru3Csrr9GZeo5jFdK0acukrlhlJy+sdzWVQnpM=; b=inzwhGP8x7twqNHYtGhUqHMFk6dT2jmSEU3/5OvjBdFnpy9qECm5ZSmuFcb8pMFmBJ D+jplhdVXqRGaor5pJWNFC+ZLM60kBOtb8sRke+vJ2FR75WjWoK/xF4kqts51N1b87zw juCx7m/o8lY1P3OR4bhr9t55K6H/MK3H76bQmIhrhYUDJwXOa2ZLWCJaQ9x15SXcU7yi EC8CTuoh9QTViVZ6Vp7N/9ShSmy7JEp6dkBcp2AgyGBk5L+e6g9ENtlxzOkKELJvo3nm xZCRp/i4ydfCSTZc4Ee/IeVyMsCLOqpCBeJ7Qp6EE0UEzQen9DoQiNae2j/U3AlnA+K6 jtPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zp+D5C1K; 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 w4-20020a656944000000b005428f25f67asi10004593pgq.618.2023.06.15.07.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 07:39:55 -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=zp+D5C1K; 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 2E12786335; Thu, 15 Jun 2023 16:39:49 +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="zp+D5C1K"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6DCDA86322; Thu, 15 Jun 2023 16:39:47 +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-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) (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 01ED98475C for ; Thu, 15 Jun 2023 16:39:45 +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-x12e.google.com with SMTP id 2adb3069b0e04-4f849a0e371so113544e87.1 for ; Thu, 15 Jun 2023 07:39:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686839984; x=1689431984; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PJ474ru3Csrr9GZeo5jFdK0acukrlhlJy+sdzWVQnpM=; b=zp+D5C1K+62ONeNKgAs3ZoFD0lCV2q5dO8ftDS5KCd6hbS46/PMV3abI38xKBjunEA trAATAngzZdkv7d+5JgygwuNrm+4XYgajGSlK+G5OkPQpaDk3IiNIU41jUoJnMO4t4Mg splK2yuyI/Z+vQuFSKoM5UlN1Ivjv0+2aCGaMr4xW2QsfVv2BOyBCBQL/+C8N5JCKWu5 acW4/PraEq+XyAYeKpgLdtZPpHkoditYQ9p1Bq4JS4sns7vJzDYbIZ7YEhVbc+A4wqU3 OtHSyVdRnH3ZHq43wu4OVvyppCABfycJn14I0h6rLwOxMqahAcJr8ZBWpFJSCX88Ns/o JFzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686839984; x=1689431984; 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=PJ474ru3Csrr9GZeo5jFdK0acukrlhlJy+sdzWVQnpM=; b=lj+y18u5w6GoG9O0W2fSpIOWvoWrUdM/mz5B8IMGmdQtmjAkxtxT0rzdd/bjItDUQw SAqWKwehU1uZo6RFZMfj8UFCv+4pj78Z20DT3OrEIoi+HqIv46AkvauXvz1LO2gZplNx nn2QgLlpVhy4neXMzRYJvor1XM8w8BFd6ZbmAtFAdq3O1LTxvu9BTxYlnO6EmnByK6NU Qe84BL4AXqqgb9P4LMVjxM7v7jfFWlEf9ItGwCKP5R81iGPpJ+Xr2uTCqznrWtDtCBtV k8GrfWOfoUJPr8h6V837WOWwGaOkkZ9YYKl8oTAuSSOgihvKAJPguZh/ccSdKV12h5zn pwVw== X-Gm-Message-State: AC+VfDxXfZ9oOuQOecXVVhGRsY/kuQ1Hp2UE8evoxJuwjK+opK8l7+Zc uk9GFiS4adxm256PETVvBdhNvznwIoPTmMw8ePVSTg== X-Received: by 2002:ac2:5b89:0:b0:4f6:2477:ed42 with SMTP id o9-20020ac25b89000000b004f62477ed42mr10557853lfn.26.1686839984203; Thu, 15 Jun 2023 07:39:44 -0700 (PDT) Received: from localhost.localdomain (ppp089210114029.access.hol.gr. [89.210.114.29]) by smtp.gmail.com with ESMTPSA id w11-20020a1cf60b000000b003f7ff6b1201sm20601273wmc.29.2023.06.15.07.39.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 07:39:43 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt Subject: [PATCH 1/5] efi_loader: check the status of disconnected drivers Date: Thu, 15 Jun 2023 17:39:37 +0300 Message-Id: <20230615143941.416924-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 efi_uninstall_protocol() calls efi_disconnect_all_drivers() but never checks the return value. Honor that and return an appropriate error if the associated controllers failed to disconnect Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_boottime.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 5006c0e1e4af..68198e6b5ff6 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1353,7 +1353,11 @@ static efi_status_t efi_uninstall_protocol if (r != EFI_SUCCESS) goto out; /* Disconnect controllers */ - efi_disconnect_all_drivers(efiobj, protocol, NULL); + r = efi_disconnect_all_drivers(efiobj, protocol, NULL); + if (r != EFI_SUCCESS) { + r = EFI_DEVICE_ERROR; + goto out; + } /* Close protocol */ list_for_each_entry_safe(item, pos, &handler->open_infos, link) { if (item->info.attributes == From patchwork Thu Jun 15 14:39:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 693007 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d91:0:0:0:0:0 with SMTP id b17csp562519wru; Thu, 15 Jun 2023 07:40:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ53VI48G4d3bwVm4PQkMJIeh5IhJbwGSfAJhtoE5VUfBFP/Bo3hLyrTIbFpQh9HW8Qn1Oho X-Received: by 2002:a17:90a:194b:b0:259:3e7f:c60d with SMTP id 11-20020a17090a194b00b002593e7fc60dmr3710686pjh.3.1686840041409; Thu, 15 Jun 2023 07:40:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686840041; cv=none; d=google.com; s=arc-20160816; b=phQcdJUKKGvLSKDy9SXtl6QMXIw4A3jhAlrjyzINlplNjlfp6NPQ42g7vsUk1R5U3B tpIhiJRKKno6UUDXmsO0BWcdD55McQXVsBv9HFYFHSNjX8Cn/BxqkuEhyizrGHvobR25 xU1J4jjYFGY8bTMWL/txejHQrEuUQhgg2EsaXnw3/drs8QmYywnrfJVb+6W+LncFAUeu LrRq0i1/pRcfLg8/EZHMAM8Lb9pFBYDk9TsAzuSzKiYsPiGZLVMPdF4SmstnpSxAl3q2 DzZss7KOnF8fLaIRl3Yb/az4W0gAFIPfDGsOHgHY8zqMG7AU9MwMKRFCpX5jMs5V4kRA Abeg== 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=CnbZStYkLf9ECvqWuRXKiiZrhgROkdKIkBlm89rxikI=; b=fbwvwbeDI9nBaOweht4hMIYAMDnYkpzLkEsM8MQ+5wzIyamdxY4kQdlhMpPE5KiKhp pjMzVr+K9GdFD6i3mMSWclZRsmAXTAmlI7ZUFnQHmzVxZLLu8SbTLO4s3uPc1YAsktab CrPVmHmCoAvhEvxS0WGZ3Ek2bvJUXEp8mm3TtrmF4Jh5vw1ZcsfGe2ts76LzYp2MTNYn xtqv4BTzcYNK151qb1jis/3V6PgdyV19SGo3fn2MeG4fv1U9B80DNRZODOOmd78r8GwP razGZaASpWBdYeUrSpw0xUy/E2aDN3S1PLDa47/9I+4kUr7BdgKisUZMgUusKXFoAGqU OqGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pzQrAJ3N; 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 w11-20020a17090a528b00b0025998ebdc4csi12770917pjh.60.2023.06.15.07.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 07:40:41 -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=pzQrAJ3N; 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 301458632B; Thu, 15 Jun 2023 16:40:00 +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="pzQrAJ3N"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 09DC4862D4; Thu, 15 Jun 2023 16:39:52 +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-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (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 D6A768631B for ; Thu, 15 Jun 2023 16:39:45 +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-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3f8d5262dc8so7029745e9.0 for ; Thu, 15 Jun 2023 07:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686839985; x=1689431985; 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=CnbZStYkLf9ECvqWuRXKiiZrhgROkdKIkBlm89rxikI=; b=pzQrAJ3NDmZhn/7jkwhU0LDsbQLkw4tqOR9d8Hn0ckCXEcmtOHWqKu6VoL1CkyZKag jWLidf8a8KVYDV0jPWbpvRaQpMA1GJfTO/QdvFvnvEh3sO8QUwwtY6kB2ppO7B/Ur1MH yxxSRwjF//YTcccO9QDLNbV/+hcOfJ8ee5UmJPxOb6CZtDlVjZciqCv3/4FI13m7vl45 iKM1BRJHFgxzbIUPPHDtZb/DTGp68IaxgbEhlpxIm88FnBZ7gonmPiZnoV/iBG6p1vee IS1vKbWDuiaVFhHP6TgBjbbMJqGvstb7VIe8v2fTsH/0QSO60Lc2ulI8WiWFevWseluN H5iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686839985; x=1689431985; 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=CnbZStYkLf9ECvqWuRXKiiZrhgROkdKIkBlm89rxikI=; b=YZSIHp0tpEXPXhyzW6m2svUp2sTO5KjX/KWiCJX64MyfGRxsY1/MEm8F1bEnX0TC0B MNLV2EYvvyrDAPvPUx/g9kBNpXR+q9hBVxLyaGBf6607cuHC33KgZy8hqeyyfBImTE/B OnGUiSy9sahyAgaJNyG1rSr5viS8TIY/PHDL+ITFcYKIE1M/Fdd7QkXZWp61oBgEDOYb 70ZZd5cN3jwWWmGUp6rIL7n8j+Jy+o6daaVf9aN1GE4VTCCpuqRpbNqBPhXB5frY8iZG 2pRkHteTtOY/wjA5zqKcX/wp7QhuJxZudlQFFvdDTooIBHrHnwi7XXIG/mJonCf7AUEW /1Qw== X-Gm-Message-State: AC+VfDzTgYqr1JuCkBwQiOtOsDHElP3f2r3xks+i/R0BNuNk7ufdzv4H nTkIA7jILQXsPnqM89fzRDFjniP2FklEMDY+Lsf64Q== X-Received: by 2002:a05:600c:2197:b0:3f6:d90:3db with SMTP id e23-20020a05600c219700b003f60d9003dbmr4240171wme.3.1686839985263; Thu, 15 Jun 2023 07:39:45 -0700 (PDT) Received: from localhost.localdomain (ppp089210114029.access.hol.gr. [89.210.114.29]) by smtp.gmail.com with ESMTPSA id w11-20020a1cf60b000000b003f7ff6b1201sm20601273wmc.29.2023.06.15.07.39.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 07:39:44 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt Subject: [PATCH 2/5] efi_loader: reconnect drivers on failure Date: Thu, 15 Jun 2023 17:39:38 +0300 Message-Id: <20230615143941.416924-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230615143941.416924-1-ilias.apalodimas@linaro.org> References: <20230615143941.416924-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 efi_disconnect_controller() doesn't reconnect drivers in case of failure. Reconnect the disconnected drivers properly Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_boottime.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 68198e6b5ff6..df675d0ad488 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -97,6 +97,12 @@ static efi_status_t EFIAPI efi_disconnect_controller( efi_handle_t driver_image_handle, efi_handle_t child_handle); +static efi_status_t EFIAPI efi_connect_controller( + efi_handle_t controller_handle, + efi_handle_t *driver_image_handle, + struct efi_device_path *remain_device_path, + bool recursive); + /* Called on every callback entry */ int __efi_entry_check(void) { @@ -1298,7 +1304,7 @@ static efi_status_t efi_disconnect_all_drivers const efi_guid_t *protocol, efi_handle_t child_handle) { - efi_uintn_t number_of_drivers; + efi_uintn_t number_of_drivers, tmp; efi_handle_t *driver_handle_buffer; efi_status_t r, ret; @@ -1308,15 +1314,30 @@ static efi_status_t efi_disconnect_all_drivers return ret; if (!number_of_drivers) return EFI_SUCCESS; - ret = EFI_NOT_FOUND; + + tmp = number_of_drivers; while (number_of_drivers) { - r = EFI_CALL(efi_disconnect_controller( + ret = EFI_CALL(efi_disconnect_controller( handle, driver_handle_buffer[--number_of_drivers], child_handle)); - if (r == EFI_SUCCESS) - ret = r; + if (ret != EFI_SUCCESS) + goto reconnect; } + + free(driver_handle_buffer); + return ret; + +reconnect: + /* Reconnect all disconnected drivers */ + for (; number_of_drivers < tmp; number_of_drivers++) { + r = EFI_CALL(efi_connect_controller(handle, + &driver_handle_buffer[number_of_drivers], + NULL, true)); + if (r != EFI_SUCCESS) + EFI_PRINT("Failed to reconnect controller\n"); + } + free(driver_handle_buffer); return ret; } From patchwork Thu Jun 15 14:39:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 693006 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d91:0:0:0:0:0 with SMTP id b17csp562435wru; Thu, 15 Jun 2023 07:40:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ64y/AqQWQK7Gdk1KJQGfVUvDipN3lsRowsWaUL787r6oi0hmJwNALHSIQDwpsvAtSnIgMg X-Received: by 2002:a05:6a00:1489:b0:666:5fc4:36b1 with SMTP id v9-20020a056a00148900b006665fc436b1mr5538230pfu.26.1686840028570; Thu, 15 Jun 2023 07:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686840028; cv=none; d=google.com; s=arc-20160816; b=FDJUkbxktO4qwbY9Bz0lINWnkO+8wWfFo9CDiPX0M7R6bPTc2fDfMarFjReTt/9KjP zp9w36Zc9q4SSCS6De5JJzjVgqvDOV0ZJh/bPJzpZuuZugqtYn0JyDF32+rRQ5D481lq JOcW0aMtZjpQsh/lYjoYtqrIDYg//tO+V9MYMQWMNtlAGcZNbRrIGXeBZxZaZTiW/tfQ z2rL3xIkfy7Uqq4GvWCfvkbcziAw2Z3+NwMpPxaAFtpR8sll1b+3og++yATtdcNxLPj/ 0EYcR60FEjOkhUOYf5XAaNU/nlVPpYZ2ZWXAsCzTFesyE+IIkrUMnYG9HBeBJd357Z27 mlSA== 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=/7gUZeDCaSwnyQGc96ye3lpyuyVRmtWbUT9YCC9IOaE=; b=is4E0wizlgLhhXtpw9o1L4BVxVvuSgBJC8T11BXxWZuhjaorPKK7+zQsmd4bew4ECv D3fgYDbggHGBIQXpfbGHEn8+91Mxi6/hOt9D47XSn2A8i7FI96VSYipAmKNhu4EE6aH7 pVzTTmvBCAr05KlLXQRyHtce/fO5ij2kCvNLZAOjaOe7jvb0AyLYljy4GBRFNYBg3A2I oL0hvdDsVzegDf6qBn2ZUlFci4zywl9E/cuo2+g6dTUkBGNtGM4LK473tS9RK84ySigL 6LVTS+nrkUY91vchVZYEgjgrI9haUDaqaexYZYVfE9gKOYY3Zy0K9Y+0koRaBqWo/O/0 e9Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SIztQrfn; 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 r26-20020aa79eda000000b00666985d0294si1393669pfq.343.2023.06.15.07.40.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 07:40:28 -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=SIztQrfn; 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 D4A218634C; Thu, 15 Jun 2023 16:39:55 +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="SIztQrfn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 401D286343; Thu, 15 Jun 2023 16:39:50 +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-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) (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 5E4778631F for ; Thu, 15 Jun 2023 16:39:47 +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-x12b.google.com with SMTP id 2adb3069b0e04-4f649db9b25so10555674e87.0 for ; Thu, 15 Jun 2023 07:39:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686839986; x=1689431986; 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=/7gUZeDCaSwnyQGc96ye3lpyuyVRmtWbUT9YCC9IOaE=; b=SIztQrfnv1d42qCn9OFjXdXGL7Rve55PytsXdUf2EdGAGLYLfudwyNpnyBCS0GegVA zV83LYSKrD2fyD3rQGfLjYyf6j+EAmUBHAhngVW+IDhAMIUph0mJxv7RO3y59HYUjfUT GTRlB6T4bzbNT8bSYU7wjmArdN8U9WSawz45lx4h1Wn5BrtuyoIgEIwFkR/IulnO3D7A FVKF4Grf8KshRc0IZ8CFceeCZ/RdqUrqKjzXmt7F79Q7KAby2M/SwKH7TMqiUUitXPLU 9utJ/7rXMqWpdOVqqP/yKqGSM9MSmCK7Dazux3jal8UuXg+0toA3b8UHqpAO4L8E6X4o BYSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686839986; x=1689431986; 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=/7gUZeDCaSwnyQGc96ye3lpyuyVRmtWbUT9YCC9IOaE=; b=K2VVVM6rd2+nYH5tI4u5vlqJwiTMXp+sAkhh0AfwmglU78slP3hCWIMbOck/gLURn8 r3jVSrq+YmlGF28WCVSjXYUL8NVHhfEBt5dyFRV+cTDHTkzvBfpgnM/TdBc7TeDG5GK2 oi43mYH9E2cBfjDBwj5TUIufAvvbW+7nDg2P39gLdtlO3rcH1zgP97UHBbKhw+7qJm/M CkErB0+ZwvJpULylzrJmcS2G/n5nCuScE3pE8Jp7EmUYGQBTHDz/+wMC9LTH7ZLyIh+r h27lwUSZN97emvzOnOwmFAA7CGmhgdwuvPdsgJmxDzCNE106z3hnsvlZh2X9iCf9UGuj 5x3Q== X-Gm-Message-State: AC+VfDxrWYKuhZGprX5oP/5Mhrz518NT3kcTPA2EO+8ZgGdOdvrxajBz gxbFk2GzvcPrS8fB84DBvj7uOHbWtjbWSrIbtC+btQ== X-Received: by 2002:a19:e34f:0:b0:4f6:1c08:e9bb with SMTP id c15-20020a19e34f000000b004f61c08e9bbmr9411871lfk.63.1686839986430; Thu, 15 Jun 2023 07:39:46 -0700 (PDT) Received: from localhost.localdomain (ppp089210114029.access.hol.gr. [89.210.114.29]) by smtp.gmail.com with ESMTPSA id w11-20020a1cf60b000000b003f7ff6b1201sm20601273wmc.29.2023.06.15.07.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 07:39:46 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt Subject: [PATCH 3/5] efi_loader: disconnect all controllers when uninstalling a protocol Date: Thu, 15 Jun 2023 17:39:39 +0300 Message-Id: <20230615143941.416924-3-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230615143941.416924-1-ilias.apalodimas@linaro.org> References: <20230615143941.416924-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 When we are trying to uninstall a protocol interface from a controller handle we are trying to disconnect drivers related to that protocol. However, when we call efi_disconnect_all_drivers() we pass the protocol GUID. If 2 different drivers are using the same protocol interface and one of them can't be stopped (e.g by returning EFI_DEVICE_ERROR) we should stop uninstalling it. Instead of explicitly passing the protocol GUID, pass NULL as an argument. That will force efi_get_drivers() to return all drivers consuming the interface regardless of the protocol GUID. While at it call efi_disconnect_all_drivers() with a handle instead of the efiobj Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_boottime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.39.2 diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index df675d0ad488..b148824c7ec5 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1374,7 +1374,7 @@ static efi_status_t efi_uninstall_protocol if (r != EFI_SUCCESS) goto out; /* Disconnect controllers */ - r = efi_disconnect_all_drivers(efiobj, protocol, NULL); + r = efi_disconnect_all_drivers(handle, NULL, NULL); if (r != EFI_SUCCESS) { r = EFI_DEVICE_ERROR; goto out; From patchwork Thu Jun 15 14:39:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 693005 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d91:0:0:0:0:0 with SMTP id b17csp562316wru; Thu, 15 Jun 2023 07:40:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5/z961uGMRu/NKX/sXLHgCQ52/xOwKHiYUFRC3NnbI2yuyX3suQnpQk4WToP19vmqq6Yrt X-Received: by 2002:a05:6a20:1596:b0:114:7637:3451 with SMTP id h22-20020a056a20159600b0011476373451mr4856735pzj.37.1686840014758; Thu, 15 Jun 2023 07:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686840014; cv=none; d=google.com; s=arc-20160816; b=g3vIhGA0sCd6GJfx7bCGX/d2FcvmTZ2r+Gzar4aYT+HlqoNW4b7cudP+uGnTiGvcVD 3HOzuLxSVRcth7Traq705TqWD0ZfbHrpPMZ7bFs+hCH9XfgwIZl24KsTTVoK0mGD/JDl CubjHaHoU20VU0hoxkon+j9ffq5CqmKnZ0c4Kn4Q1Ab9qYI93KyWocvqBpe1fg29SuKU lKShv/pHEohAx98kfegTTqYGMlrkQpjAEO1UglAunOTphSUXNw0XcBRFqmmff56sn5EZ LvJk3WCeWLvTp+n/SIi9IlwTn20WfDWMMgmP/vsFhn6pJDpxtZUCvJj7M7vni4sNpPtr icaw== 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=L0ujacndcEbKAg1szAWK2bMgGU5ZZjU4DXRkFTiFfjk=; b=bRnINKh1Hbqp6Gb/6Y5N0FtP7fo3zRkjMEfrPry1HwRe9l6L7dOZixCibqHXhkosX9 GXcSfLa5/bTaxkzciyHtNUKAWygdcRtmLz5ttP+TZam+mfDDaTEKMa7W1T+t/lqG3LV3 r94baRe6KPoWiRhMVKEcHuFZaRp4CiOQz1EcDG013xG5jb/ea0Zzk4v2T9SaREWdtDbO OKTSnlFks+rhGxInxATCsqs8ZDCDbzG5XBVWZ/NLrrMZEBjNwL8mmTbK1G86kVfPZKEH GK32dxCiwqloceGEAj2XrwQJ8lXZ2oKUn9HKbR6ujCK7JrIWCykvCA5UaTubCvkFLODM XcbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Iic2j/7t"; 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 a18-20020a637052000000b0053f2c198398si12318661pgn.888.2023.06.15.07.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 07:40:14 -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="Iic2j/7t"; 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 9EB5A8631B; Thu, 15 Jun 2023 16:39: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=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="Iic2j/7t"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1806F862D4; Thu, 15 Jun 2023 16:39:51 +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-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (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 00573862D4 for ; Thu, 15 Jun 2023 16:39:47 +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-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f8d5262dc8so7030075e9.0 for ; Thu, 15 Jun 2023 07:39:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686839987; x=1689431987; 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=L0ujacndcEbKAg1szAWK2bMgGU5ZZjU4DXRkFTiFfjk=; b=Iic2j/7t0SfBW8Y+umSsNDtsV/NMld6SDO+T2RsxvC4WzIrjS8MakNxl3L9V3ys24P gI21yGN939AkYaDQa9w79IqMHkNPqZF6Ip8dHt9GYT3dAzNuZeGO+iwS7O7qeZKeawJq BZKMnS3LAs/lnCJ/gSKTtxg679xgTTCkZwiLprw5NlSfte3Q2NhkKML5CjC3dC0kc3rM 1w+2vPybTr3bpo/9yTVXjoNoJTo8kFYas9N3F0NQ3FrgudZN3/AxqlhTU0UPDixd4W0l urHqlk2mS7m3ftmOwiQtgS++JOp+vlI+cSKbLMHo6izmuLWQUukhHi9jgbvlGvstHd1D XkwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686839987; x=1689431987; 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=L0ujacndcEbKAg1szAWK2bMgGU5ZZjU4DXRkFTiFfjk=; b=VIfk25P8SRi8J1Mu7qtivDWdZVB9ewfK5P0AND/p5msJPv/XdSv/hBbun7fExk1vgr GfLnK1orbq6JyIvNt1VuXDAHIOimJUVad8SN0TgGvQIp/LImOrlX+m0CvvSHL6Pm3goh bi3YcbckYfKDEGpVTu5aKIybYgPnFcNKEFYPFbWkvQVtiE4y1WWlRz2hZIGhFS6Gs+Pm wyjyI4BmmclXxMvyyCWoLmPoVJFmvKw73EZT1RSxFCgKu6x/dzpQTwaRhiIH6GkO+LGQ Ui33IID+hCUtjgO3ekzqiBERMCyuhga9wul5kESnXtMYFfOhcWpswBRUYtOSCcANOpl8 EMYQ== X-Gm-Message-State: AC+VfDy3KhGhJVyIrxtzK6DPwVq0Ox2vEZoEj/QjCizQ6jDtwLnV+jkc 23MxQwvxFINIZT84MzK5SZR1ykmSILkR/AmihyJVmw== X-Received: by 2002:a05:600c:3659:b0:3f7:aee8:c23a with SMTP id y25-20020a05600c365900b003f7aee8c23amr4357523wmq.19.1686839987439; Thu, 15 Jun 2023 07:39:47 -0700 (PDT) Received: from localhost.localdomain (ppp089210114029.access.hol.gr. [89.210.114.29]) by smtp.gmail.com with ESMTPSA id w11-20020a1cf60b000000b003f7ff6b1201sm20601273wmc.29.2023.06.15.07.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 07:39:47 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt Subject: [PATCH 4/5] efi_loader: fix the return codes of UninstallProtocol Date: Thu, 15 Jun 2023 17:39:40 +0300 Message-Id: <20230615143941.416924-4-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230615143941.416924-1-ilias.apalodimas@linaro.org> References: <20230615143941.416924-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 Up to now we did not check the return value of DisconnectController. A previous patch is fixing that taking into account what happened during the controller disconnect. But that check takes place before our code is trying to figure out if the interface exists to begin with. In case a driver is not allowed to unbind -- e.g returning EFI_DEVICE_ERROR, we will end up returning that error instead of EFI_NOT_FOUND. Add an extra check on the top of the function to make sure the protocol interface exists before trying to disconnect any drivers Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_boottime.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index b148824c7ec5..d6d52d4bbac8 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1373,6 +1373,8 @@ static efi_status_t efi_uninstall_protocol r = efi_search_protocol(handle, protocol, &handler); if (r != EFI_SUCCESS) goto out; + if (handler->protocol_interface != protocol_interface) + return EFI_NOT_FOUND; /* Disconnect controllers */ r = efi_disconnect_all_drivers(handle, NULL, NULL); if (r != EFI_SUCCESS) { From patchwork Thu Jun 15 14:39:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 693008 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d91:0:0:0:0:0 with SMTP id b17csp562623wru; Thu, 15 Jun 2023 07:40:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5HTPo/bpwMHZSl66mcX2jc7NMfPckQDm+HpwGfcrt3VLCQ5mtXr66+u4OpXbJvCjwu+wFS X-Received: by 2002:a17:90a:4592:b0:256:d4a:ea4c with SMTP id v18-20020a17090a459200b002560d4aea4cmr4198674pjg.30.1686840055118; Thu, 15 Jun 2023 07:40:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686840055; cv=none; d=google.com; s=arc-20160816; b=YGGC20jnqSglyEYqmnsnlvGUkmCpx0NTuQ/4cyxAWnovrYchdCMDGAuBNhrBalaZJX X0ceqh3H7R5ZG8GQoMwlXbGVEiSw2zobssFBnke4+v3AF9n1ZAV5R3o/OlZWx8egr7mM QnDT8Z1FwjtmEf8wU7SxSci+lGALun4ElSXMLc2jgSt8Au8c5laZFdRRy3sDcGLcJHEY PJX9WlAYk0PqZlTeH06y2624x7+rWDxEynOP8aNxD/EVo7W8rRgTqQfr6WHD693mx6xa HtFWDi2B+zu5XTmDx9FsrSomZ4PWRwcH8OX89Z5iF28m6Gg3cY/I1jYGsFiWCMrBxu13 P5Bg== 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=61ie7ffeZLDrV/rQmRkAKeKsA9nIScFTAiCEvUN1jVc=; b=Jb3EbJcKfXo0fNm6hz2rxl5HjwwdBvuSk05eqNrSEkAgwfVf5v3cGwR2hlfW+F4yJN rEToJPI3jgoeZ2DgrTNL/Na5wsjHGYXNudls6RBrYxU+BerDBCBUmNFDwo6QLJ84dYcJ M+hQr2fxu50QymBjNlZsBP9xN2iv0DEWtpcKbgvyLQ1vjcO9LHAidLu5dSYtJlCUuxsI ELE6dDlW/0YdBPk0PT/DK34oZVpIhjbW5a6UimWBEHqteTEazzi6VXGRej9S5tZuh7Ae YS9sxb+d3X2n8AMMq9RCbvT1D9JdRQU8gB4PX7al7lO+mFE4uwd7GAgMizEzUtOWl4Vq /QRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pEemA3lA; 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 x16-20020a17090a789000b00253160141c7si9764615pjk.83.2023.06.15.07.40.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 07:40:55 -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=pEemA3lA; 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 061CA8636A; Thu, 15 Jun 2023 16:40:06 +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="pEemA3lA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9F18B8631F; Thu, 15 Jun 2023 16:39:54 +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-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) (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 D6CB286322 for ; Thu, 15 Jun 2023 16:39:48 +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-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f8d0e814dfso17751315e9.3 for ; Thu, 15 Jun 2023 07:39:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686839988; x=1689431988; 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=61ie7ffeZLDrV/rQmRkAKeKsA9nIScFTAiCEvUN1jVc=; b=pEemA3lAagUcNAWb4QqYOPDuMKJNmCoLW0qFNbBGg6oPYgpYtEHwFWj46EwufABLbp fJZ6Hy36PIpYclj94qStXXhReklbZ1v9vI7zue7G3H6GHCHeFFC+3y+SuVHKoLeKbewD NbBNoQAqqojfrFINQOWCMAQLEd69jOPpNUxd2NQvAAkJ0VA6I3iQE0Nk8iwd3gRj8shr SkN6HhLc7BRZfhF4CjBHXYShh9wALr3vNVXENR0YL4tmHWnrU7wVBwQ+Q4yQ7xo77oUb FtqZTTVikdFW/ZweK6JDj6UHW9H7WAXPvBklDc7SLFy3gqQeQXDXmc1Jo9EL2LFSIVVh fwZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686839988; x=1689431988; 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=61ie7ffeZLDrV/rQmRkAKeKsA9nIScFTAiCEvUN1jVc=; b=f9mWWJebta840cEUXV+UDqohE6JGhcSsLBRJWEK3zyq3ZdYpgRXLcFbmDfLdfL8KQo 5IxgooXV0h9lOVBmjy2gN4I2gjk55gLOXkip7ITqFTfbCLt0DqUK3iKSvyHEeEBAhxLn ctOBNws3p7Pcui1b3oUuX2zRP8JQbLAK+cTDa6p09PZk4csGt1d1QpMeqYCTjNw0VPAz C6Ui/JaKwrpMZn7leRRbltvOYF3rqQy5vfOPQWQF6DYpnps1iL6CjfR20uqVzqBmD2Hl 3katfIM8mmNnx0UQlX6YWxDLqTlM1a4CN/GfoJKOw/agxjKNxQYPIJlnrsqc7ucc1FLJ 99Iw== X-Gm-Message-State: AC+VfDzUTI25Q/5sgM1xp09x2fqLoYce2Q7/P2q6scpjdRaPzApsiaG3 i9Im1RxEkqUYrUcNMbFMqIIdRFWXw2AiJrhD6MTtAg== X-Received: by 2002:a05:600c:a3a9:b0:3f8:d79f:dadb with SMTP id hn41-20020a05600ca3a900b003f8d79fdadbmr4275708wmb.38.1686839988365; Thu, 15 Jun 2023 07:39:48 -0700 (PDT) Received: from localhost.localdomain (ppp089210114029.access.hol.gr. [89.210.114.29]) by smtp.gmail.com with ESMTPSA id w11-20020a1cf60b000000b003f7ff6b1201sm20601273wmc.29.2023.06.15.07.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 07:39:48 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt Subject: [PATCH 5/5] efi_selftests: add extra testcases on controller handling Date: Thu, 15 Jun 2023 17:39:41 +0300 Message-Id: <20230615143941.416924-5-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230615143941.416924-1-ilias.apalodimas@linaro.org> References: <20230615143941.416924-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 We recently fixed a few issues wrt to controller handling. Add a few test cases to cover the new code. - add a second driver in the same controller handle which will refuse to unbind on the first protocol removal - add tests to verify controllers are reconnected when uninstalling a protocol fails - add tests to make sure EFI_NOT_FOUND is returned if a non existent interface is being removed Signed-off-by: Ilias Apalodimas --- lib/efi_selftest/efi_selftest_controllers.c | 221 ++++++++++++++++++-- 1 file changed, 198 insertions(+), 23 deletions(-) diff --git a/lib/efi_selftest/efi_selftest_controllers.c b/lib/efi_selftest/efi_selftest_controllers.c index 79bc86fb0c3a..d2a974079329 100644 --- a/lib/efi_selftest/efi_selftest_controllers.c +++ b/lib/efi_selftest/efi_selftest_controllers.c @@ -13,6 +13,8 @@ #include #define NUMBER_OF_CHILD_CONTROLLERS 4 +#define CONTROLLER1_DRIVERS (1 + NUMBER_OF_CHILD_CONTROLLERS) +#define CONTROLLER2_DRIVERS 1 static int interface1 = 1; static int interface2 = 2; @@ -22,24 +24,32 @@ const efi_guid_t guid_driver_binding_protocol = static efi_guid_t guid_controller = EFI_GUID(0xe6ab1d96, 0x6bff, 0xdb42, 0xaa, 0x05, 0xc8, 0x1f, 0x7f, 0x45, 0x26, 0x34); + +static efi_guid_t guid_controller2 = + EFI_GUID(0xe6ab1d96, 0x6bff, 0xdb42, + 0xaa, 0x50, 0x8c, 0xf1, 0xf7, 0x54, 0x62, 0x43); + static efi_guid_t guid_child_controller = EFI_GUID(0x1d41f6f5, 0x2c41, 0xddfb, 0xe2, 0x9b, 0xb8, 0x0e, 0x2e, 0xe8, 0x3a, 0x85); static efi_handle_t handle_controller; static efi_handle_t handle_child_controller[NUMBER_OF_CHILD_CONTROLLERS]; static efi_handle_t handle_driver; +static efi_handle_t handle_driver2; + +static bool allow_remove; /* - * Count child controllers + * Count controllers * - * @handle handle on which child controllers are installed + * @handle handle on which controllers and children are installed * @protocol protocol for which the child controllers were installed * @count number of child controllers + * @children: count children only * Return: status code */ -static efi_status_t count_child_controllers(efi_handle_t handle, - efi_guid_t *protocol, - efi_uintn_t *count) +static efi_status_t count_controllers(efi_handle_t handle, efi_guid_t *protocol, + efi_uintn_t *count, bool children) { efi_status_t ret; efi_uintn_t entry_count; @@ -52,10 +62,14 @@ static efi_status_t count_child_controllers(efi_handle_t handle, return ret; if (!entry_count) return EFI_SUCCESS; - while (entry_count) { - if (entry_buffer[--entry_count].attributes & - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) - ++*count; + if (!children) { + *count = entry_count; + } else { + while (entry_count) { + if (entry_buffer[--entry_count].attributes & + EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) + ++*count; + } } ret = boottime->free_pool(entry_buffer); if (ret != EFI_SUCCESS) @@ -153,6 +167,22 @@ static efi_status_t EFIAPI start( return EFI_ST_FAILURE; } } + + /* Attach driver to controller */ + ret = boottime->open_protocol(controller_handle, &guid_controller2, + &interface, handle_driver2, + controller_handle, + EFI_OPEN_PROTOCOL_BY_DRIVER); + switch (ret) { + case EFI_SUCCESS: + return EFI_SUCCESS; + case EFI_ALREADY_STARTED: + case EFI_ACCESS_DENIED: + return ret; + default: + return EFI_UNSUPPORTED; + } + return ret; } @@ -249,6 +279,50 @@ static efi_status_t EFIAPI stop( return EFI_SUCCESS; } +/* + * Check if the driver supports the controller. + * + * @this driver binding protocol + * @controller_handle handle of the controller + * @remaining_device_path path specifying the child controller + * Return: status code + */ +static efi_status_t EFIAPI supported2(struct efi_driver_binding_protocol *this, + efi_handle_t controller_handle, + struct efi_device_path *remaining_dp) +{ + return EFI_SUCCESS; +} + +/* + * Refuse to disconnect the controller. + * + * @this driver binding protocol + * @controller_handle handle of the controller + * @number_of_children number of child controllers to remove + * @child_handle_buffer handles of the child controllers to remove + * Return: status code + */ +static efi_status_t EFIAPI stop2(struct efi_driver_binding_protocol *this, + efi_handle_t controller_handle, + size_t number_of_children, + efi_handle_t *child_handle_buffer) +{ + efi_status_t ret; + + if (!allow_remove) + return EFI_DEVICE_ERROR; + + /* Detach driver from controller */ + ret = boottime->close_protocol(controller_handle, &guid_controller2, + handle_driver2, controller_handle); + if (ret != EFI_SUCCESS) { + efi_st_error("Cannot close protocol\n"); + return ret; + } + return EFI_SUCCESS; +} + /* Driver binding protocol interface */ static struct efi_driver_binding_protocol binding_interface = { supported, @@ -259,6 +333,15 @@ static struct efi_driver_binding_protocol binding_interface = { NULL, }; +static struct efi_driver_binding_protocol binding_interface2 = { + supported2, + start, + stop2, + 0xffffffff, + NULL, + NULL, + }; + /* * Setup unit test. * @@ -273,6 +356,18 @@ static int setup(const efi_handle_t img_handle, boottime = systable->boottime; handle_controller = NULL; handle_driver = NULL; + handle_driver2 = NULL; + allow_remove = false; + + /* Create controller handles */ + ret = boottime->install_protocol_interface(&handle_controller, + &guid_controller2, + EFI_NATIVE_INTERFACE, + &interface1); + if (ret != EFI_SUCCESS) { + efi_st_error("InstallProtocolInterface failed\n"); + return EFI_ST_FAILURE; + } /* Create controller handle */ ret = boottime->install_protocol_interface( @@ -291,6 +386,16 @@ static int setup(const efi_handle_t img_handle, return EFI_ST_FAILURE; } + /* Create driver handle which will fail on stop() */ + ret = boottime->install_protocol_interface(&handle_driver2, + &guid_driver_binding_protocol, + EFI_NATIVE_INTERFACE, + &binding_interface2); + if (ret != EFI_SUCCESS) { + efi_st_error("InstallProtocolInterface failed\n"); + return EFI_ST_FAILURE; + } + return EFI_ST_SUCCESS; } @@ -310,7 +415,7 @@ static int setup(const efi_handle_t img_handle, */ static int execute(void) { - efi_status_t ret; + efi_status_t ret = EFI_SUCCESS; efi_uintn_t count; /* Connect controller to driver */ @@ -319,9 +424,79 @@ static int execute(void) efi_st_error("Failed to connect controller\n"); return EFI_ST_FAILURE; } + /* Check number of drivers */ + ret = count_controllers(handle_controller, &guid_controller2, + &count, false); + if (ret != EFI_SUCCESS || count != CONTROLLER2_DRIVERS) { + efi_st_error("Failed to connect controller\n"); + return EFI_ST_FAILURE; + } + ret = count_controllers(handle_controller, &guid_controller, + &count, false); + if (ret != EFI_SUCCESS || count != CONTROLLER1_DRIVERS) { + efi_st_error("Failed to connect controller\n"); + return EFI_ST_FAILURE; + } + + /* Try to uninstall controller protocol which doesn't exist */ + ret = boottime->uninstall_protocol_interface(handle_controller, + &guid_controller2, + &interface2); + if (ret != EFI_NOT_FOUND) { + efi_st_error("Interface not checked when uninstalling protocol\n"); + return EFI_ST_FAILURE; + } + + /* Try to uninstall controller protocol which can't be stopped */ + ret = boottime->uninstall_protocol_interface(handle_controller, + &guid_controller, + &interface1); + if (ret != EFI_DEVICE_ERROR) { + efi_st_error("EFI_DRIVER_BINDING_PROTOCOL.Stop() not checked\n"); + return EFI_ST_FAILURE; + } + /* Check number of drivers again to make sure controolers reconnected */ + ret = count_controllers(handle_controller, &guid_controller2, + &count, false); + if (ret != EFI_SUCCESS || count != CONTROLLER2_DRIVERS) { + efi_st_error("Failed to reconnect controller\n"); + return EFI_ST_FAILURE; + } + ret = count_controllers(handle_controller, &guid_controller, + &count, false); + if (ret != EFI_SUCCESS || count != CONTROLLER1_DRIVERS) { + efi_st_error("Failed to reconnect controller\n"); + return EFI_ST_FAILURE; + } + + /* Try to uninstall controller protocol which can't be stopped */ + ret = boottime->uninstall_protocol_interface(handle_controller, + &guid_controller2, + &interface1); + if (ret != EFI_DEVICE_ERROR) { + efi_st_error("EFI_DRIVER_BINDING_PROTOCOL.Stop() not checked\n"); + return EFI_ST_FAILURE; + } + + /* Check number of drivers again to make sure controllers reconnected */ + ret = count_controllers(handle_controller, &guid_controller2, + &count, false); + if (ret != EFI_SUCCESS || count != CONTROLLER2_DRIVERS) { + efi_st_error("Failed to reconnect controller\n"); + return EFI_ST_FAILURE; + } + ret = count_controllers(handle_controller, &guid_controller, + &count, false); + if (ret != EFI_SUCCESS || count != CONTROLLER1_DRIVERS) { + efi_st_error("Failed to reconnect controller\n"); + return EFI_ST_FAILURE; + } + + allow_remove = true; + /* Check number of child controllers */ - ret = count_child_controllers(handle_controller, &guid_controller, - &count); + ret = count_controllers(handle_controller, &guid_controller, + &count, true); if (ret != EFI_SUCCESS || count != NUMBER_OF_CHILD_CONTROLLERS) { efi_st_error("Number of children %u != %u\n", (unsigned int)count, NUMBER_OF_CHILD_CONTROLLERS); @@ -335,8 +510,8 @@ static int execute(void) return EFI_ST_FAILURE; } /* Check number of child controllers */ - ret = count_child_controllers(handle_controller, &guid_controller, - &count); + ret = count_controllers(handle_controller, &guid_controller, + &count, true); if (ret != EFI_SUCCESS || count != NUMBER_OF_CHILD_CONTROLLERS - 1) { efi_st_error("Destroying single child controller failed\n"); return EFI_ST_FAILURE; @@ -348,8 +523,8 @@ static int execute(void) return EFI_ST_FAILURE; } /* Check number of child controllers */ - ret = count_child_controllers(handle_controller, &guid_controller, - &count); + ret = count_controllers(handle_controller, &guid_controller, + &count, true); if (ret != EFI_SUCCESS || count) { efi_st_error("Destroying child controllers failed\n"); return EFI_ST_FAILURE; @@ -362,8 +537,8 @@ static int execute(void) return EFI_ST_FAILURE; } /* Check number of child controllers */ - ret = count_child_controllers(handle_controller, &guid_controller, - &count); + ret = count_controllers(handle_controller, &guid_controller, + &count, true); if (ret != EFI_SUCCESS || count != NUMBER_OF_CHILD_CONTROLLERS) { efi_st_error("Number of children %u != %u\n", (unsigned int)count, NUMBER_OF_CHILD_CONTROLLERS); @@ -387,8 +562,8 @@ static int execute(void) return EFI_ST_FAILURE; } /* Check number of child controllers */ - ret = count_child_controllers(handle_controller, &guid_controller, - &count); + ret = count_controllers(handle_controller, &guid_controller, + &count, true); if (ret != EFI_SUCCESS || count != NUMBER_OF_CHILD_CONTROLLERS) { efi_st_error("Number of children %u != %u\n", (unsigned int)count, NUMBER_OF_CHILD_CONTROLLERS); @@ -402,14 +577,13 @@ static int execute(void) return EFI_ST_FAILURE; } /* Check number of child controllers */ - ret = count_child_controllers(handle_controller, &guid_controller, - &count); + ret = count_controllers(handle_controller, &guid_controller, + &count, true); if (ret == EFI_SUCCESS || count != 0) { efi_st_error("Uninstall failed\n"); return EFI_ST_FAILURE; } - return EFI_ST_SUCCESS; } @@ -420,6 +594,7 @@ static int execute(void) static int teardown(void) { efi_status_t ret; + /* Uninstall binding protocol */ ret = boottime->uninstall_protocol_interface(handle_driver, &guid_driver_binding_protocol,