Have vm_secondary_start_vcpu take vcpu rather than index.
This simplifies it, and the caller already has to check the index.
There's also no need to check whether the VM is the primary, as we
already assume it is a secondary anyway.
Change-Id: I0edd2a273fef3d4098e7c45ac7a1e81d1416844b
diff --git a/src/cpu.c b/src/cpu.c
index 56d76a4..2c7bef2 100644
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -181,6 +181,27 @@
}
/**
+ * Starts a vCPU of a secondary VM.
+ */
+void vcpu_secondary_reset_and_start(struct vcpu *vcpu, ipaddr_t entry,
+ uintreg_t arg)
+{
+ struct vm *vm = vcpu->vm;
+
+ assert(vm->id != HF_PRIMARY_VM_ID);
+
+ /*
+ * 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, false, vm->id, vcpu_index(vcpu),
+ vm->ptable.root);
+ vcpu_on(vcpu, entry, arg);
+}
+
+/**
* Handles a page fault. It does so by determining if it's a legitimate or
* spurious fault, and recovering from the latter.
*