From patchwork Tue Aug 23 08:11:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 599459 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp2259373mae; Tue, 23 Aug 2022 01:11:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR4LBKAehGS1tnJYTq00WPx3UYl/ZeMnCsQ9CIpZfjqyHMdtFQMw4RHVzZr13F4g0jg0/qQr X-Received: by 2002:a05:6402:4383:b0:446:d6ac:bddd with SMTP id o3-20020a056402438300b00446d6acbdddmr2626019edc.283.1661242311725; Tue, 23 Aug 2022 01:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661242311; cv=none; d=google.com; s=arc-20160816; b=q2goNEW/etlL2o1vyyo1xsE4PTBWw/Eyd0y6Ym8G3lHvxm37uERrPapoLkz8/KQVtP y3DePwiUrL6nbTLUJB+xkGwYN8bveXMPk+xX9TeoLWt3RPU8lmLlsXViUQwIQ5+2U7Bt /Z99hN9hCMNtn9Njws1GfiK+UOdEMUn2jJqjJwMoktBfdbqkZEWZ1BxanrcKDe4wv0Z1 IkCRJwkAWgnQgHEKAwsId6AwDbMP1eT8Z+7lZbENC5WJBTffgLUvnVkF9ely3mEcHHaN 0CloyQc5h6FHdKjhsDMHD/9R+FsDOAlIMp2etfo0monqq6BH8z5jKxBP16/H+gLt7LQ4 DrWg== 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=319BkTwe3PewIvI0w68OeldaYSRIa1u/fWOah4u4CAQ=; b=YexWAXLWoJiXnaxm13RWgxsZniy7EvBCNisxGc82P2C3HwuIyN2+ckKXf1OkyW5f0j cAGAektlUd80pFGmA2VNkbH2sjo4yclYqLmqQEcsTl+n6E7BKe0hNJ1rlfBTkr+107g5 0PDFW+0TfarrjfS8tZj0dJvibFurlC++YZUrf8J8X0rbN5FPo2Zj4qbhAaaObdqQThcf fWGPsTf7uzU5obnmfMeKr8zLPWCpQIpaqNYT3QrqapyHv48q78+0nGKAumh09IIsgZfo fc+9uFjJFZJbcJ2voRZIkYVsWTEd1H95isDJ/oOO3q1p4Zwdxk0vGLlwDx/4jl/60zgu pyJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=joUHA3FR; 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 d4-20020a50f684000000b0043d356e02fbsi1514442edn.527.2022.08.23.01.11.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 01:11:51 -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=joUHA3FR; 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 44AA4845ED; Tue, 23 Aug 2022 10:11:50 +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="joUHA3FR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8AC058460D; Tue, 23 Aug 2022 10:11:48 +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-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) (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 2EA54845B0 for ; Tue, 23 Aug 2022 10:11:46 +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-ej1-x636.google.com with SMTP id h22so15599198ejk.4 for ; Tue, 23 Aug 2022 01:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=319BkTwe3PewIvI0w68OeldaYSRIa1u/fWOah4u4CAQ=; b=joUHA3FR0LVw2E7uMN9UTUdclT/P3UP5Ybb1WuC+P99JO+M64FmFWFF34Ch2fBrTLd 7jjA9RMQmpUMjLnlsA9fgz/4AAH89C+N4mJnCi8NBDLuWUpPr4Co6j+Gpsb2+wh5y52M f9V+4E2HTBIv1SUBu+dJsYbjMETraWi9g3u5NATWe5o6lg645ClaE8XLgkMHysOQg8J1 8sGbCphlXrWYZEtTEaZnDjZuOCKLpYA3rzZZhQe6dYG1jyjE46tEouy3Hpf3MyiE+ZjX 3EOm7U6hVIE5jpw7jAZiyS+Q5852ocuDc38D246KPWoxYxo96rK+y1hy5Xto+87jbNPl xZuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=319BkTwe3PewIvI0w68OeldaYSRIa1u/fWOah4u4CAQ=; b=GDnuYV0TP7BQxZETHhro/vFrcVGogVZhCmubkz5J2jANg1YYeYr4kq8fxOUQG2nVhd g1szuBIU/npWYTutqa463oofsAxHqrF3eNRbiiCr7HgmSzj8EguNu7P3FV/nyPqhyvqk Gv0BdqWhlDN8b2H4034t2FRxsM72j4WsIIe9b3XFzl8eUbCb5S4z7od3PKCmuhvMoSni efP/uaqb1J39Hfnn2fEdLcQiPpCgjPNZjVVVZid8D0s7yPtgNikrXYW5GOnykpb2Cgq0 dBL+lBnSRei9WcOZESYT+ybcsMbD7is7yjYS+lbVQpuvrTuJCZrFUU3MFrFN9QRHpFI+ jbgA== X-Gm-Message-State: ACgBeo0X4YzlHepZ1lQrTGeYOcgQnsMZR9hFY3md6i1CoB4TRpvl5sQD TUbypaiXx5dyNlxqNi2AgBvdyzd6+Xe6AA== X-Received: by 2002:a17:907:3e07:b0:73d:760d:3e01 with SMTP id hp7-20020a1709073e0700b0073d760d3e01mr7090791ejc.136.1661242305723; Tue, 23 Aug 2022 01:11:45 -0700 (PDT) Received: from hades.. ([46.103.15.185]) by smtp.gmail.com with ESMTPSA id f26-20020a50ee9a000000b0043cbdb16fbbsm1008160edr.24.2022.08.23.01.11.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 01:11:45 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: etienne.carriere@linaro.org, Ilias Apalodimas , Jens Wiklander , Patrick Delaunay Subject: [PATCH] tee: optee: rework TA bus scanning code Date: Tue, 23 Aug 2022 11:11:41 +0300 Message-Id: <20220823081141.344833-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Late versions of OP-TEE support a pseudo bus. TAs that behave as hardware blocks (e.g TPM, RNG etc) present themselves on a bus which we can scan. Unfortunately U-Boot doesn't support that yet. It's worth noting that we already have a workaround for RNG. The details are in commit 70812bb83da6 ("tee: optee: bind rng optee driver") So let's add a list of devices based on U-Boot Kconfig options that we will scan until we properly implement the tee-bus functionality. Signed-off-by: Ilias Apalodimas --- drivers/tee/optee/core.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index a89d62aaf0b3..48a9b59171cb 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -31,6 +31,20 @@ struct optee_pdata { optee_invoke_fn *invoke_fn; }; +static const struct { + const char *drv_name; + const char *dev_name; +} optee_bus_probe[] = { +#ifdef CONFIG_RNG_OPTEE + { "optee-rng", "optee-rng" }, +#endif +#ifdef CONFIG_TPM2_FTPM_TEE + { "ftpm-tee", "ftpm-tee" }, +#endif +}; + +#define MAX_TEE_BUS_DEV_COUNT ARRAY_SIZE(optee_bus_probe) + struct rpc_param { u32 a0; u32 a1; @@ -643,7 +657,7 @@ static int optee_probe(struct udevice *dev) struct optee_pdata *pdata = dev_get_plat(dev); u32 sec_caps; struct udevice *child; - int ret; + int ret, i; if (!is_optee_api(pdata->invoke_fn)) { dev_err(dev, "OP-TEE api uid mismatch\n"); @@ -672,8 +686,10 @@ static int optee_probe(struct udevice *dev) * in U-Boot, the discovery of TA on the TEE bus is not supported: * only bind the drivers associated to the supported OP-TEE TA */ - if (IS_ENABLED(CONFIG_RNG_OPTEE)) { - ret = device_bind_driver(dev, "optee-rng", "optee-rng", &child); + + for (i = 0; i < MAX_TEE_BUS_DEV_COUNT; i++) { + ret = device_bind_driver(dev, optee_bus_probe[i].drv_name, + optee_bus_probe[i].dev_name, &child); if (ret) return ret; }