From patchwork Tue Nov 9 16:08:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 518043 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp1899462iml; Tue, 9 Nov 2021 08:09:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1zsYA5+Pk2K7YG9HwCStStwbPnU9p6mPoucHJLniqYnIXcg5YdyGLqdabBVDloYI2Lmrt X-Received: by 2002:a17:907:6d99:: with SMTP id sb25mr11835913ejc.261.1636474152653; Tue, 09 Nov 2021 08:09:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636474152; cv=none; d=google.com; s=arc-20160816; b=Nrj+FFwd976Ty3VyyjE8uaGgEUAeq9kAZIBaqSM0AEgJ7aGEXNt01b3rwlA7Aqp9tS x7oyavutx0Kh1bc1cRsYBdela2cFAqiIyHFmxDwbacUMeewA27Wid+lGvD30vojrtGFx e7uqp4EeTkv54WBR6XDi4DeDsv3SFyjtY0+9v0VYMwpnQ13OKcz5co7YrKOkbkOkyHZ4 NFtHCyX8GHEMdLKzv9g5pYU+dZw0poOZFmsjTnYqvAq0E7vcQThVNvNRF7TN7+bY9hVC p9ro3cQyI1ute4vKwpzbJBFm/CT2tFiELShsuUO1jvgmkyK3Cotm2LsMbwaS/1Vd3f7c ilBg== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=APhiAyb3qY/I1eI+ESDqCctoYgDXFZugey31t5jxaFM=; b=IKk4BZx7NEcOXNm90p4GSuO1h/oepfU4oRnlKDYAsc5czbtyhsN2Mk5QmtLGrXLONu bOIjaqyD4EFV4JZSUyVFn2xIA7L0dxZ0FUWsEWWmj5cDtK+Zo+9MCYREbZXGqrWXYXo4 mU9vz7kgtbj/KCoXbrjLQCGDh1Zx59HktI3NPbTvrGxa3Xe23FqfnwyYgwwpRMrDioHF r9o7zhXonwwHZyLjGTF91/gFq4YzWkKjTdSH+Abla+qHrBZN53xdr9MFKNu8k5iQvPSR gKE70agUmKpSymw+MqwW5/aPe//BhBV4lqmrggIgCgr/Mypil3R58/2oZJFrXv72GGgN cDIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o5gvDlQH; 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 gn6si35952654ejc.196.2021.11.09.08.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 08:09:12 -0800 (PST) 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=o5gvDlQH; 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 9F07A8394C; Tue, 9 Nov 2021 17:09:11 +0100 (CET) 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="o5gvDlQH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3DADB83969; Tue, 9 Nov 2021 17:09:09 +0100 (CET) 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-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) (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 5D7828393E for ; Tue, 9 Nov 2021 17:09:04 +0100 (CET) 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-wr1-x42b.google.com with SMTP id d27so33898456wrb.6 for ; Tue, 09 Nov 2021 08:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=APhiAyb3qY/I1eI+ESDqCctoYgDXFZugey31t5jxaFM=; b=o5gvDlQHXIeMuZx5zusEkEFSUrFjHZ79agybZUTUDoLi8R+GfNdbgGZFDf69elQDKL T9g5tmv6P29MKLiMQmfWIQv7LJr2C7FJDjNk66NeIh7Y3BrHO3g/xQYGSOpLy221p3bC 9Q6jk415Zs2+MqPiS8kdsV+e4JTUrMxE5v0Dtb9uAx/th9kq8b68oawv9v0Wr76DkoMS 1aXlPu+310pGBjowSlucQgZtubzT6KQTlAfhRlBj1rJjxlek7udKO1FGIm8sRIM+zJRX kS+ry4qfT1PKyOmRU2mGEcJd5WQN+N2Ou7bo9nh7F98/B8/KeRQJltGqhv1ro39aawGv xDFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=APhiAyb3qY/I1eI+ESDqCctoYgDXFZugey31t5jxaFM=; b=jS90zQkW0f5w1adnl1zxoYtu6aqAU9HBuxTfCro63GNJf2Uc046+mRrskXya3g3O5s C5G8iBiS4CrCsSU191sB1iSM/Z1VMtZ8kX1bGbUBSxPcuZ5Q2QCgyLyTv75I+vM9wY9n xgtxvD8In+IviLzWxPjB2/zdwsbffirIfy2y82ewB0AK8FNl7qnKunIWIrF21S8jitIC a7QFbjpHHv0f1hd2y/gwtX3SG7yAp1LDGz4668g0m+COjfzMdj3V8GR5GLp5d8y0iani qwnz0d6H+/ys40kbTmN9uhtuRXpsof0I/o3VQz3xBv2s3KhU81nwiJ/tKFiKdHmDXPSA bGEw== X-Gm-Message-State: AOAM533uagRBWRDonCCXp+Gf3GW4QPZuyKIjZFWc6cM4koWVqToUf2en zUdRgU8rJABuDw8xrSSaHzVXUEl4YZuOIe5N X-Received: by 2002:a5d:64ed:: with SMTP id g13mr10783123wri.222.1636474143562; Tue, 09 Nov 2021 08:09:03 -0800 (PST) Received: from lmecxl0524.lme.st.com ([2a04:cec0:10ec:fe30:ed93:5b26:60a4:aace]) by smtp.gmail.com with ESMTPSA id e18sm20130236wrs.48.2021.11.09.08.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 08:09:03 -0800 (PST) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Etienne Carriere , Jens Wiklander Subject: [PATCH v2 1/5] tee: define session login identifiers Date: Tue, 9 Nov 2021 17:08:20 +0100 Message-Id: <20211109160824.18268-1-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean Define identifiers for clnt_login field in struct tee_open_session_arg based in GlobalPlatform Device TEE IDs and on the REE_KERNEL identifier extension from OP-TEE OS. Cc: Jens Wiklander Reviewed-by: Patrick Delaunay Reviewed-by: Jens Wiklander Signed-off-by: Etienne Carriere --- Changes since v1: - Applied review tags Added info for v1: This change was previously discussed in the U-Boot ML, see v2 at: https://patchwork.ozlabs.org/project/uboot/patch/20210519142613.7668-1-etienne.carriere@linaro.org/ Changes since this v2 post: - Updated the inline comment describing reserved login Ids - Rephrase 'REE kernel agent' to 'REE kernel/privileged agent' to better apply to U-Boot that is not a kernel but still runs at a privileged execution level. --- include/tee.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/include/tee.h b/include/tee.h index 44e9cd4321..30ea2ee164 100644 --- a/include/tee.h +++ b/include/tee.h @@ -31,6 +31,25 @@ #define TEE_PARAM_ATTR_MASK (TEE_PARAM_ATTR_TYPE_MASK | \ TEE_PARAM_ATTR_META) +/* + * Global Platform login identifiers for tee_open_session_arg::clnt_login + */ +#define TEE_LOGIN_PUBLIC 0x00000000 +#define TEE_LOGIN_USER 0x00000001 +#define TEE_LOGIN_GROUP 0x00000002 +#define TEE_LOGIN_APPLICATION 0x00000004 +#define TEE_LOGIN_APPLICATION_USER 0x00000005 +#define TEE_LOGIN_APPLICATION_GROUP 0x00000006 +/* + * Reserve use of GP implementation specific login method range + * (0x80000000 - 0xBFFFFFFF). This range is rather being used + * for REE kernel clients or TEE implementation. + */ +#define TEE_LOGIN_REE_KERNEL_MIN 0x80000000 +#define TEE_LOGIN_REE_KERNEL_MAX 0xBFFFFFFF +/* Private login method for REE kernel/privileged clients */ +#define TEE_LOGIN_REE_KERNEL 0x80000000 + /* * Some Global Platform error codes which has a meaning if the * TEE_GEN_CAP_GP bit is returned by the driver in @@ -135,8 +154,8 @@ struct tee_param { /** * struct tee_open_session_arg - extra arguments for tee_open_session() * @uuid: [in] UUID of the Trusted Application - * @clnt_uuid: [in] Normally zeroes - * @clnt_login: [in] Normally 0 + * @clnt_uuid: [in] UUID of client, zeroes for PUBLIC/REE_KERNEL + * @clnt_login: [in] Class of client TEE_LOGIN_* * @session: [out] Session id * @ret: [out] return value * @ret_origin: [out] origin of the return value From patchwork Tue Nov 9 16:08:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 518044 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp1899663iml; Tue, 9 Nov 2021 08:09:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwI40B+h5H/wTSU2VDtkBA0xRtpajhT1WqFZywAPDu5uC/Tf1lUHvkMvImpcar3nJn3LUsB X-Received: by 2002:aa7:d3cf:: with SMTP id o15mr11947290edr.265.1636474161839; Tue, 09 Nov 2021 08:09:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636474161; cv=none; d=google.com; s=arc-20160816; b=cPTKWqM8sr5kQrmnzspLiusHyCKtaPqWSnNhIXhnV4IYiaO1ek94w+mOcpQ1KALaxs FWw+vjh2bFc6pxeWzYW/i/pv4gu+1KKw2LJ22BeWP3nQ3K+3zM1zoUDk/7Gg4I+xO132 7NhlZMgMoHjox12Exqa8Wy0n2Xj3LeIJAmj35u/XWMOOhMqBZNEkZhb3yxgHe5eLhbZk hbxGw3QMtgWEX1QtbktShfzMahDlV3tbQD/ey1C53ghB7XSdPLRtTrQdFNoe0X9sT5b+ x5wMq3a/ywN9Z+llzK52xtoArZ+aBhdGlJYJfwRWXmhQkoodkkdjeLJdAnrJlYx8X3Ib tdGw== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=qmpMmoGfdtcoNhoda3QOnbh+KNWhg0bhC0uDARsb4no=; b=IiL5lazVmvZeBilHrMcTtoISKPUhVB1FYg1gw+Nh6A5VZEdUXpLkOlTXzJoLRx6lwo lGJkYLdHskeWebpvZuIpX4NyljW4ePBY+i8FcxblkiQFZnSaDEiLID3NmBhnot2pBNRg Wq0OEM8KZr8eI8CPhtDgtGMpclzKWD4wpaYxVIGN9hkiwIVFK0zEjT6CKYo06ukKkLGS ctNH682Bp1BY7DjWpxyY4rk/8bw7+EIVsRw/evUtiFWlQ+F4+JFWtT7JHF/UExj9qpvt blJQjQH4v4UwDSB6qE2vFsORFETiQb7Dk1/rUB3MODwq0p4dh7VRcTGuVfVjpmAZkJig bdLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p6oEcpiZ; 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 dd9si37987759ejc.754.2021.11.09.08.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 08:09:21 -0800 (PST) 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=p6oEcpiZ; 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 B381183964; Tue, 9 Nov 2021 17:09:17 +0100 (CET) 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="p6oEcpiZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9B5FE8393E; Tue, 9 Nov 2021 17:09:10 +0100 (CET) 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-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) (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 534B68394D for ; Tue, 9 Nov 2021 17:09:05 +0100 (CET) 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-wr1-x42b.google.com with SMTP id w29so22331850wra.12 for ; Tue, 09 Nov 2021 08:09:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qmpMmoGfdtcoNhoda3QOnbh+KNWhg0bhC0uDARsb4no=; b=p6oEcpiZN8zlNXA694itAp0jzzCDtafkc+ptDxzzzEnCPOiOEvbtDAas4hCA97Wwhu XcMiKJ1hmb0XXPcnxrX/pby8ph0nu4Zo88BixrtUevfgtR9nIOA9eH2kluVgZQFBr7yB OtlYAbWdjb/AEsh1RM02sFaku1W6zvdHI+6JPwvGQTrMo5X+WkdyJEsIetiV1uX5LIup 0kboHpabRIRG3/1r9TnrS24/zXgBSYQYATFBe2aqUNMXX20w2vu4c4n+W6ikFwMfm50i 4rJwF+xuSz9bAHei3wLJP7oSb3hmL05+0gj370OoIhrVLrLjOZfksfkRgKgaiIlg4P+b Zpaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qmpMmoGfdtcoNhoda3QOnbh+KNWhg0bhC0uDARsb4no=; b=gVqE2RStg0eQmFqIR7jB5OZpEj/FhZ45qrj/tVrfIQQV/5suD4ivz4IFt5aXKoyrIa bljnCcYjJmRkVolHyUZ/iLRmVvaThsywgfHeU6OlWy3ArKfNGSS1BCjEHo3R10bIbcmb vS1zxacbuFg93GVAsvOrpnuqiX/Hh/eU5VrCeysqCEeqLn9mjpd2hxPD/uiMZCTIPnZY U6emP+cDl0/P+feglgDcOjxLKPyBNZwDxDp4Sd+gqmoANDJuCz7TxZxn86YYjfaGBymV LgkiAxiuKWnr9Quckn0vtsReG08J8IgVEYbo5WwgZS/4ujtOWUodtckLhxp7m9thYm94 eqgQ== X-Gm-Message-State: AOAM531MtuXCIk3Z6Uj1rpI/wWkAN4FP4fxeDNtCXAvVyNLSdPVDQK9V Sa1CrjbN7fXrKnYG4a2SALJ7UU7EPVyGiImw X-Received: by 2002:a5d:48cf:: with SMTP id p15mr5623306wrs.277.1636474144552; Tue, 09 Nov 2021 08:09:04 -0800 (PST) Received: from lmecxl0524.lme.st.com ([2a04:cec0:10ec:fe30:ed93:5b26:60a4:aace]) by smtp.gmail.com with ESMTPSA id e18sm20130236wrs.48.2021.11.09.08.09.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 08:09:04 -0800 (PST) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Etienne Carriere , Jens Wiklander Subject: [PATCH v2 2/5] tee: optee: remove unused duplicated login Id macros Date: Tue, 9 Nov 2021 17:08:21 +0100 Message-Id: <20211109160824.18268-2-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211109160824.18268-1-etienne.carriere@linaro.org> References: <20211109160824.18268-1-etienne.carriere@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean Remove unused OPTEE_MSG_LOGIN_* ID macros as suitable TEE_LOGIN_* ID macros are already defined tee.h. Cc: Jens Wiklander Reviewed-by: Patrick Delaunay Reviewed-by: Jens Wiklander Signed-off-by: Etienne Carriere --- Changes since v1: - Apply review tags Added info for v1: This change was previously discussed in the U-Boot ML, latest is "[PATCH v2 2/2] tee: optee: support session login as REE kernel", at: https://patchwork.ozlabs.org/project/uboot/patch/20210519142613.7668-2-etienne.carriere@linaro.org/ Changes since this v2 post: - Remove sanitation of the login Id passed to OP-TEE as secure world - Rephrase header line since this change now simply remove duplicated macros. - Update OPTEE_MSG_CMD_OPEN_SESSION inline description comment with a reference to TEE_LOGIN_* macros. --- drivers/tee/optee/optee_msg.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/tee/optee/optee_msg.h b/drivers/tee/optee/optee_msg.h index 8d40ce60c2..a8ef926a48 100644 --- a/drivers/tee/optee/optee_msg.h +++ b/drivers/tee/optee/optee_msg.h @@ -86,16 +86,6 @@ #define OPTEE_MSG_ATTR_CACHE_MASK GENMASK(2, 0) #define OPTEE_MSG_ATTR_CACHE_PREDEFINED 0 -/* - * Same values as TEE_LOGIN_* from TEE Internal API - */ -#define OPTEE_MSG_LOGIN_PUBLIC 0x00000000 -#define OPTEE_MSG_LOGIN_USER 0x00000001 -#define OPTEE_MSG_LOGIN_GROUP 0x00000002 -#define OPTEE_MSG_LOGIN_APPLICATION 0x00000004 -#define OPTEE_MSG_LOGIN_APPLICATION_USER 0x00000005 -#define OPTEE_MSG_LOGIN_APPLICATION_GROUP 0x00000006 - /* * Page size used in non-contiguous buffer entries */ @@ -279,7 +269,7 @@ struct optee_msg_arg { * parameters to pass the following information: * param[0].u.value.a-b uuid of Trusted Application * param[1].u.value.a-b uuid of Client - * param[1].u.value.c Login class of client OPTEE_MSG_LOGIN_* + * param[1].u.value.c Login class of client TEE_LOGIN_* * * OPTEE_MSG_CMD_INVOKE_COMMAND invokes a command a previously opened * session to a Trusted Application. struct optee_msg_arg::func is Trusted From patchwork Tue Nov 9 16:08:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 518045 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp1899846iml; Tue, 9 Nov 2021 08:09:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzAjJBmTI7tYvxwzu5AzCAHiIvPsboDewSRRgEEn9JR3mr8Lai3wwl06H27xAT1ATEl5qjc X-Received: by 2002:a05:6402:455:: with SMTP id p21mr11720978edw.384.1636474171217; Tue, 09 Nov 2021 08:09:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636474171; cv=none; d=google.com; s=arc-20160816; b=Qa4uB+ixnOUM97aYz3VHdwVtopcwq8ito0JEAdR2r0ZfD4phu4O7ncHEF2BCB/ikbn FiN9+/9DnJtwNeRzX5nghl3ynB8hkSd+6KS9Z34r16yCNis2briXgzllUCkFEvw6NR6m 58Qx5mohhHnyGusiMW2j4w7ZVyDQIllqzQDmNDc7w1E+VL8UNeye2+ogwwA73Lu2So5C LYlpcySmjxPqYry487BTabrfCaU1y/fbYblCVyP98PUESebBIpDjnQJ4wkL63LnKPvUG VJkw08hQpGcS3NwncBpPWtQJUoejiXNKe9e18bZWcJWXxuh2uI36zH5w/Hzypph7nt4I 1oWA== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Qb3P5XBmEO30RM1MFZo2YmxmHO27ojDSActweGvwFjI=; b=U83W0jIrOZrzAHKRP7h//Q8aRgyLLG3iU7i2dge24xBuGmhvn4yC5i86FLJVXhIVPv Hn40jLo0rS/hsbo3JVE/imrn4oGONecPRmydmJsyM1F3LrsXNXghiaqPTcJfsPyWKGPW cDxL74hC92NU3m2N/+DrSKPBYrTGyOrH2qRjjrDHtFFKXty749p0aSDYS46xYj6Keotx kRsIEtg3Mlu5qKn1+aCChfuH88MHsUVh5p9qd6fSbRE96d8fH0urH6pgqQ1+5kYrdOjM 0BtTMybB2w8KkG6USZINHl6QcFXOve8QmcbYUgv5E+ATrm6GUcVCRixpR/myPuxtPxn9 7tIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XJ9Rjoot; 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 cr1si2173813ejc.534.2021.11.09.08.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 08:09:31 -0800 (PST) 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=XJ9Rjoot; 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 3A90E83974; Tue, 9 Nov 2021 17:09:21 +0100 (CET) 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="XJ9Rjoot"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9E29D83969; Tue, 9 Nov 2021 17:09:12 +0100 (CET) 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-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (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 6BDAB83953 for ; Tue, 9 Nov 2021 17:09:06 +0100 (CET) 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-x332.google.com with SMTP id i8-20020a7bc948000000b0030db7b70b6bso2324009wml.1 for ; Tue, 09 Nov 2021 08:09:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Qb3P5XBmEO30RM1MFZo2YmxmHO27ojDSActweGvwFjI=; b=XJ9RjootKDnQWId74m39B2OFVMlNr1NiJm1WSCPXRo7Dz5Gvr3c5+uZLbaez4/co5z ebAHtOVPYAaHgmit8sJIrIPjxdn+QxLvaz9ddoVD0FPWKiOqp9JetAEmZ1g7RghJ+20M ZfYr4Jm2AhKLSOSbFtbm04hf13HJ3DXN0+CLGwnn2IrBP0OoGBHmTEFG31nJadWoONuA KQ/wUAWxlU8nYBpoQEKSNH/R6oyQbpXzW7oQR8IK5Ks1J34iZ+DL189axQXmZ8oCied5 d/f3e5RNVhCXhyWHLAEe2Vo1m6u2V7qouPe5prQAPSFBBTzAl4Fh4hIfPpp5aRXKBGTe +W8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Qb3P5XBmEO30RM1MFZo2YmxmHO27ojDSActweGvwFjI=; b=eZedS1ogpHVwfA5QkOmkRLE01bdPkkn7zHeof+jF9RZwNlYukQQVFbeRDZ92yvHKZX 7U1yWxFUy9Z6nMPJ6oUQT0C/BXqPGd9l8p8MWJQHwQmGgtKdsEvS+Do04Tyk1VqC9iD/ wi+tzgw6ASE4EViTALNubLOZg5p3WH/m+/9hdvrIA/TU/WqQxZwKZOTxXYaLUdpLYj7B 4/ZFMC8XtVv0mf0RbvaheKla2wtK7jPiFxI/RJnK25S8ObZpHYuSGHZtM/ukp54HQeDH hBMZXaBGWIzPygOca06BBqdLe8y2BEsvWxVNoxaLnYF3qVOeJ09VKO9G4y2nXw24KKCE 4P7w== X-Gm-Message-State: AOAM533uzD8652xrGqe1npDMOLjd3I7FZlP7qEpSuey0lY/z8cnyntYV JhkNqgaHgjq4j8HFZoHK0OsTFNNAo/LkrCKj X-Received: by 2002:a7b:c14f:: with SMTP id z15mr8444222wmi.56.1636474145695; Tue, 09 Nov 2021 08:09:05 -0800 (PST) Received: from lmecxl0524.lme.st.com ([2a04:cec0:10ec:fe30:ed93:5b26:60a4:aace]) by smtp.gmail.com with ESMTPSA id e18sm20130236wrs.48.2021.11.09.08.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 08:09:05 -0800 (PST) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Etienne Carriere , Jens Wiklander Subject: [PATCH v2 3/5] tee: optee: define TEE error code TEE_ERROR_SHORT_BUFFER Date: Tue, 9 Nov 2021 17:08:22 +0100 Message-Id: <20211109160824.18268-3-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211109160824.18268-1-etienne.carriere@linaro.org> References: <20211109160824.18268-1-etienne.carriere@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean Adds TEE_ERROR_SHORT_BUFFER as TEE error code. This error code is commonly used by TEEs to inform caller that the buffer(s) it provided is too small for the desired operation. Cc: Jens Wiklander Reviewed-by: Patrick Delaunay Reviewed-by: Jens Wiklander Signed-off-by: Etienne Carriere --- Changes since v1: - Apply review tags --- include/tee.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/tee.h b/include/tee.h index 30ea2ee164..50051496ae 100644 --- a/include/tee.h +++ b/include/tee.h @@ -64,6 +64,7 @@ #define TEE_ERROR_NOT_SUPPORTED 0xffff000a #define TEE_ERROR_COMMUNICATION 0xffff000e #define TEE_ERROR_SECURITY 0xffff000f +#define TEE_ERROR_SHORT_BUFFER 0xffff0010 #define TEE_ERROR_OUT_OF_MEMORY 0xffff000c #define TEE_ERROR_OVERFLOW 0xffff300f #define TEE_ERROR_TARGET_DEAD 0xffff3024 From patchwork Tue Nov 9 16:08:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 518046 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp1900055iml; Tue, 9 Nov 2021 08:09:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYiUJSUif8RXSInAY/IVN+R1s3WvqXmBYKMfSK49VFGqZ1QGBQ2xCLkUsfQQPlaTrRzPca X-Received: by 2002:a17:907:2da1:: with SMTP id gt33mr10785752ejc.378.1636474180537; Tue, 09 Nov 2021 08:09:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636474180; cv=none; d=google.com; s=arc-20160816; b=t4+/VBf6teC1Mm0Jq2PQixsZmbNr6ahVgiTLbeM/68Wd91wEhAbwbJxXoeB0u5PR5i fW4bAzAGykg6aWWvk6JcNVshCHTzIBM55twud35mbuJfWP9Dt2gahPaxT6B8MOVBu3Uc 40D2daxx+nvnmycK3S2+a1uakxSltzTRds8GbpqZTb9fk78nX0+Ea3iKGesumk/UXScq c3oX6XU0XfUqc0st+BilyD/HigLPVmWHgBYX2HudYUWohTcDydw0JmuHdfHXgBvYkayG keWzibSlIu/gNSZNVlhr+hMXrtWyVWH/tbz63uLQpMQngQKpmvOlw6T1jgxdF/VxxX7O CD1w== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=cbvpwsOoEqmSNb3CBX9RLhDsYwpLwYyAK/ClUm1PWsY=; b=bNMvgi2fUx6jefpPn1Glr/QwHxOK3HmvIWmMbj9/7t6HQwxzSc9vk4A4OWGa/Sy1ch kCI7ldiuj9X4B/AHxdfRD+zDUNh+PbhHzEH1GEaYXVfgOvX0UshbpWxd+Sq518LlJjVy rAkM/Ce8AFpLoXerGZIc/HA3pTGIVt/3b3UjogJqyaHINu/7Hm3y3NTP8/5xLW7kcTvU 3Ya9s941Eq852GQ+zmLlOBs4fbJm0hUxqP1pDehrTFt9KUKCQuE3Z3nA4mXIUdyxGnSD ZXEiQY+ypPdyshZFIibrvQmWTj6WeL2pgZFU1qooD0ccBOUyyNYAgfUDYP8k3Th3OEN/ cR3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G0TdY2c9; 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 h14si28931439ejt.392.2021.11.09.08.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 08:09:40 -0800 (PST) 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=G0TdY2c9; 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 DAC4D8397D; Tue, 9 Nov 2021 17:09:24 +0100 (CET) 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="G0TdY2c9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2700383953; Tue, 9 Nov 2021 17:09:14 +0100 (CET) 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-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (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 5D84083957 for ; Tue, 9 Nov 2021 17:09:07 +0100 (CET) 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-x32e.google.com with SMTP id g191-20020a1c9dc8000000b0032fbf912885so2625742wme.4 for ; Tue, 09 Nov 2021 08:09:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cbvpwsOoEqmSNb3CBX9RLhDsYwpLwYyAK/ClUm1PWsY=; b=G0TdY2c9VIiGjHOCOBZTojzk2VmxHILFSa94tl3GVRkSChL+Uk2sz4olPnWpVrlz6r BnbfQ5IiqfhA5jubv+tpzjokSJ/NA+uw1gTd9aBpHtPmUU254SH0NtZe7+XulgDiixo4 7W7UEfv0tNdJgB2qboeR0sUJvXKvUt12zgyMoNLUP5zNtAc7zkCX0VRhjXf8Kk6v6/Wr XAMtL4wYTJ+JYx/Bl2CUZkxFYY22TBx2fCGPX014ilaHhL2CDLSSZ7P8byXr1gExVQyl E/wufmNhfjp+tVjVw9y7k30ntSXVY2rDEKI4RvELT72mRW7uIBS2OClAcLzcjXAF12UE lkAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cbvpwsOoEqmSNb3CBX9RLhDsYwpLwYyAK/ClUm1PWsY=; b=EyXBXqELYc4s+ZnaVJatx2S4GpVuXVVVkj6pWexlTWwUV9qwMgOOR8Qj/tMsVXrInH XUbRG+b2s1qfAt9tL+pxiufuBSd5knd005GYSc281tfeP/emAU2KS6eUneQr4vTZbQBf UEZgVgIGL3L+NkWvicut+F7vhlYqe5KFHa4qul8alE/HSLkhJqILwBhFjyaCp3lYEEmr lt7s/NGLUDQsd1nJEElTyjH32/NplV1RSOybdye9EWO89RCiXnD4fF674SxYKRezXoXp b3zxKZXvelBXJR4Lzt2EmdTNHZ+VUZD10jW/r1Tl7WkNY11oVprJnqfmdL1jrZUqaoyf vJVg== X-Gm-Message-State: AOAM531ETT6F+rrwk0JWrEE5yuZ5tBvXvP+4ZFeq6NM1Qrf7ecHHrM/C 5XyeDuK+ZaG4g1MnLMAWTeGyHzTvOJUH+mqM X-Received: by 2002:a7b:cc1a:: with SMTP id f26mr8414896wmh.39.1636474146629; Tue, 09 Nov 2021 08:09:06 -0800 (PST) Received: from lmecxl0524.lme.st.com ([2a04:cec0:10ec:fe30:ed93:5b26:60a4:aace]) by smtp.gmail.com with ESMTPSA id e18sm20130236wrs.48.2021.11.09.08.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 08:09:06 -0800 (PST) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Etienne Carriere , Jaehoon Chung Subject: [PATCH v2 4/5] dt-bindings: arm: scmi: OP-TEE as transport channel for SCMI messages Date: Tue, 9 Nov 2021 17:08:23 +0100 Message-Id: <20211109160824.18268-4-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211109160824.18268-1-etienne.carriere@linaro.org> References: <20211109160824.18268-1-etienne.carriere@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean Introduce compatible "linaro,scmi-optee" for SCMI transport channel based on an OP-TEE service invocation. Define "linaro,optee-channel-id" property to identify the OP-TEE SCMI channel used by the protocol(s). OP-TEE SCMI transport can either use shared memory or a static shared memory buffer identified by the DT. These bindings were posted to the Linux kernel DT bindings mailing list and acked by maintainer [1]. Link: [1] https://lore.kernel.org/linux-arm-kernel/20211029102118.GG6526@e120937-lin/T/ Cc: Jaehoon Chung Reviewed-by: Patrick Delaunay Signed-off-by: Etienne Carriere --- Changes since v1: - Apply review tag --- doc/device-tree-bindings/arm/arm,scmi.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/device-tree-bindings/arm/arm,scmi.txt b/doc/device-tree-bindings/arm/arm,scmi.txt index a76124f4a3..92572eabb5 100644 --- a/doc/device-tree-bindings/arm/arm,scmi.txt +++ b/doc/device-tree-bindings/arm/arm,scmi.txt @@ -14,7 +14,8 @@ Required properties: The scmi node with the following properties shall be under the /firmware/ node. -- compatible : shall be "arm,scmi" or "arm,scmi-smc" for smc/hvc transports +- compatible : shall be "arm,scmi" or "arm,scmi-smc" for smc/hvc transports, + or "linaro,scmi-optee" for OP-TEE transport. - mboxes: List of phandle and mailbox channel specifiers. It should contain exactly one or two mailboxes, one for transmitting messages("tx") and another optional for receiving the notifications("rx") if @@ -26,6 +27,8 @@ The scmi node with the following properties shall be under the /firmware/ node. - #size-cells : should be '0' as 'reg' property doesn't have any size associated with it. - arm,smc-id : SMC id required when using smc or hvc transports +- linaro,optee-channel-id : Channel specifier required when using OP-TEE + transport. Optional properties: @@ -33,16 +36,16 @@ Optional properties: See Documentation/devicetree/bindings/mailbox/mailbox.txt for more details about the generic mailbox controller and client driver bindings. - -The mailbox is the only permitted method of calling the SCMI firmware. Mailbox doorbell is used as a mechanism to alert the presence of a messages and/or notification. Each protocol supported shall have a sub-node with corresponding compatible as described in the following sections. If the platform supports dedicated -communication channel for a particular protocol, the 3 properties namely: -mboxes, mbox-names and shmem shall be present in the sub-node corresponding -to that protocol. +communication channel for a particular protocol, properties shall be present +in the sub-node corresponding to that protocol. These properties are: +- mboxes, mbox-names and shmem for mailbox transport +- arm,smc-id and shmem for smc/hvc transport +- linaro,optee-channel-id and possibly shmem for OP-TEE transport Clock/Performance bindings for the clocks/OPPs based on SCMI Message Protocol ------------------------------------------------------------ From patchwork Tue Nov 9 16:08:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 518047 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp1900223iml; Tue, 9 Nov 2021 08:09:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxm43vyhHxkotE9ev/TQmNMrKDl3lZXFnFvDUcoGn+ych9GSdavHELtfEFQEEh4f+55Rvk X-Received: by 2002:aa7:c553:: with SMTP id s19mr11587620edr.292.1636474191002; Tue, 09 Nov 2021 08:09:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636474190; cv=none; d=google.com; s=arc-20160816; b=KyhOczpkIUAjW6RsAC/ZfA9NQFXfoA58apsYokrS69RQPn6kFXc1WAdQQSdYcRTbls Q9A7iW0ixFLnQSQdB/5l2pkCKokDvNAvIt1Pq9CjR27ytM9bLUAUN+zGVusm2CUXgqKm JnJ5Zz6H20woV545abQT6u9o+88pO3mnYIJENI+Rjps5llWvMAE0VxcBkeB/QD1EIlJt wSJ1M19pf32DX3zfoc2Nz4KfUe8OonT83YLW/vEELbY2MsjMN0Oc2Dus7qSxknRhWmrq hanZNVZDhKAkQgmOJtr+LzlNFtBDzC/atAnLPmi9i6FT8/g7pt7UUf0KR9LJwAGw+N8H 0wFA== 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:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=wXmDnWdExf4YGE6P7uUqis4fvMJ9RtOQXUsxkAA26og=; b=ILKDp6eEFEGgdQZD/mt/YPeUsoqZM5TodybaBFy3ZcNEeg7/7CKhyREPiOBwKGeEzX EVoqaW+lI/6LdegYdzgvXOSfpiJqVrXq68brC037PJBwxi4NZayCrDtVJU8rTXrVBdd5 qK7nQ2CjnhPeA40k/v4jVDQkTI06N2WMPugwiBu32bc7kLVXXwtjNHJTturdRhujAWyh WjVmALkYFj9o/AX+5d4wZbWRZbzxxpsMDn6+r23aM5bckd0IDPIjvHjGOcA/OuFbNT0f uR+/j9oJwPzz5rUTyFMFYaW4G/2+d2ZH7+HBCv1chVHf6vodWQZKRTlUvu2ouyCBJV+J ix2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c1KwySjI; 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 e10si30773757edv.299.2021.11.09.08.09.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 08:09:50 -0800 (PST) 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=c1KwySjI; 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 BB6768398B; Tue, 9 Nov 2021 17:09:31 +0100 (CET) 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="c1KwySjI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C2ECB83953; Tue, 9 Nov 2021 17:09:15 +0100 (CET) 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=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (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 8FE8D83964 for ; Tue, 9 Nov 2021 17:09:08 +0100 (CET) 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-wr1-x431.google.com with SMTP id d24so33917019wra.0 for ; Tue, 09 Nov 2021 08:09:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wXmDnWdExf4YGE6P7uUqis4fvMJ9RtOQXUsxkAA26og=; b=c1KwySjIKOC6zlbtFiJMdhnDLaY0Ukm1JEP/fBYWWW4n36BoiB/xa2xFuGVMPwm6xn 4OW7VJhYgsrRdclqXJjtrpTFgECNnB88DqCNZ9v5r4uVzRKCxRbfcQWSonotaqpYX4dk LNyZB8OHfelRdePjuGdSe/L9LT6BjFrdS5wP92O7Xq7TYQg15j7k7UQwIPnrcysSAtXA vPaoHcTGyPxOWsLdnG1PE0qepwqdRALUNl7eNkDMphwyl5sJm7s1fhtIcByw5mvs/iUr 1uXfEpB24ei5e0UvmZDpO7G5qjZFLgLe36kz63I/lwMIFLIuYO73XRcGYP00J2uRo+Zd iKyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wXmDnWdExf4YGE6P7uUqis4fvMJ9RtOQXUsxkAA26og=; b=3ZrmmHLfyk15UkRV5CqJweqSr7W0+KVELtk1sYXsVVYkugJ13tqfaukKZ2ahYKwYyi FRYNPCp0BnrQJZZcwwL9Xm/1yzyTQW8IVyJ4S/HSIb1ZN29J/O5JyNSKn4M/BSNT27hb +TIXpyA6mwOJvSo6ZOKuV6y44ma7xiRn57xAXH4UVVW6RaZrGHruPLM37eEkNbqaDYZ2 JE8BvceMSK/R8F7/8Vjwlg/9uS2JswGWNZp8o8O8L/EeFMRdrnuhbAMRLsytENXZ7tXv ZU/85c708EGx0hgszHY8iUYmim9+KBBsZM1bY39hqSQ8YMVEotnMyYt2J57I7Z0iB1Xl nmzg== X-Gm-Message-State: AOAM531gCOZSXtiII+DO6N6x+QFr6zD9nKY1XfhkPGuNvHmUZucjXdYU xL82fFMkHWTZL+KH7OHWAzIsfRTvXXwQ+kcE X-Received: by 2002:a5d:6b04:: with SMTP id v4mr11016176wrw.148.1636474147730; Tue, 09 Nov 2021 08:09:07 -0800 (PST) Received: from lmecxl0524.lme.st.com ([2a04:cec0:10ec:fe30:ed93:5b26:60a4:aace]) by smtp.gmail.com with ESMTPSA id e18sm20130236wrs.48.2021.11.09.08.09.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 08:09:07 -0800 (PST) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Etienne Carriere , Patrick Delaunay , Wolfgang Denk Subject: [PATCH v2 5/5] firmware: scmi: Add OP-TEE transport Date: Tue, 9 Nov 2021 17:08:24 +0100 Message-Id: <20211109160824.18268-5-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211109160824.18268-1-etienne.carriere@linaro.org> References: <20211109160824.18268-1-etienne.carriere@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean This change implements an SCMI transport for agent interfacing the OP-TEE SCMI service. OP-TEE provides an SCMI PTA (Pseudo-TA) for non-secure world to send SCMI messages over an identified channel. The driver implemented here uses a SMT shared memory for passing messages between client and server. The implementation opens and releases channel resources for each passed SCMI message so that resources allocated (sessions) or registered (shared memory areas) in OP-TEE firmware are released for example before relocation as the driver will likely allocate/register them back when probed after relocation. The integration of the driver using dedicated config switch CONFIG_SCMI_AGENT_OPTEE is designed on the model posted to the U-Boot ML by Patrick Delaunay [1]. Link: [1] https://lore.kernel.org/all/20211028191222.v3.4.Ib2e58ee67f4d023823d8b5404332dc4d7e847277@changeid/ Cc: Patrick Delaunay Cc: Wolfgang Denk Signed-off-by: Etienne Carriere Reviewed-by: Patrick Delaunay --- Changes since v1: - Correct error trace message on missing DT node property. --- drivers/firmware/scmi/Kconfig | 14 +- drivers/firmware/scmi/Makefile | 1 + drivers/firmware/scmi/optee_agent.c | 312 ++++++++++++++++++++++++++++ 3 files changed, 324 insertions(+), 3 deletions(-) create mode 100644 drivers/firmware/scmi/optee_agent.c diff --git a/drivers/firmware/scmi/Kconfig b/drivers/firmware/scmi/Kconfig index c3a109beac..f9c69e5352 100644 --- a/drivers/firmware/scmi/Kconfig +++ b/drivers/firmware/scmi/Kconfig @@ -2,7 +2,7 @@ config SCMI_FIRMWARE bool "Enable SCMI support" select FIRMWARE select OF_TRANSLATE - depends on SANDBOX || DM_MAILBOX || ARM_SMCCC + depends on SANDBOX || DM_MAILBOX || ARM_SMCCC || OPTEE help System Control and Management Interface (SCMI) is a communication protocol that defines standard interfaces for power, performance @@ -14,6 +14,14 @@ config SCMI_FIRMWARE or a companion host in the CPU system. Communications between agent (client) and the SCMI server are - based on message exchange. Messages can be exchange over tranport + based on message exchange. Messages can be exchanged over transport channels as a mailbox device or an Arm SMCCC service with some - piece of identified shared memory. + piece of identified shared memory, or an OP-TEE SCMI service. + +config SCMI_AGENT_OPTEE + bool "Enable SCMI agent OP-TEE" + depends on SCMI_FIRMWARE && OPTEE + default y + help + Enable the SCMI communication channel based on OP-TEE transport + for compatible "linaro,scmi-optee". diff --git a/drivers/firmware/scmi/Makefile b/drivers/firmware/scmi/Makefile index 966475ec10..f72d06a400 100644 --- a/drivers/firmware/scmi/Makefile +++ b/drivers/firmware/scmi/Makefile @@ -2,4 +2,5 @@ obj-y += scmi_agent-uclass.o obj-y += smt.o obj-$(CONFIG_ARM_SMCCC) += smccc_agent.o obj-$(CONFIG_DM_MAILBOX) += mailbox_agent.o +obj-$(CONFIG_SCMI_AGENT_OPTEE) += optee_agent.o obj-$(CONFIG_SANDBOX) += sandbox-scmi_agent.o sandbox-scmi_devices.o diff --git a/drivers/firmware/scmi/optee_agent.c b/drivers/firmware/scmi/optee_agent.c new file mode 100644 index 0000000000..1f26592234 --- /dev/null +++ b/drivers/firmware/scmi/optee_agent.c @@ -0,0 +1,312 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2020-2021 Linaro Limited. + */ + +#define LOG_CATEGORY UCLASS_SCMI_AGENT + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "smt.h" + +#define SCMI_SHM_SIZE 128 + +/** + * struct scmi_optee_channel - Description of an SCMI OP-TEE transport + * @channel_id: Channel identifier + * @smt: Shared memory buffer with synchronisation protocol + * @dyn_shm: True if using dynamically allocated shared memory + */ +struct scmi_optee_channel { + unsigned int channel_id; + struct scmi_smt smt; + bool dyn_shm; +}; + +/** + * struct channel_session - Aggreates SCMI service session context references + * @tee: OP-TEE device to invoke + * @tee_session: OP-TEE session identifier + * @tee_shm: Dynamically allocated OP-TEE shared memory, or NULL + * @channel_hdl: Channel handle provided by OP-TEE SCMI service + */ +struct channel_session { + struct udevice *tee; + u32 tee_session; + struct tee_shm *tee_shm; + u32 channel_hdl; +}; + +#define TA_SCMI_UUID { 0xa8cfe406, 0xd4f5, 0x4a2e, \ + { 0x9f, 0x8d, 0xa2, 0x5d, 0xc7, 0x54, 0xc0, 0x99 } } + +enum optee_smci_pta_cmd { + /* + * PTA_SCMI_CMD_CAPABILITIES - Get channel capabilities + * + * [out] value[0].a: Capability bit mask (enum pta_scmi_caps) + * [out] value[0].b: Extended capabilities or 0 + */ + PTA_SCMI_CMD_CAPABILITIES = 0, + + /* + * PTA_SCMI_CMD_PROCESS_SMT_CHANNEL - Process SCMI message in SMT buffer + * + * [in] value[0].a: Channel handle + * + * Shared memory used for SCMI message/response exhange is expected + * already identified and bound to channel handle in both SCMI agent + * and SCMI server (OP-TEE) parts. + * The memory uses SMT header to carry SCMI meta-data (protocol ID and + * protocol message ID). + */ + PTA_SCMI_CMD_PROCESS_SMT_CHANNEL = 1, + + /* + * PTA_SCMI_CMD_PROCESS_SMT_CHANNEL_MESSAGE - Process SMT/SCMI message + * + * [in] value[0].a: Channel handle + * [in/out] memref[1]: Message/response buffer (SMT and SCMI payload) + * + * Shared memory used for SCMI message/response is a SMT buffer + * referenced by param[1]. It shall be 128 bytes large to fit response + * payload whatever message playload size. + * The memory uses SMT header to carry SCMI meta-data (protocol ID and + * protocol message ID). + */ + PTA_SCMI_CMD_PROCESS_SMT_CHANNEL_MESSAGE = 2, + + /* + * PTA_SCMI_CMD_GET_CHANNEL - Get channel handle + * + * SCMI shm information are 0 if agent expects to use OP-TEE regular SHM + * + * [in] value[0].a: Channel identifier + * [out] value[0].a: Returned channel handle + * [in] value[0].b: Requested capabilities mask (enum pta_scmi_caps) + */ + PTA_SCMI_CMD_GET_CHANNEL = 3, +}; + +/* + * OP-TEE SCMI service capabilities bit flags (32bit) + * + * PTA_SCMI_CAPS_SMT_HEADER + * When set, OP-TEE supports command using SMT header protocol (SCMI shmem) in + * shared memory buffers to carry SCMI protocol synchronisation information. + */ +#define PTA_SCMI_CAPS_NONE 0 +#define PTA_SCMI_CAPS_SMT_HEADER BIT(0) + +static int open_channel(struct udevice *dev, struct channel_session *sess) +{ + const struct tee_optee_ta_uuid uuid = TA_SCMI_UUID; + struct scmi_optee_channel *chan = dev_get_plat(dev); + struct tee_open_session_arg sess_arg = { }; + struct tee_invoke_arg cmd_arg = { }; + struct tee_param param[1] = { }; + int ret; + + memset(sess, 0, sizeof(sess)); + + sess->tee = tee_find_device(NULL, NULL, NULL, NULL); + if (!sess->tee) + return -ENODEV; + + sess_arg.clnt_login = TEE_LOGIN_REE_KERNEL; + tee_optee_ta_uuid_to_octets(sess_arg.uuid, &uuid); + + ret = tee_open_session(sess->tee, &sess_arg, 0, NULL); + if (ret) { + dev_err(dev, "can't open session: %d\n", ret); + return ret; + } + + cmd_arg.func = PTA_SCMI_CMD_GET_CHANNEL; + cmd_arg.session = sess_arg.session; + + param[0].attr = TEE_PARAM_ATTR_TYPE_VALUE_INOUT; + param[0].u.value.a = chan->channel_id; + param[0].u.value.b = PTA_SCMI_CAPS_SMT_HEADER; + + ret = tee_invoke_func(sess->tee, &cmd_arg, ARRAY_SIZE(param), param); + if (ret || cmd_arg.ret) { + dev_err(dev, "Invoke failed: %d, 0x%x\n", ret, cmd_arg.ret); + if (!ret) + ret = -EPROTO; + + tee_close_session(sess->tee, sess_arg.session); + return ret; + } + + sess->tee_session = sess_arg.session; + sess->channel_hdl = param[0].u.value.a; + + return 0; +} + +static void close_channel(struct channel_session *sess) +{ + tee_close_session(sess->tee, sess->tee_session); +} + +static int invoke_cmd(struct udevice *dev, struct channel_session *sess, + struct scmi_msg *msg) +{ + struct scmi_optee_channel *chan = dev_get_plat(dev); + struct tee_invoke_arg arg = { }; + struct tee_param param[2] = { }; + int ret; + + scmi_write_msg_to_smt(dev, &chan->smt, msg); + + arg.session = sess->tee_session; + param[0].attr = TEE_PARAM_ATTR_TYPE_VALUE_INPUT; + param[0].u.value.a = sess->channel_hdl; + + if (chan->dyn_shm) { + arg.func = PTA_SCMI_CMD_PROCESS_SMT_CHANNEL_MESSAGE; + param[1].attr = TEE_PARAM_ATTR_TYPE_MEMREF_INOUT; + param[1].u.memref.shm = sess->tee_shm; + param[1].u.memref.size = SCMI_SHM_SIZE; + } else { + arg.func = PTA_SCMI_CMD_PROCESS_SMT_CHANNEL; + } + + ret = tee_invoke_func(sess->tee, &arg, ARRAY_SIZE(param), param); + if (ret || arg.ret) { + if (!ret) + ret = -EPROTO; + } else { + ret = scmi_read_resp_from_smt(dev, &chan->smt, msg); + } + + scmi_clear_smt_channel(&chan->smt); + + return ret; +} + +static int prepare_shm(struct udevice *dev, struct channel_session *sess) +{ + struct scmi_optee_channel *chan = dev_get_plat(dev); + int ret; + + /* Static shm is already prepared by the firmware: nothing to do */ + if (!chan->dyn_shm) + return 0; + + chan->smt.size = SCMI_SHM_SIZE; + + ret = tee_shm_alloc(sess->tee, chan->smt.size, 0, &sess->tee_shm); + if (ret) { + dev_err(dev, "Failed to allocated shmem: %d\n", ret); + return ret; + } + + chan->smt.buf = sess->tee_shm->addr; + + /* Initialize shm buffer for message exchanges */ + scmi_clear_smt_channel(&chan->smt); + + return 0; +} + +static void release_shm(struct udevice *dev, struct channel_session *sess) +{ + struct scmi_optee_channel *chan = dev_get_plat(dev); + + if (chan->dyn_shm) + tee_shm_free(sess->tee_shm); +} + +static int scmi_optee_process_msg(struct udevice *dev, struct scmi_msg *msg) +{ + struct channel_session sess; + int ret; + + ret = open_channel(dev, &sess); + if (ret) + return ret; + + ret = prepare_shm(dev, &sess); + if (ret) + goto out; + + ret = invoke_cmd(dev, &sess, msg); + + release_shm(dev, &sess); + +out: + close_channel(&sess); + + return ret; +} + +static int scmi_optee_of_to_plat(struct udevice *dev) +{ + struct scmi_optee_channel *chan = dev_get_plat(dev); + int ret; + + if (dev_read_u32(dev, "linaro,optee-channel-id", &chan->channel_id)) { + dev_err(dev, "Missing property linaro,optee-channel-id\n"); + return -EINVAL; + } + + if (dev_read_prop(dev, "shmem", NULL)) { + ret = scmi_dt_get_smt_buffer(dev, &chan->smt); + if (ret) { + dev_err(dev, "Failed to get smt resources: %d\n", ret); + return ret; + } + chan->dyn_shm = false; + } else { + chan->dyn_shm = true; + } + + return 0; +} + +static int scmi_optee_probe(struct udevice *dev) +{ + struct channel_session sess; + int ret; + + /* Check OP-TEE service acknowledges the SCMI channel */ + ret = open_channel(dev, &sess); + if (!ret) + close_channel(&sess); + + return ret; +} + +static const struct udevice_id scmi_optee_ids[] = { + { .compatible = "linaro,scmi-optee" }, + { } +}; + +static const struct scmi_agent_ops scmi_optee_ops = { + .process_msg = scmi_optee_process_msg, +}; + +U_BOOT_DRIVER(scmi_optee) = { + .name = "scmi-over-optee", + .id = UCLASS_SCMI_AGENT, + .of_match = scmi_optee_ids, + .plat_auto = sizeof(struct scmi_optee_channel), + .of_to_plat = scmi_optee_of_to_plat, + .probe = scmi_optee_probe, + .flags = DM_FLAG_OS_PREPARE, + .ops = &scmi_optee_ops, +};