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/inc/hf/api.h b/inc/hf/api.h
index cbc521e..bfbc646 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -16,6 +16,7 @@
#include "vmapi/hf/ffa.h"
void api_init(struct mpool *ppool);
+struct vcpu *api_ffa_get_vm_vcpu(struct vm *vm, struct vcpu *current);
void api_regs_state_saved(struct vcpu *vcpu);
int64_t api_mailbox_writable_get(const struct vcpu *current);
int64_t api_mailbox_waiter_get(ffa_vm_id_t vm_id, const struct vcpu *current);
@@ -61,7 +62,7 @@
struct ffa_value api_ffa_spm_id_get(void);
struct ffa_value api_ffa_features(uint32_t function_id);
struct ffa_value api_ffa_run(ffa_vm_id_t vm_id, ffa_vcpu_index_t vcpu_idx,
- const struct vcpu *current, struct vcpu **next);
+ struct vcpu *current, struct vcpu **next);
struct ffa_value api_ffa_mem_send(uint32_t share_func, uint32_t length,
uint32_t fragment_length, ipaddr_t address,
uint32_t page_count, struct vcpu *current);
@@ -93,6 +94,9 @@
struct vcpu **next);
struct ffa_value api_ffa_secondary_ep_register(ipaddr_t entry_point,
struct vcpu *current);
+struct vcpu *api_switch_to_primary(struct vcpu *current,
+ struct ffa_value primary_ret,
+ enum vcpu_state secondary_state);
struct vcpu *api_switch_to_other_world(struct vcpu *current,
struct ffa_value other_world_ret,
enum vcpu_state vcpu_state);
diff --git a/inc/hf/arch/plat/ffa.h b/inc/hf/arch/plat/ffa.h
index 2cd51e6..2462aac 100644
--- a/inc/hf/arch/plat/ffa.h
+++ b/inc/hf/arch/plat/ffa.h
@@ -136,3 +136,9 @@
bool plat_ffa_is_mem_perm_get_valid(const struct vcpu *current);
bool plat_ffa_is_mem_perm_set_valid(const struct vcpu *current);
+
+/**
+ * Check if current SP can resume target VM/SP using FFA_RUN ABI.
+ */
+bool plat_ffa_run_checks(struct vcpu *current, ffa_vm_id_t target_vm_id,
+ struct ffa_value *run_ret, struct vcpu **next);
diff --git a/inc/hf/vcpu.h b/inc/hf/vcpu.h
index 4aacdf3..e7dd9f0 100644
--- a/inc/hf/vcpu.h
+++ b/inc/hf/vcpu.h
@@ -20,14 +20,20 @@
/** The vCPU is switched off. */
VCPU_STATE_OFF,
- /** The vCPU is ready to be run. */
- VCPU_STATE_READY,
-
/** The vCPU is currently running. */
VCPU_STATE_RUNNING,
- /** The vCPU is waiting for a message. */
- VCPU_STATE_BLOCKED_MAILBOX,
+ /** 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,
@@ -70,6 +76,7 @@
*/
enum vcpu_state state;
+ bool is_bootstrapped;
struct cpu *cpu;
struct vm *vm;
struct arch_regs regs;
@@ -94,7 +101,7 @@
*/
ffa_vm_id_t direct_request_origin_vm_id;
- /* Determine whether partition is currently handling managed exit. */
+ /** Determine whether partition is currently handling managed exit. */
bool processing_managed_exit;
};