Get the cpu IDs from the FDT.
These are the IDs used to identify cores in PSCI.
Change-Id: I9e88a6c69f963864591e39f0191cdd5ce824ce6d
diff --git a/src/vm.c b/src/vm.c
index 15e7521..b68c219 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -103,14 +103,27 @@
locked->vm = NULL;
}
-/* TODO: Shall we use index or id here? */
-void vm_start_vcpu(struct vm *vm, size_t index, ipaddr_t entry, uintreg_t arg)
+/**
+ * Starts a vCPU of a secondary VM.
+ *
+ * TODO: Shall we use index or id here?
+ */
+void vm_secondary_start_vcpu(struct vm *vm, size_t index, ipaddr_t entry,
+ uintreg_t arg)
{
struct vcpu *vcpu = &vm->vcpus[index];
- if (index < vm->vcpu_count) {
- vcpu_on(vcpu, entry, arg);
- arch_regs_reset(&vcpu->regs, vm->id == HF_PRIMARY_VM_ID, vm->id,
- vm->ptable.root, vcpu_index(vcpu));
+ if (index >= vm->vcpu_count) {
+ return;
}
+
+ /*
+ * Set vCPU registers to a clean state ready for boot. As this is a
+ * secondary which can migrate between pCPUs, the ID of the vCPU is
+ * defined as the index and does not match the ID of the pCPU it is
+ * running on.
+ */
+ arch_regs_reset(&vcpu->regs, vm->id == HF_PRIMARY_VM_ID, vm->id, index,
+ vm->ptable.root);
+ vcpu_on(vcpu, entry, arg);
}