linux/drivers/tee/tstee/tstee_private.h
Balint Dobszay c835e5a315 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: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Balint Dobszay <balint.dobszay@arm.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2024-04-03 14:03:09 +02:00

93 lines
2.5 KiB
C

/* 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 */