From patchwork Sat Sep 3 07:53:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 602392 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp2094856mae; Sat, 3 Sep 2022 00:54:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR4ElIJxYFutZqns6ienVCdfcmhp8ooesG2cyEweY+7GeqxfWm6ztxnUIdXd1yMUU5Jq5sfo X-Received: by 2002:a17:907:7d90:b0:738:2f9b:9869 with SMTP id oz16-20020a1709077d9000b007382f9b9869mr30530663ejc.186.1662191649491; Sat, 03 Sep 2022 00:54:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662191649; cv=none; d=google.com; s=arc-20160816; b=ZcFY12lHR+Iz1WBqH/kKsodYo0zVq81SN2Uf1LTKf2xNPcouwUQ9EUCQo7JwqzSvxD u56ZdzxEEDZGqwRaMGz+aSgiHJ5SIP7m1baTo0x+U5LmwwKdBjFGIFvUav3GLyar/Hj/ vSraKxUUrQD3QRyXtzYmEeMg5FJmREe8Ixku4pel+Qdb0NYxwmdRDDuz0eSZojn1xDC3 Vd3NU+VkGEdBmLmpQa/zw+h7moWof2WhWA+RzC7zshM6fxrRJJfhimItQl1lodVODsyn fIZ3N5uzTNS45JT3Jo9FNMXksNEEAZDz3VvA3KANy4ANGwdfSSXbdMutJRKZQtTNMuXR U1zg== 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=jWV6wGAsGIVmnIeB7L2d+a+k4OqepTnJzayWqHeoEdI=; b=TkQC09f1sxVkgLCxI6oLeM+LGn2knKDLrihwCb/KOwpTZ3XoMxAyKZaqqlYEK4c+ej 4EfpYEjZgvNzaifUY3O0oygwUn3jyD4/LpRrs4OKvKxhO/Jri6sNxIX5W3p9eaimdx5o 9MViYAinuaLOlat3Lja15vvgRAAYOnF+n3+jPZqyTjJMw7whG2fcZo5mXvo78fkyIK7J Wo8yr+8mr13b6BTAtOuHDZOAdKpvSvYhNV6yUr8NMoqhVb8U4a+CJehVUX/TPBGxN3XG J/08f8vgl1JYy6ryUKLxrd4EbSPrVC+WJOsHbaw/Eu7zFuNJSj1wkX0X3HJzXwGy32eM ZqAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ut9Njbj0; 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 l18-20020a50d6d2000000b00444f7f2ace8si3092901edj.321.2022.09.03.00.54.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 00:54:09 -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=Ut9Njbj0; 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 B1A098456E; Sat, 3 Sep 2022 09:54: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="Ut9Njbj0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C87C88460B; Sat, 3 Sep 2022 09:54:04 +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-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) (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 193268452F for ; Sat, 3 Sep 2022 09:54:02 +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-x634.google.com with SMTP id p16so7780458ejb.9 for ; Sat, 03 Sep 2022 00:54:02 -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:subject:date; bh=jWV6wGAsGIVmnIeB7L2d+a+k4OqepTnJzayWqHeoEdI=; b=Ut9Njbj0hNCffkRB/Ybh3P/Cra1iHUGwcn84XsN+1jfA63w0ycqmJ6gh9EtZbSZjsQ lrLJHG45UB3Wy1hcBqpGopW55e3GXzR3Ng4ecTFSTe4XTLiOHaejuLpHND9NLuDxx9dD q3nPqYS1Hn3kiYXAM0SI+YFq3HTGNcqESDtTInMuDNNuRcjs3a/Clcq1xCF70qF4L5f0 nPKLVv3EXfIF8XKahPp8CO2hB+D4Q5yGC1VUKO6NjpzWJ05lgmT/eWCLSvVm6RQoytaV i1ZufMBLKT8tGRlW4iJzZ+DQKiNhk3M2bWOFnJKDxcBLYZAyG3RY5nVt2JK+eFLc4GtA bUMg== 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:subject:date; bh=jWV6wGAsGIVmnIeB7L2d+a+k4OqepTnJzayWqHeoEdI=; b=r1r3wYFdyI3IPm/ZzASCHl8UFKcsXjDAiGVERm/HsKlf3TmjjbU/q1rkFaDlZjP+uP ktDpeWY7gl7JgxrxnmKNnHiU4mK0Q3MAEOieyJLW5eXuJZOqvLstUUKM7e6XYWKProBZ RDzkYPreu++Yw/BFelFkUU4iVyQ8r3QJ1o4hHIkFSM9VxrCmsG+Nw/2H3cx/MNs/sJ40 ZWrMgPC+0USCcBF/SaFj5p8kAn+eAJqLx4dunkUnhNv/I5PAwMVScxiIEGe9euNvjQUA GC11haFyZ2NuWhXJg40T8IfxhREt1+PMtqgXuEmtO1xa/WpATFfSJoeW8uDptiWEHPas bfnw== X-Gm-Message-State: ACgBeo3UpdfrDAZnCKssJtOXT4mzZmJ2awdFSBt4oSmHu2dUrgjokNoB 2BInU/XShcFNGBj3sVQyFstYWwYQtRQSaQ== X-Received: by 2002:a17:906:85da:b0:73d:c94b:8996 with SMTP id i26-20020a17090685da00b0073dc94b8996mr29479070ejy.225.1662191641685; Sat, 03 Sep 2022 00:54:01 -0700 (PDT) Received: from hades.. ([46.103.15.185]) by smtp.gmail.com with ESMTPSA id 10-20020a170906310a00b007246492658asm2190119ejx.117.2022.09.03.00.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 00:54:00 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: etienne.carriere@linaro.org, Ilias Apalodimas , Jens Wiklander , Patrick Delaunay Subject: [PATCH v3] tee: optee: rework TA bus scanning code Date: Sat, 3 Sep 2022 10:53:56 +0300 Message-Id: <20220903075356.1892337-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 --- Changes since v:2 - Fixed typo on driver name ftpm-tee -> ftpm_tee 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..1437ba1b676b 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;