blob: 594a0bdb1e7cc867d7fec658c0cb68aaf452e265 [file] [log] [blame]
Edison Ai764d41f2018-09-21 15:56:36 +08001/*
Sherry Zhangdcab2862022-01-10 10:43:31 +08002 * Copyright (c) 2018-2022, Arm Limited. All rights reserved.
Chris Brand56b4d0c2021-12-17 16:15:58 -08003 * Copyright (c) 2021, Cypress Semiconductor Corporation. All rights reserved.
Edison Ai764d41f2018-09-21 15:56:36 +08004 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 *
7 */
Mingyang Sunda01a972019-07-12 17:32:59 +08008
Edison Ai764d41f2018-09-21 15:56:36 +08009#include <inttypes.h>
10#include <stdbool.h>
Ken Liu086b32c2021-12-27 14:44:52 +080011#include "aapcs_local.h"
Ken Liu24dffb22021-02-10 11:03:58 +080012#include "bitops.h"
Ken Liu92ede9f2021-10-20 09:35:00 +080013#include "critical_section.h"
Ken Liuf39d8eb2021-10-07 12:55:33 +080014#include "current.h"
David Huf07e97d2021-02-15 22:05:40 +080015#include "fih.h"
Jamie Foxcc31d402019-01-28 17:13:52 +000016#include "psa/client.h"
17#include "psa/service.h"
Ken Liu5d73c872021-08-19 19:23:17 +080018#include "thread.h"
Ken Liubcae38b2021-01-20 15:47:44 +080019#include "internal_errors.h"
Mingyang Sund44522a2020-01-16 16:48:37 +080020#include "tfm_spm_hal.h"
Mingyang Sund44522a2020-01-16 16:48:37 +080021#include "tfm_api.h"
Kevin Pengb20b0322022-02-09 16:47:19 +080022#include "tfm_arch.h"
Mingyang Sund44522a2020-01-16 16:48:37 +080023#include "tfm_secure_api.h"
24#include "tfm_memory_utils.h"
Mingyang Sund1ed6732020-08-26 15:52:21 +080025#include "tfm_hal_defs.h"
Kevin Pengd399a1f2021-09-08 15:33:14 +080026#include "tfm_hal_interrupt.h"
Mingyang Sund1ed6732020-08-26 15:52:21 +080027#include "tfm_hal_isolation.h"
Mingyang Sun7397b4f2020-06-17 15:07:45 +080028#include "spm_ipc.h"
Mingyang Sund44522a2020-01-16 16:48:37 +080029#include "tfm_peripherals_def.h"
Mingyang Sund44522a2020-01-16 16:48:37 +080030#include "tfm_core_utils.h"
Kevin Peng385fda82021-08-18 10:41:19 +080031#include "tfm_nspm.h"
Mingyang Sund44522a2020-01-16 16:48:37 +080032#include "tfm_rpc.h"
Mingyang Sund44522a2020-01-16 16:48:37 +080033#include "tfm_core_trustzone.h"
Ken Liu24dffb22021-02-10 11:03:58 +080034#include "lists.h"
Edison Ai764d41f2018-09-21 15:56:36 +080035#include "tfm_pools.h"
Mingyang Sun22a3faf2021-07-09 15:32:47 +080036#include "region.h"
Mingyang Sun7397b4f2020-06-17 15:07:45 +080037#include "psa_manifest/pid.h"
Mingyang Sundeae45d2021-09-06 15:31:07 +080038#include "ffm/backend.h"
Mingyang Sun00df2352021-04-15 15:46:08 +080039#include "load/partition_defs.h"
40#include "load/service_defs.h"
Ken Liu86686282021-04-27 11:11:15 +080041#include "load/asset_defs.h"
Ken Liuacd2a572021-05-12 16:19:04 +080042#include "load/spm_load_api.h"
Sherry Zhnag482b88b2021-08-19 17:51:47 +080043#include "tfm_nspm.h"
Edison Ai764d41f2018-09-21 15:56:36 +080044
Sherry Zhang86a71c62022-01-12 18:19:02 +080045#if !(defined CONFIG_TFM_CONN_HANDLE_MAX_NUM) || (CONFIG_TFM_CONN_HANDLE_MAX_NUM == 0)
46#error "CONFIG_TFM_CONN_HANDLE_MAX_NUM must be defined and not zero."
47#endif
48
Ken Liuea45b0d2021-05-22 17:41:25 +080049/* Partition and service runtime data list head/runtime data table */
Ken Liuea45b0d2021-05-22 17:41:25 +080050static struct service_head_t services_listhead;
Ken Liub3b2cb62021-05-22 00:39:28 +080051struct service_t *stateless_services_ref_tbl[STATIC_HANDLE_NUM_LIMIT];
Summer Qind99509f2019-08-02 17:36:58 +080052
Edison Ai764d41f2018-09-21 15:56:36 +080053/* Pools */
54TFM_POOL_DECLARE(conn_handle_pool, sizeof(struct tfm_conn_handle_t),
Sherry Zhang86a71c62022-01-12 18:19:02 +080055 CONFIG_TFM_CONN_HANDLE_MAX_NUM);
Edison Ai764d41f2018-09-21 15:56:36 +080056
Mingyang Sun620c8562021-11-10 11:44:58 +080057extern uint32_t scheduler_lock;
58
Summer Qin373feb12020-03-27 15:35:33 +080059/*********************** Connection handle conversion APIs *******************/
60
Summer Qin373feb12020-03-27 15:35:33 +080061#define CONVERSION_FACTOR_BITOFFSET 3
62#define CONVERSION_FACTOR_VALUE (1 << CONVERSION_FACTOR_BITOFFSET)
63/* Set 32 as the maximum */
64#define CONVERSION_FACTOR_VALUE_MAX 0x20
65
66#if CONVERSION_FACTOR_VALUE > CONVERSION_FACTOR_VALUE_MAX
67#error "CONVERSION FACTOR OUT OF RANGE"
68#endif
69
70static uint32_t loop_index;
71
72/*
73 * A handle instance psa_handle_t allocated inside SPM is actually a memory
74 * address among the handle pool. Return this handle to the client directly
75 * exposes information of secure memory address. In this case, converting the
76 * handle into another value does not represent the memory address to avoid
77 * exposing secure memory directly to clients.
78 *
79 * This function converts the handle instance into another value by scaling the
80 * handle in pool offset, the converted value is named as a user handle.
81 *
82 * The formula:
83 * user_handle = (handle_instance - POOL_START) * CONVERSION_FACTOR_VALUE +
84 * CLIENT_HANDLE_VALUE_MIN + loop_index
85 * where:
86 * CONVERSION_FACTOR_VALUE = 1 << CONVERSION_FACTOR_BITOFFSET, and should not
87 * exceed CONVERSION_FACTOR_VALUE_MAX.
88 *
89 * handle_instance in RANGE[POOL_START, POOL_END]
90 * user_handle in RANGE[CLIENT_HANDLE_VALUE_MIN, 0x3FFFFFFF]
91 * loop_index in RANGE[0, CONVERSION_FACTOR_VALUE - 1]
92 *
93 * note:
94 * loop_index is used to promise same handle instance is converted into
95 * different user handles in short time.
96 */
Ken Liu505b1702020-05-29 13:19:58 +080097psa_handle_t tfm_spm_to_user_handle(struct tfm_conn_handle_t *handle_instance)
Summer Qin373feb12020-03-27 15:35:33 +080098{
99 psa_handle_t user_handle;
100
101 loop_index = (loop_index + 1) % CONVERSION_FACTOR_VALUE;
102 user_handle = (psa_handle_t)((((uintptr_t)handle_instance -
103 (uintptr_t)conn_handle_pool) << CONVERSION_FACTOR_BITOFFSET) +
104 CLIENT_HANDLE_VALUE_MIN + loop_index);
105
106 return user_handle;
107}
108
109/*
110 * This function converts a user handle into a corresponded handle instance.
111 * The converted value is validated before returning, an invalid handle instance
112 * is returned as NULL.
113 *
114 * The formula:
115 * handle_instance = ((user_handle - CLIENT_HANDLE_VALUE_MIN) /
116 * CONVERSION_FACTOR_VALUE) + POOL_START
117 * where:
118 * CONVERSION_FACTOR_VALUE = 1 << CONVERSION_FACTOR_BITOFFSET, and should not
119 * exceed CONVERSION_FACTOR_VALUE_MAX.
120 *
121 * handle_instance in RANGE[POOL_START, POOL_END]
122 * user_handle in RANGE[CLIENT_HANDLE_VALUE_MIN, 0x3FFFFFFF]
123 * loop_index in RANGE[0, CONVERSION_FACTOR_VALUE - 1]
124 */
125struct tfm_conn_handle_t *tfm_spm_to_handle_instance(psa_handle_t user_handle)
126{
127 struct tfm_conn_handle_t *handle_instance;
128
129 if (user_handle == PSA_NULL_HANDLE) {
130 return NULL;
131 }
132
133 handle_instance = (struct tfm_conn_handle_t *)((((uintptr_t)user_handle -
134 CLIENT_HANDLE_VALUE_MIN) >> CONVERSION_FACTOR_BITOFFSET) +
135 (uintptr_t)conn_handle_pool);
136
137 return handle_instance;
138}
139
Edison Ai764d41f2018-09-21 15:56:36 +0800140/* Service handle management functions */
Mingyang Sun783a59b2021-04-20 15:52:18 +0800141struct tfm_conn_handle_t *tfm_spm_create_conn_handle(struct service_t *service,
142 int32_t client_id)
Edison Ai764d41f2018-09-21 15:56:36 +0800143{
Edison Ai9cc26242019-08-06 11:28:04 +0800144 struct tfm_conn_handle_t *p_handle;
Edison Ai764d41f2018-09-21 15:56:36 +0800145
Ken Liuf250b8b2019-12-27 16:31:24 +0800146 TFM_CORE_ASSERT(service);
Edison Ai764d41f2018-09-21 15:56:36 +0800147
148 /* Get buffer for handle list structure from handle pool */
Edison Ai9cc26242019-08-06 11:28:04 +0800149 p_handle = (struct tfm_conn_handle_t *)tfm_pool_alloc(conn_handle_pool);
150 if (!p_handle) {
Summer Qin630c76b2020-05-20 10:32:58 +0800151 return NULL;
Edison Ai764d41f2018-09-21 15:56:36 +0800152 }
153
Kevin Peng2cc25722021-11-18 11:46:02 +0800154 spm_memset(p_handle, 0, sizeof(*p_handle));
155
Ken Liuf39d8eb2021-10-07 12:55:33 +0800156 p_handle->internal_msg.service = service;
Shawn Shancc39fcb2019-11-13 15:38:16 +0800157 p_handle->status = TFM_HANDLE_STATUS_IDLE;
Summer Qin1ce712a2019-10-14 18:04:05 +0800158 p_handle->client_id = client_id;
Edison Ai764d41f2018-09-21 15:56:36 +0800159
Summer Qin630c76b2020-05-20 10:32:58 +0800160 return p_handle;
Edison Ai764d41f2018-09-21 15:56:36 +0800161}
162
Summer Qin630c76b2020-05-20 10:32:58 +0800163int32_t tfm_spm_validate_conn_handle(
164 const struct tfm_conn_handle_t *conn_handle,
165 int32_t client_id)
Summer Qin1ce712a2019-10-14 18:04:05 +0800166{
167 /* Check the handle address is validated */
168 if (is_valid_chunk_data_in_pool(conn_handle_pool,
169 (uint8_t *)conn_handle) != true) {
Ken Liubcae38b2021-01-20 15:47:44 +0800170 return SPM_ERROR_GENERIC;
Summer Qin1ce712a2019-10-14 18:04:05 +0800171 }
172
173 /* Check the handle caller is correct */
Summer Qin630c76b2020-05-20 10:32:58 +0800174 if (conn_handle->client_id != client_id) {
Ken Liubcae38b2021-01-20 15:47:44 +0800175 return SPM_ERROR_GENERIC;
Summer Qin1ce712a2019-10-14 18:04:05 +0800176 }
177
Ken Liubcae38b2021-01-20 15:47:44 +0800178 return SPM_SUCCESS;
Summer Qin1ce712a2019-10-14 18:04:05 +0800179}
180
Mingyang Sun783a59b2021-04-20 15:52:18 +0800181int32_t tfm_spm_free_conn_handle(struct service_t *service,
Summer Qin02f7f072020-08-24 16:02:54 +0800182 struct tfm_conn_handle_t *conn_handle)
Edison Ai764d41f2018-09-21 15:56:36 +0800183{
Mingyang Sun620c8562021-11-10 11:44:58 +0800184 struct critical_section_t cs_assert = CRITICAL_SECTION_STATIC_INIT;
185
Ken Liuf250b8b2019-12-27 16:31:24 +0800186 TFM_CORE_ASSERT(service);
Summer Qin630c76b2020-05-20 10:32:58 +0800187 TFM_CORE_ASSERT(conn_handle != NULL);
Edison Ai764d41f2018-09-21 15:56:36 +0800188
Mate Toth-Pala4b5d242019-09-23 09:14:47 +0200189 /* Clear magic as the handler is not used anymore */
Summer Qin630c76b2020-05-20 10:32:58 +0800190 conn_handle->internal_msg.magic = 0;
Mate Toth-Pala4b5d242019-09-23 09:14:47 +0200191
Mingyang Sun620c8562021-11-10 11:44:58 +0800192 CRITICAL_SECTION_ENTER(cs_assert);
Edison Ai764d41f2018-09-21 15:56:36 +0800193
194 /* Back handle buffer to pool */
Ken Liu66ca6132021-02-24 08:49:51 +0800195 tfm_pool_free(conn_handle_pool, conn_handle);
Mingyang Sun620c8562021-11-10 11:44:58 +0800196 CRITICAL_SECTION_LEAVE(cs_assert);
197
Ken Liubcae38b2021-01-20 15:47:44 +0800198 return SPM_SUCCESS;
Edison Ai764d41f2018-09-21 15:56:36 +0800199}
200
Mingyang Sun783a59b2021-04-20 15:52:18 +0800201int32_t tfm_spm_set_rhandle(struct service_t *service,
Summer Qin02f7f072020-08-24 16:02:54 +0800202 struct tfm_conn_handle_t *conn_handle,
203 void *rhandle)
Edison Ai764d41f2018-09-21 15:56:36 +0800204{
Ken Liuf250b8b2019-12-27 16:31:24 +0800205 TFM_CORE_ASSERT(service);
Edison Ai764d41f2018-09-21 15:56:36 +0800206 /* Set reverse handle value only be allowed for a connected handle */
Summer Qin630c76b2020-05-20 10:32:58 +0800207 TFM_CORE_ASSERT(conn_handle != NULL);
Edison Ai764d41f2018-09-21 15:56:36 +0800208
Summer Qin630c76b2020-05-20 10:32:58 +0800209 conn_handle->rhandle = rhandle;
Ken Liubcae38b2021-01-20 15:47:44 +0800210 return SPM_SUCCESS;
Edison Ai764d41f2018-09-21 15:56:36 +0800211}
212
Mingyang Sund44522a2020-01-16 16:48:37 +0800213/**
Xinyu Zhang3a453242021-04-16 17:57:09 +0800214 * \brief Get reverse handle value from connection handle.
Mingyang Sund44522a2020-01-16 16:48:37 +0800215 *
216 * \param[in] service Target service context pointer
217 * \param[in] conn_handle Connection handle created by
Summer Qin630c76b2020-05-20 10:32:58 +0800218 * tfm_spm_create_conn_handle()
Mingyang Sund44522a2020-01-16 16:48:37 +0800219 *
220 * \retval void * Success
221 * \retval "Does not return" Panic for those:
222 * service pointer are NULL
Xinyu Zhang3a453242021-04-16 17:57:09 +0800223 * handle is \ref PSA_NULL_HANDLE
Mingyang Sund44522a2020-01-16 16:48:37 +0800224 * handle node does not be found
225 */
Mingyang Sun783a59b2021-04-20 15:52:18 +0800226static void *tfm_spm_get_rhandle(struct service_t *service,
Summer Qin630c76b2020-05-20 10:32:58 +0800227 struct tfm_conn_handle_t *conn_handle)
Edison Ai764d41f2018-09-21 15:56:36 +0800228{
Ken Liuf250b8b2019-12-27 16:31:24 +0800229 TFM_CORE_ASSERT(service);
Edison Ai764d41f2018-09-21 15:56:36 +0800230 /* Get reverse handle value only be allowed for a connected handle */
Summer Qin630c76b2020-05-20 10:32:58 +0800231 TFM_CORE_ASSERT(conn_handle != NULL);
Edison Ai764d41f2018-09-21 15:56:36 +0800232
Summer Qin630c76b2020-05-20 10:32:58 +0800233 return conn_handle->rhandle;
Edison Ai764d41f2018-09-21 15:56:36 +0800234}
235
236/* Partition management functions */
Mingyang Sund44522a2020-01-16 16:48:37 +0800237
Ken Liu5a28da32022-01-19 14:37:05 +0800238struct tfm_msg_body_t *spm_get_msg_with_signal(struct partition_t *p_ptn,
239 psa_signal_t signal)
Edison Ai764d41f2018-09-21 15:56:36 +0800240{
Ken Liu5a28da32022-01-19 14:37:05 +0800241 struct tfm_msg_body_t *p_msg_iter;
242 struct tfm_msg_body_t **pr_msg_iter, **last_found_msg_holder = NULL;
Ken Liu92ede9f2021-10-20 09:35:00 +0800243 struct critical_section_t cs_assert = CRITICAL_SECTION_STATIC_INIT;
Ken Liu5a28da32022-01-19 14:37:05 +0800244 uint32_t nr_found_msgs = 0;
Edison Ai764d41f2018-09-21 15:56:36 +0800245
Mingyang Sun620c8562021-11-10 11:44:58 +0800246 CRITICAL_SECTION_ENTER(cs_assert);
Ken Liu5a28da32022-01-19 14:37:05 +0800247
248 /* Return the last found message which applies a FIFO mechanism. */
249 UNI_LIST_FOREACH_NODE_PNODE(pr_msg_iter, p_msg_iter, p_ptn, p_messages) {
250 if (p_msg_iter->service->p_ldinf->signal == signal) {
251 last_found_msg_holder = pr_msg_iter;
252 nr_found_msgs++;
Edison Ai764d41f2018-09-21 15:56:36 +0800253 }
254 }
Mingyang Sun73056b62020-07-03 15:18:46 +0800255
Ken Liu5a28da32022-01-19 14:37:05 +0800256 if (last_found_msg_holder) {
257 p_msg_iter = *last_found_msg_holder;
258 UNI_LIST_REMOVE_NODE_BY_PNODE(last_found_msg_holder, p_messages);
259
260 /* Clear the signal bit since the only message is removed. */
261 if (nr_found_msgs == 1) {
262 p_ptn->signals_asserted &= ~signal;
263 }
264 }
265
Ken Liu92ede9f2021-10-20 09:35:00 +0800266 CRITICAL_SECTION_LEAVE(cs_assert);
Mingyang Sun73056b62020-07-03 15:18:46 +0800267
Ken Liu5a28da32022-01-19 14:37:05 +0800268 return p_msg_iter;
Edison Ai764d41f2018-09-21 15:56:36 +0800269}
270
Mingyang Sun783a59b2021-04-20 15:52:18 +0800271struct service_t *tfm_spm_get_service_by_sid(uint32_t sid)
Edison Ai764d41f2018-09-21 15:56:36 +0800272{
Feder.Liangaeb5a792021-08-10 16:12:56 +0800273 struct service_t *p_prev, *p_curr;
Edison Ai764d41f2018-09-21 15:56:36 +0800274
Ken Liu5a28da32022-01-19 14:37:05 +0800275 UNI_LIST_FOREACH_NODE_PREV(p_prev, p_curr, &services_listhead, next) {
Feder.Liangaeb5a792021-08-10 16:12:56 +0800276 if (p_curr->p_ldinf->sid == sid) {
Ken Liu5a28da32022-01-19 14:37:05 +0800277 UNI_LIST_MOVE_AFTER(&services_listhead, p_prev, p_curr, next);
Feder.Liangaeb5a792021-08-10 16:12:56 +0800278 return p_curr;
Mingyang Sunef42f442021-06-11 15:07:58 +0800279 }
280 }
281
Ken Liuea45b0d2021-05-22 17:41:25 +0800282 return NULL;
Edison Ai764d41f2018-09-21 15:56:36 +0800283}
284
Mingyang Sund44522a2020-01-16 16:48:37 +0800285/**
286 * \brief Get the partition context by partition ID.
287 *
288 * \param[in] partition_id Partition identity
289 *
290 * \retval NULL Failed
291 * \retval "Not NULL" Target partition context pointer,
Mingyang Sunae70d8d2020-06-30 15:56:05 +0800292 * \ref partition_t structures
Mingyang Sund44522a2020-01-16 16:48:37 +0800293 */
Kevin Pengeca45b92021-02-09 14:46:50 +0800294struct partition_t *tfm_spm_get_partition_by_id(int32_t partition_id)
Edison Ai764d41f2018-09-21 15:56:36 +0800295{
Ken Liuea45b0d2021-05-22 17:41:25 +0800296 struct partition_t *p_part;
Edison Ai764d41f2018-09-21 15:56:36 +0800297
Ken Liu5a28da32022-01-19 14:37:05 +0800298 UNI_LIST_FOREACH(p_part, PARTITION_LIST_ADDR, next) {
Ken Liuea45b0d2021-05-22 17:41:25 +0800299 if (p_part->p_ldinf->pid == partition_id) {
300 return p_part;
301 }
Edison Ai764d41f2018-09-21 15:56:36 +0800302 }
Ken Liuea45b0d2021-05-22 17:41:25 +0800303
Edison Ai764d41f2018-09-21 15:56:36 +0800304 return NULL;
305}
306
Mingyang Sun783a59b2021-04-20 15:52:18 +0800307int32_t tfm_spm_check_client_version(struct service_t *service,
Jaykumar Pitambarbhai Patel3a986022019-10-08 17:37:15 +0530308 uint32_t version)
Edison Ai764d41f2018-09-21 15:56:36 +0800309{
Ken Liuf250b8b2019-12-27 16:31:24 +0800310 TFM_CORE_ASSERT(service);
Edison Ai764d41f2018-09-21 15:56:36 +0800311
Ken Liuacd2a572021-05-12 16:19:04 +0800312 switch (SERVICE_GET_VERSION_POLICY(service->p_ldinf->flags)) {
Ken Liub3b2cb62021-05-22 00:39:28 +0800313 case SERVICE_VERSION_POLICY_RELAXED:
Ken Liuacd2a572021-05-12 16:19:04 +0800314 if (version > service->p_ldinf->version) {
Ken Liubcae38b2021-01-20 15:47:44 +0800315 return SPM_ERROR_VERSION;
Edison Ai764d41f2018-09-21 15:56:36 +0800316 }
317 break;
Ken Liub3b2cb62021-05-22 00:39:28 +0800318 case SERVICE_VERSION_POLICY_STRICT:
Ken Liuacd2a572021-05-12 16:19:04 +0800319 if (version != service->p_ldinf->version) {
Ken Liubcae38b2021-01-20 15:47:44 +0800320 return SPM_ERROR_VERSION;
Edison Ai764d41f2018-09-21 15:56:36 +0800321 }
322 break;
323 default:
Ken Liubcae38b2021-01-20 15:47:44 +0800324 return SPM_ERROR_VERSION;
Edison Ai764d41f2018-09-21 15:56:36 +0800325 }
Ken Liubcae38b2021-01-20 15:47:44 +0800326 return SPM_SUCCESS;
Edison Ai764d41f2018-09-21 15:56:36 +0800327}
328
Edison Aie728fbf2019-11-13 09:37:12 +0800329int32_t tfm_spm_check_authorization(uint32_t sid,
Mingyang Sun783a59b2021-04-20 15:52:18 +0800330 struct service_t *service,
Summer Qin618e8c32019-12-09 10:47:20 +0800331 bool ns_caller)
Edison Aie728fbf2019-11-13 09:37:12 +0800332{
Mingyang Sunae70d8d2020-06-30 15:56:05 +0800333 struct partition_t *partition = NULL;
Mingyang Sun2b352662021-04-21 11:35:43 +0800334 uint32_t *dep;
Edison Aie728fbf2019-11-13 09:37:12 +0800335 int32_t i;
336
Ken Liuf250b8b2019-12-27 16:31:24 +0800337 TFM_CORE_ASSERT(service);
Edison Aie728fbf2019-11-13 09:37:12 +0800338
339 if (ns_caller) {
Ken Liuacd2a572021-05-12 16:19:04 +0800340 if (!SERVICE_IS_NS_ACCESSIBLE(service->p_ldinf->flags)) {
Ken Liubcae38b2021-01-20 15:47:44 +0800341 return SPM_ERROR_GENERIC;
Edison Aie728fbf2019-11-13 09:37:12 +0800342 }
343 } else {
Kevin Pengcdf3ae22022-01-19 14:53:52 +0800344 partition = GET_CURRENT_COMPONENT();
Edison Aie728fbf2019-11-13 09:37:12 +0800345 if (!partition) {
Edison Ai9059ea02019-11-28 13:46:14 +0800346 tfm_core_panic();
Edison Aie728fbf2019-11-13 09:37:12 +0800347 }
348
Ken Liuacd2a572021-05-12 16:19:04 +0800349 dep = (uint32_t *)LOAD_INFO_DEPS(partition->p_ldinf);
350 for (i = 0; i < partition->p_ldinf->ndeps; i++) {
Mingyang Sun2b352662021-04-21 11:35:43 +0800351 if (dep[i] == sid) {
Edison Aie728fbf2019-11-13 09:37:12 +0800352 break;
353 }
354 }
355
Ken Liuacd2a572021-05-12 16:19:04 +0800356 if (i == partition->p_ldinf->ndeps) {
Ken Liubcae38b2021-01-20 15:47:44 +0800357 return SPM_ERROR_GENERIC;
Edison Aie728fbf2019-11-13 09:37:12 +0800358 }
359 }
Ken Liubcae38b2021-01-20 15:47:44 +0800360 return SPM_SUCCESS;
Edison Aie728fbf2019-11-13 09:37:12 +0800361}
362
Edison Ai764d41f2018-09-21 15:56:36 +0800363/* Message functions */
Mingyang Sund44522a2020-01-16 16:48:37 +0800364
Summer Qin02f7f072020-08-24 16:02:54 +0800365struct tfm_msg_body_t *tfm_spm_get_msg_from_handle(psa_handle_t msg_handle)
Edison Ai764d41f2018-09-21 15:56:36 +0800366{
367 /*
Mate Toth-Pala4b5d242019-09-23 09:14:47 +0200368 * The message handler passed by the caller is considered invalid in the
369 * following cases:
370 * 1. Not a valid message handle. (The address of a message is not the
371 * address of a possible handle from the pool
372 * 2. Handle not belongs to the caller partition (The handle is either
373 * unused, or owned by anither partition)
374 * Check the conditions above
Edison Ai764d41f2018-09-21 15:56:36 +0800375 */
Ken Liu505b1702020-05-29 13:19:58 +0800376 struct tfm_msg_body_t *p_msg;
Kevin Pengeec41a82021-08-18 13:56:23 +0800377 int32_t partition_id;
Ken Liu505b1702020-05-29 13:19:58 +0800378 struct tfm_conn_handle_t *p_conn_handle =
Ken Liu5d73c872021-08-19 19:23:17 +0800379 tfm_spm_to_handle_instance(msg_handle);
Mate Toth-Pala4b5d242019-09-23 09:14:47 +0200380
381 if (is_valid_chunk_data_in_pool(
Ken Liu505b1702020-05-29 13:19:58 +0800382 conn_handle_pool, (uint8_t *)p_conn_handle) != 1) {
Edison Ai764d41f2018-09-21 15:56:36 +0800383 return NULL;
384 }
385
Ken Liu505b1702020-05-29 13:19:58 +0800386 p_msg = &p_conn_handle->internal_msg;
387
Edison Ai764d41f2018-09-21 15:56:36 +0800388 /*
Mate Toth-Pala4b5d242019-09-23 09:14:47 +0200389 * Check that the magic number is correct. This proves that the message
390 * structure contains an active message.
Edison Ai764d41f2018-09-21 15:56:36 +0800391 */
Ken Liu505b1702020-05-29 13:19:58 +0800392 if (p_msg->magic != TFM_MSG_MAGIC) {
Edison Ai764d41f2018-09-21 15:56:36 +0800393 return NULL;
394 }
395
Mate Toth-Pala4b5d242019-09-23 09:14:47 +0200396 /* Check that the running partition owns the message */
Mingyang Sunf3d29892019-07-10 17:50:23 +0800397 partition_id = tfm_spm_partition_get_running_partition_id();
Ken Liuacd2a572021-05-12 16:19:04 +0800398 if (partition_id != p_msg->service->partition->p_ldinf->pid) {
Edison Ai764d41f2018-09-21 15:56:36 +0800399 return NULL;
400 }
401
Ken Liu505b1702020-05-29 13:19:58 +0800402 return p_msg;
Edison Ai764d41f2018-09-21 15:56:36 +0800403}
404
Edison Ai97115822019-08-01 14:22:19 +0800405void tfm_spm_fill_msg(struct tfm_msg_body_t *msg,
Mingyang Sun783a59b2021-04-20 15:52:18 +0800406 struct service_t *service,
Ken Liu505b1702020-05-29 13:19:58 +0800407 psa_handle_t handle,
Summer Qin1ce712a2019-10-14 18:04:05 +0800408 int32_t type, int32_t client_id,
Edison Ai97115822019-08-01 14:22:19 +0800409 psa_invec *invec, size_t in_len,
410 psa_outvec *outvec, size_t out_len,
411 psa_outvec *caller_outvec)
412{
Edison Ai764d41f2018-09-21 15:56:36 +0800413 uint32_t i;
Ken Liu505b1702020-05-29 13:19:58 +0800414 struct tfm_conn_handle_t *conn_handle;
Edison Ai764d41f2018-09-21 15:56:36 +0800415
Ken Liuf250b8b2019-12-27 16:31:24 +0800416 TFM_CORE_ASSERT(msg);
417 TFM_CORE_ASSERT(service);
418 TFM_CORE_ASSERT(!(invec == NULL && in_len != 0));
419 TFM_CORE_ASSERT(!(outvec == NULL && out_len != 0));
420 TFM_CORE_ASSERT(in_len <= PSA_MAX_IOVEC);
421 TFM_CORE_ASSERT(out_len <= PSA_MAX_IOVEC);
422 TFM_CORE_ASSERT(in_len + out_len <= PSA_MAX_IOVEC);
Edison Ai764d41f2018-09-21 15:56:36 +0800423
Edison Ai764d41f2018-09-21 15:56:36 +0800424 /* Clear message buffer before using it */
Ken Liuf39d8eb2021-10-07 12:55:33 +0800425 spm_memset(&msg->msg, 0, sizeof(psa_msg_t));
Edison Ai764d41f2018-09-21 15:56:36 +0800426
Ken Liu5d73c872021-08-19 19:23:17 +0800427 THRD_SYNC_INIT(&msg->ack_evnt);
Edison Ai764d41f2018-09-21 15:56:36 +0800428 msg->magic = TFM_MSG_MAGIC;
429 msg->service = service;
Ken Liuf39d8eb2021-10-07 12:55:33 +0800430 msg->p_client = GET_CURRENT_COMPONENT();
Edison Ai764d41f2018-09-21 15:56:36 +0800431 msg->caller_outvec = caller_outvec;
Summer Qin1ce712a2019-10-14 18:04:05 +0800432 msg->msg.client_id = client_id;
Edison Ai764d41f2018-09-21 15:56:36 +0800433
434 /* Copy contents */
435 msg->msg.type = type;
436
437 for (i = 0; i < in_len; i++) {
438 msg->msg.in_size[i] = invec[i].len;
439 msg->invec[i].base = invec[i].base;
440 }
441
442 for (i = 0; i < out_len; i++) {
443 msg->msg.out_size[i] = outvec[i].len;
444 msg->outvec[i].base = outvec[i].base;
445 /* Out len is used to record the writed number, set 0 here again */
446 msg->outvec[i].len = 0;
447 }
448
Ken Liu505b1702020-05-29 13:19:58 +0800449 /* Use the user connect handle as the message handle */
450 msg->msg.handle = handle;
Edison Ai764d41f2018-09-21 15:56:36 +0800451
Ken Liu505b1702020-05-29 13:19:58 +0800452 conn_handle = tfm_spm_to_handle_instance(handle);
Edison Ai764d41f2018-09-21 15:56:36 +0800453 /* For connected handle, set rhandle to every message */
Ken Liu505b1702020-05-29 13:19:58 +0800454 if (conn_handle) {
455 msg->msg.rhandle = tfm_spm_get_rhandle(service, conn_handle);
Edison Ai764d41f2018-09-21 15:56:36 +0800456 }
David Hu46603dd2019-12-11 18:05:16 +0800457
458 /* Set the private data of NSPE client caller in multi-core topology */
459 if (TFM_CLIENT_ID_IS_NS(client_id)) {
460 tfm_rpc_set_caller_data(msg, client_id);
461 }
Edison Ai764d41f2018-09-21 15:56:36 +0800462}
463
Kevin Pengeec41a82021-08-18 13:56:23 +0800464int32_t tfm_spm_partition_get_running_partition_id(void)
Edison Ai764d41f2018-09-21 15:56:36 +0800465{
Mingyang Sunae70d8d2020-06-30 15:56:05 +0800466 struct partition_t *partition;
Edison Ai764d41f2018-09-21 15:56:36 +0800467
Kevin Pengcdf3ae22022-01-19 14:53:52 +0800468 partition = GET_CURRENT_COMPONENT();
Ken Liuacd2a572021-05-12 16:19:04 +0800469 if (partition && partition->p_ldinf) {
470 return partition->p_ldinf->pid;
Kevin Peng79c2bda2020-07-24 16:31:12 +0800471 } else {
472 return INVALID_PARTITION_ID;
473 }
Edison Ai764d41f2018-09-21 15:56:36 +0800474}
475
Summer Qin43c185d2019-10-10 15:44:42 +0800476int32_t tfm_memory_check(const void *buffer, size_t len, bool ns_caller,
Summer Qineb537e52019-03-29 09:57:10 +0800477 enum tfm_memory_access_e access,
478 uint32_t privileged)
Summer Qin2bfd2a02018-09-26 17:10:41 +0800479{
Mingyang Sund1ed6732020-08-26 15:52:21 +0800480 enum tfm_hal_status_t err;
481 uint32_t attr = 0;
Summer Qin2bfd2a02018-09-26 17:10:41 +0800482
483 /* If len is zero, this indicates an empty buffer and base is ignored */
484 if (len == 0) {
Ken Liubcae38b2021-01-20 15:47:44 +0800485 return SPM_SUCCESS;
Summer Qin2bfd2a02018-09-26 17:10:41 +0800486 }
487
488 if (!buffer) {
Ken Liubcae38b2021-01-20 15:47:44 +0800489 return SPM_ERROR_BAD_PARAMETERS;
Summer Qin2bfd2a02018-09-26 17:10:41 +0800490 }
491
492 if ((uintptr_t)buffer > (UINTPTR_MAX - len)) {
Ken Liubcae38b2021-01-20 15:47:44 +0800493 return SPM_ERROR_MEMORY_CHECK;
Summer Qin2bfd2a02018-09-26 17:10:41 +0800494 }
495
Summer Qin424d4db2019-03-25 14:09:51 +0800496 if (access == TFM_MEMORY_ACCESS_RW) {
Mingyang Sund1ed6732020-08-26 15:52:21 +0800497 attr |= (TFM_HAL_ACCESS_READABLE | TFM_HAL_ACCESS_WRITABLE);
Summer Qin2bfd2a02018-09-26 17:10:41 +0800498 } else {
Mingyang Sund1ed6732020-08-26 15:52:21 +0800499 attr |= TFM_HAL_ACCESS_READABLE;
Summer Qin424d4db2019-03-25 14:09:51 +0800500 }
Mingyang Sund1ed6732020-08-26 15:52:21 +0800501
502 if (privileged == TFM_PARTITION_UNPRIVILEGED_MODE) {
503 attr |= TFM_HAL_ACCESS_UNPRIVILEGED;
504 } else {
505 attr &= ~TFM_HAL_ACCESS_UNPRIVILEGED;
506 }
507
508 if (ns_caller) {
509 attr |= TFM_HAL_ACCESS_NS;
510 }
511
512 err = tfm_hal_memory_has_access((uintptr_t)buffer, len, attr);
513
514 if (err == TFM_HAL_SUCCESS) {
Ken Liubcae38b2021-01-20 15:47:44 +0800515 return SPM_SUCCESS;
Summer Qin2bfd2a02018-09-26 17:10:41 +0800516 }
517
Ken Liubcae38b2021-01-20 15:47:44 +0800518 return SPM_ERROR_MEMORY_CHECK;
Summer Qin2bfd2a02018-09-26 17:10:41 +0800519}
520
Mingyang Sun22a3faf2021-07-09 15:32:47 +0800521bool tfm_spm_is_ns_caller(void)
522{
Kevin Pengcdf3ae22022-01-19 14:53:52 +0800523 struct partition_t *partition = GET_CURRENT_COMPONENT();
Ken Liu897e8f12022-02-10 03:21:17 +0100524
525 if (!partition) {
526 tfm_core_panic();
527 }
528
529 return (partition->p_ldinf->pid == TFM_SP_NON_SECURE_ID);
Mingyang Sun22a3faf2021-07-09 15:32:47 +0800530}
531
Kevin Peng385fda82021-08-18 10:41:19 +0800532int32_t tfm_spm_get_client_id(bool ns_caller)
533{
534 int32_t client_id;
535
536 if (ns_caller) {
537 client_id = tfm_nspm_get_current_client_id();
538 } else {
539 client_id = tfm_spm_partition_get_running_partition_id();
540 }
541
542 if (ns_caller != (client_id < 0)) {
543 /* NS client ID must be negative and Secure ID must >= 0 */
544 tfm_core_panic();
545 }
546
547 return client_id;
548}
549
Ken Liuce2692d2020-02-11 12:39:36 +0800550uint32_t tfm_spm_init(void)
Edison Ai764d41f2018-09-21 15:56:36 +0800551{
Mingyang Sunae70d8d2020-06-30 15:56:05 +0800552 struct partition_t *partition;
Mingyang Sundeae45d2021-09-06 15:31:07 +0800553 const struct partition_load_info_t *p_pldi;
554 uint32_t service_setting = 0;
Ken Liuce58bfc2021-05-12 17:54:48 +0800555
David Huf07e97d2021-02-15 22:05:40 +0800556#ifdef TFM_FIH_PROFILE_ON
557 fih_int fih_rc = FIH_FAILURE;
558#endif
Edison Ai764d41f2018-09-21 15:56:36 +0800559
560 tfm_pool_init(conn_handle_pool,
561 POOL_BUFFER_SIZE(conn_handle_pool),
562 sizeof(struct tfm_conn_handle_t),
Sherry Zhang86a71c62022-01-12 18:19:02 +0800563 CONFIG_TFM_CONN_HANDLE_MAX_NUM);
Edison Ai764d41f2018-09-21 15:56:36 +0800564
Ken Liu5a28da32022-01-19 14:37:05 +0800565 UNI_LISI_INIT_NODE(PARTITION_LIST_ADDR, next);
566 UNI_LISI_INIT_NODE(&services_listhead, next);
Ken Liuea45b0d2021-05-22 17:41:25 +0800567
Sherry Zhnag482b88b2021-08-19 17:51:47 +0800568 /* Init the nonsecure context. */
Chris Brand56b4d0c2021-12-17 16:15:58 -0800569 tfm_nspm_ctx_init();
Sherry Zhnag482b88b2021-08-19 17:51:47 +0800570
Ken Liuacd2a572021-05-12 16:19:04 +0800571 while (1) {
Mingyang Sundeae45d2021-09-06 15:31:07 +0800572 partition = load_a_partition_assuredly(PARTITION_LIST_ADDR);
Shawn Shan23331062021-09-01 14:58:21 +0800573 if (partition == NO_MORE_PARTITION) {
Ken Liuacd2a572021-05-12 16:19:04 +0800574 break;
Kevin Peng79c2bda2020-07-24 16:31:12 +0800575 }
576
Mingyang Sundeae45d2021-09-06 15:31:07 +0800577 p_pldi = partition->p_ldinf;
Mingyang Sun2b352662021-04-21 11:35:43 +0800578
Mingyang Sundeae45d2021-09-06 15:31:07 +0800579 if (p_pldi->nservices) {
580 service_setting = load_services_assuredly(
581 partition,
582 &services_listhead,
583 stateless_services_ref_tbl,
584 sizeof(stateless_services_ref_tbl));
Kevin Peng27e42272021-05-24 17:58:53 +0800585 }
586
Mingyang Sundeae45d2021-09-06 15:31:07 +0800587 if (p_pldi->nirqs) {
Kevin Peng27e42272021-05-24 17:58:53 +0800588 load_irqs_assuredly(partition);
589 }
590
Mingyang Sundeae45d2021-09-06 15:31:07 +0800591 /* Bind the partition with platform. */
Ken Liuce58bfc2021-05-12 17:54:48 +0800592#if TFM_FIH_PROFILE_ON
593 FIH_CALL(tfm_hal_bind_boundaries, fih_rc, partition->p_ldinf,
Mingyang Sundeae45d2021-09-06 15:31:07 +0800594 &partition->p_boundaries);
Ken Liuce58bfc2021-05-12 17:54:48 +0800595 if (fih_not_eq(fih_rc, fih_int_encode(TFM_HAL_SUCCESS))) {
596 tfm_core_panic();
Mingyang Sun61f8fbc2021-06-04 17:49:56 +0800597 }
Ken Liu86686282021-04-27 11:11:15 +0800598#else /* TFM_FIH_PROFILE_ON */
Ken Liuce58bfc2021-05-12 17:54:48 +0800599 if (tfm_hal_bind_boundaries(partition->p_ldinf,
Mingyang Sundeae45d2021-09-06 15:31:07 +0800600 &partition->p_boundaries)
601 != TFM_HAL_SUCCESS) {
Ken Liuce58bfc2021-05-12 17:54:48 +0800602 tfm_core_panic();
Mate Toth-Pal8ac98a72019-11-21 17:30:10 +0100603 }
Ken Liuce58bfc2021-05-12 17:54:48 +0800604#endif /* TFM_FIH_PROFILE_ON */
Mate Toth-Pal8ac98a72019-11-21 17:30:10 +0100605
Mingyang Sundeae45d2021-09-06 15:31:07 +0800606 backend_instance.comp_init_assuredly(partition, service_setting);
Edison Ai764d41f2018-09-21 15:56:36 +0800607 }
608
Mingyang Sundeae45d2021-09-06 15:31:07 +0800609 return backend_instance.system_run();
Edison Ai764d41f2018-09-21 15:56:36 +0800610}
Ken Liu2d175172019-03-21 17:08:41 +0800611
Ken Liu5d73c872021-08-19 19:23:17 +0800612uint64_t do_schedule(void)
613{
Ken Liu086b32c2021-12-27 14:44:52 +0800614 AAPCS_DUAL_U32_T ctx_ctrls;
Ken Liu5d73c872021-08-19 19:23:17 +0800615 struct partition_t *p_part_curr, *p_part_next;
Kevin Pengb20b0322022-02-09 16:47:19 +0800616 struct context_ctrl_t *p_curr_ctx;
Ken Liu5d73c872021-08-19 19:23:17 +0800617 struct thread_t *pth_next = thrd_next();
Kevin Pengca59ec02021-12-09 14:35:50 +0800618 struct critical_section_t cs = CRITICAL_SECTION_STATIC_INIT;
Ken Liu5d73c872021-08-19 19:23:17 +0800619
Kevin Pengb20b0322022-02-09 16:47:19 +0800620 p_curr_ctx = (struct context_ctrl_t *)(CURRENT_THREAD->p_context_ctrl);
Ken Liu086b32c2021-12-27 14:44:52 +0800621
Kevin Pengb20b0322022-02-09 16:47:19 +0800622 AAPCS_DUAL_U32_SET(ctx_ctrls, (uint32_t)p_curr_ctx, (uint32_t)p_curr_ctx);
623
624 p_part_curr = GET_CURRENT_COMPONENT();
Mingyang Sun4f08f4d2021-09-10 17:41:28 +0800625 p_part_next = GET_THRD_OWNER(pth_next);
Ken Liu5d73c872021-08-19 19:23:17 +0800626
Mingyang Sun620c8562021-11-10 11:44:58 +0800627 if (scheduler_lock != SCHEDULER_LOCKED && pth_next != NULL &&
628 p_part_curr != p_part_next) {
Ken Liu5d73c872021-08-19 19:23:17 +0800629 /* Check if there is enough room on stack to save more context */
Kevin Pengb20b0322022-02-09 16:47:19 +0800630 if ((p_curr_ctx->sp_limit +
631 sizeof(struct tfm_additional_context_t)) > __get_PSP()) {
Ken Liu5d73c872021-08-19 19:23:17 +0800632 tfm_core_panic();
633 }
Mate Toth-Palc430b992019-05-09 21:01:14 +0200634
Kevin Pengca59ec02021-12-09 14:35:50 +0800635 CRITICAL_SECTION_ENTER(cs);
Ken Liuce58bfc2021-05-12 17:54:48 +0800636 /*
637 * If required, let the platform update boundary based on its
638 * implementation. Change privilege, MPU or other configurations.
639 */
640 if (p_part_curr->p_boundaries != p_part_next->p_boundaries) {
641 if (tfm_hal_update_boundaries(p_part_next->p_ldinf,
642 p_part_next->p_boundaries)
643 != TFM_HAL_SUCCESS) {
644 tfm_core_panic();
645 }
646 }
Feder Liang42f5b562021-09-10 17:38:36 +0800647 ARCH_FLUSH_FP_CONTEXT();
Mingyang Sun620c8562021-11-10 11:44:58 +0800648
Ken Liu086b32c2021-12-27 14:44:52 +0800649 AAPCS_DUAL_U32_SET_A1(ctx_ctrls, (uint32_t)pth_next->p_context_ctrl);
650
Mingyang Sun620c8562021-11-10 11:44:58 +0800651 CURRENT_THREAD = pth_next;
Kevin Pengca59ec02021-12-09 14:35:50 +0800652 CRITICAL_SECTION_LEAVE(cs);
Ken Liu2d175172019-03-21 17:08:41 +0800653 }
David Hufb38d562019-09-23 15:58:34 +0800654
Ken Liu086b32c2021-12-27 14:44:52 +0800655 return AAPCS_DUAL_U32_AS_U64(ctx_ctrls);
Ken Liu2d175172019-03-21 17:08:41 +0800656}
Mingyang Sund44522a2020-01-16 16:48:37 +0800657
Summer Qin02f7f072020-08-24 16:02:54 +0800658void update_caller_outvec_len(struct tfm_msg_body_t *msg)
Mingyang Sund44522a2020-01-16 16:48:37 +0800659{
660 uint32_t i;
661
662 /*
663 * FixeMe: abstract these part into dedicated functions to avoid
664 * accessing thread context in psa layer
665 */
Ken Liuf39d8eb2021-10-07 12:55:33 +0800666 /*
667 * If it is a NS request via RPC, the owner of this message is not set.
668 * Or if it is a SFN message, it does not have owner thread state either.
669 */
670 if ((!is_tfm_rpc_msg(msg)) && (msg->sfn_magic != TFM_MSG_MAGIC_SFN)) {
Mingyang Sund44522a2020-01-16 16:48:37 +0800671 TFM_CORE_ASSERT(msg->ack_evnt.owner->state == THRD_STATE_BLOCK);
672 }
673
674 for (i = 0; i < PSA_MAX_IOVEC; i++) {
675 if (msg->msg.out_size[i] == 0) {
676 continue;
677 }
678
679 TFM_CORE_ASSERT(msg->caller_outvec[i].base == msg->outvec[i].base);
680
681 msg->caller_outvec[i].len = msg->outvec[i].len;
682 }
683}
684
Ken Liu5d73c872021-08-19 19:23:17 +0800685void spm_assert_signal(void *p_pt, psa_signal_t signal)
Mingyang Sund44522a2020-01-16 16:48:37 +0800686{
Ken Liu92ede9f2021-10-20 09:35:00 +0800687 struct critical_section_t cs_assert = CRITICAL_SECTION_STATIC_INIT;
Ken Liu5d73c872021-08-19 19:23:17 +0800688 struct partition_t *partition = (struct partition_t *)p_pt;
Mingyang Sund44522a2020-01-16 16:48:37 +0800689
Mingyang Sund44522a2020-01-16 16:48:37 +0800690 if (!partition) {
691 tfm_core_panic();
692 }
693
Ken Liu92ede9f2021-10-20 09:35:00 +0800694 CRITICAL_SECTION_ENTER(cs_assert);
695
Mingyang Sunaf22ffa2020-07-09 17:48:37 +0800696 partition->signals_asserted |= signal;
Mingyang Sund44522a2020-01-16 16:48:37 +0800697
Kevin Peng8dac6102021-03-09 16:44:00 +0800698 if (partition->signals_waiting & signal) {
Ken Liu5d73c872021-08-19 19:23:17 +0800699 thrd_wake_up(&partition->waitobj,
700 partition->signals_asserted & partition->signals_waiting);
Kevin Peng8dac6102021-03-09 16:44:00 +0800701 partition->signals_waiting &= ~signal;
702 }
Ken Liu92ede9f2021-10-20 09:35:00 +0800703
704 CRITICAL_SECTION_LEAVE(cs_assert);
Mingyang Sund44522a2020-01-16 16:48:37 +0800705}