···11+=============
22+TEE uclass
33+=============
44+55+This document describes the TEE uclass in U-Boot
66+77+A TEE (Trusted Execution Environment) is a trusted OS running in some
88+secure environment, for example, TrustZone on ARM CPUs, or a separate
99+secure co-processor etc. A TEE driver handles the details needed to
1010+communicate with the TEE.
1111+1212+This uclass deals with:
1313+1414+- Registration of TEE drivers
1515+1616+- Managing shared memory between U-Boot and the TEE
1717+1818+- Providing a generic API to the TEE
1919+2020+The TEE interface
2121+=================
2222+2323+include/tee.h defines the generic interface to a TEE.
2424+2525+A client finds the TEE device via tee_find_device(). Other important functions
2626+when interfacing with a TEE are:
2727+2828+- tee_shm_alloc(), tee_shm_register() and tee_shm_free() to manage shared
2929+ memory objects often needed when communicating with the TEE.
3030+3131+- tee_get_version() lets the client know which the capabilities of the TEE
3232+ device.
3333+3434+- tee_open_session() opens a session to a Trusted Application
3535+3636+- tee_invoke_func() invokes a function in a Trusted Application
3737+3838+- tee_close_session() closes a session to a Trusted Application
3939+4040+Much of the communication between clients and the TEE is opaque to the
4141+driver. The main job for the driver is to receive requests from the
4242+clients, forward them to the TEE and send back the results.
4343+4444+OP-TEE driver
4545+=============
4646+4747+The OP-TEE driver handles OP-TEE [1] based TEEs. Currently it is only the ARM
4848+TrustZone based OP-TEE solution that is supported.
4949+5050+Lowest level of communication with OP-TEE builds on ARM SMC Calling
5151+Convention (SMCCC) [2], which is the foundation for OP-TEE's SMC interface
5252+[3] used internally by the driver. Stacked on top of that is OP-TEE Message
5353+Protocol [4].
5454+5555+OP-TEE SMC interface provides the basic functions required by SMCCC and some
5656+additional functions specific for OP-TEE. The most interesting functions are:
5757+5858+- OPTEE_SMC_FUNCID_CALLS_UID (part of SMCCC) returns the version information
5959+ which is then returned by TEE_IOC_VERSION
6060+6161+- OPTEE_SMC_CALL_GET_OS_UUID returns the particular OP-TEE implementation, used
6262+ to tell, for instance, a TrustZone OP-TEE apart from an OP-TEE running on a
6363+ separate secure co-processor.
6464+6565+- OPTEE_SMC_CALL_WITH_ARG drives the OP-TEE message protocol
6666+6767+- OPTEE_SMC_GET_SHM_CONFIG lets the driver and OP-TEE agree on which memory
6868+ range to used for shared memory between Linux and OP-TEE.
6969+7070+The GlobalPlatform TEE Client API [5] is implemented on top of the generic
7171+TEE API.
7272+7373+Picture of the relationship between the different components in the
7474+OP-TEE architecture:
7575+7676+ U-Boot Secure world
7777+ ~~~~~~ ~~~~~~~~~~~~
7878+ +------------+ +-------------+
7979+ | Client | | Trusted |
8080+ | | | Application |
8181+ +------------+ +-------------+
8282+ /\ /\
8383+ || ||
8484+ \/ \/
8585+ +------------+ +-------------+
8686+ | TEE | | TEE Internal|
8787+ | uclass | | API |
8888+ +------------+ +-------------+
8989+ | OP-TEE | | OP-TEE |
9090+ | driver | | Trusted OS |
9191+ +------------+-----------+-------------+
9292+ | OP-TEE MSG |
9393+ | SMCCC (OPTEE_SMC_CALL_*) |
9494+ +--------------------------------------+
9595+9696+RPC (Remote Procedure Call) are requests from secure world to the driver.
9797+An RPC is identified by a special range of SMCCC return values from
9898+OPTEE_SMC_CALL_WITH_ARG.
9999+100100+References
101101+==========
102102+103103+[1] https://github.com/OP-TEE/optee_os
104104+105105+[2] http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html
106106+107107+[3] drivers/tee/optee/optee_smc.h
108108+109109+[4] drivers/tee/optee/optee_msg.h
110110+111111+[5] http://www.globalplatform.org/specificationsdevice.asp look for
112112+ "TEE Client API Specification v1.0" and click download.