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 9C3B7C433EF for ; Mon, 6 Jun 2022 09:49:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2734783C61; Mon, 6 Jun 2022 11:49:52 +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="MEFtezOa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7185B83608; Mon, 6 Jun 2022 11:49:50 +0200 (CEST) Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) (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 BF02F83608 for ; Mon, 6 Jun 2022 11:49:47 +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-wm1-x335.google.com with SMTP id z9so591865wmf.3 for ; Mon, 06 Jun 2022 02:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=mwW/NK1rrDwoDYExOkIMv4jXQsbf30RigbmX/8VBWP0=; b=MEFtezOa4dIgCtWY7NOeP3q71jGpb4xqo/4us81kQ+t+Db/UDMK0oVm6tpLyWJUOiq FCpnGUGTi+7DMEuW6K5VG4wJ64SJbZYNlcx+vLuvve03GQ1Aj4wfEe8v3TKdM3ZAT7rJ CMWq0MYn8f7uBoO9WMehD3lGMWBUfy93DoLyOKmfGtjoXg6mHSDniXr0nW1XSZuOPm7a vPBDdBdiMXQd2dLvK9qgrIw5rUiCM8/ktkCSDZYl6tNFPeukl9Y4bNia7YZZQ7sARIEi NX18IssTRTwNcy5VvOp4oiSQlaeBLHLATjLRnE6OTxYPnVrG3rG+CyrxIvNQ857WNVYa Tnng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mwW/NK1rrDwoDYExOkIMv4jXQsbf30RigbmX/8VBWP0=; b=dxQJmT5Y0HOHsB1gtHa7iI2y7x05omJUTWrYvDC/WJmnB8INmf+KdAhyBVr6GTcQzB vJFDnGQqCmqm+vXROKoLRkAntwivD18CxvDhl8xMoBMbZli8S0LqDEbRpSBPLE2JUj3n bUodWha+onXZopscJ3xPnf7vqJlSEhKOfTGUxfgXkNqDAG42x6M7rvJQffWBKUCVeJJR P6rU0XAW7zqT1WfHyXH6N2ZzMUBFdCB510nxbx34IZO7s0P7B14OJHszj5oMxocsEjxu PbsQgc/QH2RKk2fyc6LlsE2myJrPeGdmEmCOEzqP3FdlC9O2QEnDb+F+76zvfLXYDl8V RVmg== X-Gm-Message-State: AOAM5335upo6muqqj+qvOVFAO8hbZd9Yig8FcE9BwIaIV7b0sCJ9lh3Y C/0IwTLpVGK2/jn2pECDQDn4hg== X-Google-Smtp-Source: ABdhPJxEAg/R/X8ByWVhNpdGUIshmIlHdasH50PgR1mGsVNEM1xPhLxzspcdcs9ECOdFREJ1NxF92A== X-Received: by 2002:a1c:f710:0:b0:394:1960:e8a1 with SMTP id v16-20020a1cf710000000b003941960e8a1mr21763541wmh.154.1654508987252; Mon, 06 Jun 2022 02:49:47 -0700 (PDT) Received: from hades (ppp089210241233.access.hol.gr. [89.210.241.233]) by smtp.gmail.com with ESMTPSA id bv18-20020a0560001f1200b002183cedbf34sm2574639wrb.73.2022.06.06.02.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 02:49:46 -0700 (PDT) Date: Mon, 6 Jun 2022 12:49:44 +0300 From: Ilias Apalodimas To: Etienne Carriere Cc: u-boot@lists.denx.de, Jens Wiklander , Patrick Delaunay Subject: Re: [PATCH 1/2] drivers: tee: optee: discover OP-TEE services Message-ID: References: <20220601082752.301602-1-etienne.carriere@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220601082752.301602-1-etienne.carriere@linaro.org> 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.5 at phobos.denx.de X-Virus-Status: Clean Hi Etienne, On Wed, Jun 01, 2022 at 10:27:51AM +0200, Etienne Carriere wrote: > This change defines resources for OP-TEE service drivers to register > themselves for being bound to when OP-TEE firmware reports the related > service is supported. OP-TEE services are discovered during optee > driver probe sequence. Discovery of optee services and binding to > related U-Boot drivers is embedded upon configuration switch > CONFIG_OPTEE_SERVICE_DISCOVERY. > > Cc: Jens Wiklander > Cc: Patrick Delaunay > Signed-off-by: Etienne Carriere > --- > drivers/tee/optee/Kconfig | 8 ++ > drivers/tee/optee/core.c | 187 +++++++++++++++++++++++++++++++++++- > include/tee/optee_service.h | 29 ++++++ > 3 files changed, 223 insertions(+), 1 deletion(-) > create mode 100644 include/tee/optee_service.h > > diff --git a/drivers/tee/optee/Kconfig b/drivers/tee/optee/Kconfig > index d03028070b..9dc65b0501 100644 > --- a/drivers/tee/optee/Kconfig > +++ b/drivers/tee/optee/Kconfig > @@ -37,6 +37,14 @@ config OPTEE_TA_SCP03 > [...] > +static int enum_services(struct udevice *dev, struct tee_shm **shm, size_t *count, u32 tee_sess) > +{ > + size_t shm_size = 0; > + int ret; > + > + ret = __enum_services(dev, NULL, &shm_size, tee_sess); > + if (ret) > + return ret; > + > + ret = tee_shm_alloc(dev, shm_size, 0, shm); > + if (ret) { > + dev_err(dev, "Failed to allocated shared memory: %d\n", ret); > + return ret; > + } > + > + ret = __enum_services(dev, *shm, &shm_size, tee_sess); > + if (ret) > + tee_shm_free(*shm); I'd prefer if we handled this a bit differently. Instead of freeing the buffer here, just release it on bind_service_drivers() always > + else > + *count = shm_size / sizeof(struct tee_optee_ta_uuid); > + > + return ret; > +} > + > + > static int optee_probe(struct udevice *dev) > { > struct optee_pdata *pdata = dev_get_plat(dev); > u32 sec_caps; > - struct udevice *child; > int ret; > > if (!is_optee_api(pdata->invoke_fn)) { > @@ -668,15 +842,23 @@ static int optee_probe(struct udevice *dev) > return -ENOENT; > } > > + ret = bind_service_drivers(dev); > + if (ret) > + return ret; > + > +#ifndef CONFIG_OPTEE_SERVICE_DISCOVERY > /* > * 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)) { > + struct udevice *child; > + > ret = device_bind_driver(dev, "optee-rng", "optee-rng", &child); The same principle applies for fTPM. Moreover the linux kernel supports bus scanning, which creates a conflict when the fTPM is added on the .dts (for u-boot to scan it). Can we make this a bit more generic, even though only the rng is added on this patch? something like struct devices { const char *drv_name; const char *dev_name; } tee_bus_devices = { { "optee-rng", "optee-rng", }, } and add an array of the 'scanable' devices? It would make adding the ftpm and other devices trivial > if (ret) > return ret; > } > +#endif [...] Thanks! /Ilias