aboutsummaryrefslogtreecommitdiffstats
path: root/lib/psci/psci_private.h
diff options
context:
space:
mode:
authorGraeme Gregory <graeme@nuviainc.com>2020-12-02 16:24:32 +0000
committerGraeme Gregory <graeme@nuviainc.com>2020-12-22 07:39:51 +0000
commita86865ac42ac6f518da14474c94f38869c032488 (patch)
tree53e46ee9670a6819af8182cf58141374b66515cb /lib/psci/psci_private.h
parent669ee776ccad9986b45f9015724955c3830fd471 (diff)
downloadplatform_external_arm-trusted-firmware-a86865ac42ac6f518da14474c94f38869c032488.tar.gz
platform_external_arm-trusted-firmware-a86865ac42ac6f518da14474c94f38869c032488.tar.bz2
platform_external_arm-trusted-firmware-a86865ac42ac6f518da14474c94f38869c032488.zip
PSCI: fix limit of 256 CPUs caused by cast to unsigned char
In psci_setup.c psci_init_pwr_domain_node() takes an unsigned char as node_idx which limits it to initialising only the first 256 CPUs. As the calling function does not check for a limit of 256 I think this is a bug so change the unsigned char to uint16_t and change the cast from the calling site in populate_power_domain_tree(). Also update the non_cpu_pwr_domain_node structure lock_index to uint16_t and update the function signature for psci_lock_init() appropriately. Finally add a define PSCI_MAX_CPUS_INDEX to psci_private.h and add a CASSERT to psci_setup.c to make sure PLATFORM_CORE_COUNT cannot exceed the index value. Signed-off-by: Graeme Gregory <graeme@nuviainc.com> Change-Id: I9e26842277db7483fd698b46bbac62aa86e71b45
Diffstat (limited to 'lib/psci/psci_private.h')
-rw-r--r--lib/psci/psci_private.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/psci/psci_private.h b/lib/psci/psci_private.h
index e2dcfa8b1..72bd6bd11 100644
--- a/lib/psci/psci_private.h
+++ b/lib/psci/psci_private.h
@@ -42,6 +42,11 @@
define_psci_cap(PSCI_SYSTEM_RESET2_AARCH64) | \
define_psci_cap(PSCI_MEM_CHK_RANGE_AARCH64))
+/* Internally PSCI uses a uint16_t for various cpu indexes so
+ * define a limit to number of CPUs that can be initialised.
+ */
+#define PSCI_MAX_CPUS_INDEX 0xFFFFU
+
/*
* Helper functions to get/set the fields of PSCI per-cpu data.
*/
@@ -134,7 +139,7 @@ typedef struct non_cpu_pwr_domain_node {
unsigned char level;
/* For indexing the psci_lock array*/
- unsigned char lock_index;
+ uint16_t lock_index;
} non_cpu_pd_node_t;
typedef struct cpu_pwr_domain_node {
@@ -239,7 +244,7 @@ static inline void psci_lock_release(non_cpu_pd_node_t *non_cpu_pd_node)
#endif /* HW_ASSISTED_COHERENCY */
static inline void psci_lock_init(non_cpu_pd_node_t *non_cpu_pd_node,
- unsigned char idx)
+ uint16_t idx)
{
non_cpu_pd_node[idx].lock_index = idx;
}