Skip to content

Commit 67a4e6d

Browse files
Edison AiMichael Schwarcz
authored andcommitted
TF-M patch: Fix psa_set_rhandle() issue during CONNECT (TF-M issue #216)
- Link to bug tracking: https://developer.trustedfirmware.org/T216
1 parent 008bf1b commit 67a4e6d

File tree

1 file changed

+14
-3
lines changed
  • components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/secure_fw/core/ipc

1 file changed

+14
-3
lines changed

components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/secure_fw/core/ipc/tfm_svcalls.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,15 @@ static void tfm_svcall_psa_set_rhandle(uint32_t *args)
435435
tfm_panic();
436436
}
437437

438-
if (tfm_spm_set_rhandle(msg->service, msg->handle,
439-
rhandle) != IPC_SUCCESS) {
440-
tfm_panic();
438+
/*
439+
* Connection handle is not created while SP is processing PSA_IPC_CONNECT
440+
* message. Store reverse handle temporarily and re-set it after the
441+
* connection created.
442+
*/
443+
if (msg->handle != PSA_NULL_HANDLE) {
444+
tfm_spm_set_rhandle(msg->service, msg->handle, rhandle);
445+
} else {
446+
msg->msg.rhandle = rhandle;
441447
}
442448
}
443449

@@ -744,6 +750,11 @@ static void tfm_svcall_psa_reply(uint32_t *args)
744750
tfm_panic();
745751
}
746752
ret = connect_handle;
753+
754+
/* Set reverse handle after connection created if needed. */
755+
if (msg->msg.rhandle) {
756+
tfm_spm_set_rhandle(service, connect_handle, msg->msg.rhandle);
757+
}
747758
} else if (status == PSA_CONNECTION_REFUSED) {
748759
ret = PSA_CONNECTION_REFUSED;
749760
} else if (status == PSA_CONNECTION_BUSY) {

0 commit comments

Comments
 (0)