TEE (Trusted Execution Environment) Userspace API¶
include/uapi/linux/tee.h defines the generic interface to a TEE.
User space (the client) connects to the driver by opening /dev/tee[0-9]* or/dev/teepriv[0-9]*.
TEE_IOC_SHM_ALLOC allocates shared memory and returns a file descriptorwhich user space can mmap. When user space doesn’t need the filedescriptor any more, it should be closed. When shared memory isn’t neededany longer it should be unmapped with
munmap()to allow the reuse ofmemory.TEE_IOC_VERSION lets user space know which TEE this driver handles andits capabilities.
TEE_IOC_OPEN_SESSION opens a new session to a Trusted Application.
TEE_IOC_INVOKE invokes a function in a Trusted Application.
TEE_IOC_CANCEL may cancel an ongoing TEE_IOC_OPEN_SESSION or TEE_IOC_INVOKE.
TEE_IOC_CLOSE_SESSION closes a session to a Trusted Application.
There are two classes of clients, normal clients and supplicants. The latter isa helper process for the TEE to access resources in Linux, for example filesystem access. A normal client opens /dev/tee[0-9]* and a supplicant opens/dev/teepriv[0-9].
Much of the communication between clients and the TEE is opaque to thedriver. The main job for the driver is to receive requests from theclients, forward them to the TEE and send back the results. In the case ofsupplicants the communication goes in the other direction, the TEE sendsrequests to the supplicant which then sends back the result.