FF-A: secondary EC cold boot

When the SPMC boots, all Secure Partitions are initialized
on their primary Execution Context. A Secure Partition calls
FFA_SECONDARY_EP_REGISTER at virtual FF-A instance from
its first EC passing the entry point address for secondary
ECs. A secondary EC is first resumed either upon invocation
of PSCI_CPU_ON from the NWd to which a SP is registered
(currently the first SP) or by ffa_run invocation.

Change-Id: Ic6050af16d4081ca31729744995fbb999b170e11
Signed-off-by: Max Shvetsov <maksims.svecovs@arm.com>
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/src/vcpu.c b/src/vcpu.c
index 7fd2e75..b3b3f5a 100644
--- a/src/vcpu.c
+++ b/src/vcpu.c
@@ -114,16 +114,14 @@
  * Returns true if the secondary was reset and started, or false if it was
  * already on and so nothing was done.
  */
-bool vcpu_secondary_reset_and_start(struct vcpu *vcpu, ipaddr_t entry,
-				    uintreg_t arg)
+bool vcpu_secondary_reset_and_start(struct vcpu_locked vcpu_locked,
+				    ipaddr_t entry, uintreg_t arg)
 {
-	struct vcpu_locked vcpu_locked;
-	struct vm *vm = vcpu->vm;
+	struct vm *vm = vcpu_locked.vcpu->vm;
 	bool vcpu_was_off;
 
 	CHECK(vm->id != HF_PRIMARY_VM_ID);
 
-	vcpu_locked = vcpu_lock(vcpu);
 	vcpu_was_off = vcpu_is_off(vcpu_locked);
 	if (vcpu_was_off) {
 		/*
@@ -132,10 +130,9 @@
 		 * vCPU is defined as the index and does not match the ID of the
 		 * pCPU it is running on.
 		 */
-		arch_regs_reset(vcpu);
+		arch_regs_reset(vcpu_locked.vcpu);
 		vcpu_on(vcpu_locked, entry, arg);
 	}
-	vcpu_unlock(&vcpu_locked);
 
 	return vcpu_was_off;
 }
@@ -186,7 +183,7 @@
 
 void vcpu_reset(struct vcpu *vcpu)
 {
-	arch_cpu_init(vcpu->cpu, ipa_init(0));
+	arch_cpu_init(vcpu->cpu, vcpu->vm->secondary_ep);
 
 	/* Reset the registers to give a clean start for vCPU. */
 	arch_regs_reset(vcpu);