From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF16EC38145 for ; Tue, 6 Sep 2022 06:20:34 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 028F284A38; Tue, 6 Sep 2022 08:20:33 +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="VokoKVRD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9BE4884A3D; Tue, 6 Sep 2022 08:20:31 +0200 (CEST) Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) (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 B992384A0A for ; Tue, 6 Sep 2022 08:20:28 +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=jens.wiklander@linaro.org Received: by mail-pg1-x535.google.com with SMTP id s206so9760858pgs.3 for ; Mon, 05 Sep 2022 23:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=kCIQEu2HHMQVS6poJ2t6eby+bW0yzx2plXcKQroTJuo=; b=VokoKVRDshWFdhMjINl7HZHeHbiALWEP6hx/LwtPaB1lLIVpAD9rLFaNS76xICl0CW tXDfDPdfugu7oGdjGReZSXSgx8lGTTmAAndSsSt+r4hrdZ4I9XkGnBOS1SN+ZnEbTonm 7T4xSSFAsbJMchNDvMUAL7NV2WVDsTtokGwcR8nV3C4J1AAO7Iu+O3PewUKuy9Ys6R0I ZoebjZrNdrCoBJTYaWo9zdjO9oHg/ZoyNoCze3wlXP5Pomz7T8o0UuWxEGtWAGxB0MU4 nCYZ3pqgl7OEads/r4ZuhCj22WKCdDz2Igb3PTWiObeBnzMvhUp6GHlocrZuXDv2UonO CKKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=kCIQEu2HHMQVS6poJ2t6eby+bW0yzx2plXcKQroTJuo=; b=w3FUUePlhpbodsrkyrsHYGJOmpqn+HltOctkUgVbJVRBBveutu9WKcBQ0vI3rf/7A9 k5KNDkQKZH/Ik8kyHnSTYqOiQiz7/eAwE/+rfwLqKalV3FXTPEp6CFTnWtcQPitqzM92 S0zY70y12ND0Xb7xXwVMMGFYASlMjwo66HKcYAvXOgzav7avEZhXbhjiaZMf4DZLuTaq 8N4ZE3oHl0P06LqTtKHHmzqarU5ca4FHJZcXGMW5z+SaKj4iobP4RZu+4+UiMiv8T2XF VrqvrqDhliqqhHvqvSYH/ue65dyFmL5OYZO/OIchjm8coJdmZTZe/MSLmEBPwwrhuur5 4cTg== X-Gm-Message-State: ACgBeo2hEpukkA/HPiJM1bMDDeo+QDNPDHd3tpCiGcLsmTQcTP9cdCqf 9f+b6YxjMXm6wXiXxhp45KVSxRQMMgoAU4Km3KIpGQ== X-Google-Smtp-Source: AA6agR4qiUQEiELbk4DDLNg+2SP3JXwZYLjo/Dx96ewjfXY6lRkQx3VxCJKlJzBZphLq9+JulNdz3MeejLjMNE4cdB4= X-Received: by 2002:a63:85c1:0:b0:434:3bc1:df34 with SMTP id u184-20020a6385c1000000b004343bc1df34mr9175222pgd.107.1662445226898; Mon, 05 Sep 2022 23:20:26 -0700 (PDT) MIME-Version: 1.0 References: <20220829063400.421456-1-ilias.apalodimas@linaro.org> In-Reply-To: From: Jens Wiklander Date: Tue, 6 Sep 2022 08:20:16 +0200 Message-ID: Subject: Re: [PATCH v2] tee: optee: rework TA bus scanning code To: Ilias Apalodimas Cc: u-boot@lists.denx.de, etienne.carriere@linaro.org, Patrick Delaunay Content-Type: text/plain; charset="UTF-8" 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 On Fri, Sep 2, 2022 at 9:11 PM Ilias Apalodimas wrote: > > Thanks Jens > > On Wed, 31 Aug 2022 at 08:59, Jens Wiklander wrote: > > > > On Mon, Aug 29, 2022 at 8:34 AM Ilias Apalodimas > > wrote: > > > > > > 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 > > There's a typo in that patch. For the tpm to work the string needs to > be ftpm_tee instead of ftpm-tee. I'll send a v3, shall I keep your > RB? Yes, please. Cheers, Jens > > Cheers > /Ilias > > > > Cheers, > > Jens > > > > > 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; > > > -- > > > 2.34.1 > > >