1OP-TEE SPMC tests
2=================
3
4Build and run
5-------------
6
7Please follow the instructions of :ref:`build-spmc-tests`.
8
9Structure
10---------
11
12* `xtest`_ is the |NWd| test application which is used to send multiple |FF-A| messages to the SPMC and to the test SPs in
13  the |SWd|. It is part of the `optee_test`_ repository.
14* The ``arm-ffa-user`` driver provides access to the FF-A layer from the |NWd| user space. ``xtest`` uses it to send |FF-A|
15  messages.
16* The test SPs implement various testing functions which can be invoked from ``xtest``.
17
18.. uml:: uml/SpmcTestStructure.puml
19
20Implementation
21--------------
22
23* |TS|
24    * ``components/service/spm_test`` implements the common code of the test SPs.
25    * ``deployments/spm-test*`` are the test SP deployments. There are currently four test SPs to cover various test
26      scenarios. SPM test SPs use |FF-A| v1.1 except SPM test SP 2 which uses v1.0 to cover the backwards compatibility test
27      of the SPMC.
28* `optee_test`_
29    * `ffa_spmc_1000.c`_ contains the SPMC test cases of ``xtest``.
30
31SPMC test RPC protocol
32----------------------
33
34Tests can invoke the functions of the test SPs via an SPMC test specific RPC interface which is built on top of FF-A direct
35messages.
36
37.. list-table:: Test RPC protocol
38  :header-rows: 1
39
40  * - Message ID
41    - Description
42    - ``args[0]``
43    - ``args[1]``
44    - ``args[2]``
45    - ``args[3]``
46    - ``args[4]``
47  * - EP_TEST_SP
48    - Run internal SP tests
49    - ``0x00000000``
50    - ``0x00000000``
51    - ``0x00000000``
52    - ``0x00000000``
53    - ``0x00000000``
54  * - EP_TEST_SP_COMMUNICATION
55    - Test FF-A direct message request
56    - ``0x00000001``
57    - The destination SP's FF-A endpoint ID
58    - ``0x00000000``
59    - ``0x00000000``
60    - ``0x00000000``
61  * - EP_TEST_SP_INCREASE
62    - Increase each ``param`` value by one and return response
63    - ``0x00000002``
64    - ``param[0]``
65    - ``param[1]``
66    - ``param[2]``
67    - ``param[3]``
68  * - EP_TRY_R_ACCESS
69    - Test shared buffer read access
70    - ``0x00000003``
71    - ``0x00000000``
72    - ``0x00000000``
73    - ``0x00000000``
74    - ``0x00000000``
75  * - EP_TRY_W_ACCESS
76    - Test shared buffer write access
77    - ``0x00000004``
78    - ``0x00000000``
79    - ``0x00000000``
80    - ``0x00000000``
81    - ``0x00000000``
82  * - EP_RETRIEVE
83    - Do FF-A memory retrieve
84    - ``0x00000005``
85    - Memory handle LSW
86    - Memory handle MSW
87    - Sender endpoint ID
88    - ``0x00000000``
89  * - EP_RELINQUISH
90    - Do FF-A memory relinquish
91    - ``0x00000006``
92    - Memory handle LSW
93    - Memory handle MSW
94    - Flags
95    - ``0x00000000``
96  * - EP_SP_MEM_SHARING
97    - Test FF-A memory sharing
98    - ``0x00000007``
99    - Target endpoint's FF-A ID
100    - ``0x00000000``
101    - ``0x00000000``
102    - ``0x00000000``
103  * - EP_SP_MEM_SHARING_MULTI
104    - Test FF-A memory sharing with multiple endpoints
105    - ``0x00000008``
106    - Target endpoint 1 FF-A ID
107    - Target endpoint 2 FF-A ID
108    - ``0x00000000``
109    - ``0x00000000``
110  * - EP_SP_MEM_SHARING_EXC
111    - Test exclusive FF-A memory sharing
112    - ``0x00000009``
113    - Target endpoint's FF-A ID
114    - ``0x00000000``
115    - ``0x00000000``
116    - ``0x00000000``
117  * - EP_SP_MEM_INCORRECT_ACCESS
118    - Negative FF-A memory sharing test
119    - ``0x0000000a``
120    - Target endpoint's FF-A ID
121    - ``0x00000000``
122    - ``0x00000000``
123    - ``0x00000000``
124  * - EP_SP_NOP
125    - No operation
126    - ``0x0000000b``
127    - ``0x00000000``
128    - ``0x00000000``
129    - ``0x00000000``
130    - ``0x00000000``
131  * - EP_TEST_SP_COMMUNICATION_RESPONSE
132    - Test FF-A direct message response
133    - ``0x0000000c``
134    - ``0x00000000``
135    - ``0x00000000``
136    - ``0x00000000``
137    - ``0x00000000``
138  * - SP_TEST_OK
139    - Successful test response
140    - ``0x000000aa``
141    - Request specific parameter
142    - Request specific parameter
143    - Request specific parameter
144    - Request specific parameter
145  * - SP_TEST_ERROR
146    - Error test response
147    - ``0x000000ff``
148    - Error code
149    - ``0x00000000``
150    - ``0x00000000``
151    - ``0x00000000``
152
153Test cases
154----------
155
156The following test cases are defined in ``ffa_spmc_1000.c``:
157
158* 1001: Test basic FF-A communication
159    * Try to connect to multiple SPs
160    * Have different SPs sending messages to each other
161    * Test standard SP messages (partition_info_get, get_own_id, ...)
162* 1002: Test FF-A memory
163    * Test memory sharing between the |NWd| and the |SWd|
164* 1003: Test FF-A memory: SP to SP
165    * Test memory sharing between to SPs
166* 1004: Test FF-A memory: Access and flags
167    * Test the different access modifiers and flags when sharing memory
168* 1005: Test FF-A memory: multiple receiver
169    * Share a memory region with multiple SPs
170
171--------------
172
173.. _`xtest`: https://optee.readthedocs.io/en/latest/building/gits/optee_test.html
174.. _`optee_test`: https://github.com/OP-TEE/optee_test
175.. _`ffa_spmc_1000.c`: https://github.com/OP-TEE/optee_test/blob/master/host/xtest/ffa_spmc_1000.c
176
177
178*Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.*
179
180SPDX-License-Identifier: BSD-3-Clause