1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3 * Copyright (c) 2021, Linaro Limited
4 */
5
6 #include <ta_large.h>
7 #include <tee_internal_api.h>
8
9 /*
10 * Declare a large buffer likely to span mutiple translation tables.
11 *
12 * Ideally we'd like to have one that is slightly larger than 2MiB since
13 * that would guarantee this. But that would consume yet another static
14 * translation table (MAX_XLAT_TABLES) which would typically only be needed
15 * when loading this TA but would cause a permanent increase in the OP-TEE
16 * memory footprint.
17 *
18 * So we settle with this size, it should quite often be enough if
19 * configured with CFG_TA_ASLR=y. It will be 100% effective with
20 * CFG_WITH_LPAE=n.
21 */
22 static const uint8_t large_buffer[1024 * 1024 ] = { 1 };
23
TA_CreateEntryPoint(void)24 TEE_Result TA_CreateEntryPoint(void)
25 {
26 return TEE_SUCCESS;
27 }
28
TA_DestroyEntryPoint(void)29 void TA_DestroyEntryPoint(void)
30 {
31 }
32
TA_OpenSessionEntryPoint(uint32_t param_types,TEE_Param params[4],void ** session_ctx)33 TEE_Result TA_OpenSessionEntryPoint(uint32_t param_types,
34 TEE_Param params[4],
35 void **session_ctx)
36 {
37 (void)param_types;
38 (void)params;
39
40 /* Don't let the linker garbage collect this symbol. */
41 *session_ctx = (void *)large_buffer;
42
43 return TEE_SUCCESS;
44 }
45
TA_CloseSessionEntryPoint(void * session_ctx)46 void TA_CloseSessionEntryPoint(void *session_ctx)
47 {
48 (void)session_ctx;
49 }
50
TA_InvokeCommandEntryPoint(void * session_ctx,uint32_t cmd_id,uint32_t param_types,TEE_Param params[4])51 TEE_Result TA_InvokeCommandEntryPoint(void *session_ctx,
52 uint32_t cmd_id, uint32_t param_types,
53 TEE_Param params[4])
54 {
55 (void)session_ctx;
56 (void)cmd_id;
57 (void)param_types;
58 (void)params;
59
60 return TEE_ERROR_GENERIC;
61 }
62