SPCI: SPCI_YIELD.
Adapted hf_vcpu_yield to conform with the spci_yield specification.
Change-Id: I7ad11e83f068a09a19fd930dcead787b5a22e498
diff --git a/src/api.c b/src/api.c
index 60954c3..ecc45b3 100644
--- a/src/api.c
+++ b/src/api.c
@@ -128,9 +128,9 @@
/**
* Returns to the primary vm to allow this cpu to be used for other tasks as the
* vcpu does not have work to do at this moment. The current vcpu is marked as
- * ready to be scheduled again.
+ * ready to be scheduled again. This SPCI function always returns SPCI_SUCCESS.
*/
-struct vcpu *api_yield(struct vcpu *current)
+int32_t api_spci_yield(struct vcpu *current, struct vcpu **next)
{
struct hf_vcpu_run_return ret = {
.code = HF_VCPU_RUN_YIELD,
@@ -138,10 +138,13 @@
if (current->vm->id == HF_PRIMARY_VM_ID) {
/* Noop on the primary as it makes the scheduling decisions. */
- return NULL;
+ return SPCI_SUCCESS;
}
- return api_switch_to_primary(current, ret, VCPU_STATE_READY);
+ *next = api_switch_to_primary(current, ret, VCPU_STATE_READY);
+
+ /* SPCI_YIELD always returns SPCI_SUCCESS. */
+ return SPCI_SUCCESS;
}
/**
diff --git a/src/arch/aarch64/handler.c b/src/arch/aarch64/handler.c
index 7aa3a3e..9402fe5 100644
--- a/src/arch/aarch64/handler.c
+++ b/src/arch/aarch64/handler.c
@@ -410,9 +410,8 @@
api_vcpu_run(arg1, arg2, current(), &ret.new));
break;
- case HF_VCPU_YIELD:
- ret.user_ret = 0;
- ret.new = api_yield(current());
+ case SPCI_YIELD_32:
+ ret.user_ret = api_spci_yield(current(), &ret.new);
break;
case HF_VM_CONFIGURE:
@@ -544,6 +543,7 @@
{
struct vcpu *vcpu = current();
struct vcpu_fault_info info;
+ struct vcpu *new_vcpu;
switch (esr >> 26) {
case 0x01: /* EC = 000001, WFI or WFE. */
@@ -556,7 +556,8 @@
* TODO: consider giving the scheduler more context,
* somehow.
*/
- return api_yield(vcpu);
+ api_spci_yield(vcpu, &new_vcpu);
+ return new_vcpu;
}
/* WFI */
return api_wait_for_interrupt(vcpu);