fix(psci): mask MBZ bits in PSCI target_cpu arguments
The PSCI specification defines the target_cpu values almost the same as
the MPIDR_EL1 register value, however it only contains the Aff0-3 fields
and the rest is declared as MBZ. Mask the MBZ bits to follow the PSCI
specification.
Change-Id: I4196b5039aa774b357cb6932d3c2c24060f1f228
Signed-off-by: Imre Kis <imre.kis@arm.com>
diff --git a/include/runtime_services/psci.h b/include/runtime_services/psci.h
index 0e56bdc..e76156b 100644
--- a/include/runtime_services/psci.h
+++ b/include/runtime_services/psci.h
@@ -110,6 +110,13 @@
#endif /* __ASSEMBLY__ */
/*******************************************************************************
+ * PSCI target CPU defines
+ ******************************************************************************/
+
+#define PSCI_TARGET_CPU_MASK ULL(0x000000FF00FFFFFF)
+#define psci_target_cpu_from_mpid(mpidr) ((mpidr) & PSCI_TARGET_CPU_MASK)
+
+/*******************************************************************************
* PSCI Migrate specific defines
******************************************************************************/
#define PSCI_TOS_UP_MIG_CAP 0
diff --git a/lib/psci/psci.c b/lib/psci/psci.c
index 42e53b9..720d319 100644
--- a/lib/psci/psci.c
+++ b/lib/psci/psci.c
@@ -60,7 +60,7 @@
{
smc_args args = {
SMC_PSCI_CPU_ON,
- target_cpu,
+ psci_target_cpu_from_mpid(target_cpu),
entry_point_address,
context_id
};
@@ -97,7 +97,7 @@
{
smc_args args = {
SMC_PSCI_STAT_RESIDENCY,
- target_cpu,
+ psci_target_cpu_from_mpid(target_cpu),
power_state,
};
smc_ret_values ret_vals;
@@ -111,7 +111,7 @@
{
smc_args args = {
SMC_PSCI_STAT_COUNT,
- target_cpu,
+ psci_target_cpu_from_mpid(target_cpu),
power_state,
};
smc_ret_values ret_vals;
@@ -127,7 +127,7 @@
smc_args args = {
SMC_PSCI_AFFINITY_INFO,
- target_affinity,
+ psci_target_cpu_from_mpid(target_affinity),
lowest_affinity_level
};
@@ -139,7 +139,7 @@
{
smc_args args = {
SMC_PSCI_CPU_HW_STATE,
- target_cpu,
+ psci_target_cpu_from_mpid(target_cpu),
power_level
};
smc_ret_values ret;
diff --git a/tftf/tests/runtime_services/standard_service/psci/api_tests/migrate_info_type/test_migrate_info_type.c b/tftf/tests/runtime_services/standard_service/psci/api_tests/migrate_info_type/test_migrate_info_type.c
index 50462d7..a3141a5 100644
--- a/tftf/tests/runtime_services/standard_service/psci/api_tests/migrate_info_type/test_migrate_info_type.c
+++ b/tftf/tests/runtime_services/standard_service/psci/api_tests/migrate_info_type/test_migrate_info_type.c
@@ -89,7 +89,7 @@
* Pass a valid MPID so that the MIGRATE call doesn't fail because of
* invalid parameters
*/
- args.arg1 = read_mpidr_el1() & MPID_MASK;
+ args.arg1 = psci_target_cpu_from_mpid(read_mpidr_el1());
ret = tftf_smc(&args);
migrate_ret = (int32_t) ret.ret0;