SPM: Prevent simultaneous blocking calls
Blocking calls can only succeed if the target Secure Partition is idle.
Change-Id: Iabeaa0b8d3e653fd8581fa086758936abfc1c772
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
diff --git a/services/std_svc/spm/spci.c b/services/std_svc/spm/spci.c
index cbb0f3c..1544ae1 100644
--- a/services/std_svc/spm/spci.c
+++ b/services/std_svc/spm/spci.c
@@ -291,6 +291,12 @@
SMC_RET1(handle, SPCI_BUSY);
}
+ if (spm_sp_request_increase_if_zero(sp_ctx) == -1) {
+ spin_unlock(&spci_handles_lock);
+
+ SMC_RET1(handle, SPCI_BUSY);
+ }
+
/* Prevent this handle from being closed */
handle_info->num_active_requests += 1;
@@ -348,6 +354,7 @@
spin_lock(&spci_handles_lock);
handle_info->num_active_requests -= 1;
spin_unlock(&spci_handles_lock);
+ spm_sp_request_decrease(sp_ctx);
/* Restore non-secure state */
cm_el1_sysregs_context_restore(NON_SECURE);