Skip to content

Commit

Permalink
modules: trusted-firmware-m: lock scheduler around secure calls
Browse files Browse the repository at this point in the history
Prevent a thread from being preempted, while executing a Secure
function. This is required to prevent system crashes that could
occur if a thead context switch is triggered in the middle of a
Secure call.

Signed-off-by: Ioannis Glaropoulos <[email protected]>
  • Loading branch information
ioannisg committed Mar 26, 2021
1 parent aecbd9b commit 3a3693c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions modules/trusted-firmware-m/interface/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,19 @@ int32_t tfm_ns_interface_dispatch(veneer_fn fn,
return (int32_t)TFM_ERROR_GENERIC;
}

/*
* Prevent the thread from being preempted, while executing a Secure
* function. This is required to prevent system crashes that could
* occur, if a thead context switch is triggered in the middle of a
* Secure call.
*/
k_sched_lock();

result = fn(arg0, arg1, arg2, arg3);

/* Unlock the scheduler, to allow the thread to be preempted. */
k_sched_unlock();

k_mutex_unlock(&tfm_mutex);

return result;
Expand Down

0 comments on commit 3a3693c

Please sign in to comment.