refactor(ffa): change the runtime states of an ..
endpoint execution context based on FF-A v1.1. Allow FFA_RUN from SP.
The various state enumerations defined in the specification along
with few other auxiliary states needed for state transitions, such
as VCPU_STATE_OFF and VCPU_STATE_ABORTED, are described as follows:
/** The vCPU is switched off. */
VCPU_STATE_OFF,
/** The vCPU is currently running. */
VCPU_STATE_RUNNING,
/** The vCPU is waiting to be allocated CPU cycles to do work.*/
VCPU_STATE_WAITING,
/** The vCPU is blocked and waiting for some work to complete
on its behalf. */
VCPU_STATE_BLOCKED,
/** The vCPU has been preempted by an interrupt. */
VCPU_STATE_PREEMPTED,
/** The vCPU is waiting for an interrupt. */
VCPU_STATE_BLOCKED_INTERRUPT,
/** The vCPU has aborted. */
VCPU_STATE_ABORTED,
Moreover, this patch also removes the constraint on FFA_RUN. As per
FF-A v1.1 spec, any SP can invoke FFA_RUN. We leverage this capability
for secure interrupt signal completion in further patches.
Change-Id: I3801b4a053df56a4b5a2803e74d4cbf743ad2678
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
diff --git a/src/vcpu.c b/src/vcpu.c
index 68acd00..2c79ae5 100644
--- a/src/vcpu.c
+++ b/src/vcpu.c
@@ -66,12 +66,12 @@
/**
* Initialise the registers for the given vCPU and set the state to
- * VCPU_STATE_READY. The caller must hold the vCPU lock while calling this.
+ * VCPU_STATE_WAITING. The caller must hold the vCPU lock while calling this.
*/
void vcpu_on(struct vcpu_locked vcpu, ipaddr_t entry, uintreg_t arg)
{
arch_regs_set_pc_arg(&vcpu.vcpu->regs, entry, arg);
- vcpu.vcpu->state = VCPU_STATE_READY;
+ vcpu.vcpu->state = VCPU_STATE_WAITING;
}
ffa_vcpu_index_t vcpu_index(const struct vcpu *vcpu)
@@ -84,28 +84,14 @@
/**
* Check whether the given vcpu_state is an off state, for the purpose of
- * turning vCPUs on and off. Note that aborted still counts as on in this
- * context.
+ * turning vCPUs on and off. Note that Aborted still counts as ON for the
+ * purposes of PSCI, because according to the PSCI specification (section
+ * 5.7.1) a core is only considered to be off if it has been turned off
+ * with a CPU_OFF call or hasn't yet been turned on with a CPU_ON call.
*/
bool vcpu_is_off(struct vcpu_locked vcpu)
{
- switch (vcpu.vcpu->state) {
- case VCPU_STATE_OFF:
- return true;
- case VCPU_STATE_READY:
- case VCPU_STATE_RUNNING:
- case VCPU_STATE_BLOCKED_MAILBOX:
- case VCPU_STATE_BLOCKED_INTERRUPT:
- case VCPU_STATE_ABORTED:
- /*
- * Aborted still counts as ON for the purposes of PSCI,
- * because according to the PSCI specification (section
- * 5.7.1) a core is only considered to be off if it has
- * been turned off with a CPU_OFF call or hasn't yet
- * been turned on with a CPU_ON call.
- */
- return false;
- }
+ return (vcpu.vcpu->state == VCPU_STATE_OFF);
}
/**