refactor: boot protocol
Set the default vCPU runtime model to RTM_SP_INIT from vcpu_init
function rather than vcpu_reset.
Remove the impdef is_bootstrapped and initialized flags from vCPU and VM
contexts. Rely on the RTM_SP_INIT state to reflect that a vCPU is
initializing rather than using the mentioned flags.
Similarly, revisit the SP boot loop to consume the vCPU state.
Add an SPMC initialized flag hinting that VM's first vCPU contexts are
booted and the SPMC is initialized. This information is no longer stored
individually within VM contexts.
Revisit conditions for FFA_MSG_WAIT, FFA_SECONDARY_EP_REGISTER,
FFA_MEM_PERM_SET/GET to rely on the vCPU RTM_SP_INIT state.
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Change-Id: I5af3b41b1f9d1121792636a37c2525d4bf22af2b
diff --git a/src/api.c b/src/api.c
index 2c6fa76..581e7bf 100644
--- a/src/api.c
+++ b/src/api.c
@@ -795,11 +795,15 @@
case VCPU_STATE_WAITING:
/*
- * An initial FFA_RUN is necessary for secondary VM/SP to reach
- * the message wait loop.
+ * An initial FFA_RUN is necessary for SP's secondary vCPUs to
+ * reach the message wait loop.
*/
- if (!vcpu->is_bootstrapped) {
- vcpu->is_bootstrapped = true;
+ if (vcpu->rt_model == RTM_SP_INIT) {
+ /*
+ * TODO: this should be removed, but omitting it makes
+ * normal world arch gicv3 tests failing.
+ */
+ vcpu->rt_model = RTM_NONE;
break;
}
@@ -3241,7 +3245,7 @@
struct vcpu *current)
{
struct vm_locked vm_locked;
- struct ffa_value ret = ffa_error(FFA_DENIED);
+ struct vcpu_locked current_locked;
/*
* Reject if interface is not supported at this FF-A instance
@@ -3264,19 +3268,21 @@
* address specified in the last valid invocation must be used by the
* callee.
*/
- vm_locked = vm_lock(current->vm);
- if (vm_locked.vm->initialized) {
- goto out;
+ current_locked = vcpu_lock(current);
+ if (current->rt_model != RTM_SP_INIT) {
+ dlog_error(
+ "FFA_SECONDARY_EP_REGISTER can only be called while "
+ "vCPU in run-time state for initialization.\n");
+ vcpu_unlock(¤t_locked);
+ return ffa_error(FFA_DENIED);
}
+ vcpu_unlock(¤t_locked);
+ vm_locked = vm_lock(current->vm);
vm_locked.vm->secondary_ep = entry_point;
-
- ret = (struct ffa_value){.func = FFA_SUCCESS_32};
-
-out:
vm_unlock(&vm_locked);
- return ret;
+ return (struct ffa_value){.func = FFA_SUCCESS_32};
}
struct ffa_value api_ffa_notification_bitmap_create(ffa_vm_id_t vm_id,