test: deny prohibited ABIs while handling CPU_OFF psci msg
FF-A spec states that SPs are prohibited from invoking Direct request,
FFA_RUN and FFA_YIELD interfaces while handling power management
framework message. Make the Cactus SP intentionally invoke prohibited
interfaces and attest that SPMC should deny such invocations.
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
Change-Id: I0a823bf950e3895cb4aff7320c6a0ef7fdec634b
diff --git a/include/runtime_services/ffa_helpers.h b/include/runtime_services/ffa_helpers.h
index 24a7e38..67fd393 100644
--- a/include/runtime_services/ffa_helpers.h
+++ b/include/runtime_services/ffa_helpers.h
@@ -965,6 +965,7 @@
uint32_t status_code);
struct ffa_value ffa_run(uint32_t dest_id, uint32_t vcpu_id);
+struct ffa_value ffa_yield(void);
struct ffa_value ffa_version(uint32_t input_version);
struct ffa_value ffa_id_get(void);
struct ffa_value ffa_spm_id_get(void);
diff --git a/spm/cactus/cactus_tests/cactus_message_loop.c b/spm/cactus/cactus_tests/cactus_message_loop.c
index 8dc37b9..aba3124 100644
--- a/spm/cactus/cactus_tests/cactus_message_loop.c
+++ b/spm/cactus/cactus_tests/cactus_message_loop.c
@@ -11,6 +11,7 @@
#include <ffa_helpers.h>
#include <events.h>
#include <platform.h>
+#include <sp_helpers.h>
#include <spm_helpers.h>
#include <psci.h>
@@ -110,6 +111,7 @@
#if CACTUS_PWR_MGMT_SUPPORT == 1
uint32_t framework_msg = ffa_get_framework_msg(args);
uint32_t psci_function = args.arg3;
+ struct ffa_value ret;
/*
* As of now, Cactus supports receiving only PSCI power management
@@ -138,6 +140,38 @@
}
status_code = PSCI_E_SUCCESS;
+
+ /*
+ * FF-A spec states that SPs are prohibited from invoking Direct
+ * request, FFA_RUN and FFA_YIELD interfaces while handling power
+ * management framework message. Make the Cactus SP intentionally
+ * invoke prohibited interfaces and attest that SPMC should deny such
+ * invocations.
+ */
+ ret = cactus_success_resp(destination_id, source_id, status_code);
+
+ /* Non-framework direct response must be denied. */
+ EXPECT(ffa_func_id(ret), FFA_ERROR);
+ EXPECT(ffa_error_code(ret), FFA_ERROR_DENIED);
+
+ ret = cactus_echo_send_cmd(destination_id, SP_ID(4), 0x9999);
+
+ /* Direct request message must be denied. */
+ EXPECT(ffa_func_id(ret), FFA_ERROR);
+ EXPECT(ffa_error_code(ret), FFA_ERROR_DENIED);
+
+ ret = ffa_run(SP_ID(4), 0);
+
+ /* FFA_RUN invocation must be denied. */
+ EXPECT(ffa_func_id(ret), FFA_ERROR);
+ EXPECT(ffa_error_code(ret), FFA_ERROR_DENIED);
+
+ ret = ffa_yield();
+
+ /* FFA_YIELD invocation must be denied. */
+ EXPECT(ffa_func_id(ret), FFA_ERROR);
+ EXPECT(ffa_error_code(ret), FFA_ERROR_DENIED);
+
/*
* Return successful status for PSCI power management request through
* direct response Framework message.
diff --git a/tftf/tests/runtime_services/secure_service/ffa_helpers.c b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
index 1d128ab..3dc7036 100644
--- a/tftf/tests/runtime_services/secure_service/ffa_helpers.c
+++ b/tftf/tests/runtime_services/secure_service/ffa_helpers.c
@@ -156,6 +156,15 @@
return ffa_service_call(&args);
}
+struct ffa_value ffa_yield(void)
+{
+ struct ffa_value args = {
+ .fid = FFA_MSG_YIELD,
+ };
+
+ return ffa_service_call(&args);
+}
+
void ffa_memory_region_init_header(struct ffa_memory_region *memory_region,
ffa_id_t sender,
ffa_memory_attributes_t attributes,