From patchwork Mon Aug 29 06:33:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 600863 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1763101mae; Sun, 28 Aug 2022 23:34:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR5v+HMx7hlpcQI9X+B44/RlDySuYeaPLdbHKiBbZR2IBKCibuTV2oBQ7OT5MBNacxBJsyma X-Received: by 2002:a17:907:3f88:b0:73e:484d:9d6c with SMTP id hr8-20020a1709073f8800b0073e484d9d6cmr9578846ejc.283.1661754852339; Sun, 28 Aug 2022 23:34:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661754852; cv=none; d=google.com; s=arc-20160816; b=vIpiMd5V1DubhCv9zvljhuBegoTZSiUNI9ol00PR+Q6K/aCWhuSsxnEVzbd8h75RB1 0vfWIBHcTw6+GO/BQpG1PeY5crSjodhpiIn+EI09dIGJnUPRxhMv371Qg2q+wRn22lmA AAjNqeVoqSNJsQQbvz0H6C0EUWic9o/j1lGZscZWzJdMNbqJ66HDFKI0B5yCC+MRZ94u q/BO9TjkfM60ScuQFn15qVBghUV4ntMs2yavlsHMu8vk1m10ZWBiDvbRCxDKa+a/fu0V G+sSqxhPtXvtyzNJrTRYh/Yk/MlDCRj0UIyIGJIS0V0K4cUU1uZTvFK4B8aQ+zEOdocB Bu9g== 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=P5ShWM1YofKtJEh+ZD7P6274wnsF3u2opoPt/cKpMFg=; b=KlqL/ZsCLSypKuwSvG6pzUB2h5eJRYXC42DS2h9883eyWs2f0VVL5fwidfgpDlDG+s NO9EIS4g5HjH7cfxFzS1JrJFRY/NjlAD3WreKUslIXgD96NRfr75M1YfrBeOZAYWZJR/ mvcROUJ/LMU0zDF0BnHoZA0b1OOXIadjpNrnF7pBoPQvIPuSw3qAr08fx9/RsupNAMUv beTsfWUnt1b+OB0RM4BsK/2Ai1Ak4zhJa0EetGAgiOhxBAqr5vogAzDzcxdPs8c2cpsg CNDKOPUfdrHCaYzP37DtFqsFGh7HB45TlfcyzNY8IuCKf/AnpNVtI4fx7ttyL9O1Ik60 tn9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bihtxNd9; 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 n23-20020a170906b31700b0073dba60b49bsi5281252ejz.303.2022.08.28.23.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Aug 2022 23:34:12 -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=bihtxNd9; 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 5DE2A83FFF; Mon, 29 Aug 2022 08:34:11 +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="bihtxNd9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7879C83F9A; Mon, 29 Aug 2022 08:34:09 +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-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) (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 9E3BD83FFF for ; Mon, 29 Aug 2022 08:34: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=ilias.apalodimas@linaro.org Received: by mail-ed1-x534.google.com with SMTP id z2so8858897edc.1 for ; Sun, 28 Aug 2022 23:34:06 -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=P5ShWM1YofKtJEh+ZD7P6274wnsF3u2opoPt/cKpMFg=; b=bihtxNd9rSGNQMCAv87T9ZGFlCon1CohaoVGt2CUsbX11K6VwPvbzK06sD4IGGW1fz sDDVT0yltxrrs8CvTZTAp+4xf4xDB8O3tKevWE4Gfo9H7fYQd9BkCyFVCRQGagCqyAGd iYqQVK/0j4F8H5szIop2HlSiQAzUXhI25KSSK9ZnYNczebO/tfPsYXELlYKXzW0QBO4O b9fb6uI4qt4D11hiRvN5PLwJIMpmirPVO4fFEn1ppjhMrQvVr8ssN+DScL6VUkxEWUQe J4kSkGf4UOs5JPl++NQksPetQHSYjlj4Re00aKGv3a3m9TKt0IcEMpsE6RYnlMCpOwQM TldA== 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=P5ShWM1YofKtJEh+ZD7P6274wnsF3u2opoPt/cKpMFg=; b=wVWT/v4LqKEwTbzILNss5NUiL1OA1Uwf9ypN5yxmIcLRjmqWtg/cZmFmOcYo0K9+LY Z7VP4cvoKusKD33HGSwrJHh/CpsBjRDXykk3hgCE85EugA5JRVeDfbKKbTPqr+OIPrlV 6uIVjuGUNLLA4mpGvnHbgXKQ7wpl75WbpJQDMbx9sbu58SnVnnTlwREEBepEOQnHTodL Vqo594F8+wN3lB1GZbcpJ6GiHNXpfKP7NLBrhB+aswj9R0iTfSe9K+i0mKDuHdqI+lRK AQe+eQ0sb4Gf3Bg1r0sqGyvf8sSv/0r67Ljm20i6gEYiiKAAqEG+2EXL8u9iPVypX9tc e9/g== X-Gm-Message-State: ACgBeo2FnR2hqMzFqHeHm7T65VU27vsCo52w8xcwAWSrEkePTO0o56N+ 1QrtUgflLRoU11fdy7Yt9N0wr7zSvKEf5Q== X-Received: by 2002:a05:6402:14e:b0:443:f58:17e9 with SMTP id s14-20020a056402014e00b004430f5817e9mr15640521edu.106.1661754846230; Sun, 28 Aug 2022 23:34:06 -0700 (PDT) Received: from hades.. ([46.103.15.185]) by smtp.gmail.com with ESMTPSA id k7-20020a17090632c700b0073d218af237sm4087655ejk.216.2022.08.28.23.34.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Aug 2022 23:34:05 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: etienne.carriere@linaro.org, Ilias Apalodimas , Jens Wiklander , Patrick Delaunay Subject: [PATCH v2] tee: optee: rework TA bus scanning code Date: Mon, 29 Aug 2022 09:33:59 +0300 Message-Id: <20220829063400.421456-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. While at it change the behaviour of the tee core itself wrt to device binding. If some device binding fails, print a warning instead of disabling OP-TEE. Signed-off-by: Ilias Apalodimas Reviewed-by: Jens Wiklander Reviewed-by: Etienne Carriere with minor comments. --- Changes since v1: - remove a macro and use ARRAY_SIZE directly - print a warning instead of disabling op-tee if a driver binding fails drivers/tee/optee/core.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index a89d62aaf0b3..3cc92f09d299 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -31,6 +31,18 @@ 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 +}; + struct rpc_param { u32 a0; u32 a1; @@ -643,7 +655,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,10 +684,13 @@ 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 < ARRAY_SIZE(optee_bus_probe); i++) { + ret = device_bind_driver(dev, optee_bus_probe[i].drv_name, + optee_bus_probe[i].dev_name, &child); if (ret) - return ret; + dev_warn(dev, "Failed to bind device %s\n", + optee_bus_probe[i].dev_name); } return 0;