blob: 7472deeede6615f2dbd331d50ead12994e8a18a6 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001Introduction
2============
3
4The tzcom (TrustZone Communicator) device driver provides IOCTLs for userspace
5to communicate with TrustZone Operating Environment (TZBSP) using Secure
6Channel Manager (SCM) interface. It also provides a way for TZBSP to utilize
7services in HLOS.
8
9Hardware description
10====================
11
12The hardware interaction is specified in Secure Channel Manager for TZBSP design
13document. This driver exercises the SCM interface (scm_call).
14
15Software description
16====================
17
18This driver is a character device driver and following operations are registered:
19- tzcom_open()
20- tzcom_release()
21- tzcom_ioctl()
22
23
24This driver provides following IOCTL methods:
25 TZCOM_IOCTL_REGISTER_SERVICE_REQ - to register HLOS service
26 TZCOM_IOCTL_UNREGISTER_SERVICE_REQ - to unregister HLOS service
27 TZCOM_IOCTL_SEND_CMD_REQ - send a command to a service
28 TZCOM_IOCTL_READ_NEXT_CMD_REQ - wait for a cmd from TZBSP to use HLOS service
29 TZCOM_IOCTL_CONTINUE_CMD_REQ - continue the last incomplete cmd on TZBSP
30
31TZCOM_IOCTL_REGISTER_SERVICE_REQ sequence diagram:
32
33 +--------------+ +---------------+
34 | USERSPACE | | TZCOM |
35 +------+-------+ +-------+-------+
36 | REGISTER_SERVICE |
37 |----------------->| ___
38 | |,-' ``.
39 | + verify &`.
40 | | add |
41 | | service |
42 | | to a list|
43 | registered |<-.._,,,,/
44 |<-----------------|
45 | |
46
47TZCOM_IOCTL_READ_NEXT_CMD_REQ, TZCOM_IOCTL_SEND_CMD_REQ and
48TZCOM_IOCTL_CONTINUE_CMD_REQ sequence:
49
50 +--------------+ +---------------+ +-------------+ +----------------+
51 | USERSPACE | | TZCOM | | SCM | | TZBSP |
52 +---+--+-------+ +-------+-------+ +------+------+ +-------+--------+
53 | | READ_NEXT_CMD | | |
54 +--|----------------->| | |
55 | | |.--------. | |
56 | | || BLOCKED| | |
57 | | |`--------' | |
58 | | | | |
59 | | | | |
60 | | SEND_CMD | | |
61 | +----------------->| | |
62 | | | scm_call | |
63 | | +---------------->| SEND_CMD |
64 | | | +---------------->|
65 | | | | cmd incomplete |
66 | | | scm_call returns|<----------------+
67 | | |<----------------+ |
68 | | | | |
69 | | |,-'''-. | |
70 | | + READ `. | |
71 | | | NEXT | | |
72 | | | CMD / | |
73 | | READ_NEXT_CMD ret|<.____,' | |
74 |<-|------------------+ | |
75 ,---. | | | | |
76 / \ | | | | |
77/perform\| | | | |
78 received) | | | |
79\command/| | | | |
80 \ / | | | | |
81 `---' | | | | |
82 | | | | |
83 | | CONTINUE_CMD | | |
84 +--|----------------->| | |
85 | | returns | _,... | |
86 | | immediately |' `. | |
87 | | | fill in`. | |
88 | | | incomplete | |
89 | | | cmd ; | |
90 | |<-...---' | |
91 | | scm_call | |
92 | +---------------->| SEND_CMD |
93 | | +---------------->|
94 | | | cmd complete |
95 | | scm_call returns|<----------------+
96 |SEND_CMD return |<----------------+ |
97 |<-----------------+ | |
98 | | | |
99
100
101
102There are three shared buffers between TZCOM driver and TZBSP.
1031) For command and response buffers for SEND_CMD requests
1042) For commands originated from TZBSP and their corresponding responses
1053) For debug service
106
107When calling IOCTL_SEND_CMD_REQ from userspace, command request and response
108buffers are initialized and provided in the IOCTL arguments. Where request and
109response buffers will be passed as an arguments to the smc_call method.
110
111The requests are synchronous. The driver will put the process to sleep,
112waiting for the completion of the requests using wait_for_completion().
113
114This driver uses kmalloc for shared buffer pools which get initialized at driver
115initialization. There are three buffers each 20 KB. If any of the buffers fail
116to initialize then driver will fail to load. Assumption is the allocated
117memory for buffers is contiguous.
118
119
120Design
121======
122
123The goal of this driver is to provide a communication API for the userspace
124application to execute services in TrustZone as well as TrustZone operating
125environment to access services in HLOS.
126
127Currently TZ->HLOS communication happens from a blocking call to READ_NEXT_CMD
128that is initiated from the userspace and on receiving a command request from TZ
129service, command is placed on a queue to unblock READ_NEXT_CMD call. This could
130have been solved by using a callback, but the practice of invoking callbacks in
131userspace from kernel is discouraged.
132
133Power Management
134================
135
136n/a
137
138SMP/multi-core
139==============
140
141TZCOM allows multiple services being registered from HLOS and multiple processes
142or threads can call IOCTL_READ_NEXT_MSG. These services will block until new
143data arrives on the shared buffer (buffer #2 as mentioned in Software
144Description). This is achieved using wait queues.
145
146Security
147========
148
149Please refer to Security Channel Manager design document.
150
151Performance
152===========
153
154Every scm_call is a context switch between non-trusted and trusted operating
155environment. There are no performance related matrix for scm_call available as
156of now.
157
158Interface
159=========
160
161This driver will have a /dev/tzcom node and following IOCTL calls can be made.
162
163Userspace API (ioctl calls):
164 TZCOM_IOCTL_REGISTER_SERVICE_REQ - to register HLOS service
165 TZCOM_IOCTL_UNREGISTER_SERVICE_REQ - to unregister HLOS service
166 TZCOM_IOCTL_SEND_CMD_REQ - send a command to a service
167 TZCOM_IOCTL_READ_NEXT_CMD_REQ - wait for a cmd from TZBSP to use HLOS service
168 TZCOM_IOCTL_CONTINUE_CMD_REQ - continue the last incomplete cmd on TZBSP
169
170
171Dependencies
172============
173
174This driver interacts with Trustzone operating environment, thus depends on
175the TZBSP supported architecture.
176
177
178To do
179=====
180
181TBD