From patchwork Wed Sep 28 07:47:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 610067 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp100292pvb; Wed, 28 Sep 2022 00:48:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5YM/JrM3gQEGJbqRJFavksJkyKz8Apkpz+y5Kagmruq0KJyV9OjJ6zNaEDYY3K5m+LTTtj X-Received: by 2002:a17:907:160e:b0:781:d884:936f with SMTP id hb14-20020a170907160e00b00781d884936fmr25550855ejc.315.1664351327876; Wed, 28 Sep 2022 00:48:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664351327; cv=none; d=google.com; s=arc-20160816; b=oPZW2wouBFJq/MsslUfe2NgRwz04dPJiXcPhxoN8H9kAoD6pwGG+J7xZWC/lMDqGwj uPZ/CojTP0AJXZ8TIH90KJpL+b3KhY6XRIbQSAZVCWiqhS6M+xhp6BWZs73LF8hzRfwU gRgX9KILqQoXzIpbANIVa6a24FZ7IJhrtM6xui6Pv6C7qHZ1+MTqORGXVhcDDh3EnYAJ If18BQ06ldj+2str/PoXm9mdX2i+g603d6cPWVOitxf4gdYk/TBmGfOcgcCOmjULFhtW ZJYP3RLWp6ny6Hx15snPO6Hqvyvh8M9r7oXK/DhgzMrPg0iykP09RJGwlZ6U4xazYsqz eYuQ== 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=1KEPhSYocI4ZEjSbSPyLlK/qbdDlsC3D0+reh6NL6ko=; b=trvd5N7V5ZSy6I1FX1Jz+YvLCKWvILPWWFz68kGqEBx8tdPkt6mj4x/Lj2tAcn4Vo+ xWvAuqyIfIWZhugeCO3ElA3+rK7cQzRYzPKInfPxsTlWkxBxKMYV51+ZVICtBWoA0U6V XS+qfVmjggtNAPRDknsmgHLl6lHDaYb79zfjcDUuNnfxckil8/OomrHLPhQMRLWralpP o96SrmkZ3SxQZ9oGyI+8d2skq+GE9ksnuu4FHqRrqxz4OHFkdTq1z5paxkNAfNROpQfT C+uNPcN53MLcsUnrhdc6/nRHZG1oZy+hxwTLJkPgv1vDVQD3lBy9q7roZ9Iri5OAfVXJ 7rtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oXcveiuf; 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 i10-20020a0564020f0a00b0045200965a24si3645140eda.524.2022.09.28.00.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 00:48:47 -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=oXcveiuf; 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 CA4B284A30; Wed, 28 Sep 2022 09:48:20 +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="oXcveiuf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 05B8184A5F; Wed, 28 Sep 2022 09:48:19 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (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 BC6AC84AF4 for ; Wed, 28 Sep 2022 09:48:15 +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=etienne.carriere@linaro.org Received: by mail-wm1-x334.google.com with SMTP id l8so7984009wmi.2 for ; Wed, 28 Sep 2022 00:48:15 -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=1KEPhSYocI4ZEjSbSPyLlK/qbdDlsC3D0+reh6NL6ko=; b=oXcveiufV9gHccyffMfbsvqGnFb3tLok45IcD2PaXsq4iO0eR0RD8dFWuuC2oc0TII m30+yA4I5bPN7KtUcQOVPCupbe/tv4VPU+CuViuGhbztiUGpf9pkvUspRt9Mr1+Vgfkk erDvL2hkbhibYTDuEj21GzRGuAgCa2eXNXTrFPBfitHQYgx8sJOHpeAYDr79bm8MRibD bAI/fbxl8qds88cFxbb19dl+cmuU2NARF4pKpmAFLB5kp2AzEhBnU5ypp85HZPRmV87m hgA9ARbQ+pzV1EeeXLhB13mxPeozUGpANIImL3jHHIBytwsUALvx7+pIYprXsBfttcxi DkSg== 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=1KEPhSYocI4ZEjSbSPyLlK/qbdDlsC3D0+reh6NL6ko=; b=lV0LFT9FL9YGQR+c9JZWRNUFR/n/jKeweXvVz20Pd7ehep72BSOWiqmjq72VFUuQLH zwJBmSWiaSwd6kX3U+yvRLYt62VhPMK1W5l8+53XUqeFYREeWotyEHvvCnFDZdoFgKc8 FD+0mP0xOrLokCJ4rqy7q0fyBcAxRHgz0m1KkyWHBuC66L0C286bkGAHYt7Lh98j/3NJ AIuXx5K42IV2IBIMVOfd0c/gFL0WkWla8HrHHFzL0UeRgznn7ZAF9SSfFRB3RCUPnZO7 p42Vq2w/aCMo1GqnNEZa9U+tCwJJubu5AqDnSE6g46XWtiz533LIgf+c67WYzshlxSQ4 UTjg== X-Gm-Message-State: ACrzQf2uaow5GPDjy8i9+1ilGT2A8GukrmIieP1X0dt4FveDfct+TuLO DL2PTFxN4TpI7dKzrmYddFrSK376CXicvA== X-Received: by 2002:a05:600c:1547:b0:3b4:c56b:a3a6 with SMTP id f7-20020a05600c154700b003b4c56ba3a6mr5804332wmg.29.1664351294903; Wed, 28 Sep 2022 00:48:14 -0700 (PDT) Received: from lmecxl1178.lme.st.com ([2a04:cec0:10fd:ab90:93e8:8fe:e575:1ddd]) by smtp.gmail.com with ESMTPSA id g6-20020a05600c310600b003b4f86b31dfsm398714wmo.33.2022.09.28.00.48.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 00:48:14 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Jens Wiklander , Patrick Delaunay , Ilias Apalodimas , Simon Glass , Etienne Carriere Subject: [PATCH] tee: optee: discover services dependent on tee-supplicant Date: Wed, 28 Sep 2022 09:47:25 +0200 Message-Id: <20220928074725.2228353-1-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.25.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 This change makes OP-TEE to enumerate both standalone services and the services depending on tee-supplicant support in U-Boot. This change also drivers for this later to be bind. It is assumed that one implementing an OP-TEE device driver has all expected tee-supplicant services support in U-Boot. Signed-off-by: Etienne Carriere --- drivers/tee/optee/core.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index 9240277579..7da35f2eda 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -102,13 +102,14 @@ static int bind_service_list(struct udevice *dev, struct tee_shm *service_list, return 0; } -static int __enum_services(struct udevice *dev, struct tee_shm *shm, size_t *shm_size, u32 tee_sess) +static int __enum_services(struct udevice *dev, struct tee_shm *shm, size_t *shm_size, u32 tee_sess, + unsigned int pta_cmd) { struct tee_invoke_arg arg = { }; struct tee_param param = { }; int ret = 0; - arg.func = PTA_CMD_GET_DEVICES; + arg.func = pta_cmd; arg.session = tee_sess; /* Fill invoke cmd params */ @@ -118,7 +119,7 @@ static int __enum_services(struct udevice *dev, struct tee_shm *shm, size_t *shm ret = tee_invoke_func(dev, &arg, 1, ¶m); if (ret || (arg.ret && arg.ret != TEE_ERROR_SHORT_BUFFER)) { - dev_err(dev, "PTA_CMD_GET_DEVICES invoke function err: 0x%x\n", arg.ret); + dev_err(dev, "Enumeration command 0x%x failed: 0x%x\n", pta_cmd, arg.ret); return -EINVAL; } @@ -127,12 +128,13 @@ static int __enum_services(struct udevice *dev, struct tee_shm *shm, size_t *shm return 0; } -static int enum_services(struct udevice *dev, struct tee_shm **shm, size_t *count, u32 tee_sess) +static int enum_services(struct udevice *dev, struct tee_shm **shm, size_t *count, u32 tee_sess, + unsigned int pta_cmd) { size_t shm_size = 0; int ret; - ret = __enum_services(dev, NULL, &shm_size, tee_sess); + ret = __enum_services(dev, NULL, &shm_size, tee_sess, pta_cmd); if (ret) return ret; @@ -142,7 +144,7 @@ static int enum_services(struct udevice *dev, struct tee_shm **shm, size_t *coun return ret; } - ret = __enum_services(dev, *shm, &shm_size, tee_sess); + ret = __enum_services(dev, *shm, &shm_size, tee_sess, pta_cmd); if (!ret) *count = shm_size / sizeof(struct tee_optee_ta_uuid); @@ -174,20 +176,32 @@ static int bind_service_drivers(struct udevice *dev) struct tee_shm *service_list = NULL; size_t service_count; u32 tee_sess; - int ret; + int ret, ret2; ret = open_enum_session(dev, &tee_sess); if (ret) return ret; - ret = enum_services(dev, &service_list, &service_count, tee_sess); + ret = enum_services(dev, &service_list, &service_count, tee_sess, + PTA_CMD_GET_DEVICES); if (!ret) ret = bind_service_list(dev, service_list, service_count); tee_shm_free(service_list); + + ret2 = enum_services(dev, &service_list, &service_count, tee_sess, + PTA_CMD_GET_DEVICES_SUPP); + if (!ret2) + ret2 = bind_service_list(dev, service_list, service_count); + + tee_shm_free(service_list); + tee_close_session(dev, tee_sess); - return ret; + if (ret) + return ret; + + return ret2; } /**