blob: 4e4d2988963611d46545ce3680530a57d63135de [file] [log] [blame]
Pascal Brandc639ac82015-07-02 08:53:34 +02001/*
2 * Copyright (c) 2014, STMicroelectronics International N.V.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
Etienne Carrierea4653552017-01-11 10:04:24 +010014#include <limits.h>
15#include <pthread.h>
Pascal Brandc639ac82015-07-02 08:53:34 +020016#include <stdio.h>
Jens Wiklanderec545fb2017-11-24 16:58:07 +010017#include <stdlib.h>
Pascal Brandc639ac82015-07-02 08:53:34 +020018#include <string.h>
David Brownb2865ab2016-08-02 11:44:41 -060019#include <sys/stat.h>
20#include <sys/types.h>
Etienne Carrierea4653552017-01-11 10:04:24 +010021#include <unistd.h>
Pascal Brandc639ac82015-07-02 08:53:34 +020022
23#include "xtest_test.h"
24#include "xtest_helpers.h"
Jens Wiklander4441fe22015-10-23 16:53:02 +020025#include <signed_hdr.h>
Pascal Brandc639ac82015-07-02 08:53:34 +020026
Etienne Carriere726d8bc2017-03-21 15:45:59 +010027#include <pta_invoke_tests.h>
Pascal Brandc639ac82015-07-02 08:53:34 +020028#include <ta_crypt.h>
29#include <ta_os_test.h>
30#include <ta_create_fail_test.h>
31#include <ta_rpc_test.h>
32#include <ta_sims_test.h>
Jens Wiklanderac27ec12015-07-15 15:23:14 +020033#include <ta_concurrent.h>
Etienne Carriere50abf9a2017-03-24 11:33:50 +010034#include <sdp_basic.h>
Jens Wiklanderec545fb2017-11-24 16:58:07 +010035#ifdef CFG_SECSTOR_TA_MGMT_PTA
36#include <pta_secstor_ta_mgmt.h>
37#endif
38
39#ifndef MIN
40#define MIN(a, b) ((a) < (b) ? (a) : (b))
41#endif
Pascal Brandc639ac82015-07-02 08:53:34 +020042
43static void xtest_tee_test_1001(ADBG_Case_t *Case_p);
Jens Wiklander1d70a112017-10-16 15:16:39 +020044static void xtest_tee_test_1002(ADBG_Case_t *Case_p);
Jens Wiklander0c86bc32017-11-13 19:52:03 +010045static void xtest_tee_test_1003(ADBG_Case_t *Case_p);
Pascal Brandc639ac82015-07-02 08:53:34 +020046static void xtest_tee_test_1004(ADBG_Case_t *Case_p);
47static void xtest_tee_test_1005(ADBG_Case_t *Case_p);
48static void xtest_tee_test_1006(ADBG_Case_t *Case_p);
49static void xtest_tee_test_1007(ADBG_Case_t *Case_p);
50static void xtest_tee_test_1008(ADBG_Case_t *Case_p);
51static void xtest_tee_test_1009(ADBG_Case_t *Case_p);
52static void xtest_tee_test_1010(ADBG_Case_t *Case_p);
53static void xtest_tee_test_1011(ADBG_Case_t *Case_p);
54static void xtest_tee_test_1012(ADBG_Case_t *Case_p);
Jens Wiklanderac27ec12015-07-15 15:23:14 +020055static void xtest_tee_test_1013(ADBG_Case_t *Case_p);
Etienne Carriere50abf9a2017-03-24 11:33:50 +010056#ifdef CFG_SECURE_DATA_PATH
57static void xtest_tee_test_1014(ADBG_Case_t *Case_p);
58#endif
Jens Wiklander272d3642017-04-03 13:03:47 +020059static void xtest_tee_test_1015(ADBG_Case_t *Case_p);
Jerome Forissiere916b102017-06-07 17:55:52 +020060static void xtest_tee_test_1016(ADBG_Case_t *Case_p);
Pascal Brandc639ac82015-07-02 08:53:34 +020061
Jens Wiklander74abfe32017-01-03 14:17:47 +010062ADBG_CASE_DEFINE(regression, 1001, xtest_tee_test_1001, "Core self tests");
Jens Wiklander1d70a112017-10-16 15:16:39 +020063ADBG_CASE_DEFINE(regression, 1002, xtest_tee_test_1002, "PTA parameters");
Jens Wiklander0c86bc32017-11-13 19:52:03 +010064ADBG_CASE_DEFINE(regression, 1003, xtest_tee_test_1003,
65 "Core internal read/write mutex");
Jens Wiklander74abfe32017-01-03 14:17:47 +010066ADBG_CASE_DEFINE(regression, 1004, xtest_tee_test_1004, "Test User Crypt TA");
67ADBG_CASE_DEFINE(regression, 1005, xtest_tee_test_1005, "Many sessions");
68ADBG_CASE_DEFINE(regression, 1006, xtest_tee_test_1006,
69 "Test Basic OS features");
70ADBG_CASE_DEFINE(regression, 1007, xtest_tee_test_1007, "Test Panic");
71ADBG_CASE_DEFINE(regression, 1008, xtest_tee_test_1008,
Jens Wiklander25a57fe2016-12-26 21:46:24 +010072 "TEE internal client API");
Jens Wiklander74abfe32017-01-03 14:17:47 +010073ADBG_CASE_DEFINE(regression, 1009, xtest_tee_test_1009, "TEE Wait");
74ADBG_CASE_DEFINE(regression, 1010, xtest_tee_test_1010,
75 "Invalid memory access");
76ADBG_CASE_DEFINE(regression, 1011, xtest_tee_test_1011,
Jens Wiklanderf7b9c632017-01-03 17:32:26 +010077 "Test TA-to-TA features with User Crypt TA");
Jens Wiklander74abfe32017-01-03 14:17:47 +010078ADBG_CASE_DEFINE(regression, 1012, xtest_tee_test_1012,
Jens Wiklander25a57fe2016-12-26 21:46:24 +010079 "Test Single Instance Multi Session features with SIMS TA");
Jens Wiklander74abfe32017-01-03 14:17:47 +010080ADBG_CASE_DEFINE(regression, 1013, xtest_tee_test_1013,
Jens Wiklander25a57fe2016-12-26 21:46:24 +010081 "Test concurency with concurrent TA");
Etienne Carriere50abf9a2017-03-24 11:33:50 +010082#ifdef CFG_SECURE_DATA_PATH
83ADBG_CASE_DEFINE(regression, 1014, xtest_tee_test_1014,
84 "Test secure data path against SDP TAs and pTAs");
85#endif
Jens Wiklander272d3642017-04-03 13:03:47 +020086ADBG_CASE_DEFINE(regression, 1015, xtest_tee_test_1015,
87 "FS hash-tree corner cases");
Jerome Forissiere916b102017-06-07 17:55:52 +020088ADBG_CASE_DEFINE(regression, 1016, xtest_tee_test_1016,
89 "Test TA to TA transfers (in/out/inout memrefs on the stack)");
Jens Wiklanderac27ec12015-07-15 15:23:14 +020090
Pascal Brandc639ac82015-07-02 08:53:34 +020091struct xtest_crypto_session {
92 ADBG_Case_t *c;
93 TEEC_Session *session;
94 uint32_t cmd_id_sha256;
95 uint32_t cmd_id_aes256ecb_encrypt;
96 uint32_t cmd_id_aes256ecb_decrypt;
97};
98
99static void xtest_crypto_test(struct xtest_crypto_session *cs)
100{
101 uint32_t ret_orig;
102 uint8_t crypt_out[16];
103 uint8_t crypt_in[16] = { 22, 17 };
104
105 crypt_in[15] = 60;
106
107 Do_ADBG_BeginSubCase(cs->c, "AES encrypt");
108 {
109 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
110
111 op.params[0].tmpref.buffer = crypt_in;
112 op.params[0].tmpref.size = sizeof(crypt_in);
113 op.params[1].tmpref.buffer = crypt_out;
114 op.params[1].tmpref.size = sizeof(crypt_out);
115 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,
116 TEEC_MEMREF_TEMP_OUTPUT,
117 TEEC_NONE, TEEC_NONE);
118
119 (void)ADBG_EXPECT_TEEC_SUCCESS(cs->c,
120 TEEC_InvokeCommand(cs->session,
121 cs->
122 cmd_id_aes256ecb_encrypt,
123 &op,
124 &ret_orig));
125 }
126 Do_ADBG_EndSubCase(cs->c, "AES encrypt");
127
128 Do_ADBG_BeginSubCase(cs->c, "AES decrypt");
129 {
130 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
131 uint8_t out[16];
132
133 op.params[0].tmpref.buffer = crypt_out;
134 op.params[0].tmpref.size = sizeof(crypt_out);
135 op.params[1].tmpref.buffer = out;
136 op.params[1].tmpref.size = sizeof(out);
137 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,
138 TEEC_MEMREF_TEMP_OUTPUT,
139 TEEC_NONE, TEEC_NONE);
140
141 (void)ADBG_EXPECT_TEEC_SUCCESS(cs->c,
142 TEEC_InvokeCommand(cs->session,
143 cs->
144 cmd_id_aes256ecb_decrypt,
145 &op,
146 &ret_orig));
147
148 if (!ADBG_EXPECT(cs->c, 0,
149 memcmp(crypt_in, out, sizeof(crypt_in)))) {
150 Do_ADBG_Log("crypt_in:");
151 Do_ADBG_HexLog(crypt_in, sizeof(crypt_in), 16);
152 Do_ADBG_Log("out:");
153 Do_ADBG_HexLog(out, sizeof(out), 16);
154 }
155 }
156 Do_ADBG_EndSubCase(cs->c, "AES decrypt");
157
158 Do_ADBG_BeginSubCase(cs->c, "SHA-256 test, 3 bytes input");
159 {
160 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
161 static const uint8_t sha256_in[] = { 'a', 'b', 'c' };
162 static const uint8_t sha256_out[] = {
163 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
164 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
165 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
166 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad
167 };
168 uint8_t out[32] = { 0 };
169
170 op.params[0].tmpref.buffer = (void *)sha256_in;
171 op.params[0].tmpref.size = sizeof(sha256_in);
172 op.params[1].tmpref.buffer = out;
173 op.params[1].tmpref.size = sizeof(out);
174 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,
175 TEEC_MEMREF_TEMP_OUTPUT,
176 TEEC_NONE, TEEC_NONE);
177
178 (void)ADBG_EXPECT_TEEC_SUCCESS(cs->c,
179 TEEC_InvokeCommand(cs->session,
180 cs->
181 cmd_id_sha256,
182 &op,
183 &ret_orig));
184
185 if (!ADBG_EXPECT(cs->c, 0, memcmp(sha256_out, out,
186 sizeof(sha256_out)))) {
187 Do_ADBG_Log("sha256_out:");
188 Do_ADBG_HexLog(sha256_out, sizeof(sha256_out), 16);
189 Do_ADBG_Log("out:");
190 Do_ADBG_HexLog(out, sizeof(out), 16);
191 }
192 }
193 Do_ADBG_EndSubCase(cs->c, "SHA-256 test, 3 bytes input");
194
Etienne Carrierea3198522017-10-26 09:48:55 +0200195 Do_ADBG_BeginSubCase(cs->c, "AES-256 ECB encrypt (32B, fixed key)");
Pascal Brandc639ac82015-07-02 08:53:34 +0200196 {
197 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
198 static const uint8_t in[] = {
199 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
200 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
201 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
202 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
203 };
204 static const uint8_t exp_out[] = {
205 0x5A, 0x6E, 0x04, 0x57, 0x08, 0xFB, 0x71, 0x96,
206 0xF0, 0x2E, 0x55, 0x3D, 0x02, 0xC3, 0xA6, 0x92,
207 0xE9, 0xC3, 0xEF, 0x8A, 0xB2, 0x34, 0x53, 0xE6,
208 0xF0, 0x74, 0x9C, 0xD6, 0x36, 0xE7, 0xA8, 0x8E
209 };
210 uint8_t out[sizeof(exp_out)];
211
212 op.params[0].tmpref.buffer = (void *)in;
213 op.params[0].tmpref.size = sizeof(in);
214 op.params[1].tmpref.buffer = out;
215 op.params[1].tmpref.size = sizeof(out);
216 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,
217 TEEC_MEMREF_TEMP_OUTPUT,
218 TEEC_NONE, TEEC_NONE);
219
220 (void)ADBG_EXPECT_TEEC_SUCCESS(cs->c,
221 TEEC_InvokeCommand(cs->session,
222 cs->
223 cmd_id_aes256ecb_encrypt,
224 &op,
225 &ret_orig));
226
227 if (!ADBG_EXPECT(cs->c, 0,
228 memcmp(exp_out, out, sizeof(exp_out)))) {
229 Do_ADBG_Log("exp_out:");
230 Do_ADBG_HexLog(exp_out, sizeof(exp_out), 16);
231 Do_ADBG_Log("out:");
232 Do_ADBG_HexLog(out, sizeof(out), 16);
233 }
234 }
Etienne Carrierea3198522017-10-26 09:48:55 +0200235 Do_ADBG_EndSubCase(cs->c, "AES-256 ECB encrypt (32B, fixed key)");
Pascal Brandc639ac82015-07-02 08:53:34 +0200236
Etienne Carrierea3198522017-10-26 09:48:55 +0200237 Do_ADBG_BeginSubCase(cs->c, "AES-256 ECB decrypt (32B, fixed key)");
Pascal Brandc639ac82015-07-02 08:53:34 +0200238 {
239 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
240 static const uint8_t in[] = {
241 0x5A, 0x6E, 0x04, 0x57, 0x08, 0xFB, 0x71, 0x96,
242 0xF0, 0x2E, 0x55, 0x3D, 0x02, 0xC3, 0xA6, 0x92,
243 0xE9, 0xC3, 0xEF, 0x8A, 0xB2, 0x34, 0x53, 0xE6,
244 0xF0, 0x74, 0x9C, 0xD6, 0x36, 0xE7, 0xA8, 0x8E
245 };
246 static const uint8_t exp_out[] = {
247 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
248 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
249 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
250 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
251 };
252 uint8_t out[sizeof(exp_out)];
253
254 op.params[0].tmpref.buffer = (void *)in;
255 op.params[0].tmpref.size = sizeof(in);
256 op.params[1].tmpref.buffer = out;
257 op.params[1].tmpref.size = sizeof(out);
258 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,
259 TEEC_MEMREF_TEMP_OUTPUT,
260 TEEC_NONE, TEEC_NONE);
261
262 (void)ADBG_EXPECT_TEEC_SUCCESS(cs->c,
263 TEEC_InvokeCommand(cs->session,
264 cs->
265 cmd_id_aes256ecb_decrypt,
266 &op,
267 &ret_orig));
268
269 if (!ADBG_EXPECT(cs->c, 0,
270 memcmp(exp_out, out, sizeof(exp_out)))) {
271 Do_ADBG_Log("exp_out:");
272 Do_ADBG_HexLog(exp_out, sizeof(exp_out), 16);
273 Do_ADBG_Log("out:");
274 Do_ADBG_HexLog(out, sizeof(out), 16);
275 }
276 }
Etienne Carrierea3198522017-10-26 09:48:55 +0200277 Do_ADBG_EndSubCase(cs->c, "AES-256 ECB decrypt (32B, fixed key)");
Pascal Brandc639ac82015-07-02 08:53:34 +0200278}
279
280static void xtest_tee_test_1001(ADBG_Case_t *c)
281{
Jens Wiklandercf16e842016-02-10 09:07:09 +0100282 TEEC_Result res;
283 TEEC_Session session = { 0 };
284 uint32_t ret_orig;
Pascal Brandc639ac82015-07-02 08:53:34 +0200285
Etienne Carriere11093162017-10-26 09:49:04 +0200286 /* Pseudo TA is optional: warn and nicely exit if not found */
Etienne Carriere726d8bc2017-03-21 15:45:59 +0100287 res = xtest_teec_open_session(&session, &pta_invoke_tests_ta_uuid, NULL,
Jens Wiklandercf16e842016-02-10 09:07:09 +0100288 &ret_orig);
Etienne Carriere11093162017-10-26 09:49:04 +0200289 if (res == TEEC_ERROR_ITEM_NOT_FOUND) {
290 Do_ADBG_Log(" - 1001 - skip test, pseudo TA not found");
Jens Wiklandercf16e842016-02-10 09:07:09 +0100291 return;
Etienne Carriere11093162017-10-26 09:49:04 +0200292 }
293 ADBG_EXPECT_TEEC_SUCCESS(c, res);
Pascal Brandc639ac82015-07-02 08:53:34 +0200294
Jens Wiklandercf16e842016-02-10 09:07:09 +0100295 (void)ADBG_EXPECT_TEEC_SUCCESS(c, TEEC_InvokeCommand(
Etienne Carriere726d8bc2017-03-21 15:45:59 +0100296 &session, PTA_INVOKE_TESTS_CMD_SELF_TESTS, NULL, &ret_orig));
Jens Wiklandercf16e842016-02-10 09:07:09 +0100297 TEEC_CloseSession(&session);
Pascal Brandc639ac82015-07-02 08:53:34 +0200298}
299
Jens Wiklander1d70a112017-10-16 15:16:39 +0200300static void xtest_tee_test_1002(ADBG_Case_t *c)
301{
302 TEEC_Result res;
303 TEEC_Session session = { 0 };
304 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
305 uint32_t ret_orig;
306 uint8_t buf[16 * 1024];
307 uint8_t exp_sum = 0;
308 size_t n;
309
Etienne Carriere11093162017-10-26 09:49:04 +0200310 /* Pseudo TA is optional: warn and nicely exit if not found */
Jens Wiklander1d70a112017-10-16 15:16:39 +0200311 res = xtest_teec_open_session(&session, &pta_invoke_tests_ta_uuid, NULL,
312 &ret_orig);
Etienne Carriere11093162017-10-26 09:49:04 +0200313 if (res == TEEC_ERROR_ITEM_NOT_FOUND) {
314 Do_ADBG_Log(" - 1002 - skip test, pseudo TA not found");
Jens Wiklander1d70a112017-10-16 15:16:39 +0200315 return;
Etienne Carriere11093162017-10-26 09:49:04 +0200316 }
317 ADBG_EXPECT_TEEC_SUCCESS(c, res);
Jens Wiklander1d70a112017-10-16 15:16:39 +0200318
319 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INOUT, TEEC_NONE,
320 TEEC_NONE, TEEC_NONE);
321 op.params[0].tmpref.size = sizeof(buf);
322 op.params[0].tmpref.buffer = buf;
323
324 for (n = 0; n < sizeof(buf); n++)
325 buf[n] = n + 1;
326 for (n = 0; n < sizeof(buf); n++)
327 exp_sum += buf[n];
328
329 if (!ADBG_EXPECT_TEEC_SUCCESS(c, TEEC_InvokeCommand(
330 &session, PTA_INVOKE_TESTS_CMD_PARAMS, &op, &ret_orig)))
331 goto out;
332
333 ADBG_EXPECT_COMPARE_SIGNED(c, exp_sum, ==, buf[0]);
334out:
335 TEEC_CloseSession(&session);
336}
337
Jens Wiklander0c86bc32017-11-13 19:52:03 +0100338struct test_1003_arg {
339 uint32_t test_type;
340 size_t repeat;
341 size_t max_before_lockers;
342 size_t max_during_lockers;
343 size_t before_lockers;
344 size_t during_lockers;
345 TEEC_Result res;
346 uint32_t error_orig;
347};
Jens Wiklander1d70a112017-10-16 15:16:39 +0200348
Jens Wiklander0c86bc32017-11-13 19:52:03 +0100349static void *test_1003_thread(void *arg)
350{
351 struct test_1003_arg *a = arg;
352 TEEC_Session session = { 0 };
353 size_t rounds = 64 * 1024;
354 size_t n;
355
356 a->res = xtest_teec_open_session(&session, &pta_invoke_tests_ta_uuid,
357 NULL, &a->error_orig);
358 if (a->res != TEEC_SUCCESS)
359 return NULL;
360
361 for (n = 0; n < a->repeat; n++) {
362 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
363
364 op.params[0].value.a = a->test_type;
365 op.params[0].value.b = rounds;
366
367 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
368 TEEC_VALUE_OUTPUT,
369 TEEC_NONE, TEEC_NONE);
370 a->res = TEEC_InvokeCommand(&session,
371 PTA_INVOKE_TESTS_CMD_MUTEX,
372 &op, &a->error_orig);
373 if (a->test_type == PTA_MUTEX_TEST_WRITER &&
374 op.params[1].value.b != 1) {
375 Do_ADBG_Log("n %zu %" PRIu32, n, op.params[1].value.b);
376 a->res = TEEC_ERROR_BAD_STATE;
377 a->error_orig = 42;
378 break;
379 }
380
381 if (a->test_type == PTA_MUTEX_TEST_READER) {
382 if (op.params[1].value.a > a->max_before_lockers)
383 a->max_before_lockers = op.params[1].value.a;
384
385 if (op.params[1].value.b > a->max_during_lockers)
386 a->max_during_lockers = op.params[1].value.b;
387
388 a->before_lockers += op.params[1].value.a;
389 a->during_lockers += op.params[1].value.b;
390 }
391 }
392 TEEC_CloseSession(&session);
393
394 return NULL;
395}
396
397static void xtest_tee_test_1003(ADBG_Case_t *c)
398{
399 size_t num_threads = 3 * 2;
400 TEEC_Result res;
401 TEEC_Session session = { 0 };
402 uint32_t ret_orig;
403 size_t repeat = 20;
404 pthread_t thr[num_threads];
405 struct test_1003_arg arg[num_threads];
406 size_t max_read_concurrency = 0;
407 size_t max_read_waiters = 0;
408 size_t num_concurrent_read_lockers = 0;
409 size_t num_concurrent_read_waiters = 0;
410 size_t n;
411 size_t nt = num_threads;
412 double mean_read_concurrency;
413 double mean_read_waiters;
414 size_t num_writers = 0;
415 size_t num_readers = 0;
416
417 /* Pseudo TA is optional: warn and nicely exit if not found */
418 res = xtest_teec_open_session(&session, &pta_invoke_tests_ta_uuid, NULL,
419 &ret_orig);
420 if (res == TEEC_ERROR_ITEM_NOT_FOUND) {
421 Do_ADBG_Log(" - 1003 - skip test, pseudo TA not found");
422 return;
423 }
424 ADBG_EXPECT_TEEC_SUCCESS(c, res);
425 TEEC_CloseSession(&session);
426
427 memset(arg, 0, sizeof(arg));
428
429 for (n = 0; n < nt; n++) {
430 if (n % 3) {
431 arg[n].test_type = PTA_MUTEX_TEST_READER;
432 num_readers++;
433 } else {
434 arg[n].test_type = PTA_MUTEX_TEST_WRITER;
435 num_writers++;
436 }
437 arg[n].repeat = repeat;
438 if (!ADBG_EXPECT(c, 0, pthread_create(thr + n, NULL,
439 test_1003_thread, arg + n)))
440 nt = n; /* break loop and start cleanup */
441 }
442
443 for (n = 0; n < nt; n++) {
444 ADBG_EXPECT(c, 0, pthread_join(thr[n], NULL));
445 if (!ADBG_EXPECT_TEEC_SUCCESS(c, arg[n].res))
446 Do_ADBG_Log("error origin %" PRIu32,
447 arg[n].error_orig);
448 if (arg[n].test_type == PTA_MUTEX_TEST_READER) {
449 if (arg[n].max_during_lockers > max_read_concurrency)
450 max_read_concurrency =
451 arg[n].max_during_lockers;
452
453 if (arg[n].max_before_lockers > max_read_waiters)
454 max_read_waiters = arg[n].max_before_lockers;
455
456 num_concurrent_read_lockers += arg[n].during_lockers;
457 num_concurrent_read_waiters += arg[n].before_lockers;
458 }
459 }
460
461 mean_read_concurrency = (double)num_concurrent_read_lockers /
462 (double)(repeat * num_readers);
463 mean_read_waiters = (double)num_concurrent_read_waiters /
464 (double)(repeat * num_readers);
465
466 Do_ADBG_Log(" Number of parallel threads: %zu (%zu writers and %zu readers)",
467 num_threads, num_writers, num_readers);
468 Do_ADBG_Log(" Max read concurrency: %zu", max_read_concurrency);
469 Do_ADBG_Log(" Max read waiters: %zu", max_read_waiters);
470 Do_ADBG_Log(" Mean read concurrency: %g", mean_read_concurrency);
471 Do_ADBG_Log(" Mean read waiting: %g", mean_read_waiters);
472}
Jens Wiklander1d70a112017-10-16 15:16:39 +0200473
Pascal Brandc639ac82015-07-02 08:53:34 +0200474static void xtest_tee_test_1004(ADBG_Case_t *c)
475{
476 TEEC_Session session = { 0 };
477 uint32_t ret_orig;
478 struct xtest_crypto_session cs = { c, &session, TA_CRYPT_CMD_SHA256,
479 TA_CRYPT_CMD_AES256ECB_ENC,
480 TA_CRYPT_CMD_AES256ECB_DEC };
481
482 if (!ADBG_EXPECT_TEEC_SUCCESS(c, xtest_teec_open_session(
483 &session, &crypt_user_ta_uuid,
484 NULL, &ret_orig)))
485 return;
486
487 /* Run the "complete crypto test suite" */
488 xtest_crypto_test(&cs);
489
490 TEEC_CloseSession(&session);
491}
492
493#ifndef TEEC_ERROR_TARGET_DEAD
494/* To be removed when we have TEEC_ERROR_TARGET_DEAD from tee_client_api.h */
495#define TEEC_ERROR_TARGET_DEAD 0xFFFF3024
496#endif
497
498static void xtest_tee_test_invalid_mem_access(ADBG_Case_t *c, uint32_t n)
499{
500 TEEC_Session session = { 0 };
501 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
502 uint32_t ret_orig;
503
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300504 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
Pascal Brandc639ac82015-07-02 08:53:34 +0200505 xtest_teec_open_session(&session, &os_test_ta_uuid, NULL,
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300506 &ret_orig)))
507 return;
Pascal Brandc639ac82015-07-02 08:53:34 +0200508
509 op.params[0].value.a = n;
510 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE,
511 TEEC_NONE);
512
513 (void)ADBG_EXPECT_TEEC_RESULT(c,
514 TEEC_ERROR_TARGET_DEAD,
515 TEEC_InvokeCommand(&session, TA_OS_TEST_CMD_BAD_MEM_ACCESS, &op,
516 &ret_orig));
517
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300518 (void)ADBG_EXPECT_TEEC_RESULT(c,
519 TEEC_ERROR_TARGET_DEAD,
520 TEEC_InvokeCommand(&session, TA_OS_TEST_CMD_BAD_MEM_ACCESS, &op,
Pascal Brandc639ac82015-07-02 08:53:34 +0200521 &ret_orig));
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300522
Pascal Brandc639ac82015-07-02 08:53:34 +0200523 (void)ADBG_EXPECT_TEEC_ERROR_ORIGIN(c, TEEC_ORIGIN_TEE, ret_orig);
524
525 TEEC_CloseSession(&session);
526}
527
528static void xtest_tee_test_1005(ADBG_Case_t *c)
529{
530 uint32_t ret_orig;
531#define MAX_SESSIONS 3
532 TEEC_Session sessions[MAX_SESSIONS];
533 int i;
534
535 for (i = 0; i < MAX_SESSIONS; i++) {
536 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
Jens Wiklandereb6bce72016-09-23 11:37:33 +0200537 xtest_teec_open_session(&sessions[i],
538 &concurrent_ta_uuid,
Pascal Brandc639ac82015-07-02 08:53:34 +0200539 NULL, &ret_orig)))
540 break;
541 }
542
543 for (; --i >= 0; )
544 TEEC_CloseSession(&sessions[i]);
545}
546
547static void xtest_tee_test_1006(ADBG_Case_t *c)
548{
549 TEEC_Session session = { 0 };
550 uint32_t ret_orig;
551 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
552 uint8_t buf[32];
553
554 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
555 xtest_teec_open_session(&session, &os_test_ta_uuid, NULL,
556 &ret_orig)))
557 return;
558
559 op.params[0].tmpref.buffer = buf;
560 op.params[0].tmpref.size = sizeof(buf);
561 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT, TEEC_NONE,
562 TEEC_NONE, TEEC_NONE);
563
564 (void)ADBG_EXPECT_TEEC_SUCCESS(c,
565 TEEC_InvokeCommand(&session, TA_OS_TEST_CMD_BASIC, &op,
566 &ret_orig));
567
568 TEEC_CloseSession(&session);
569}
570
571static void xtest_tee_test_1007(ADBG_Case_t *c)
572{
573 TEEC_Session session = { 0 };
574 uint32_t ret_orig;
575
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300576 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
Pascal Brandc639ac82015-07-02 08:53:34 +0200577 xtest_teec_open_session(&session, &os_test_ta_uuid, NULL,
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300578 &ret_orig)))
579 return;
Pascal Brandc639ac82015-07-02 08:53:34 +0200580
581 (void)ADBG_EXPECT_TEEC_RESULT(c,
582 TEEC_ERROR_TARGET_DEAD,
583 TEEC_InvokeCommand(&session, TA_OS_TEST_CMD_PANIC, NULL,
584 &ret_orig));
585
586 (void)ADBG_EXPECT_TEEC_ERROR_ORIGIN(c, TEEC_ORIGIN_TEE, ret_orig);
587
588 (void)ADBG_EXPECT_TEEC_RESULT(c,
589 TEEC_ERROR_TARGET_DEAD,
590 TEEC_InvokeCommand(&session, TA_OS_TEST_CMD_INIT, NULL,
591 &ret_orig));
592
593 (void)ADBG_EXPECT_TEEC_ERROR_ORIGIN(c, TEEC_ORIGIN_TEE, ret_orig);
594
595 TEEC_CloseSession(&session);
596}
597
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100598#ifdef CFG_SECSTOR_TA_MGMT_PTA
Jerome Forissierf02a2212015-10-29 14:33:35 +0100599#ifndef TA_DIR
Victor Chong3d8798f2017-03-01 18:31:48 +0000600# ifdef __ANDROID__
601#define TA_DIR "/system/lib/optee_armtz"
602# else
Jerome Forissierf02a2212015-10-29 14:33:35 +0100603#define TA_DIR "/lib/optee_armtz"
Victor Chong3d8798f2017-03-01 18:31:48 +0000604# endif
Jerome Forissierf02a2212015-10-29 14:33:35 +0100605#endif
606
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100607static FILE *open_ta_file(const TEEC_UUID *uuid, const char *mode)
David Brownb2865ab2016-08-02 11:44:41 -0600608{
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100609 char buf[PATH_MAX];
David Brownb2865ab2016-08-02 11:44:41 -0600610
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100611 snprintf(buf, sizeof(buf),
Jens Wiklander6203b872016-12-08 19:18:29 +0100612 "%s/%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x.ta",
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100613 TA_DIR, uuid->timeLow, uuid->timeMid, uuid->timeHiAndVersion,
Jens Wiklanderb7940892015-10-23 16:02:40 +0200614 uuid->clockSeqAndNode[0], uuid->clockSeqAndNode[1],
615 uuid->clockSeqAndNode[2], uuid->clockSeqAndNode[3],
616 uuid->clockSeqAndNode[4], uuid->clockSeqAndNode[5],
David Brownb2865ab2016-08-02 11:44:41 -0600617 uuid->clockSeqAndNode[6], uuid->clockSeqAndNode[7]);
Jens Wiklanderb7940892015-10-23 16:02:40 +0200618
Jens Wiklanderb7940892015-10-23 16:02:40 +0200619 return fopen(buf, mode);
620}
621
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100622static bool load_corrupt_ta(ADBG_Case_t *c, size_t offs, uint8_t mask)
Jens Wiklander4441fe22015-10-23 16:53:02 +0200623{
624 TEEC_Session session = { 0 };
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100625 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
626 TEEC_UUID uuid = PTA_SECSTOR_TA_MGMT_UUID;
Jens Wiklander4441fe22015-10-23 16:53:02 +0200627 TEEC_Result res;
628 uint32_t ret_orig;
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100629 FILE *f = NULL;
630 bool r = false;
631 uint8_t *buf = NULL;
632 size_t sz;
633 size_t fread_res;
Jens Wiklander4441fe22015-10-23 16:53:02 +0200634
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100635 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
636 xtest_teec_open_session(&session, &uuid, NULL, &ret_orig)))
637 goto out;
Jens Wiklander4441fe22015-10-23 16:53:02 +0200638
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100639 f = open_ta_file(&create_fail_test_ta_uuid, "rb");
640 if (!ADBG_EXPECT_NOT_NULL(c, f))
641 goto out;
642 if (!ADBG_EXPECT_TRUE(c, !fseek(f, 0, SEEK_END)))
643 goto out;
644 sz = ftell(f);
645 rewind(f);
646
647 buf = malloc(sz);
648 if (!ADBG_EXPECT_NOT_NULL(c, buf))
649 goto out;
650
651 fread_res = fread(buf, 1, sz, f);
652 if (!ADBG_EXPECT_COMPARE_UNSIGNED(c, fread_res, ==, sz))
653 goto out;
654
Jens Wiklander4441fe22015-10-23 16:53:02 +0200655 fclose(f);
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100656 f = NULL;
Jens Wiklander4441fe22015-10-23 16:53:02 +0200657
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100658 buf[MIN(offs, sz)] ^= mask;
Jens Wiklander4441fe22015-10-23 16:53:02 +0200659
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100660 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT, TEEC_NONE,
661 TEEC_NONE, TEEC_NONE);
662 op.params[0].tmpref.buffer = buf;
663 op.params[0].tmpref.size = sz;
664
665 res = TEEC_InvokeCommand(&session, PTA_SECSTOR_TA_MGMT_BOOTSTRAP, &op,
666 &ret_orig);
667 r = ADBG_EXPECT_TEEC_RESULT(c, TEEC_ERROR_SECURITY, res);
668out:
669 free(buf);
670 if (f)
671 fclose(f);
672 TEEC_CloseSession(&session);
Jens Wiklander4441fe22015-10-23 16:53:02 +0200673 return r;
674}
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100675#endif /*CFG_SECSTOR_TA_MGMT_PTA*/
Jens Wiklander4441fe22015-10-23 16:53:02 +0200676
Pascal Brandc639ac82015-07-02 08:53:34 +0200677static void xtest_tee_test_1008(ADBG_Case_t *c)
678{
679 TEEC_Session session = { 0 };
680 TEEC_Session session_crypt = { 0 };
681 uint32_t ret_orig;
682
683 Do_ADBG_BeginSubCase(c, "Invoke command");
684 {
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300685 if (ADBG_EXPECT_TEEC_SUCCESS(c,
Pascal Brandc639ac82015-07-02 08:53:34 +0200686 xtest_teec_open_session(&session, &os_test_ta_uuid,
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300687 NULL, &ret_orig))) {
Pascal Brandc639ac82015-07-02 08:53:34 +0200688
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300689 (void)ADBG_EXPECT_TEEC_SUCCESS(c,
690 TEEC_InvokeCommand(&session, TA_OS_TEST_CMD_CLIENT,
691 NULL, &ret_orig));
692 TEEC_CloseSession(&session);
693 }
Pascal Brandc639ac82015-07-02 08:53:34 +0200694
Pascal Brandc639ac82015-07-02 08:53:34 +0200695 }
696 Do_ADBG_EndSubCase(c, "Invoke command");
697
698 Do_ADBG_BeginSubCase(c, "Invoke command with timeout");
699 {
700 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
701
702 op.params[0].value.a = 2000;
703 op.paramTypes = TEEC_PARAM_TYPES(
704 TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE);
705
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300706 if (ADBG_EXPECT_TEEC_SUCCESS(c,
Pascal Brandc639ac82015-07-02 08:53:34 +0200707 xtest_teec_open_session(&session,
708 &os_test_ta_uuid,
709 NULL,
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300710 &ret_orig))) {
Pascal Brandc639ac82015-07-02 08:53:34 +0200711
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300712 (void)ADBG_EXPECT_TEEC_SUCCESS(c,
713 TEEC_InvokeCommand(&session,
714 TA_OS_TEST_CMD_CLIENT_WITH_TIMEOUT,
715 &op, &ret_orig));
716 TEEC_CloseSession(&session);
717 }
Pascal Brandc639ac82015-07-02 08:53:34 +0200718 }
719 Do_ADBG_EndSubCase(c, "Invoke command with timeout");
720
721 Do_ADBG_BeginSubCase(c, "Create session fail");
722 {
Jens Wiklanderb7940892015-10-23 16:02:40 +0200723 size_t n;
724
Pascal Brandc639ac82015-07-02 08:53:34 +0200725 (void)ADBG_EXPECT_TEEC_RESULT(c, TEEC_ERROR_GENERIC,
726 xtest_teec_open_session(&session_crypt,
727 &create_fail_test_ta_uuid, NULL,
728 &ret_orig));
Pascal Brandc639ac82015-07-02 08:53:34 +0200729 /*
730 * Run this several times to see that there's no memory leakage.
731 */
732 for (n = 0; n < 100; n++) {
733 Do_ADBG_Log("n = %zu", n);
734 (void)ADBG_EXPECT_TEEC_RESULT(c, TEEC_ERROR_GENERIC,
735 xtest_teec_open_session(&session_crypt,
736 &create_fail_test_ta_uuid,
737 NULL, &ret_orig));
738 }
739 }
740 Do_ADBG_EndSubCase(c, "Create session fail");
Jens Wiklanderb7940892015-10-23 16:02:40 +0200741
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100742#ifdef CFG_SECSTOR_TA_MGMT_PTA
Jens Wiklander4441fe22015-10-23 16:53:02 +0200743 Do_ADBG_BeginSubCase(c, "Load corrupt TA");
744 ADBG_EXPECT_TRUE(c,
745 load_corrupt_ta(c, offsetof(struct shdr, magic), 1));
746 ADBG_EXPECT_TRUE(c,
747 load_corrupt_ta(c, offsetof(struct shdr, img_type), 1));
748 ADBG_EXPECT_TRUE(c,
749 load_corrupt_ta(c, offsetof(struct shdr, img_size), 1));
750 ADBG_EXPECT_TRUE(c,
751 load_corrupt_ta(c, offsetof(struct shdr, algo), 1));
752 ADBG_EXPECT_TRUE(c,
753 load_corrupt_ta(c, offsetof(struct shdr, hash_size), 1));
754 ADBG_EXPECT_TRUE(c,
755 load_corrupt_ta(c, offsetof(struct shdr, sig_size), 1));
756 ADBG_EXPECT_TRUE(c,
757 load_corrupt_ta(c, sizeof(struct shdr), 1)); /* hash */
758 ADBG_EXPECT_TRUE(c,
759 load_corrupt_ta(c, sizeof(struct shdr) + 32, 1)); /* sig */
760 ADBG_EXPECT_TRUE(c, load_corrupt_ta(c, 3000, 1)); /* payload */
761 ADBG_EXPECT_TRUE(c, load_corrupt_ta(c, 30000, 1)); /* payload */
762 Do_ADBG_EndSubCase(c, "Load corrupt TA");
Jens Wiklanderec545fb2017-11-24 16:58:07 +0100763#endif /*CFG_SECSTOR_TA_MGMT_PTA*/
Pascal Brandc639ac82015-07-02 08:53:34 +0200764}
765
Pascal Brandc639ac82015-07-02 08:53:34 +0200766static void *cancellation_thread(void *arg)
767{
768 /*
769 * Sleep 0.5 seconds before cancellation to make sure that the other
770 * thread is in RPC_WAIT.
771 */
772 (void)usleep(500000);
773 TEEC_RequestCancellation(arg);
774 return NULL;
775}
Pascal Brandc639ac82015-07-02 08:53:34 +0200776
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300777static void xtest_tee_test_1009_subcase(ADBG_Case_t *c, const char *subcase,
778 uint32_t timeout, bool cancel)
Pascal Brandc639ac82015-07-02 08:53:34 +0200779{
780 TEEC_Session session = { 0 };
781 uint32_t ret_orig;
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300782 pthread_t thr;
Pascal Brandc639ac82015-07-02 08:53:34 +0200783
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300784 Do_ADBG_BeginSubCase(c, "%s", subcase);
Pascal Brandc639ac82015-07-02 08:53:34 +0200785 {
786 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
787
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300788 if (ADBG_EXPECT_TEEC_SUCCESS(c,
789 xtest_teec_open_session(&session, &os_test_ta_uuid,
790 NULL, &ret_orig))) {
Pascal Brandc639ac82015-07-02 08:53:34 +0200791
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300792 (void)ADBG_EXPECT_TEEC_ERROR_ORIGIN(c,
793 TEEC_ORIGIN_TRUSTED_APP,
794 ret_orig);
Pascal Brandc639ac82015-07-02 08:53:34 +0200795
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300796 op.params[0].value.a = timeout;
797 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
798 TEEC_NONE,
799 TEEC_NONE, TEEC_NONE);
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300800 if (cancel) {
801 (void)ADBG_EXPECT(c, 0,
802 pthread_create(&thr, NULL,
803 cancellation_thread, &op));
Pascal Brandc639ac82015-07-02 08:53:34 +0200804
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300805 (void)ADBG_EXPECT_TEEC_RESULT(c,
806 TEEC_ERROR_CANCEL,
807 TEEC_InvokeCommand(&session,
808 TA_OS_TEST_CMD_WAIT,
809 &op,
810 &ret_orig));
811 } else
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300812
813 (void)ADBG_EXPECT_TEEC_SUCCESS(c,
814 TEEC_InvokeCommand(&session,
815 TA_OS_TEST_CMD_WAIT,
816 &op,
817 &ret_orig));
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300818 if (cancel)
819 (void)ADBG_EXPECT(c, 0, pthread_join(thr, NULL));
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300820
821 TEEC_CloseSession(&session);
822 }
Pascal Brandc639ac82015-07-02 08:53:34 +0200823 }
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300824 Do_ADBG_EndSubCase(c, "%s", subcase);
825}
826
827static void xtest_tee_test_1009(ADBG_Case_t *c)
828{
829 xtest_tee_test_1009_subcase(c, "TEE Wait 0.1s", 100, false);
830 xtest_tee_test_1009_subcase(c, "TEE Wait 0.5s", 500, false);
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300831 xtest_tee_test_1009_subcase(c, "TEE Wait 2s cancel", 2000, true);
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300832 xtest_tee_test_1009_subcase(c, "TEE Wait 2s", 2000, false);
Pascal Brandc639ac82015-07-02 08:53:34 +0200833}
834
835static void xtest_tee_test_1010(ADBG_Case_t *c)
836{
837 unsigned n;
838
839 for (n = 1; n <= 5; n++) {
840 Do_ADBG_BeginSubCase(c, "Invalid memory access %u", n);
841 xtest_tee_test_invalid_mem_access(c, n);
842 Do_ADBG_EndSubCase(c, "Invalid memory access %u", n);
843 }
844}
845
846static void xtest_tee_test_1011(ADBG_Case_t *c)
847{
848 TEEC_Session session = { 0 };
849 uint32_t ret_orig;
850 struct xtest_crypto_session cs = {
851 c, &session, TA_RPC_CMD_CRYPT_SHA256,
852 TA_RPC_CMD_CRYPT_AES256ECB_ENC,
853 TA_RPC_CMD_CRYPT_AES256ECB_DEC
854 };
Jens Wiklanderf7b9c632017-01-03 17:32:26 +0100855 struct xtest_crypto_session cs_privmem = {
856 c, &session,
857 TA_RPC_CMD_CRYPT_PRIVMEM_SHA256,
858 TA_RPC_CMD_CRYPT_PRIVMEM_AES256ECB_ENC,
859 TA_RPC_CMD_CRYPT_PRIVMEM_AES256ECB_DEC
860 };
Pascal Brandc639ac82015-07-02 08:53:34 +0200861 TEEC_UUID uuid = rpc_test_ta_uuid;
862
863 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
864 xtest_teec_open_session(&session, &uuid, NULL, &ret_orig)))
865 return;
866
Jens Wiklanderf7b9c632017-01-03 17:32:26 +0100867 Do_ADBG_BeginSubCase(c, "TA-to-TA via non-secure shared memory");
Pascal Brandc639ac82015-07-02 08:53:34 +0200868 /*
Jens Wiklanderf7b9c632017-01-03 17:32:26 +0100869 * Run the "complete crypto test suite" using TA-to-TA
870 * communication
Pascal Brandc639ac82015-07-02 08:53:34 +0200871 */
872 xtest_crypto_test(&cs);
Jens Wiklanderf7b9c632017-01-03 17:32:26 +0100873 Do_ADBG_EndSubCase(c, "TA-to-TA via non-secure shared memory");
874
875 Do_ADBG_BeginSubCase(c, "TA-to-TA via TA private memory");
876 /*
877 * Run the "complete crypto test suite" using TA-to-TA
878 * communication via TA private memory.
879 */
880 xtest_crypto_test(&cs_privmem);
881 Do_ADBG_EndSubCase(c, "TA-to-TA via TA private memory");
882
Pascal Brandc639ac82015-07-02 08:53:34 +0200883 TEEC_CloseSession(&session);
884}
885
886/*
887 * Note that this test is failing when
888 * - running twice in a raw
889 * - and the user TA is statically linked
890 * This is because the counter is not reseted when opening the first session
891 * in case the TA is statically linked
892 */
893static void xtest_tee_test_1012(ADBG_Case_t *c)
894{
895 TEEC_Session session1 = { 0 };
896 TEEC_Session session2 = { 0 };
897 uint32_t ret_orig;
898 TEEC_UUID uuid = sims_test_ta_uuid;
899
900 Do_ADBG_BeginSubCase(c, "Single Instance Multi Session");
901 {
902 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
903 static const uint8_t in[] = {
904 0x5A, 0x6E, 0x04, 0x57, 0x08, 0xFB, 0x71, 0x96,
905 0xF0, 0x2E, 0x55, 0x3D, 0x02, 0xC3, 0xA6, 0x92,
906 0xE9, 0xC3, 0xEF, 0x8A, 0xB2, 0x34, 0x53, 0xE6,
907 0xF0, 0x74, 0x9C, 0xD6, 0x36, 0xE7, 0xA8, 0x8E
908 };
909 uint8_t out[32] = { 0 };
910 int i;
911
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300912 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
Pascal Brandc639ac82015-07-02 08:53:34 +0200913 xtest_teec_open_session(&session1, &uuid, NULL,
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300914 &ret_orig)))
915 return;
Pascal Brandc639ac82015-07-02 08:53:34 +0200916
917 op.params[0].value.a = 0;
918 op.params[1].tmpref.buffer = (void *)in;
919 op.params[1].tmpref.size = sizeof(in);
920 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
921 TEEC_MEMREF_TEMP_INPUT,
922 TEEC_NONE, TEEC_NONE);
923
924 (void)ADBG_EXPECT_TEEC_SUCCESS(c,
925 TEEC_InvokeCommand(&session1, TA_SIMS_CMD_WRITE, &op,
926 &ret_orig));
927
Jerome Forissier3cc0a422017-12-14 09:53:24 +0100928 for (i = 1; i < 3; i++) {
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300929 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
Pascal Brandc639ac82015-07-02 08:53:34 +0200930 xtest_teec_open_session(&session2, &uuid, NULL,
Volodymyr Babchukae3dcd72016-10-20 16:51:59 +0300931 &ret_orig)))
932 continue;
Pascal Brandc639ac82015-07-02 08:53:34 +0200933
934 op.params[0].value.a = 0;
935 op.params[1].tmpref.buffer = out;
936 op.params[1].tmpref.size = sizeof(out);
937 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
938 TEEC_MEMREF_TEMP_OUTPUT,
939 TEEC_NONE, TEEC_NONE);
940
941 (void)ADBG_EXPECT_TEEC_SUCCESS(c,
942 TEEC_InvokeCommand(&session2, TA_SIMS_CMD_READ,
943 &op, &ret_orig));
944
945 if (!ADBG_EXPECT_BUFFER(c, in, sizeof(in), out,
946 sizeof(out))) {
947 Do_ADBG_Log("in:");
948 Do_ADBG_HexLog(in, sizeof(in), 16);
949 Do_ADBG_Log("out:");
950 Do_ADBG_HexLog(out, sizeof(out), 16);
951 }
952
953 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_OUTPUT,
954 TEEC_NONE, TEEC_NONE,
955 TEEC_NONE);
956
957 (void)ADBG_EXPECT_TEEC_SUCCESS(c,
958 TEEC_InvokeCommand(&session1,
959 TA_SIMS_CMD_GET_COUNTER,
960 &op, &ret_orig));
961
962 (void)ADBG_EXPECT(c, 0, op.params[0].value.a);
963
964 (void)ADBG_EXPECT_TEEC_SUCCESS(c,
965 TEEC_InvokeCommand(&session2,
966 TA_SIMS_CMD_GET_COUNTER, &op,
967 &ret_orig));
968
969 (void)ADBG_EXPECT(c, i, op.params[0].value.a);
970 TEEC_CloseSession(&session2);
971 }
972
973 memset(out, 0, sizeof(out));
974 op.params[0].value.a = 0;
975 op.params[1].tmpref.buffer = out;
976 op.params[1].tmpref.size = sizeof(out);
977 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
978 TEEC_MEMREF_TEMP_OUTPUT,
979 TEEC_NONE, TEEC_NONE);
980
981 (void)ADBG_EXPECT_TEEC_SUCCESS(c,
982 TEEC_InvokeCommand(&session1, TA_SIMS_CMD_READ, &op,
983 &ret_orig));
984
985 if (!ADBG_EXPECT(c, 0, memcmp(in, out, sizeof(in)))) {
986 Do_ADBG_Log("in:");
987 Do_ADBG_HexLog(in, sizeof(in), 16);
988 Do_ADBG_Log("out:");
989 Do_ADBG_HexLog(out, sizeof(out), 16);
990 }
991
992 TEEC_CloseSession(&session1);
993 }
994}
Jens Wiklanderac27ec12015-07-15 15:23:14 +0200995
996struct test_1013_thread_arg {
Jens Wiklander70672972016-04-06 00:01:45 +0200997 const TEEC_UUID *uuid;
Jens Wiklanderac27ec12015-07-15 15:23:14 +0200998 uint32_t cmd;
999 uint32_t repeat;
1000 TEEC_SharedMemory *shm;
1001 uint32_t error_orig;
1002 TEEC_Result res;
1003 uint32_t max_concurrency;
1004 const uint8_t *in;
1005 size_t in_len;
1006 uint8_t *out;
1007 size_t out_len;
1008};
1009
1010static void *test_1013_thread(void *arg)
1011{
1012 struct test_1013_thread_arg *a = arg;
1013 TEEC_Session session = { 0 };
1014 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
1015 uint8_t p2 = TEEC_NONE;
1016 uint8_t p3 = TEEC_NONE;
1017
Jens Wiklander70672972016-04-06 00:01:45 +02001018 a->res = xtest_teec_open_session(&session, a->uuid, NULL,
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001019 &a->error_orig);
1020 if (a->res != TEEC_SUCCESS)
1021 return NULL;
1022
1023 op.params[0].memref.parent = a->shm;
1024 op.params[0].memref.size = a->shm->size;
1025 op.params[0].memref.offset = 0;
1026 op.params[1].value.a = a->repeat;
1027 op.params[1].value.b = 0;
1028 op.params[2].tmpref.buffer = (void *)a->in;
1029 op.params[2].tmpref.size = a->in_len;
1030 op.params[3].tmpref.buffer = a->out;
1031 op.params[3].tmpref.size = a->out_len;
1032
1033 if (a->in_len)
1034 p2 = TEEC_MEMREF_TEMP_INPUT;
1035 if (a->out_len)
1036 p3 = TEEC_MEMREF_TEMP_OUTPUT;
1037
1038 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_PARTIAL_INOUT,
1039 TEEC_VALUE_INOUT, p2, p3);
1040
1041 a->res = TEEC_InvokeCommand(&session, a->cmd, &op, &a->error_orig);
1042 a->max_concurrency = op.params[1].value.b;
1043 a->out_len = op.params[3].tmpref.size;
1044 TEEC_CloseSession(&session);
1045 return NULL;
1046}
1047
Pascal Brand4fa35582015-12-17 10:59:12 +01001048#define NUM_THREADS 3
1049
Jens Wiklander70672972016-04-06 00:01:45 +02001050static void xtest_tee_test_1013_single(ADBG_Case_t *c, double *mean_concurrency,
1051 const TEEC_UUID *uuid)
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001052{
Pascal Brand4fa35582015-12-17 10:59:12 +01001053 size_t num_threads = NUM_THREADS;
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001054 size_t nt;
1055 size_t n;
Jens Wiklander70672972016-04-06 00:01:45 +02001056 size_t repeat = 1000;
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001057 pthread_t thr[num_threads];
1058 TEEC_SharedMemory shm;
1059 size_t max_concurrency;
1060 struct test_1013_thread_arg arg[num_threads];
1061 static const uint8_t sha256_in[] = { 'a', 'b', 'c' };
1062 static const uint8_t sha256_out[] = {
1063 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea,
1064 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23,
1065 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c,
1066 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad
1067 };
1068 uint8_t out[32] = { 0 };
1069
Jens Wiklander70672972016-04-06 00:01:45 +02001070 Do_ADBG_BeginSubCase(c, "Busy loop repeat %zu", repeat * 10);
Pascal Brand4fa35582015-12-17 10:59:12 +01001071 *mean_concurrency = 0;
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001072
1073 memset(&shm, 0, sizeof(shm));
1074 shm.size = sizeof(struct ta_concurrent_shm);
1075 shm.flags = TEEC_MEM_INPUT | TEEC_MEM_OUTPUT;
1076 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1077 TEEC_AllocateSharedMemory(&xtest_teec_ctx, &shm)))
1078 return;
1079
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001080 memset(shm.buffer, 0, shm.size);
1081 memset(arg, 0, sizeof(arg));
1082 max_concurrency = 0;
1083 nt = num_threads;
1084
1085 for (n = 0; n < nt; n++) {
Jens Wiklander70672972016-04-06 00:01:45 +02001086 arg[n].uuid = uuid;
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001087 arg[n].cmd = TA_CONCURRENT_CMD_BUSY_LOOP;
Jens Wiklander70672972016-04-06 00:01:45 +02001088 arg[n].repeat = repeat * 10;
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001089 arg[n].shm = &shm;
1090 if (!ADBG_EXPECT(c, 0, pthread_create(thr + n, NULL,
1091 test_1013_thread, arg + n)))
1092 nt = n; /* break loop and start cleanup */
1093 }
1094
1095 for (n = 0; n < nt; n++) {
1096 ADBG_EXPECT(c, 0, pthread_join(thr[n], NULL));
1097 ADBG_EXPECT_TEEC_SUCCESS(c, arg[n].res);
1098 if (arg[n].max_concurrency > max_concurrency)
1099 max_concurrency = arg[n].max_concurrency;
1100 }
1101
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001102 /*
1103 * Concurrency can be limited by several factors, for instance in a
1104 * single CPU system it's dependent on the Preemtion Model used by
1105 * the kernel (Preemptible Kernel (Low-Latency Desktop) gives the
1106 * best result there).
1107 */
1108 (void)ADBG_EXPECT_COMPARE_UNSIGNED(c, max_concurrency, >, 0);
1109 (void)ADBG_EXPECT_COMPARE_UNSIGNED(c, max_concurrency, <=, num_threads);
Pascal Brand4fa35582015-12-17 10:59:12 +01001110 *mean_concurrency += max_concurrency;
Jens Wiklander70672972016-04-06 00:01:45 +02001111 Do_ADBG_EndSubCase(c, "Busy loop repeat %zu", repeat * 10);
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001112
Jens Wiklander70672972016-04-06 00:01:45 +02001113 Do_ADBG_BeginSubCase(c, "SHA-256 loop repeat %zu", repeat);
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001114 memset(shm.buffer, 0, shm.size);
1115 memset(arg, 0, sizeof(arg));
1116 max_concurrency = 0;
1117 nt = num_threads;
1118
1119 for (n = 0; n < nt; n++) {
Jens Wiklander70672972016-04-06 00:01:45 +02001120 arg[n].uuid = uuid;
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001121 arg[n].cmd = TA_CONCURRENT_CMD_SHA256;
Jens Wiklander70672972016-04-06 00:01:45 +02001122 arg[n].repeat = repeat;
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001123 arg[n].shm = &shm;
1124 arg[n].in = sha256_in;
1125 arg[n].in_len = sizeof(sha256_in);
1126 arg[n].out = out;
1127 arg[n].out_len = sizeof(out);
1128 if (!ADBG_EXPECT(c, 0, pthread_create(thr + n, NULL,
1129 test_1013_thread, arg + n)))
1130 nt = n; /* break loop and start cleanup */
1131 }
1132
1133 for (n = 0; n < nt; n++) {
1134 if (ADBG_EXPECT(c, 0, pthread_join(thr[n], NULL)) &&
1135 ADBG_EXPECT_TEEC_SUCCESS(c, arg[n].res))
1136 ADBG_EXPECT_BUFFER(c, sha256_out, sizeof(sha256_out),
1137 arg[n].out, arg[n].out_len);
1138 if (arg[n].max_concurrency > max_concurrency)
1139 max_concurrency = arg[n].max_concurrency;
1140 }
Pascal Brand4fa35582015-12-17 10:59:12 +01001141 *mean_concurrency += max_concurrency;
Jens Wiklander70672972016-04-06 00:01:45 +02001142 Do_ADBG_EndSubCase(c, "SHA-256 loop repeat %zu", repeat);
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001143
Pascal Brand4fa35582015-12-17 10:59:12 +01001144 *mean_concurrency /= 2.0;
Jens Wiklanderac27ec12015-07-15 15:23:14 +02001145 TEEC_ReleaseSharedMemory(&shm);
1146}
Pascal Brand4fa35582015-12-17 10:59:12 +01001147
1148static void xtest_tee_test_1013(ADBG_Case_t *c)
1149{
1150 int i;
1151 double mean_concurrency;
1152 double concurrency;
Jens Wiklander70672972016-04-06 00:01:45 +02001153 int nb_loops = 24;
Jens Wiklander6a9d15a2016-02-01 10:29:42 +01001154
1155 if (level == 0)
1156 nb_loops /= 2;
Pascal Brand4fa35582015-12-17 10:59:12 +01001157
Jens Wiklander70672972016-04-06 00:01:45 +02001158 Do_ADBG_BeginSubCase(c, "Using small concurrency TA");
Pascal Brand4fa35582015-12-17 10:59:12 +01001159 mean_concurrency = 0;
1160 for (i = 0; i < nb_loops; i++) {
Jens Wiklander70672972016-04-06 00:01:45 +02001161 xtest_tee_test_1013_single(c, &concurrency,
1162 &concurrent_ta_uuid);
Pascal Brand4fa35582015-12-17 10:59:12 +01001163 mean_concurrency += concurrency;
1164 }
1165 mean_concurrency /= nb_loops;
1166
1167 Do_ADBG_Log(" Number of parallel threads: %d", NUM_THREADS);
1168 Do_ADBG_Log(" Mean concurrency: %g", mean_concurrency);
Jens Wiklander70672972016-04-06 00:01:45 +02001169 Do_ADBG_EndSubCase(c, "Using small concurrency TA");
Pascal Brand4fa35582015-12-17 10:59:12 +01001170
Jens Wiklanderc9d7b242016-06-28 18:35:08 +02001171#ifndef CFG_PAGED_USER_TA
Jens Wiklander70672972016-04-06 00:01:45 +02001172 Do_ADBG_BeginSubCase(c, "Using large concurrency TA");
1173 mean_concurrency = 0;
1174 for (i = 0; i < nb_loops; i++) {
1175 xtest_tee_test_1013_single(c, &concurrency,
1176 &concurrent_large_ta_uuid);
1177 mean_concurrency += concurrency;
1178 }
1179 mean_concurrency /= nb_loops;
1180
1181 Do_ADBG_Log(" Number of parallel threads: %d", NUM_THREADS);
1182 Do_ADBG_Log(" Mean concurrency: %g", mean_concurrency);
1183 Do_ADBG_EndSubCase(c, "Using large concurrency TA");
Jens Wiklanderc9d7b242016-06-28 18:35:08 +02001184#endif
Jens Wiklander70672972016-04-06 00:01:45 +02001185}
Etienne Carriere50abf9a2017-03-24 11:33:50 +01001186
1187#ifdef CFG_SECURE_DATA_PATH
1188static void xtest_tee_test_1014(ADBG_Case_t *c)
1189{
1190 UNUSED(c);
1191
1192 int size = 17000;
1193 int loop = 10;
1194 int ion_heap = DEFAULT_ION_HEAP_TYPE;
1195 int rnd_offset = 1;
1196 int test;
1197 int ret;
1198
1199 test = TEST_NS_TO_TA;
1200 Do_ADBG_BeginSubCase(c, "SDP: NonSecure client invokes a SDP TA");
Etienne Carriereb9a95822017-04-26 15:03:53 +02001201 ret = sdp_basic_test(test, size, loop, ion_heap, rnd_offset, 0);
Etienne Carriere50abf9a2017-03-24 11:33:50 +01001202 ADBG_EXPECT(c, 0, ret);
1203 Do_ADBG_EndSubCase(c, "SDP: NonSecure client invokes a SDP TA");
1204
1205 test = TEST_TA_TO_TA;
1206 Do_ADBG_BeginSubCase(c, "SDP: SDP TA invokes a SDP TA");
Etienne Carriereb9a95822017-04-26 15:03:53 +02001207 ret = sdp_basic_test(test, size, loop, ion_heap, rnd_offset, 0);
Etienne Carriere50abf9a2017-03-24 11:33:50 +01001208 ADBG_EXPECT(c, 0, ret);
1209 Do_ADBG_EndSubCase(c, "SDP: SDP TA invokes a SDP TA");
1210
1211 test = TEST_TA_TO_PTA;
1212 Do_ADBG_BeginSubCase(c, "SDP: SDP TA invokes a SDP pTA");
Etienne Carriereb9a95822017-04-26 15:03:53 +02001213 ret = sdp_basic_test(test, size, loop, ion_heap, rnd_offset, 0);
Etienne Carriere50abf9a2017-03-24 11:33:50 +01001214 ADBG_EXPECT(c, 0, ret);
1215 Do_ADBG_EndSubCase(c, "SDP: SDP TA invokes a SDP pTA");
1216
1217 test = TEST_NS_TO_PTA;
Etienne Carrierea3198522017-10-26 09:48:55 +02001218 Do_ADBG_BeginSubCase(c, "SDP: NSec CA invokes SDP pTA (should fail)");
Etienne Carriereb9a95822017-04-26 15:03:53 +02001219 ret = sdp_basic_test(test, size, loop, ion_heap, rnd_offset, 0);
Etienne Carriere50abf9a2017-03-24 11:33:50 +01001220 ADBG_EXPECT(c, 1, ret);
Etienne Carrierea3198522017-10-26 09:48:55 +02001221 Do_ADBG_EndSubCase(c, "SDP: NSec CA invokes SDP pTA (should fail)");
Etienne Carriere50abf9a2017-03-24 11:33:50 +01001222}
1223#endif
Jens Wiklander272d3642017-04-03 13:03:47 +02001224
1225static void xtest_tee_test_1015(ADBG_Case_t *c)
1226{
1227 TEEC_Result res;
1228 TEEC_Session session = { 0 };
1229 uint32_t ret_orig;
1230
Etienne Carriere11093162017-10-26 09:49:04 +02001231 /* Pseudo TA is optional: warn and nicely exit if not found */
Jens Wiklander272d3642017-04-03 13:03:47 +02001232 res = xtest_teec_open_session(&session, &pta_invoke_tests_ta_uuid, NULL,
1233 &ret_orig);
Etienne Carriere11093162017-10-26 09:49:04 +02001234 if (res == TEEC_ERROR_ITEM_NOT_FOUND) {
1235 Do_ADBG_Log(" - 1015 - skip test, pseudo TA not found");
Jens Wiklander272d3642017-04-03 13:03:47 +02001236 return;
Etienne Carriere11093162017-10-26 09:49:04 +02001237 }
1238 ADBG_EXPECT_TEEC_SUCCESS(c, res);
Jens Wiklander272d3642017-04-03 13:03:47 +02001239
1240 ADBG_EXPECT_TEEC_SUCCESS(c,
1241 TEEC_InvokeCommand(&session, PTA_INVOKE_TESTS_CMD_FS_HTREE,
1242 NULL, &ret_orig));
1243 TEEC_CloseSession(&session);
1244}
Jerome Forissiere916b102017-06-07 17:55:52 +02001245
1246static void xtest_tee_test_1016(ADBG_Case_t *c)
1247{
1248 TEEC_Session session = { 0 };
1249 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
1250 uint32_t ret_orig;
1251
1252 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1253 xtest_teec_open_session(&session, &os_test_ta_uuid, NULL,
1254 &ret_orig)))
1255 return;
1256
1257 op.paramTypes = TEEC_PARAM_TYPES(TEEC_NONE, TEEC_NONE, TEEC_NONE,
1258 TEEC_NONE);
1259
1260 (void)ADBG_EXPECT_TEEC_SUCCESS(c,
1261 TEEC_InvokeCommand(&session, TA_OS_TEST_CMD_TA2TA_MEMREF, &op,
1262 &ret_orig));
1263
1264 TEEC_CloseSession(&session);
1265}