From patchwork Wed Dec 7 15:30:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 631554 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp336942pvb; Wed, 7 Dec 2022 07:30:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf4USoUe9z5T9bmUeqIhBvtmfu+oaEc/tzFMegqNm/wnRvp0nSKAFMxt7lCCArpSJYik5hO2 X-Received: by 2002:a02:6309:0:b0:375:4dbf:6ca4 with SMTP id j9-20020a026309000000b003754dbf6ca4mr32231821jac.315.1670427032205; Wed, 07 Dec 2022 07:30:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670427032; cv=none; d=google.com; s=arc-20160816; b=Qesr61O8m2MK6189rOJYzDQ8GWajtFVR5PHV+12j6GHq+sYse/KB5vvEKMfw+kYww4 kCvkRlHGA2wWROusoDZuYFlOt2Tr5uOaOZlscTCfDL0CmjxMIp4eA6SI1bRJbWUNG/dw RYhICbgol/uRKWRnBPuRBl2lzvpa8yn5/48fmfDWC7JYFnUZTRz4MdO+pkHrgX1AuNdq 9qxkFgTLPECTl0muW46KHcazH9fuQOluf8EJppp1N8CbhCmEKL/NAuXm67htSrlEfaGm IbvnV5iRWKTIuA046DzJIRL8t4I3IeCAgwTvLC4ttmT0gPjQCOrUpboHpjryA1NOZOa3 sX9A== 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=OF2lyMQ621BtVhwtq2IFwKZ0UXjmF0nM+dr1hoVu2uU=; b=FfcZsVpA+qvhfIps9C2bx8KfEnMm9KOYOi5SZu4u9QwYrOH27OvTf6acuqYfv8sXhG 36buSu1ixc0vGW8YGQbdqcgzS5MfTnouhvWPeBML1ylxGx1e1Fquor9lr/ZuXtaGOQ7A WaJTV231Hs72XcvbC3xzswpIdgmm1X6zlaXkllcAxIOMRhj7SN1KPab/xrE2Kk/eSHTj bPoF+7dqk4bO/6890c4e4Gn1WIKbnAXKznACbElA18QFfD04IMAqcf+65vkeyuD95pZ6 FSW9UPHih1yCKYxaehnkl7bRK7H0VfSujRjGyS0uEu7Fa9H/oAYBkNrOHh1BTnjb4T9z rHAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vHMWW74f; 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 l2-20020a056e021c0200b00300e56f28b9si9679646ilh.139.2022.12.07.07.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 07:30:32 -0800 (PST) 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=vHMWW74f; 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 A44268556A; Wed, 7 Dec 2022 16:30:15 +0100 (CET) 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="vHMWW74f"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D24658556A; Wed, 7 Dec 2022 16:30:13 +0100 (CET) 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-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) (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 AE57384FB4 for ; Wed, 7 Dec 2022 16:30:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=etienne.carriere@linaro.org Received: by mail-wr1-x433.google.com with SMTP id w15so28576989wrl.9 for ; Wed, 07 Dec 2022 07:30:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=OF2lyMQ621BtVhwtq2IFwKZ0UXjmF0nM+dr1hoVu2uU=; b=vHMWW74fxDheESxKdhuiDmO9ifTyh8r6EszAtGyjYwTQ1SJuSLa6ofOzolkYCd12FW oR6e9mpBJdpOOjUHwV5APnYjxKMeqr0ZboIpb47ZvpqxQeq6yOlQ+toH28j+6XzkUSAt /DVrOeXlpbfG4/afow2RZmIkUa8Bn2a/5J044QsMXJs/0qJG6/kMclICwnCuli0/q51r SfT2C1kwRwAU5jIguTvl0h5erEW3PnXTC+83Kunjh4laK5IdUG5fRLms5SFcAn24WvGi GgY1ku3LPYJIIL72Mtm5iMEcu1e8Qn+rnQ3xD7yRZcyodm6rXgcMoVQrKPPDhnY6awi9 DtVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=OF2lyMQ621BtVhwtq2IFwKZ0UXjmF0nM+dr1hoVu2uU=; b=mI/kcRtLEDYDJlh/5vp8xKXMc5GDpGtEb6cLFMW9rVI7DmC9f2uoF+SKx3esFmyala H7ZJ6l2g9SQMxgm2N1oUaPVIWnnnf+Eo/wEhWCzbSHeMw3XL6+EePHhBoSXpGBE7FzKW uFxK60hbeVP+cgQVSLv3TsPedVBJj4/Kc4WqekBU4amL0zWvo9cQbCVN3UGzSd1JRpuL f02+L4HLcPdAzcmLaTSjSYKYGz9wvsae/62QZNLLh9x2Nlpc+1yjv2g7dULaTo2KluIo 9d/D8YhMokwQBTT7HcO0hFDzYLTxEgD6GJbdWNigxVYDp/ln2Eg1X964RVu87fyX+mAa 33Lg== X-Gm-Message-State: ANoB5pmgBmiNgRtrrYGs7zFcwJDdn+hfnS/gLRLGFK/DMguL+Vf0nFAx BgkUC0N36W3vLLNPJSaL2D8KsqGgjUrYLE3p X-Received: by 2002:adf:f910:0:b0:241:65d4:8bab with SMTP id b16-20020adff910000000b0024165d48babmr356393wrr.54.1670427008947; Wed, 07 Dec 2022 07:30:08 -0800 (PST) Received: from lmecxl1178.lme.st.com ([80.215.162.103]) by smtp.gmail.com with ESMTPSA id l2-20020a5d6742000000b0024216d2e386sm19411957wrw.16.2022.12.07.07.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 07:30:08 -0800 (PST) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Jens Wiklander , Patrick Delaunay , Etienne Carriere Subject: [PATCH 2/2] tee: optee: discover services dependent on tee-supplicant Date: Wed, 7 Dec 2022 16:30:00 +0100 Message-Id: <20221207153000.534581-2-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221207153000.534581-1-etienne.carriere@linaro.org> References: <20221207153000.534581-1-etienne.carriere@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.6 at phobos.denx.de X-Virus-Status: Clean Makes OP-TEE to enumerate also services depending on tee-supplicant support in U-Boot. This change allows OP-TEE services like fTPM TA to be discovered and get a TPM device registered in U-Boot. Signed-off-by: Etienne Carriere Reviewed-by: Ilias Apalodimas Reviewed-by: Jens Wiklander Reviewed-by: Patrick Delaunay --- drivers/tee/optee/core.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index 604fd1414f..b21031d7d8 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -102,13 +102,14 @@ static int bind_service_list(struct udevice *dev, struct tee_shm *service_list, return 0; } -static int __enum_services(struct udevice *dev, struct tee_shm *shm, size_t *shm_size, u32 tee_sess) +static int __enum_services(struct udevice *dev, struct tee_shm *shm, size_t *shm_size, u32 tee_sess, + unsigned int pta_cmd) { struct tee_invoke_arg arg = { }; struct tee_param param = { }; int ret = 0; - arg.func = PTA_CMD_GET_DEVICES; + arg.func = pta_cmd; arg.session = tee_sess; /* Fill invoke cmd params */ @@ -118,7 +119,7 @@ static int __enum_services(struct udevice *dev, struct tee_shm *shm, size_t *shm ret = tee_invoke_func(dev, &arg, 1, ¶m); if (ret || (arg.ret && arg.ret != TEE_ERROR_SHORT_BUFFER)) { - dev_err(dev, "PTA_CMD_GET_DEVICES invoke function err: 0x%x\n", arg.ret); + dev_err(dev, "Enumeration command 0x%x failed: 0x%x\n", pta_cmd, arg.ret); return -EINVAL; } @@ -127,12 +128,13 @@ static int __enum_services(struct udevice *dev, struct tee_shm *shm, size_t *shm return 0; } -static int enum_services(struct udevice *dev, struct tee_shm **shm, size_t *count, u32 tee_sess) +static int enum_services(struct udevice *dev, struct tee_shm **shm, size_t *count, u32 tee_sess, + unsigned int pta_cmd) { size_t shm_size = 0; int ret; - ret = __enum_services(dev, NULL, &shm_size, tee_sess); + ret = __enum_services(dev, NULL, &shm_size, tee_sess, pta_cmd); if (ret) return ret; @@ -142,7 +144,7 @@ static int enum_services(struct udevice *dev, struct tee_shm **shm, size_t *coun return ret; } - ret = __enum_services(dev, *shm, &shm_size, tee_sess); + ret = __enum_services(dev, *shm, &shm_size, tee_sess, pta_cmd); if (!ret) *count = shm_size / sizeof(struct tee_optee_ta_uuid); @@ -174,20 +176,32 @@ static int bind_service_drivers(struct udevice *dev) struct tee_shm *service_list = NULL; size_t service_count; u32 tee_sess; - int ret; + int ret, ret2; ret = open_enum_session(dev, &tee_sess); if (ret) return ret; - ret = enum_services(dev, &service_list, &service_count, tee_sess); + ret = enum_services(dev, &service_list, &service_count, tee_sess, + PTA_CMD_GET_DEVICES); if (!ret) ret = bind_service_list(dev, service_list, service_count); tee_shm_free(service_list); + + ret2 = enum_services(dev, &service_list, &service_count, tee_sess, + PTA_CMD_GET_DEVICES_SUPP); + if (!ret2) + ret2 = bind_service_list(dev, service_list, service_count); + + tee_shm_free(service_list); + tee_close_session(dev, tee_sess); - return ret; + if (ret) + return ret; + + return ret2; } /**