feat: add build flag to control support for CPU_OFF psci msg
Please check the inline comments for detailed description of the
new build flag. This flag will help us to create a negative test
scenario where we can exercise sending DENIED response to SPMC,
ultimately leading to a panic by SPMD.
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
Change-Id: I30d2ea7f3fbf09e4e4febceb85f045e25f3e6035
diff --git a/Makefile b/Makefile
index 4936ff7..29b0f3b 100644
--- a/Makefile
+++ b/Makefile
@@ -171,6 +171,7 @@
$(eval $(call assert_boolean,ENABLE_REALM_PAYLOAD_TESTS))
$(eval $(call assert_boolean,TRANSFER_LIST))
$(eval $(call assert_boolean,SPMC_AT_EL3))
+$(eval $(call assert_boolean,CACTUS_PWR_MGMT_SUPPORT))
################################################################################
# Process build options
@@ -199,6 +200,7 @@
$(eval $(call add_define,TFTF_DEFINES,TRANSFER_LIST))
$(eval $(call add_define,TFTF_DEFINES,PLAT_AMU_GROUP1_COUNTERS_MASK))
$(eval $(call add_define,TFTF_DEFINES,SPMC_AT_EL3))
+$(eval $(call add_define,TFTF_DEFINES,CACTUS_PWR_MGMT_SUPPORT))
################################################################################
diff --git a/docs/getting_started/build-options.rst b/docs/getting_started/build-options.rst
index 08343e3..3f62958 100644
--- a/docs/getting_started/build-options.rst
+++ b/docs/getting_started/build-options.rst
@@ -155,6 +155,14 @@
- ``SPMC_AT_EL3``: This flag is required to match the feature set of Cactus SP that
are implemented in TF-A EL3 SPMC. Default value is 0.
+- ``CACTUS_PWR_MGMT_SUPPORT``: If a Cactus SP subscribes to receiving power
+ management framework message through its partition manifest, this flag
+ controls whether the SP supports handling the aforementioned message. This
+ option can take either 0 (unsupported) or 1 (supported). Default value is 1.
+
+ Note that a value of 0 is particularly useful in stress testing of power
+ management handling by the SPMC.
+
Realm payload specific Build Options
------------------------------------
diff --git a/make_helpers/defaults.mk b/make_helpers/defaults.mk
index 3a7f8bf..337c6a6 100644
--- a/make_helpers/defaults.mk
+++ b/make_helpers/defaults.mk
@@ -59,3 +59,10 @@
# This flag is required to match the feature set of Cactus SP that are
# implemented in TF-A EL3 SPMC.
SPMC_AT_EL3 := 0
+
+# If a Cactus SP subscribes to receiving power management framework message
+# through its partition manifest, this flag controls whether the SP supports
+# handling the aforementioned message. This option can take either 0
+# (unsupported) or 1 (supported). Default value is 1. Note that a value of 0 is
+# particularly useful in stress testing of power management handling by the SPMC.
+CACTUS_PWR_MGMT_SUPPORT := 1
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index 7d39221..34565f0 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -100,6 +100,7 @@
$(eval $(call add_define,CACTUS_DEFINES,PLAT_${PLAT}))
$(eval $(call add_define,CACTUS_DEFINES,PLAT_XLAT_TABLES_DYNAMIC))
$(eval $(call add_define,CACTUS_DEFINES,SPMC_AT_EL3))
+$(eval $(call add_define,CACTUS_DEFINES,CACTUS_PWR_MGMT_SUPPORT))
$(CACTUS_DTB) : $(BUILD_PLAT)/cactus $(BUILD_PLAT)/cactus/cactus.elf
$(CACTUS_DTB) : $(CACTUS_DTS)
diff --git a/spm/cactus/cactus_tests/cactus_message_loop.c b/spm/cactus/cactus_tests/cactus_message_loop.c
index 9a8e9a1..8dc37b9 100644
--- a/spm/cactus/cactus_tests/cactus_message_loop.c
+++ b/spm/cactus/cactus_tests/cactus_message_loop.c
@@ -106,6 +106,8 @@
ffa_id_t source_id = ffa_dir_msg_source(args);
ffa_id_t destination_id = ffa_dir_msg_dest(args);
uint32_t status_code;
+
+#if CACTUS_PWR_MGMT_SUPPORT == 1
uint32_t framework_msg = ffa_get_framework_msg(args);
uint32_t psci_function = args.arg3;
@@ -143,6 +145,9 @@
VERBOSE("PSCI power management request handled successfully by SP:%x\n",
destination_id);
out:
+#else
+ status_code = PSCI_E_DENIED;
+#endif
return ffa_framework_msg_send_direct_resp(destination_id, source_id,
FFA_FRAMEWORK_MSG_PSCI_RESP, status_code);
}