diff options
author | danh-arm <dan.handley@arm.com> | 2015-01-07 12:58:37 +0000 |
---|---|---|
committer | danh-arm <dan.handley@arm.com> | 2015-01-07 12:58:37 +0000 |
commit | 02b5678ca5d15b36d6feea1c0b7d26f6a07274fd (patch) | |
tree | 307db87ddc1e0be24d8d4057256e5dd08759879d /services/std_svc/psci/psci_setup.c | |
parent | 2060f0c0181fec2afd0d28f08370e080e27824f2 (diff) | |
parent | 264999fc601e5b72e31aeb66101b57e409e2f68b (diff) |
Merge pull request #227 from soby-mathew/sm/afflvl_fix
Fix CPU_SUSPEND when invoked with affinity level higher than get_max_aff...
Diffstat (limited to 'services/std_svc/psci/psci_setup.c')
-rw-r--r-- | services/std_svc/psci/psci_setup.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/services/std_svc/psci/psci_setup.c b/services/std_svc/psci/psci_setup.c index a5ae4ef5..8e9d15dc 100644 --- a/services/std_svc/psci/psci_setup.c +++ b/services/std_svc/psci/psci_setup.c @@ -77,12 +77,18 @@ static int psci_aff_map_get_idx(unsigned long key, return PSCI_E_INVALID_PARAMS; /* + * Make sure we are within array limits. + */ + assert(min_idx >= 0 && max_idx < PSCI_NUM_AFFS); + + /* * Bisect the array around 'mid' and then recurse into the array chunk * where the key is likely to be found. The mpidrs in each node in the * 'psci_aff_map' for a given affinity level are stored in an ascending * order which makes the binary search possible. */ mid = min_idx + ((max_idx - min_idx) >> 1); /* Divide by 2 */ + if (psci_aff_map[mid].mpidr > key) return psci_aff_map_get_idx(key, min_idx, mid - 1); else if (psci_aff_map[mid].mpidr < key) @@ -95,6 +101,9 @@ aff_map_node_t *psci_get_aff_map_node(unsigned long mpidr, int aff_lvl) { int rc; + if (aff_lvl > get_max_afflvl()) + return NULL; + /* Right shift the mpidr to the required affinity level */ mpidr = mpidr_mask_lower_afflvls(mpidr, aff_lvl); |