Commit c835e5a3 authored by Balint Dobszay's avatar Balint Dobszay Committed by Jens Wiklander

tee: tstee: Add Trusted Services TEE driver

The Trusted Services project provides a framework for developing and
deploying device Root of Trust services in FF-A Secure Partitions. The
FF-A SPs are accessible through the FF-A driver, but this doesn't
provide a user space interface. The goal of this TEE driver is to make
Trusted Services SPs accessible for user space clients.

All TS SPs have the same FF-A UUID, it identifies the RPC protocol used
by TS. A TS SP can host one or more services, a service is identified by
its service UUID. The same type of service cannot be present twice in
the same SP. During SP boot each service in an SP is assigned an
interface ID, this is just a short ID to simplify message addressing.
There is 1:1 mapping between TS SPs and TEE devices, i.e. a separate TEE
device is registered for each TS SP. This is required since contrary to
the generic TEE design where memory is shared with the whole TEE
implementation, in case of FF-A, memory is shared with a specific SP. A
user space client has to be able to separately share memory with each SP
based on its endpoint ID.
Acked-by: default avatarSumit Garg <sumit.garg@linaro.org>
Signed-off-by: default avatarBalint Dobszay <balint.dobszay@arm.com>
Signed-off-by: default avatarJens Wiklander <jens.wiklander@linaro.org>
parent cf444150
......@@ -15,5 +15,6 @@ if TEE
source "drivers/tee/optee/Kconfig"
source "drivers/tee/amdtee/Kconfig"
source "drivers/tee/tstee/Kconfig"
endif
......@@ -5,3 +5,4 @@ tee-objs += tee_shm.o
tee-objs += tee_shm_pool.o
obj-$(CONFIG_OPTEE) += optee/
obj-$(CONFIG_AMDTEE) += amdtee/
obj-$(CONFIG_ARM_TSTEE) += tstee/
# SPDX-License-Identifier: GPL-2.0-only
config ARM_TSTEE
tristate "Arm Trusted Services TEE driver"
depends on ARM_FFA_TRANSPORT
default n
help
The Trusted Services project provides a framework for developing and
deploying device Root of Trust services in FF-A Secure Partitions.
This driver provides an interface to make Trusted Services Secure
Partitions accessible for user space clients, since the FF-A driver
doesn't implement a user space interface directly.
# SPDX-License-Identifier: GPL-2.0-only
arm-tstee-objs := core.o
obj-$(CONFIG_ARM_TSTEE) = arm-tstee.o
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2023, Arm Limited
*/
#ifndef TSTEE_PRIVATE_H
#define TSTEE_PRIVATE_H
#include <linux/arm_ffa.h>
#include <linux/bitops.h>
#include <linux/tee_core.h>
#include <linux/types.h>
#include <linux/uuid.h>
#include <linux/xarray.h>
/*
* The description of the ABI implemented in this file is available at
* https://trusted-services.readthedocs.io/en/v1.0.0/developer/service-access-protocols.html#abi
*/
/* UUID of this protocol */
#define TS_RPC_UUID UUID_INIT(0xbdcd76d7, 0x825e, 0x4751, \
0x96, 0x3b, 0x86, 0xd4, 0xf8, 0x49, 0x43, 0xac)
/* Protocol version*/
#define TS_RPC_PROTOCOL_VERSION (1)
/* Status codes */
#define TS_RPC_OK (0)
/* RPC control register */
#define TS_RPC_CTRL_REG (0)
#define OPCODE_MASK GENMASK(15, 0)
#define IFACE_ID_MASK GENMASK(23, 16)
#define TS_RPC_CTRL_OPCODE(x) ((u16)(FIELD_GET(OPCODE_MASK, (x))))
#define TS_RPC_CTRL_IFACE_ID(x) ((u8)(FIELD_GET(IFACE_ID_MASK, (x))))
#define TS_RPC_CTRL_PACK_IFACE_OPCODE(i, o) \
(FIELD_PREP(IFACE_ID_MASK, (i)) | FIELD_PREP(OPCODE_MASK, (o)))
#define TS_RPC_CTRL_SAP_RC BIT(30)
#define TS_RPC_CTRL_SAP_ERR BIT(31)
/* Interface ID for RPC management operations */
#define TS_RPC_MGMT_IFACE_ID (0xff)
/* Management calls */
#define TS_RPC_OP_GET_VERSION (0x0000)
#define TS_RPC_GET_VERSION_RESP (1)
#define TS_RPC_OP_RETRIEVE_MEM (0x0001)
#define TS_RPC_RETRIEVE_MEM_HANDLE_LSW (1)
#define TS_RPC_RETRIEVE_MEM_HANDLE_MSW (2)
#define TS_RPC_RETRIEVE_MEM_TAG_LSW (3)
#define TS_RPC_RETRIEVE_MEM_TAG_MSW (4)
#define TS_RPC_RETRIEVE_MEM_RPC_STATUS (1)
#define TS_RPC_OP_RELINQ_MEM (0x0002)
#define TS_RPC_RELINQ_MEM_HANDLE_LSW (1)
#define TS_RPC_RELINQ_MEM_HANDLE_MSW (2)
#define TS_RPC_RELINQ_MEM_RPC_STATUS (1)
#define TS_RPC_OP_SERVICE_INFO (0x0003)
#define TS_RPC_SERVICE_INFO_UUID0 (1)
#define TS_RPC_SERVICE_INFO_UUID1 (2)
#define TS_RPC_SERVICE_INFO_UUID2 (3)
#define TS_RPC_SERVICE_INFO_UUID3 (4)
#define TS_RPC_SERVICE_INFO_RPC_STATUS (1)
#define TS_RPC_SERVICE_INFO_IFACE (2)
/* Service call */
#define TS_RPC_SERVICE_MEM_HANDLE_LSW (1)
#define TS_RPC_SERVICE_MEM_HANDLE_MSW (2)
#define TS_RPC_SERVICE_REQ_LEN (3)
#define TS_RPC_SERVICE_CLIENT_ID (4)
#define TS_RPC_SERVICE_RPC_STATUS (1)
#define TS_RPC_SERVICE_STATUS (2)
#define TS_RPC_SERVICE_RESP_LEN (3)
struct tstee {
struct ffa_device *ffa_dev;
struct tee_device *teedev;
struct tee_shm_pool *pool;
};
struct ts_session {
u8 iface_id;
};
struct ts_context_data {
struct xarray sess_list;
};
#endif /* TSTEE_PRIVATE_H */
......@@ -56,6 +56,7 @@
*/
#define TEE_IMPL_ID_OPTEE 1
#define TEE_IMPL_ID_AMDTEE 2
#define TEE_IMPL_ID_TSTEE 3
/*
* OP-TEE specific capabilities
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment