Skip to content

Commit f314399

Browse files
JordanYatesdleach02
authored andcommitted
modules: tfm: interface: handle ISR context
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 #79687. Signed-off-by: Jordan Yates <[email protected]>
1 parent dd7cfbc commit f314399

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

modules/trusted-firmware-m/interface/interface.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ int32_t tfm_ns_interface_dispatch(veneer_fn fn,
2828
uint32_t arg0, uint32_t arg1,
2929
uint32_t arg2, uint32_t arg3)
3030
{
31-
int32_t result;
32-
bool is_pre_kernel = k_is_pre_kernel();
31+
bool isr_mode = k_is_in_isr() || k_is_pre_kernel();
3332
int tfm_ns_saved_prio;
33+
int32_t result;
3434

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

6262
z_arm_restore_fp_context(&context_buffer);
6363

64-
if (!is_pre_kernel) {
64+
if (!isr_mode) {
6565
#if !defined(CONFIG_ARM_NONSECURE_PREEMPTIBLE_SECURE_CALLS)
6666
/* Restore thread priority, to allow the thread to be preempted. */
6767
k_thread_priority_set(k_current_get(), tfm_ns_saved_prio);

0 commit comments

Comments
 (0)