Using new-style return values for spci_yield.
Bug: 132395846
Change-Id: I6af4343c3f84e90e1fee608988585e9eaf2ee6d4
diff --git a/inc/hf/api.h b/inc/hf/api.h
index 7dcdad3..cc45a05 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -57,7 +57,7 @@
spci_return_t api_spci_msg_send(uint32_t attributes, struct vcpu *current,
struct vcpu **next);
int32_t api_spci_msg_recv(bool block, struct vcpu *current, struct vcpu **next);
-int32_t api_spci_yield(struct vcpu *current, struct vcpu **next);
+void api_yield(struct vcpu *current, struct vcpu **next);
struct spci_value api_spci_version(void);
spci_return_t api_spci_share_memory(struct vm_locked to_locked,
struct vm_locked from_locked,
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index 56bf012..b99f15b 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -89,9 +89,9 @@
* Hints that the vcpu is willing to yield its current use of the physical CPU.
* This call always returns SPCI_SUCCESS.
*/
-static inline int64_t spci_yield(void)
+static inline struct spci_value spci_yield(void)
{
- return hf_call(SPCI_YIELD_32, 0, 0, 0);
+ return spci_call((struct spci_value){.func = SPCI_YIELD_32});
}
/**
diff --git a/src/api.c b/src/api.c
index a605ac4..b803cf5 100644
--- a/src/api.c
+++ b/src/api.c
@@ -149,23 +149,20 @@
/**
* 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. This SPCI function always returns SPCI_SUCCESS.
+ * ready to be scheduled again.
*/
-int32_t api_spci_yield(struct vcpu *current, struct vcpu **next)
+void api_yield(struct vcpu *current, struct vcpu **next)
{
- struct hf_vcpu_run_return ret = {
+ struct hf_vcpu_run_return primary_ret = {
.code = HF_VCPU_RUN_YIELD,
};
if (current->vm->id == HF_PRIMARY_VM_ID) {
/* Noop on the primary as it makes the scheduling decisions. */
- return SPCI_SUCCESS;
+ return;
}
- *next = api_switch_to_primary(current, ret, VCPU_STATE_READY);
-
- /* SPCI_YIELD always returns SPCI_SUCCESS. */
- return SPCI_SUCCESS;
+ *next = api_switch_to_primary(current, primary_ret, VCPU_STATE_READY);
}
/**
diff --git a/src/arch/aarch64/hypervisor/handler.c b/src/arch/aarch64/hypervisor/handler.c
index 154610a..440cd66 100644
--- a/src/arch/aarch64/hypervisor/handler.c
+++ b/src/arch/aarch64/hypervisor/handler.c
@@ -310,7 +310,11 @@
*args = api_spci_version();
return true;
case SPCI_YIELD_32:
- args->func = api_spci_yield(current(), next);
+ api_yield(current(), next);
+
+ /* SPCI_YIELD always returns SPCI_SUCCESS. */
+ *args = (struct spci_value){.func = SPCI_SUCCESS_32};
+
return true;
case SPCI_MSG_SEND_32:
args->func = api_spci_msg_send(args->arg1, current(), next);
@@ -552,7 +556,7 @@
* TODO: consider giving the scheduler more context,
* somehow.
*/
- api_spci_yield(vcpu, &new_vcpu);
+ api_yield(vcpu, &new_vcpu);
return new_vcpu;
}
/* WFI */
diff --git a/test/vmapi/primary_only/primary_only.c b/test/vmapi/primary_only/primary_only.c
index 3ed4186..45fce1d 100644
--- a/test/vmapi/primary_only/primary_only.c
+++ b/test/vmapi/primary_only/primary_only.c
@@ -111,7 +111,7 @@
*/
TEST(spci_yield, yield_is_noop_for_primary)
{
- EXPECT_EQ(spci_yield(), SPCI_SUCCESS);
+ EXPECT_EQ(spci_yield().func, SPCI_SUCCESS_32);
}
/**
diff --git a/test/vmapi/primary_with_secondaries/services/floating_point.c b/test/vmapi/primary_with_secondaries/services/floating_point.c
index e535a6a..a1ccbb7 100644
--- a/test/vmapi/primary_with_secondaries/services/floating_point.c
+++ b/test/vmapi/primary_with_secondaries/services/floating_point.c
@@ -28,7 +28,7 @@
{
const double value = 0.75;
fill_fp_registers(value);
- EXPECT_EQ(spci_yield(), SPCI_SUCCESS);
+ EXPECT_EQ(spci_yield().func, SPCI_SUCCESS_32);
ASSERT_TRUE(check_fp_register(value));
spci_yield();
@@ -38,7 +38,7 @@
{
uintreg_t value = 3 << 22; /* Set RMode to RZ */
write_msr(fpcr, value);
- EXPECT_EQ(spci_yield(), SPCI_SUCCESS);
+ EXPECT_EQ(spci_yield().func, SPCI_SUCCESS_32);
ASSERT_EQ(read_msr(fpcr), value);
spci_yield();
diff --git a/test/vmapi/primary_with_secondaries/services/memory.c b/test/vmapi/primary_with_secondaries/services/memory.c
index fbd7cb1..8e4dc6f 100644
--- a/test/vmapi/primary_with_secondaries/services/memory.c
+++ b/test/vmapi/primary_with_secondaries/services/memory.c
@@ -43,7 +43,7 @@
}
/* Allow the memory to be populated. */
- EXPECT_EQ(spci_yield(), SPCI_SUCCESS);
+ EXPECT_EQ(spci_yield().func, SPCI_SUCCESS_32);
/* Increment each byte of memory. */
for (i = 0; i < PAGE_SIZE; ++i) {