Skip to content

Commit

Permalink
modules: tfm: interface: handle ISR context
Browse files Browse the repository at this point in the history
Don't attempt to take a mutex if operating from inside an ISR. The only
expected use-case where this should occur is when attempting to reboot
via `tfm_platform_system_reset` from an exception handler.

Fixes zephyrproject-rtos#79687.

Signed-off-by: Jordan Yates <[email protected]>
  • Loading branch information
JordanYates authored and dleach02 committed Oct 15, 2024
1 parent dd7cfbc commit f314399
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/trusted-firmware-m/interface/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ int32_t tfm_ns_interface_dispatch(veneer_fn fn,
uint32_t arg0, uint32_t arg1,
uint32_t arg2, uint32_t arg3)
{
int32_t result;
bool is_pre_kernel = k_is_pre_kernel();
bool isr_mode = k_is_in_isr() || k_is_pre_kernel();
int tfm_ns_saved_prio;
int32_t result;

if (!is_pre_kernel) {
if (!isr_mode) {
/* TF-M request protected by NS lock */
if (k_mutex_lock(&tfm_mutex, K_FOREVER) != 0) {
return (int32_t)PSA_ERROR_GENERIC_ERROR;
Expand Down Expand Up @@ -61,7 +61,7 @@ int32_t tfm_ns_interface_dispatch(veneer_fn fn,

z_arm_restore_fp_context(&context_buffer);

if (!is_pre_kernel) {
if (!isr_mode) {
#if !defined(CONFIG_ARM_NONSECURE_PREEMPTIBLE_SECURE_CALLS)
/* Restore thread priority, to allow the thread to be preempted. */
k_thread_priority_set(k_current_get(), tfm_ns_saved_prio);
Expand Down

0 comments on commit f314399

Please sign in to comment.