Call spci_run directly in tests rather than hf_vcpu_run.
Re-submitted after fixing timer race condition which was causing
intermittent test failures.
Bug: 141469322
Change-Id: Icfd823b977933f12b6a9d3970820438513465122
diff --git a/test/vmapi/primary_with_secondaries/abort.c b/test/vmapi/primary_with_secondaries/abort.c
index ce7f778..5337d18 100644
--- a/test/vmapi/primary_with_secondaries/abort.c
+++ b/test/vmapi/primary_with_secondaries/abort.c
@@ -25,13 +25,13 @@
*/
TEST(abort, data_abort)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "data_abort", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -39,13 +39,13 @@
*/
TEST(abort, straddling_data_abort)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "straddling_data_abort", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -53,13 +53,13 @@
*/
TEST(abort, instruction_abort)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "instruction_abort", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -67,11 +67,11 @@
*/
TEST(abort, straddling_instruction_abort)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "straddling_instruction_abort", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
diff --git a/test/vmapi/primary_with_secondaries/boot.c b/test/vmapi/primary_with_secondaries/boot.c
index d6aa553..a793d28 100644
--- a/test/vmapi/primary_with_secondaries/boot.c
+++ b/test/vmapi/primary_with_secondaries/boot.c
@@ -27,13 +27,13 @@
*/
TEST(boot, memory_size)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "boot_memory", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}
/**
@@ -41,13 +41,13 @@
*/
TEST(boot, beyond_memory_size)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "boot_memory_overrun", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -55,11 +55,11 @@
*/
TEST(boot, memory_before_image)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "boot_memory_underrun", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
diff --git a/test/vmapi/primary_with_secondaries/debug_el1.c b/test/vmapi/primary_with_secondaries/debug_el1.c
index 74d2647..5f826c8 100644
--- a/test/vmapi/primary_with_secondaries/debug_el1.c
+++ b/test/vmapi/primary_with_secondaries/debug_el1.c
@@ -33,57 +33,57 @@
TEST(debug_el1, secondary_mdccint_el1)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "debug_el1_secondary_mdccint_el1", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
TEST(debug_el1, secondary_dbgbcr0_el1)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "debug_el1_secondary_dbgbcr0_el1", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
TEST(debug_el1, secondary_dbgbvr0_el1)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "debug_el1_secondary_dbgbvr0_el1", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
TEST(debug_el1, secondary_dbgwcr0_el1)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "debug_el1_secondary_dbgwcr0_el1", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
TEST(debug_el1, secondary_dbgwvr0_el1)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "debug_el1_secondary_dbgwvr0_el1", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
diff --git a/test/vmapi/primary_with_secondaries/floating_point.c b/test/vmapi/primary_with_secondaries/floating_point.c
index a480a8b..23660ce 100644
--- a/test/vmapi/primary_with_secondaries/floating_point.c
+++ b/test/vmapi/primary_with_secondaries/floating_point.c
@@ -35,18 +35,18 @@
{
const double first = 1.2;
const double second = -2.3;
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
fill_fp_registers(first);
SERVICE_SELECT(SERVICE_VM0, "fp_fill", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
EXPECT_EQ(check_fp_register(first), true);
fill_fp_registers(second);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
EXPECT_EQ(check_fp_register(second), true);
}
@@ -57,17 +57,17 @@
TEST(floating_point, fp_fpcr)
{
uintreg_t value = 0;
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
EXPECT_EQ(read_msr(fpcr), value);
SERVICE_SELECT(SERVICE_VM0, "fp_fpcr", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
EXPECT_EQ(read_msr(fpcr), value);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
EXPECT_EQ(read_msr(fpcr), value);
}
diff --git a/test/vmapi/primary_with_secondaries/interrupts.c b/test/vmapi/primary_with_secondaries/interrupts.c
index 31db0b0..dfd6b20 100644
--- a/test/vmapi/primary_with_secondaries/interrupts.c
+++ b/test/vmapi/primary_with_secondaries/interrupts.c
@@ -32,14 +32,14 @@
{
const char message[] = "Ping";
const char expected_response[] = "Got IRQ 05.";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "interruptible", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Set the message, echo it and wait for a response. */
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
@@ -47,9 +47,9 @@
spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(expected_response));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
EXPECT_EQ(hf_mailbox_clear(), 0);
@@ -63,29 +63,29 @@
TEST(interrupts, inject_interrupt_twice)
{
const char expected_response[] = "Got IRQ 07.";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "interruptible", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Inject the interrupt and wait for a message. */
hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(expected_response));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
EXPECT_EQ(hf_mailbox_clear(), 0);
/* Inject the interrupt again, and wait for the same message. */
hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(expected_response));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
EXPECT_EQ(hf_mailbox_clear(), 0);
@@ -99,29 +99,29 @@
{
const char expected_response[] = "Got IRQ 07.";
const char expected_response_2[] = "Got IRQ 08.";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "interruptible", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Inject the interrupt and wait for a message. */
hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(expected_response));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
EXPECT_EQ(hf_mailbox_clear(), 0);
/* Inject a different interrupt and wait for a different message. */
hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_B);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(expected_response_2));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response_2));
EXPECT_EQ(memcmp(mb.recv, expected_response_2,
sizeof(expected_response_2)),
0);
@@ -138,27 +138,27 @@
const char expected_response[] = "Got IRQ 07.";
const char message[] = "Ping";
const char expected_response_2[] = "Got IRQ 05.";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "interruptible", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Inject the interrupt and wait for a message. */
hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(expected_response));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
EXPECT_EQ(hf_mailbox_clear(), 0);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Now send a message to the secondary. */
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
@@ -166,9 +166,9 @@
spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(expected_response_2));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response_2));
EXPECT_EQ(memcmp(mb.recv, expected_response_2,
sizeof(expected_response_2)),
0);
@@ -184,16 +184,16 @@
{
const char expected_response[] = "Got IRQ 09.";
const char message[] = "Enable interrupt C";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "interruptible", mb.send);
/* Inject the interrupt and expect not to get a message. */
hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_C);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/*
* Now send a message to the secondary to enable the interrupt ID, and
@@ -204,9 +204,9 @@
spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(expected_response));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
EXPECT_EQ(hf_mailbox_clear(), 0);
@@ -220,7 +220,7 @@
TEST(interrupts, pending_interrupt_no_blocking_receive)
{
const char expected_response[] = "Done waiting";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "receive_block", mb.send);
@@ -231,9 +231,9 @@
* back after failing to receive a message a few times.
*/
hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(expected_response));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
EXPECT_EQ(hf_mailbox_clear(), 0);
@@ -247,7 +247,7 @@
TEST(interrupts, pending_interrupt_wfi_not_trapped)
{
const char expected_response[] = "Done waiting";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "wfi", mb.send);
@@ -258,9 +258,9 @@
* back after running WFI a few times.
*/
hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(expected_response));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response));
EXPECT_EQ(memcmp(mb.recv, expected_response, sizeof(expected_response)),
0);
EXPECT_EQ(hf_mailbox_clear(), 0);
@@ -273,14 +273,14 @@
TEST(interrupts, deliver_interrupt_and_message)
{
const char message[] = "I\'ll see you again.";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "interruptible_echo", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
EXPECT_EQ(
@@ -288,9 +288,9 @@
.func,
SPCI_SUCCESS_32);
hf_interrupt_inject(SERVICE_VM0, 0, EXTERNAL_INTERRUPT_ID_A);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(message));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
EXPECT_EQ(hf_mailbox_clear(), 0);
}
diff --git a/test/vmapi/primary_with_secondaries/mailbox.c b/test/vmapi/primary_with_secondaries/mailbox.c
index 934f741..9593dc7 100644
--- a/test/vmapi/primary_with_secondaries/mailbox.c
+++ b/test/vmapi/primary_with_secondaries/mailbox.c
@@ -79,14 +79,14 @@
TEST(mailbox, echo)
{
const char message[] = "Echo this back to me!";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "echo", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Set the message, echo it and check it didn't change. */
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
@@ -94,10 +94,10 @@
spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(message));
- EXPECT_EQ(memcmp(mb.send, message, sizeof(message)), 0);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
+ EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
EXPECT_EQ(hf_mailbox_clear(), 0);
}
@@ -107,7 +107,7 @@
TEST(mailbox, repeated_echo)
{
char message[] = "Echo this back to me!";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
uint8_t i;
struct mailbox_buffers mb = set_up_mailbox();
@@ -115,9 +115,9 @@
for (i = 0; i < 100; i++) {
/* Run secondary until it reaches the wait for messages. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Set the message, echo it and check it didn't change. */
next_permutation(message, sizeof(message) - 1);
@@ -127,9 +127,9 @@
sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(message));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
EXPECT_EQ(hf_mailbox_clear(), 0);
}
@@ -142,18 +142,18 @@
TEST(mailbox, relay)
{
const char message[] = "Send this round the relay!";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "relay", mb.send);
SERVICE_SELECT(SERVICE_VM1, "relay", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
- run_res = hf_vcpu_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/*
* Build the message chain so the message is sent from here to
@@ -176,18 +176,18 @@
}
/* Let SERVICE_VM0 forward the message. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.vm_id, SERVICE_VM1);
- EXPECT_EQ(run_res.message.size, 0);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_receiver(run_res), SERVICE_VM1);
+ EXPECT_EQ(spci_msg_send_size(run_res), 0);
/* Let SERVICE_VM1 forward the message. */
- run_res = hf_vcpu_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Ensure the message is intact. */
- EXPECT_EQ(run_res.message.vm_id, HF_PRIMARY_VM_ID);
- EXPECT_EQ(run_res.message.size, sizeof(message));
+ EXPECT_EQ(spci_msg_send_receiver(run_res), HF_PRIMARY_VM_ID);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
EXPECT_EQ(hf_mailbox_clear(), 0);
}
@@ -198,15 +198,16 @@
*/
TEST(mailbox, no_primary_to_secondary_notification_on_configure)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
+
set_up_mailbox();
EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, 0, 0),
SPCI_BUSY);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, 0, 0).func,
SPCI_SUCCESS_32);
@@ -218,7 +219,8 @@
*/
TEST(mailbox, secondary_to_primary_notification_on_configure)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
+
set_up_mailbox();
EXPECT_SPCI_ERROR(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, 0,
@@ -229,8 +231,8 @@
* Run first VM for it to configure itself. It should result in
* notifications having to be issued.
*/
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_NOTIFY_WAITERS);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_RX_RELEASE_32);
/* A single waiter is returned. */
EXPECT_EQ(hf_mailbox_waiter_get(SERVICE_VM0), HF_PRIMARY_VM_ID);
@@ -249,14 +251,14 @@
TEST(mailbox, primary_to_secondary)
{
char message[] = "not ready echo";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "echo_with_notification", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Send a message to echo service, and get response back. */
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
@@ -264,15 +266,15 @@
spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(message));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
/* Let secondary VM continue running so that it will wait again. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Without clearing our mailbox, send message again. */
reverse(message, strnlen_s(message, sizeof(message)));
@@ -283,9 +285,9 @@
spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, sizeof(message), 0)
.func,
SPCI_SUCCESS_32);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_INTERRUPT);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, HF_SPCI_RUN_WAIT_FOR_INTERRUPT);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Clear the mailbox. We expect to be told there are pending waiters. */
EXPECT_EQ(hf_mailbox_clear(), 1);
@@ -301,9 +303,9 @@
EXPECT_EQ(
hf_interrupt_inject(SERVICE_VM0, 0, HF_MAILBOX_WRITABLE_INTID),
1);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(message));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
}
@@ -315,14 +317,14 @@
TEST(mailbox, secondary_to_primary_notification)
{
const char message[] = "not ready echo";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "echo_with_notification", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
/* Send a message to echo service twice. The second should fail. */
memcpy_s(mb.send, SPCI_MSG_PAYLOAD_MAX, message, sizeof(message));
@@ -335,14 +337,14 @@
SPCI_BUSY);
/* Receive a reply for the first message. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(message));
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(message));
EXPECT_EQ(memcmp(mb.recv, message, sizeof(message)), 0);
/* Run VM again so that it clears its mailbox. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_NOTIFY_WAITERS);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_RX_RELEASE_32);
/* Retrieve a single waiter. */
EXPECT_EQ(hf_mailbox_waiter_get(SERVICE_VM0), HF_PRIMARY_VM_ID);
diff --git a/test/vmapi/primary_with_secondaries/memory_sharing.c b/test/vmapi/primary_with_secondaries/memory_sharing.c
index 76d0739..745bd8b 100644
--- a/test/vmapi/primary_with_secondaries/memory_sharing.c
+++ b/test/vmapi/primary_with_secondaries/memory_sharing.c
@@ -286,7 +286,7 @@
*/
TEST(memory_sharing, concurrent)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
@@ -307,15 +307,15 @@
.func,
SPCI_SUCCESS_32);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
for (int i = 0; i < PAGE_SIZE; ++i) {
page[i] = i;
}
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
for (int i = 0; i < PAGE_SIZE; ++i) {
uint8_t value = i + 1;
@@ -329,7 +329,7 @@
*/
TEST(memory_sharing, share_concurrently_and_get_back)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
@@ -352,15 +352,15 @@
SPCI_SUCCESS_32);
/* Let the memory be returned. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
for (int i = 0; i < PAGE_SIZE; ++i) {
ASSERT_EQ(ptr[i], 0);
}
/* Observe the service faulting when accessing the memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -387,7 +387,7 @@
*/
TEST(memory_sharing, spci_give_and_get_back)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -411,10 +411,10 @@
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM0, 0);
/* Let the memory be returned. */
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Ensure that the secondary VM accessed the region. */
for (int i = 0; i < PAGE_SIZE; ++i) {
@@ -422,8 +422,8 @@
}
/* Observe the service faulting when accessing the memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -431,7 +431,7 @@
*/
TEST(memory_sharing, spci_lend_relinquish)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -454,10 +454,10 @@
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM0, 0);
/* Let the memory be returned. */
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Ensure that the secondary VM accessed the region. */
for (int i = 0; i < PAGE_SIZE; ++i) {
@@ -465,8 +465,8 @@
}
/* Observe the service faulting when accessing the memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -474,7 +474,7 @@
*/
TEST(memory_sharing, give_and_get_back)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
@@ -497,15 +497,15 @@
SPCI_SUCCESS_32);
/* Let the memory be returned. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
for (int i = 0; i < PAGE_SIZE; ++i) {
ASSERT_EQ(ptr[i], 0);
}
/* Observe the service faulting when accessing the memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -513,7 +513,7 @@
*/
TEST(memory_sharing, lend_and_get_back)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
@@ -536,15 +536,15 @@
SPCI_SUCCESS_32);
/* Let the memory be returned. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
for (int i = 0; i < PAGE_SIZE; ++i) {
ASSERT_EQ(ptr[i], 0);
}
/* Observe the service faulting when accessing the memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -552,7 +552,7 @@
*/
TEST(memory_sharing, reshare_after_return)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
@@ -574,8 +574,8 @@
SPCI_SUCCESS_32);
/* Let the memory be returned. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Share the memory again after it has been returned. */
ASSERT_EQ(hf_share_memory(SERVICE_VM0, (hf_ipaddr_t)&page, PAGE_SIZE,
@@ -583,9 +583,9 @@
0);
/* Observe the service doesn't fault when accessing the memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
}
/**
@@ -593,7 +593,7 @@
*/
TEST(memory_sharing, share_elsewhere_after_return)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
@@ -615,8 +615,8 @@
SPCI_SUCCESS_32);
/* Let the memory be returned. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Share the memory with a differnt VM after it has been returned. */
ASSERT_EQ(hf_share_memory(SERVICE_VM1, (hf_ipaddr_t)&page, PAGE_SIZE,
@@ -624,8 +624,8 @@
0);
/* Observe the service faulting when accessing the memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -633,15 +633,15 @@
*/
TEST(memory_sharing, give_memory_and_lose_access)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr;
SERVICE_SELECT(SERVICE_VM0, "give_memory_and_fault", mb.send);
/* Have the memory be given. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Check the memory was cleared. */
ptr = *(uint8_t **)mb.recv;
@@ -650,8 +650,8 @@
}
/* Observe the service fault when it tries to access it. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -659,15 +659,15 @@
*/
TEST(memory_sharing, lend_memory_and_lose_access)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr;
SERVICE_SELECT(SERVICE_VM0, "lend_memory_and_fault", mb.send);
/* Have the memory be lent. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Check the memory was cleared. */
ptr = *(uint8_t **)mb.recv;
@@ -676,8 +676,8 @@
}
/* Observe the service fault when it tries to access it. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -685,7 +685,7 @@
*/
TEST(memory_sharing, spci_donate_check_upper_bounds)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -709,8 +709,8 @@
SPCI_SUCCESS_32);
/* Observe the service faulting when accessing the memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -718,7 +718,7 @@
*/
TEST(memory_sharing, spci_donate_check_lower_bounds)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -742,8 +742,8 @@
SPCI_SUCCESS_32);
/* Observe the service faulting when accessing the memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -752,7 +752,7 @@
*/
TEST(memory_sharing, spci_donate_elsewhere_after_return)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -776,10 +776,10 @@
SPCI_MSG_SEND_LEGACY_MEMORY)
.func,
SPCI_SUCCESS_32);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
+ run_res = spci_run(SERVICE_VM0, 0);
/* Let the memory be returned. */
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Share the memory with another VM. */
msg_size = spci_memory_donate_init(
@@ -792,8 +792,8 @@
SPCI_SUCCESS_32);
/* Observe the original service faulting when accessing the memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -802,7 +802,7 @@
*/
TEST(memory_sharing, spci_donate_vms)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -818,8 +818,8 @@
};
/* Set up VM1 to wait for message. */
- run_res = hf_vcpu_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_MESSAGE);
+ run_res = spci_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_WAIT_32);
/* Donate memory. */
msg_size = spci_memory_donate_init(
@@ -832,20 +832,20 @@
SPCI_SUCCESS_32);
/* Let the memory be sent from VM0 to VM1. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Receive memory in VM1. */
- run_res = hf_vcpu_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Try to access memory in VM0 and fail. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
/* Ensure that memory in VM1 remains the same. */
- run_res = hf_vcpu_run(SERVICE_VM1, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM1, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}
/**
@@ -853,7 +853,7 @@
*/
TEST(memory_sharing, spci_donate_twice)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -879,8 +879,8 @@
SPCI_SUCCESS_32);
/* Let the memory be received. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Fail to share memory again with any VM. */
spci_check_cannot_donate_memory(mb, constituents, 1, -1);
@@ -888,15 +888,15 @@
spci_check_cannot_relinquish_memory(mb, constituents, 1);
/* Let the memory be sent from VM0 to PRIMARY (returned). */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Check we have access again. */
ptr[0] = 'f';
/* Try and fail to donate memory from VM0 to VM1. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}
/**
@@ -977,7 +977,7 @@
*/
TEST(memory_sharing, spci_donate_invalid_source)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -1027,12 +1027,12 @@
SPCI_SUCCESS_32);
/* Receive and return memory from VM0. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Use VM0 to fail to donate memory from the primary to VM1. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}
/**
@@ -1074,7 +1074,7 @@
*/
TEST(memory_sharing, spci_lend_invalid_source)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -1107,12 +1107,12 @@
SPCI_SUCCESS_32);
/* Receive and return memory from VM0. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Try to lend memory from primary in VM0. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}
/**
@@ -1121,7 +1121,7 @@
*/
TEST(memory_sharing, spci_lend_relinquish_X_RW)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -1146,12 +1146,12 @@
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Let service write to and return memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Re-initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
@@ -1167,12 +1167,12 @@
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Observe the service faulting when writing to the memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -1181,7 +1181,7 @@
*/
TEST(memory_sharing, spci_share_relinquish_X_RW)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -1206,8 +1206,8 @@
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Ensure we still have access. */
for (int i = 0; i < PAGE_SIZE; ++i) {
@@ -1216,8 +1216,8 @@
}
/* Let service write to and return memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Re-initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
@@ -1233,8 +1233,8 @@
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Ensure we still have access. */
for (int i = 0; i < PAGE_SIZE; ++i) {
@@ -1243,8 +1243,8 @@
}
/* Observe the service faulting when writing to the memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -1253,7 +1253,7 @@
*/
TEST(memory_sharing, spci_share_relinquish_NX_RW)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -1278,8 +1278,8 @@
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Ensure we still have access. */
for (int i = 0; i < PAGE_SIZE; ++i) {
@@ -1287,8 +1287,8 @@
}
/* Let service write to and return memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
/* Re-initialise the memory before giving it. */
memset_s(ptr, sizeof(page), 'b', PAGE_SIZE);
@@ -1304,8 +1304,8 @@
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Ensure we still have access. */
for (int i = 0; i < PAGE_SIZE; ++i) {
@@ -1314,8 +1314,8 @@
}
/* Observe the service faulting when writing to the memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -1323,7 +1323,7 @@
*/
TEST(memory_sharing, spci_lend_relinquish_RW_X)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -1351,8 +1351,8 @@
SPCI_SUCCESS_32);
/* Attempt to execute from memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
msg_size = spci_memory_lend_init(
mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RW_NX,
@@ -1364,8 +1364,8 @@
SPCI_SUCCESS_32);
/* Try and fail to execute from the memory region. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -1373,7 +1373,7 @@
*/
TEST(memory_sharing, spci_lend_relinquish_RO_X)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -1401,8 +1401,8 @@
SPCI_SUCCESS_32);
/* Attempt to execute from memory. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
msg_size = spci_memory_lend_init(
mb.send, SERVICE_VM0, constituents, 1, 0, SPCI_MEMORY_RO_NX,
@@ -1414,8 +1414,8 @@
SPCI_SUCCESS_32);
/* Try and fail to execute from the memory region. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
@@ -1423,7 +1423,7 @@
*/
TEST(memory_sharing, spci_lend_donate)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -1449,8 +1449,8 @@
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Ensure we can't donate any sub section of memory to another VM. */
constituents[0].page_count = 1;
@@ -1483,7 +1483,7 @@
*/
TEST(memory_sharing, spci_share_donate)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -1509,8 +1509,8 @@
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Ensure we can't donate any sub section of memory to another VM. */
constituents[0].page_count = 1;
@@ -1543,7 +1543,7 @@
*/
TEST(memory_sharing, spci_lend_twice)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -1569,8 +1569,8 @@
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Attempt to lend the same area of memory. */
spci_check_cannot_lend_memory(mb, constituents);
@@ -1602,7 +1602,7 @@
*/
TEST(memory_sharing, spci_share_twice)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
uint8_t *ptr = page;
uint32_t msg_size;
@@ -1628,8 +1628,8 @@
SPCI_SUCCESS_32);
/* Let the memory be accessed. */
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
/* Attempt to share the same area of memory. */
spci_check_cannot_share_memory(mb, constituents);
diff --git a/test/vmapi/primary_with_secondaries/no_services.c b/test/vmapi/primary_with_secondaries/no_services.c
index 0f60bed..9d43cd7 100644
--- a/test/vmapi/primary_with_secondaries/no_services.c
+++ b/test/vmapi/primary_with_secondaries/no_services.c
@@ -25,6 +25,7 @@
#include "hftest.h"
#include "primary_with_secondary.h"
+#include "util.h"
static alignas(PAGE_SIZE) uint8_t send_page[PAGE_SIZE];
static alignas(PAGE_SIZE) uint8_t recv_page[PAGE_SIZE];
@@ -82,31 +83,28 @@
/**
* The primary can't be run by the hypervisor.
*/
-TEST(hf_vcpu_run, cannot_run_primary)
+TEST(spci_run, cannot_run_primary)
{
- struct hf_vcpu_run_return res = hf_vcpu_run(HF_PRIMARY_VM_ID, 0);
- EXPECT_EQ(res.code, HF_VCPU_RUN_WAIT_FOR_INTERRUPT);
- EXPECT_EQ(res.sleep.ns, HF_SLEEP_INDEFINITE);
+ struct spci_value res = spci_run(HF_PRIMARY_VM_ID, 0);
+ EXPECT_SPCI_ERROR(res, SPCI_INVALID_PARAMETERS);
}
/**
* Can only run a VM that exists.
*/
-TEST(hf_vcpu_run, cannot_run_absent_secondary)
+TEST(spci_run, cannot_run_absent_secondary)
{
- struct hf_vcpu_run_return res = hf_vcpu_run(1234, 0);
- EXPECT_EQ(res.code, HF_VCPU_RUN_WAIT_FOR_INTERRUPT);
- EXPECT_EQ(res.sleep.ns, HF_SLEEP_INDEFINITE);
+ struct spci_value res = spci_run(1234, 0);
+ EXPECT_SPCI_ERROR(res, SPCI_INVALID_PARAMETERS);
}
/**
* Can only run a vcpu that exists.
*/
-TEST(hf_vcpu_run, cannot_run_absent_vcpu)
+TEST(spci_run, cannot_run_absent_vcpu)
{
- struct hf_vcpu_run_return res = hf_vcpu_run(SERVICE_VM0, 1234);
- EXPECT_EQ(res.code, HF_VCPU_RUN_WAIT_FOR_INTERRUPT);
- EXPECT_EQ(res.sleep.ns, HF_SLEEP_INDEFINITE);
+ struct spci_value res = spci_run(SERVICE_VM0, 1234);
+ EXPECT_SPCI_ERROR(res, SPCI_INVALID_PARAMETERS);
}
/**
@@ -162,7 +160,7 @@
}
/**
- * The primary receives messages from hf_vcpu_run().
+ * The primary receives messages from spci_run().
*/
TEST(hf_mailbox_receive, cannot_receive_from_primary_blocking)
{
@@ -171,7 +169,7 @@
}
/**
- * The primary receives messages from hf_vcpu_run().
+ * The primary receives messages from spci_run().
*/
TEST(hf_mailbox_receive, cannot_receive_from_primary_non_blocking)
{
diff --git a/test/vmapi/primary_with_secondaries/perfmon.c b/test/vmapi/primary_with_secondaries/perfmon.c
index 34165da..8fd0aba 100644
--- a/test/vmapi/primary_with_secondaries/perfmon.c
+++ b/test/vmapi/primary_with_secondaries/perfmon.c
@@ -30,36 +30,36 @@
TEST(perfmon, secondary_pmccfiltr_el0)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "perfmon_secondary_pmccfiltr_el0", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
TEST(perfmon, secondary_pmcr_el0)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "perfmon_secondary_pmcr_el0", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
TEST(perfmon, secondary_pmintenset_el1)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "perfmon_secondary_pmintenset_el1",
mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_ABORTED);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_SPCI_ERROR(run_res, SPCI_ABORTED);
}
/**
diff --git a/test/vmapi/primary_with_secondaries/run_race.c b/test/vmapi/primary_with_secondaries/run_race.c
index 0ef3387..3a9ffcb 100644
--- a/test/vmapi/primary_with_secondaries/run_race.c
+++ b/test/vmapi/primary_with_secondaries/run_race.c
@@ -34,19 +34,19 @@
*/
static bool run_loop(struct mailbox_buffers *mb)
{
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
bool ok = false;
for (;;) {
/* Run until it manages to schedule vCPU on this CPU. */
do {
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- } while (run_res.code == HF_VCPU_RUN_WAIT_FOR_INTERRUPT &&
- run_res.sleep.ns == HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM0, 0);
+ } while (run_res.func == HF_SPCI_RUN_WAIT_FOR_INTERRUPT &&
+ run_res.arg2 == HF_SLEEP_INDEFINITE);
/* Break out if we received a message with non-zero length. */
- if (run_res.code == HF_VCPU_RUN_MESSAGE &&
- run_res.message.size != 0) {
+ if (run_res.func == SPCI_MSG_SEND_32 &&
+ spci_msg_send_size(run_res) != 0) {
break;
}
@@ -55,7 +55,7 @@
}
/* Copies the contents of the received boolean to the return value. */
- if (run_res.message.size == sizeof(ok)) {
+ if (spci_msg_send_size(run_res) == sizeof(ok)) {
ok = *(bool *)mb->recv;
}
diff --git a/test/vmapi/primary_with_secondaries/smp.c b/test/vmapi/primary_with_secondaries/smp.c
index af5c637..5ffda15 100644
--- a/test/vmapi/primary_with_secondaries/smp.c
+++ b/test/vmapi/primary_with_secondaries/smp.c
@@ -32,22 +32,22 @@
{
const char expected_response_0[] = "vCPU 0";
const char expected_response_1[] = "vCPU 1";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM2, "smp", mb.send);
/* Let the first vCPU start the second vCPU. */
- run_res = hf_vcpu_run(SERVICE_VM2, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAKE_UP);
- EXPECT_EQ(run_res.wake_up.vm_id, SERVICE_VM2);
- EXPECT_EQ(run_res.wake_up.vcpu, 1);
+ run_res = spci_run(SERVICE_VM2, 0);
+ EXPECT_EQ(run_res.func, HF_SPCI_RUN_WAKE_UP);
+ EXPECT_EQ(wake_up_get_vm_id(run_res), SERVICE_VM2);
+ EXPECT_EQ(wake_up_get_vcpu(run_res), 1);
/* Run the second vCPU and wait for a message. */
dlog("Run second vCPU for message\n");
- run_res = hf_vcpu_run(SERVICE_VM2, 1);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(expected_response_1));
+ run_res = spci_run(SERVICE_VM2, 1);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response_1));
EXPECT_EQ(memcmp(mb.recv, expected_response_1,
sizeof(expected_response_1)),
0);
@@ -55,9 +55,9 @@
/* Run the first vCPU and wait for a different message. */
dlog("Run first vCPU for message\n");
- run_res = hf_vcpu_run(SERVICE_VM2, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_MESSAGE);
- EXPECT_EQ(run_res.message.size, sizeof(expected_response_0));
+ run_res = spci_run(SERVICE_VM2, 0);
+ EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_size(run_res), sizeof(expected_response_0));
EXPECT_EQ(memcmp(mb.recv, expected_response_0,
sizeof(expected_response_0)),
0);
@@ -65,7 +65,7 @@
/* Run the second vCPU again, and expect it to turn itself off. */
dlog("Run second vCPU for poweroff.\n");
- run_res = hf_vcpu_run(SERVICE_VM2, 1);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_WAIT_FOR_INTERRUPT);
- EXPECT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE);
+ run_res = spci_run(SERVICE_VM2, 1);
+ EXPECT_EQ(run_res.func, HF_SPCI_RUN_WAIT_FOR_INTERRUPT);
+ EXPECT_EQ(run_res.arg2, SPCI_SLEEP_INDEFINITE);
}
diff --git a/test/vmapi/primary_with_secondaries/spci.c b/test/vmapi/primary_with_secondaries/spci.c
index f551830..017b080 100644
--- a/test/vmapi/primary_with_secondaries/spci.c
+++ b/test/vmapi/primary_with_secondaries/spci.c
@@ -33,7 +33,7 @@
TEST(spci, msg_send)
{
const char message[] = "spci_msg_send";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "spci_check", mb.send);
@@ -45,8 +45,8 @@
.func,
SPCI_SUCCESS_32);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}
/**
@@ -88,7 +88,7 @@
TEST(spci, spci_incorrect_length)
{
const char message[] = "this should be truncated";
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
struct mailbox_buffers mb = set_up_mailbox();
SERVICE_SELECT(SERVICE_VM0, "spci_length", mb.send);
@@ -98,8 +98,8 @@
/* Hard code incorrect length. */
EXPECT_EQ(spci_msg_send(HF_PRIMARY_VM_ID, SERVICE_VM0, 16, 0).func,
SPCI_SUCCESS_32);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}
/**
@@ -123,10 +123,10 @@
TEST(spci, spci_recv_non_blocking)
{
struct mailbox_buffers mb = set_up_mailbox();
- struct hf_vcpu_run_return run_res;
+ struct spci_value run_res;
/* Check is performed in secondary vm. */
SERVICE_SELECT(SERVICE_VM0, "spci_recv_non_blocking", mb.send);
- run_res = hf_vcpu_run(SERVICE_VM0, 0);
- EXPECT_EQ(run_res.code, HF_VCPU_RUN_YIELD);
+ run_res = spci_run(SERVICE_VM0, 0);
+ EXPECT_EQ(run_res.func, SPCI_YIELD_32);
}