Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/965483/?format=api
{ "id": 965483, "url": "http://patchwork.ozlabs.org/api/patches/965483/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20180903144711.31585-7-jens.wiklander@linaro.org/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20180903144711.31585-7-jens.wiklander@linaro.org>", "list_archive_url": null, "date": "2018-09-03T14:46:57", "name": "[U-Boot,v3,06/20] Add UCLASS_TEE for Trusted Execution Environment", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "1b5dbc8b0d6df8d3cd3829d40f9b882db1d46bbb", "submitter": { "id": 66201, "url": "http://patchwork.ozlabs.org/api/people/66201/?format=api", "name": "Jens Wiklander", "email": "jens.wiklander@linaro.org" }, "delegate": { "id": 3651, "url": "http://patchwork.ozlabs.org/api/users/3651/?format=api", "username": "trini", "first_name": "Tom", "last_name": "Rini", "email": "trini@ti.com" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20180903144711.31585-7-jens.wiklander@linaro.org/mbox/", "series": [ { "id": 63875, "url": "http://patchwork.ozlabs.org/api/series/63875/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=63875", "date": "2018-09-03T14:46:51", "name": "AVB using OP-TEE", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/63875/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/965483/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/965483/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)", "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=linaro.org", "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"czeSarBb\"; dkim-atps=neutral" ], "Received": [ "from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 423tJf19bSz9s4Z\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 4 Sep 2018 00:53:54 +1000 (AEST)", "by lists.denx.de (Postfix, from userid 105)\n\tid D40BFC21E16; Mon, 3 Sep 2018 14:52:38 +0000 (UTC)", "from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 7A817C21EE7;\n\tMon, 3 Sep 2018 14:47:48 +0000 (UTC)", "by lists.denx.de (Postfix, from userid 105)\n\tid 633E8C21E77; Mon, 3 Sep 2018 14:47:36 +0000 (UTC)", "from mail-lf1-f68.google.com (mail-lf1-f68.google.com\n\t[209.85.167.68])\n\tby lists.denx.de (Postfix) with ESMTPS id 8AD51C21EBB\n\tfor <u-boot@lists.denx.de>; Mon, 3 Sep 2018 14:47:28 +0000 (UTC)", "by mail-lf1-f68.google.com with SMTP id q13-v6so667408lfc.2\n\tfor <u-boot@lists.denx.de>; Mon, 03 Sep 2018 07:47:28 -0700 (PDT)", "from jax.ideon.se ([85.235.10.227])\n\tby smtp.gmail.com with ESMTPSA id\n\tw18-v6sm3343431ljd.73.2018.09.03.07.47.25\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 03 Sep 2018 07:47:26 -0700 (PDT)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2,\n\tT_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=QxlYcu5pNMU9EByveXU4SfbTHqW8o+fuW7xpqj+jA/M=;\n\tb=czeSarBbdrZWDSDeordioktvtOFpx7ErDvr9TAfHJEsirEbwKCm/qiSx7Gek9WTTV6\n\tfU7s1nkv1t3SYnAxPtn0KxFOs0iG2ZhMrpMovIapTI7fAaXOWGsleIDzzNVKFim2h/ee\n\tyDjgUZ9EqMjGRIWphMlP583xMTtB3QfK33/Gk=", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=QxlYcu5pNMU9EByveXU4SfbTHqW8o+fuW7xpqj+jA/M=;\n\tb=W3VMiZP9CnH1fpzaQgMmXH7VU7Eqyz6cfZD8PXZfMESWtjyJK597fTVmNq1/1St5XG\n\tWtowgpR7GmcW3NfzOH6LtdRq0HzpSL5Dku8Z8qpe+fYenLnwz7FeQ3gp/TOYL2QF1cjQ\n\taEUnMhB9OhLCsLe3Dd3iGuCLPLzBi7fKmi7ayQ1iBQyHH30Gb4WVcaCvQhSzy6MqtBsw\n\t8pMJcEq1euJDCMPWpmOy7UD6Cab8e+crN7KyL6dLXfvUUPfMKtchcXZHLvTLY0TjNmCc\n\twk0mbhrUdcDRprhyRBlxXIgL9bjnxUyRyzYpAKnWlUoeFobEWKFcxmr+Js02+pJR9XUS\n\t4ilQ==", "X-Gm-Message-State": "APzg51Dm1ELkRHpj1X84qgDl1N1LMLRiw15qk4qMzbKz7+3wz9Pvzj3h\n\tZpV3k6Wg2ipxQ3JUkpKQOd5+lxN8I3s=", "X-Google-Smtp-Source": "ANB0VdY5IrX4XzMngAKZvwkN3a+FJhv+/6N9JN22DqOA9tS/rBz64MjFx8Md/9kiEWIuiAsUrejC1w==", "X-Received": "by 2002:a19:aa52:: with SMTP id\n\tt79-v6mr18562119lfe.85.1535986047354; \n\tMon, 03 Sep 2018 07:47:27 -0700 (PDT)", "From": "Jens Wiklander <jens.wiklander@linaro.org>", "To": "u-boot@lists.denx.de", "Date": "Mon, 3 Sep 2018 16:46:57 +0200", "Message-Id": "<20180903144711.31585-7-jens.wiklander@linaro.org>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20180903144711.31585-1-jens.wiklander@linaro.org>", "References": "<20180903144711.31585-1-jens.wiklander@linaro.org>", "Cc": "Tom Rini <trini@konsulko.com>, Pierre Aubert <p.aubert@staubli.com>", "Subject": "[U-Boot] [PATCH v3 06/20] Add UCLASS_TEE for Trusted Execution\n\tEnvironment", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.18", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<http://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>" }, "content": "Adds a uclass to interface with a TEE (Trusted Execution Environment).\n\nA TEE driver is a driver that interfaces with a trusted OS running in\nsome secure environment, for example, TrustZone on ARM cpus, or a\nseparate secure co-processor etc.\n\nThe TEE subsystem can serve a TEE driver for a Global Platform compliant\nTEE, but it's not limited to only Global Platform TEEs.\n\nThe over all design is based on the TEE subsystem in the Linux kernel,\ntailored for U-Boot.\n\nReviewed-by: Simon Glass <sjg@chromium.org>\nTested-by: Igor Opaniuk <igor.opaniuk@linaro.org>\nSigned-off-by: Jens Wiklander <jens.wiklander@linaro.org>\n---\n MAINTAINERS | 6 +\n drivers/Kconfig | 2 +\n drivers/Makefile | 1 +\n drivers/tee/Kconfig | 11 ++\n drivers/tee/Makefile | 3 +\n drivers/tee/tee-uclass.c | 209 ++++++++++++++++++++++++\n include/dm/uclass-id.h | 1 +\n include/tee.h | 336 +++++++++++++++++++++++++++++++++++++++\n 8 files changed, 569 insertions(+)\n create mode 100644 drivers/tee/Kconfig\n create mode 100644 drivers/tee/Makefile\n create mode 100644 drivers/tee/tee-uclass.c\n create mode 100644 include/tee.h", "diff": "diff --git a/MAINTAINERS b/MAINTAINERS\nindex 58b61ac05882..7458c606ee92 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -571,6 +571,12 @@ TQ GROUP\n S:\tOrphaned (Since 2016-02)\n T:\tgit git://git.denx.de/u-boot-tq-group.git\n \n+TEE\n+M:\tJens Wiklander <jens.wiklander@linaro.org>\n+S:\tMaintained\n+F:\tdrivers/tee/\n+F:\tinclude/tee.h\n+\n UBI\n M:\tKyungmin Park <kmpark@infradead.org>\n M:\tHeiko Schocher <hs@denx.de>\ndiff --git a/drivers/Kconfig b/drivers/Kconfig\nindex c72abf893297..f3249ab1d143 100644\n--- a/drivers/Kconfig\n+++ b/drivers/Kconfig\n@@ -94,6 +94,8 @@ source \"drivers/spmi/Kconfig\"\n \n source \"drivers/sysreset/Kconfig\"\n \n+source \"drivers/tee/Kconfig\"\n+\n source \"drivers/thermal/Kconfig\"\n \n source \"drivers/timer/Kconfig\"\ndiff --git a/drivers/Makefile b/drivers/Makefile\nindex d53208540ea6..0fcae36f50f7 100644\n--- a/drivers/Makefile\n+++ b/drivers/Makefile\n@@ -103,6 +103,7 @@ obj-y += smem/\n obj-y += soc/\n obj-$(CONFIG_REMOTEPROC) += remoteproc/\n obj-y += thermal/\n+obj-$(CONFIG_TEE) += tee/\n \n obj-$(CONFIG_MACH_PIC32) += ddr/microchip/\n endif\ndiff --git a/drivers/tee/Kconfig b/drivers/tee/Kconfig\nnew file mode 100644\nindex 000000000000..f3fc3c2ca790\n--- /dev/null\n+++ b/drivers/tee/Kconfig\n@@ -0,0 +1,11 @@\n+# Generic Trusted Execution Environment Configuration\n+config TEE\n+\tbool \"Trusted Execution Environment support\"\n+\tdepends on ARM && (ARM64 || CPU_V7A)\n+\tselect ARM_SMCCC\n+\thelp\n+\t This implements a generic interface towards a Trusted Execution\n+\t Environment (TEE). A TEE is a trusted OS running in some secure\n+\t environment, for example, TrustZone on ARM cpus, or a separate\n+\t secure co-processor etc. See also:\n+\t https://en.wikipedia.org/wiki/Trusted_execution_environment\ndiff --git a/drivers/tee/Makefile b/drivers/tee/Makefile\nnew file mode 100644\nindex 000000000000..b6d8e16e6211\n--- /dev/null\n+++ b/drivers/tee/Makefile\n@@ -0,0 +1,3 @@\n+# SPDX-License-Identifier: GPL-2.0+\n+\n+obj-y += tee-uclass.o\ndiff --git a/drivers/tee/tee-uclass.c b/drivers/tee/tee-uclass.c\nnew file mode 100644\nindex 000000000000..1bee54ebf4af\n--- /dev/null\n+++ b/drivers/tee/tee-uclass.c\n@@ -0,0 +1,209 @@\n+// SPDX-License-Identifier: GPL-2.0+\n+/*\n+ * Copyright (c) 2018 Linaro Limited\n+ */\n+\n+#include <common.h>\n+#include <dm.h>\n+#include <dm/device-internal.h>\n+#include <dm/uclass-internal.h>\n+#include <tee.h>\n+\n+/**\n+ * struct tee_uclass_priv - information of a TEE, stored by the uclass\n+ *\n+ * @list_shm:\tlist of structe tee_shm representing memory blocks shared\n+ *\t\twith the TEE.\n+ */\n+struct tee_uclass_priv {\n+\tstruct list_head list_shm;\n+};\n+\n+static const struct tee_driver_ops *tee_get_ops(struct udevice *dev)\n+{\n+\treturn device_get_ops(dev);\n+}\n+\n+void tee_get_version(struct udevice *dev, struct tee_version_data *vers)\n+{\n+\ttee_get_ops(dev)->get_version(dev, vers);\n+}\n+\n+int tee_open_session(struct udevice *dev, struct tee_open_session_arg *arg,\n+\t\t uint num_param, struct tee_param *param)\n+{\n+\treturn tee_get_ops(dev)->open_session(dev, arg, num_param, param);\n+}\n+\n+int tee_close_session(struct udevice *dev, u32 session)\n+{\n+\treturn tee_get_ops(dev)->close_session(dev, session);\n+}\n+\n+int tee_invoke_func(struct udevice *dev, struct tee_invoke_arg *arg,\n+\t\t uint num_param, struct tee_param *param)\n+{\n+\treturn tee_get_ops(dev)->invoke_func(dev, arg, num_param, param);\n+}\n+\n+int __tee_shm_add(struct udevice *dev, ulong align, void *addr, ulong size,\n+\t\t u32 flags, struct tee_shm **shmp)\n+{\n+\tstruct tee_shm *shm;\n+\tvoid *p = addr;\n+\tint rc;\n+\n+\tif (flags & TEE_SHM_ALLOC) {\n+\t\tif (align)\n+\t\t\tp = memalign(align, size);\n+\t\telse\n+\t\t\tp = malloc(size);\n+\t}\n+\tif (!p)\n+\t\treturn -ENOMEM;\n+\n+\tshm = calloc(1, sizeof(*shm));\n+\tif (!shm) {\n+\t\trc = -ENOMEM;\n+\t\tgoto err;\n+\t}\n+\n+\tshm->dev = dev;\n+\tshm->addr = p;\n+\tshm->size = size;\n+\tshm->flags = flags;\n+\n+\tif (flags & TEE_SHM_SEC_REGISTER) {\n+\t\trc = tee_get_ops(dev)->shm_register(dev, shm);\n+\t\tif (rc)\n+\t\t\tgoto err;\n+\t}\n+\n+\tif (flags & TEE_SHM_REGISTER) {\n+\t\tstruct tee_uclass_priv *priv = dev_get_uclass_priv(dev);\n+\n+\t\tlist_add(&shm->link, &priv->list_shm);\n+\t}\n+\n+\t*shmp = shm;\n+\n+\treturn 0;\n+err:\n+\tfree(shm);\n+\tif (flags & TEE_SHM_ALLOC)\n+\t\tfree(p);\n+\n+\treturn rc;\n+}\n+\n+int tee_shm_alloc(struct udevice *dev, ulong size, u32 flags,\n+\t\t struct tee_shm **shmp)\n+{\n+\tu32 f = flags;\n+\n+\tf |= TEE_SHM_SEC_REGISTER | TEE_SHM_REGISTER | TEE_SHM_ALLOC;\n+\n+\treturn __tee_shm_add(dev, 0, NULL, size, f, shmp);\n+}\n+\n+int tee_shm_register(struct udevice *dev, void *addr, ulong size, u32 flags,\n+\t\t struct tee_shm **shmp)\n+{\n+\tu32 f = flags & ~TEE_SHM_ALLOC;\n+\n+\tf |= TEE_SHM_SEC_REGISTER | TEE_SHM_REGISTER;\n+\n+\treturn __tee_shm_add(dev, 0, addr, size, f, shmp);\n+}\n+\n+void tee_shm_free(struct tee_shm *shm)\n+{\n+\tif (!shm)\n+\t\treturn;\n+\n+\tif (shm->flags & TEE_SHM_SEC_REGISTER)\n+\t\ttee_get_ops(shm->dev)->shm_unregister(shm->dev, shm);\n+\n+\tif (shm->flags & TEE_SHM_REGISTER)\n+\t\tlist_del(&shm->link);\n+\n+\tif (shm->flags & TEE_SHM_ALLOC)\n+\t\tfree(shm->addr);\n+\n+\tfree(shm);\n+}\n+\n+bool tee_shm_is_registered(struct tee_shm *shm, struct udevice *dev)\n+{\n+\tstruct tee_uclass_priv *priv = dev_get_uclass_priv(dev);\n+\tstruct tee_shm *s;\n+\n+\tlist_for_each_entry(s, &priv->list_shm, link)\n+\t\tif (s == shm)\n+\t\t\treturn true;\n+\n+\treturn false;\n+}\n+\n+struct udevice *tee_find_device(struct udevice *start,\n+\t\t\t\tint (*match)(struct tee_version_data *vers,\n+\t\t\t\t\t const void *data),\n+\t\t\t\tconst void *data,\n+\t\t\t\tstruct tee_version_data *vers)\n+{\n+\tstruct udevice *dev = start;\n+\tstruct tee_version_data lv;\n+\tstruct tee_version_data *v = vers ? vers : &lv;\n+\n+\tif (!dev)\n+\t\tuclass_find_first_device(UCLASS_TEE, &dev);\n+\telse\n+\t\tuclass_find_next_device(&dev);\n+\n+\tfor (; dev; uclass_find_next_device(&dev)) {\n+\t\tif (device_probe(dev))\n+\t\t\tcontinue;\n+\t\ttee_get_ops(dev)->get_version(dev, v);\n+\t\tif (!match || match(v, data))\n+\t\t\treturn dev;\n+\t}\n+\n+\treturn NULL;\n+}\n+\n+static int tee_pre_probe(struct udevice *dev)\n+{\n+\tstruct tee_uclass_priv *priv = dev_get_uclass_priv(dev);\n+\n+\tINIT_LIST_HEAD(&priv->list_shm);\n+\n+\treturn 0;\n+}\n+\n+static int tee_pre_remove(struct udevice *dev)\n+{\n+\tstruct tee_uclass_priv *priv = dev_get_uclass_priv(dev);\n+\tstruct tee_shm *shm;\n+\n+\t/*\n+\t * Any remaining shared memory must be unregistered now as U-Boot\n+\t * is about to hand over to the next stage and that memory will be\n+\t * reused.\n+\t */\n+\twhile (!list_empty(&priv->list_shm)) {\n+\t\tshm = list_first_entry(&priv->list_shm, struct tee_shm, link);\n+\t\tdebug(\"%s: freeing leftover shm %p (size %lu, flags %#x)\\n\",\n+\t\t __func__, (void *)shm, shm->size, shm->flags);\n+\t\ttee_shm_free(shm);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+UCLASS_DRIVER(tee) = {\n+\t.id = UCLASS_TEE,\n+\t.name = \"tee\",\n+\t.per_device_auto_alloc_size = sizeof(struct tee_uclass_priv),\n+\t.pre_probe = tee_pre_probe,\n+\t.pre_remove = tee_pre_remove,\n+};\ndiff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h\nindex a39643ec5eef..955e0a915b87 100644\n--- a/include/dm/uclass-id.h\n+++ b/include/dm/uclass-id.h\n@@ -81,6 +81,7 @@ enum uclass_id {\n \tUCLASS_SPI_GENERIC,\t/* Generic SPI flash target */\n \tUCLASS_SYSCON,\t\t/* System configuration device */\n \tUCLASS_SYSRESET,\t/* System reset device */\n+\tUCLASS_TEE,\t\t/* Trusted Execution Environment device */\n \tUCLASS_THERMAL,\t\t/* Thermal sensor */\n \tUCLASS_TIMER,\t\t/* Timer device */\n \tUCLASS_TPM,\t\t/* Trusted Platform Module TIS interface */\ndiff --git a/include/tee.h b/include/tee.h\nnew file mode 100644\nindex 000000000000..b86dbec257b4\n--- /dev/null\n+++ b/include/tee.h\n@@ -0,0 +1,336 @@\n+/* SPDX-License-Identifier: GPL-2.0+ */\n+/*\n+ * Copyright (c) 2018 Linaro Limited\n+ */\n+\n+#ifndef __TEE_H\n+#define __TEE_H\n+\n+#define TEE_UUID_LEN\t\t16\n+\n+#define TEE_GEN_CAP_GP BIT(0)\t/* GlobalPlatform compliant TEE */\n+#define TEE_GEN_CAP_REG_MEM BIT(1)\t/* Supports registering shared memory */\n+\n+#define TEE_SHM_REGISTER\tBIT(0)\t/* In list of shared memory */\n+#define TEE_SHM_SEC_REGISTER\tBIT(1)\t/* TEE notified of this memory */\n+#define TEE_SHM_ALLOC\t\tBIT(2)\t/* The memory is malloced() and must */\n+\t\t\t\t\t/* be freed() */\n+\n+#define TEE_PARAM_ATTR_TYPE_NONE\t\t0\t/* parameter not used */\n+#define TEE_PARAM_ATTR_TYPE_VALUE_INPUT\t\t1\n+#define TEE_PARAM_ATTR_TYPE_VALUE_OUTPUT\t2\n+#define TEE_PARAM_ATTR_TYPE_VALUE_INOUT\t\t3\t/* input and output */\n+#define TEE_PARAM_ATTR_TYPE_MEMREF_INPUT\t5\n+#define TEE_PARAM_ATTR_TYPE_MEMREF_OUTPUT\t6\n+#define TEE_PARAM_ATTR_TYPE_MEMREF_INOUT\t7\t/* input and output */\n+#define TEE_PARAM_ATTR_TYPE_MASK\t\t0xff\n+#define TEE_PARAM_ATTR_META\t\t\t0x100\n+#define TEE_PARAM_ATTR_MASK\t\t\t(TEE_PARAM_ATTR_TYPE_MASK | \\\n+\t\t\t\t\t\t TEE_PARAM_ATTR_META)\n+\n+/*\n+ * Some Global Platform error codes which has a meaning if the\n+ * TEE_GEN_CAP_GP bit is returned by the driver in\n+ * struct tee_version_data::gen_caps\n+ */\n+#define TEE_SUCCESS\t\t\t0x00000000\n+#define TEE_ERROR_GENERIC\t\t0xffff0000\n+#define TEE_ERROR_BAD_PARAMETERS\t0xffff0006\n+#define TEE_ERROR_ITEM_NOT_FOUND\t0xffff0008\n+#define TEE_ERROR_NOT_IMPLEMENTED\t0xffff0009\n+#define TEE_ERROR_NOT_SUPPORTED\t\t0xffff000a\n+#define TEE_ERROR_COMMUNICATION\t\t0xffff000e\n+#define TEE_ERROR_SECURITY\t\t0xffff000f\n+#define TEE_ERROR_OUT_OF_MEMORY\t\t0xffff000c\n+#define TEE_ERROR_TARGET_DEAD\t\t0xffff3024\n+\n+#define TEE_ORIGIN_COMMS\t\t0x00000002\n+#define TEE_ORIGIN_TEE\t\t\t0x00000003\n+#define TEE_ORIGIN_TRUSTED_APP\t\t0x00000004\n+\n+struct udevice;\n+/**\n+ * struct tee_shm - memory shared with the TEE\n+ * @dev:\tThe TEE device\n+ * @link:\tList node in the list in struct struct tee_uclass_priv\n+ * @addr:\tPointer to the shared memory\n+ * @size:\tSize of the the shared memory\n+ * @flags:\tTEE_SHM_* above\n+ */\n+struct tee_shm {\n+\tstruct udevice *dev;\n+\tstruct list_head link;\n+\tvoid *addr;\n+\tulong size;\n+\tu32 flags;\n+};\n+\n+/**\n+ * struct tee_param_memref - memory reference for a Trusted Application\n+ * @shm_offs:\tOffset in bytes into the shared memory object @shm\n+ * @size:\tSize in bytes of the memory reference\n+ * @shm:\tPointer to a shared memory object for the buffer\n+ *\n+ * Used as a part of struct tee_param, see that for more information.\n+ */\n+struct tee_param_memref {\n+\tulong shm_offs;\n+\tulong size;\n+\tstruct tee_shm *shm;\n+};\n+\n+/**\n+ * struct tee_param_value - value parameter for a Trusted Application\n+ * @a, @b, @c:\tParameters passed by value\n+ *\n+ * Used as a part of struct tee_param, see that for more information.\n+ */\n+struct tee_param_value {\n+\tu64 a;\n+\tu64 b;\n+\tu64 c;\n+};\n+\n+/**\n+ * struct tee_param - invoke parameter for a Trusted Application\n+ * @attr:\tAttributes\n+ * @u.memref:\tMemref parameter if (@attr & TEE_PARAM_ATTR_MASK) is one of\n+ *\t\tTEE_PARAM_ATTR_TYPE_MEMREF_* above\n+ * @u.value:\tValue parameter if (@attr & TEE_PARAM_ATTR_MASK) is one of\n+ *\t\tTEE_PARAM_ATTR_TYPE_VALUE_* above\n+ *\n+ * Parameters to TA are passed using an array of this struct, for\n+ * flexibility both value parameters and memory refereces can be used.\n+ */\n+struct tee_param {\n+\tu64 attr;\n+\tunion {\n+\t\tstruct tee_param_memref memref;\n+\t\tstruct tee_param_value value;\n+\t} u;\n+};\n+\n+/**\n+ * struct tee_open_session_arg - extra arguments for tee_open_session()\n+ * @uuid:\t[in] UUID of the Trusted Application\n+ * @clnt_uuid:\t[in] Normally zeroes\n+ * @clnt_login:\t[in] Normally 0\n+ * @session:\t[out] Session id\n+ * @ret:\t[out] return value\n+ * @ret_origin:\t[out] origin of the return value\n+ */\n+struct tee_open_session_arg {\n+\tu8 uuid[TEE_UUID_LEN];\n+\tu8 clnt_uuid[TEE_UUID_LEN];\n+\tu32 clnt_login;\n+\tu32 session;\n+\tu32 ret;\n+\tu32 ret_origin;\n+};\n+\n+/**\n+ * struct tee_invoke_arg - extra arguments for tee_invoke_func()\n+ * @func:\t[in] Trusted Application function, specific to the TA\n+ * @session:\t[in] Session id, from open session\n+ * @ret:\t[out] return value\n+ * @ret_origin:\t[out] origin of the return value\n+ */\n+struct tee_invoke_arg {\n+\tu32 func;\n+\tu32 session;\n+\tu32 ret;\n+\tu32 ret_origin;\n+};\n+\n+/**\n+ * struct tee_version_data - description of TEE\n+ * @gen_caps:\tGeneric capabilities, TEE_GEN_CAP_* above\n+ */\n+struct tee_version_data {\n+\tu32 gen_caps;\n+};\n+\n+/**\n+ * struct tee_driver_ops - TEE driver operations\n+ * @get_version:\tQuery capabilities of TEE device,\n+ * @open_session:\tOpens a session to a Trusted Application in the TEE,\n+ * @close_session:\tCloses a session to Trusted Application,\n+ * @invoke_func:\tInvokes a function in a Trusted Application,\n+ * @shm_register:\tRegisters memory shared with the TEE\n+ * @shm_unregister:\tUnregisters memory shared with the TEE\n+ */\n+struct tee_driver_ops {\n+\t/**\n+\t * get_version() - Query capabilities of TEE device\n+\t * @dev:\tThe TEE device\n+\t * @vers:\tPointer to version data\n+\t */\n+\tvoid (*get_version)(struct udevice *dev, struct tee_version_data *vers);\n+\t/**\n+\t * open_session() - Open a session to a Trusted Application\n+\t * @dev:\tThe TEE device\n+\t * @arg:\tOpen session arguments\n+\t * @num_param:\tNumber of elements in @param\n+\t * @param:\tParameters for Trusted Application\n+\t *\n+\t * Returns < 0 on error else see @arg->ret for result. If @arg->ret is\n+\t * TEE_SUCCESS the session identifier is available in @arg->session.\n+\t */\n+\tint (*open_session)(struct udevice *dev,\n+\t\t\t struct tee_open_session_arg *arg, uint num_param,\n+\t\t\t struct tee_param *param);\n+\t/**\n+\t * close_session() - Close a session to a Trusted Application\n+\t * @dev:\tThe TEE device\n+\t * @session:\tSession id\n+\t *\n+\t * Return < 0 on error else 0, regardless the session will not be valid\n+\t * after this function has returned.\n+\t */\n+\tint (*close_session)(struct udevice *dev, u32 session);\n+\t/**\n+\t * tee_invoke_func() - Invoke a function in a Trusted Application\n+\t * @dev:\tThe TEE device\n+\t * @arg:\tInvoke arguments\n+\t * @num_param:\tNumber of elements in @param\n+\t * @param:\tParameters for Trusted Application\n+\t *\n+\t * Returns < 0 on error else see @arg->ret for result.\n+\t */\n+\tint (*invoke_func)(struct udevice *dev, struct tee_invoke_arg *arg,\n+\t\t\t uint num_param, struct tee_param *param);\n+\t/**\n+\t * shm_register() - Registers memory shared with the TEE\n+\t * @dev:\tThe TEE device\n+\t * @shm:\tPointer to a shared memory object\n+\t * Returns 0 on success or < 0 on failure.\n+\t */\n+\tint (*shm_register)(struct udevice *dev, struct tee_shm *shm);\n+\t/**\n+\t * shm_unregister() - Unregisters memory shared with the TEE\n+\t * @dev:\tThe TEE device\n+\t * @shm:\tPointer to a shared memory object\n+\t * Returns 0 on success or < 0 on failure.\n+\t */\n+\tint (*shm_unregister)(struct udevice *dev, struct tee_shm *shm);\n+};\n+\n+/**\n+ * __tee_shm_add() - Internal helper function to register shared memory\n+ * @dev:\tThe TEE device\n+ * @align:\tRequired alignment of allocated memory block if\n+ *\t\t(@flags & TEE_SHM_ALLOC)\n+ * @addr:\tAddress of memory block, ignored if (@flags & TEE_SHM_ALLOC)\n+ * @size:\tSize of memory block\n+ * @flags:\tTEE_SHM_* above\n+ * @shmp:\tIf the function return 0, this holds the allocated\n+ *\t\tstruct tee_shm\n+ *\n+ * returns 0 on success or < 0 on failure.\n+ */\n+int __tee_shm_add(struct udevice *dev, ulong align, void *addr, ulong size,\n+\t\t u32 flags, struct tee_shm **shmp);\n+\n+/**\n+ * tee_shm_alloc() - Allocate shared memory\n+ * @dev:\tThe TEE device\n+ * @size:\tSize of memory block\n+ * @flags:\tTEE_SHM_* above\n+ * @shmp:\tIf the function return 0, this holds the allocated\n+ *\t\tstruct tee_shm\n+ *\n+ * returns 0 on success or < 0 on failure.\n+ */\n+int tee_shm_alloc(struct udevice *dev, ulong size, u32 flags,\n+\t\t struct tee_shm **shmp);\n+\n+/**\n+ * tee_shm_register() - Registers shared memory\n+ * @dev:\tThe TEE device\n+ * @addr:\tAddress of memory block\n+ * @size:\tSize of memory block\n+ * @flags:\tTEE_SHM_* above\n+ * @shmp:\tIf the function return 0, this holds the allocated\n+ *\t\tstruct tee_shm\n+ *\n+ * returns 0 on success or < 0 on failure.\n+ */\n+int tee_shm_register(struct udevice *dev, void *addr, ulong size, u32 flags,\n+\t\t struct tee_shm **shmp);\n+\n+/**\n+ * tee_shm_free() - Frees shared memory\n+ * @shm:\tShared memory object\n+ */\n+void tee_shm_free(struct tee_shm *shm);\n+\n+/**\n+ * tee_shm_is_registered() - Check register status of shared memory object\n+ * @shm:\tPointer to shared memory object\n+ * @dev:\tThe TEE device\n+ *\n+ * Returns true if the shared memory object is registered for the supplied\n+ * TEE device\n+ */\n+bool tee_shm_is_registered(struct tee_shm *shm, struct udevice *dev);\n+\n+/**\n+ * tee_find_device() - Look up a TEE device\n+ * @start:\tif not NULL, continue search after this device\n+ * @match:\tfunction to check TEE device, returns != 0 if the device\n+ *\t\tmatches\n+ * @data:\tdata for match function\n+ * @vers:\tif not NULL, version data of TEE device of the device returned\n+ *\n+ * Returns a probed TEE device of the first TEE device matched by the\n+ * match() callback or NULL.\n+ */\n+struct udevice *tee_find_device(struct udevice *start,\n+\t\t\t\tint (*match)(struct tee_version_data *vers,\n+\t\t\t\t\t const void *data),\n+\t\t\t\tconst void *data,\n+\t\t\t\tstruct tee_version_data *vers);\n+\n+/**\n+ * tee_get_version() - Query capabilities of TEE device\n+ * @dev:\tThe TEE device\n+ * @vers:\tPointer to version data\n+ */\n+void tee_get_version(struct udevice *dev, struct tee_version_data *vers);\n+\n+/**\n+ * tee_open_session() - Open a session to a Trusted Application\n+ * @dev:\tThe TEE device\n+ * @arg:\tOpen session arguments\n+ * @num_param:\tNumber of elements in @param\n+ * @param:\tParameters for Trusted Application\n+ *\n+ * Returns < 0 on error else see @arg->ret for result. If @arg->ret is\n+ * TEE_SUCCESS the session identifier is available in @arg->session.\n+ */\n+int tee_open_session(struct udevice *dev, struct tee_open_session_arg *arg,\n+\t\t uint num_param, struct tee_param *param);\n+\n+/**\n+ * tee_close_session() - Close a session to a Trusted Application\n+ * @dev:\tThe TEE device\n+ * @session:\tSession id\n+ *\n+ * Return < 0 on error else 0, regardless the session will not be valid\n+ * after this function has returned.\n+ */\n+int tee_close_session(struct udevice *dev, u32 session);\n+\n+/**\n+ * tee_invoke_func() - Invoke a function in a Trusted Application\n+ * @dev:\tThe TEE device\n+ * @arg:\tInvoke arguments\n+ * @num_param:\tNumber of elements in @param\n+ * @param:\tParameters for Trusted Application\n+ *\n+ * Returns < 0 on error else see @arg->ret for result.\n+ */\n+int tee_invoke_func(struct udevice *dev, struct tee_invoke_arg *arg,\n+\t\t uint num_param, struct tee_param *param);\n+\n+#endif /* __TEE_H */\n", "prefixes": [ "U-Boot", "v3", "06/20" ] }