summaryrefslogtreecommitdiff
path: root/services/std_svc
diff options
context:
space:
mode:
authorSoby Mathew <soby.mathew@arm.com>2015-01-12 13:01:31 +0000
committerSoby Mathew <soby.mathew@arm.com>2015-01-23 15:14:36 +0000
commit2f5aadedc4b722841155f0ff6630e220dac3f30b (patch)
tree586d74b6db7fa2bc386e75e1967ea1fba937df54 /services/std_svc
parente146f4cc6c93ab5efe93f73c0dd53bce8c99555f (diff)
PSCI: Check early for invalid CPU state during CPU ON
This patch moves the check for valid CPU state during PSCI_CPU_ON to before the non secure entry point is programmed so as to enable it to return early on error. Change-Id: I1b1a21be421e2b2a6e33db236e91dee8688efffa
Diffstat (limited to 'services/std_svc')
-rw-r--r--services/std_svc/psci/psci_afflvl_on.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/services/std_svc/psci/psci_afflvl_on.c b/services/std_svc/psci/psci_afflvl_on.c
index d6e35f73..04529d2f 100644
--- a/services/std_svc/psci/psci_afflvl_on.c
+++ b/services/std_svc/psci/psci_afflvl_on.c
@@ -48,13 +48,8 @@ typedef int (*afflvl_on_handler_t)(unsigned long target_cpu,
* This function checks whether a cpu which has been requested to be turned on
* is OFF to begin with.
******************************************************************************/
-static int cpu_on_validate_state(aff_map_node_t *node)
+static int cpu_on_validate_state(unsigned int psci_state)
{
- unsigned int psci_state;
-
- /* Get the raw psci state */
- psci_state = psci_get_state(node);
-
if (psci_state == PSCI_STATE_ON || psci_state == PSCI_STATE_SUSPEND)
return PSCI_E_ALREADY_ON;
@@ -84,14 +79,6 @@ static int psci_afflvl0_on(unsigned long target_cpu,
assert(cpu_node->level == MPIDR_AFFLVL0);
/*
- * Generic management: Ensure that the cpu is off to be
- * turned on
- */
- rc = cpu_on_validate_state(cpu_node);
- if (rc != PSCI_E_SUCCESS)
- return rc;
-
- /*
* Call the cpu on handler registered by the Secure Payload Dispatcher
* to let it do any bookeeping. If the handler encounters an error, it's
* expected to assert within
@@ -290,6 +277,15 @@ int psci_afflvl_on(unsigned long target_cpu,
end_afflvl,
target_cpu_nodes);
+ /*
+ * Generic management: Ensure that the cpu is off to be
+ * turned on.
+ */
+ rc = cpu_on_validate_state(psci_get_state(
+ (aff_map_node_t *)target_cpu_nodes[MPIDR_AFFLVL0]));
+ if (rc != PSCI_E_SUCCESS)
+ goto exit;
+
/* Perform generic, architecture and platform specific handling. */
rc = psci_call_on_handlers(target_cpu_nodes,
start_afflvl,
@@ -309,6 +305,7 @@ int psci_afflvl_on(unsigned long target_cpu,
target_cpu_nodes,
PSCI_STATE_ON_PENDING);
+exit:
/*
* This loop releases the lock corresponding to each affinity level
* in the reverse order to which they were acquired.