SPCI: Introduce SPCI_MSG_SEND.
Morph the vmapi service HF_MAILBOX_SEND onto SPCI_MSG_SEND.
The current SPCI_MSG_SEND only allows for implementation defined
messages to be exchanged between VMs.
The new SPCI service returns SPCI_SUCCESS if message is delivered or one
of the following error codes:
SPCI_INVALID_PARAMETER: one of the parameters in the header does
not conform;
SPCI_BUSY: the mailbox was full or the target VM does not exist.
Adapted the tests to this new service.
Added tests specific to spci_message_init and spci_msg_send.
Change-Id: I55adfe68502ddc7bf864432f3e567b6cfe785f92
diff --git a/test/hftest/hftest_service.c b/test/hftest/hftest_service.c
index 9850a07..2a1b2a0 100644
--- a/test/hftest/hftest_service.c
+++ b/test/hftest/hftest_service.c
@@ -20,6 +20,7 @@
#include "hf/arch/std.h"
#include "hf/memiter.h"
+#include "hf/spci.h"
#include "vmapi/hf/call.h"
@@ -80,17 +81,18 @@
{
struct memiter args;
hftest_test_fn service;
- struct hf_mailbox_receive_return res;
struct hftest_context *ctx;
+ struct spci_message *recv_msg = (struct spci_message *)recv;
+
/* Prepare the context. */
/* Set up the mailbox. */
hf_vm_configure(send_addr, recv_addr);
/* Receive the name of the service to run. */
- res = hf_mailbox_receive(true);
- memiter_init(&args, recv, res.size);
+ hf_mailbox_receive(true);
+ memiter_init(&args, recv_msg->payload, recv_msg->length);
service = find_service(&args);
hf_mailbox_clear();
@@ -108,8 +110,8 @@
ctx = hftest_get_context();
memset(ctx, 0, sizeof(*ctx));
ctx->abort = abort;
- ctx->send = send;
- ctx->recv = recv;
+ ctx->send = (struct spci_message *)send;
+ ctx->recv = (struct spci_message *)recv;
/* Pause so the next time cycles are given the service will be run. */
hf_vcpu_yield();
diff --git a/test/hftest/inc/hftest_impl.h b/test/hftest/inc/hftest_impl.h
index 5778b20..328f664 100644
--- a/test/hftest/inc/hftest_impl.h
+++ b/test/hftest/inc/hftest_impl.h
@@ -20,6 +20,8 @@
#include "hf/arch/std.h"
+#include "hf/spci.h"
+
#define HFTEST_MAX_TESTS 50
/*
@@ -133,8 +135,8 @@
noreturn void (*abort)(void);
/* These are used in services. */
- void *send;
- void *recv;
+ struct spci_message *send;
+ struct spci_message *recv;
};
struct hftest_context *hftest_get_context(void);
@@ -271,6 +273,7 @@
#define HFTEST_SERVICE_SELECT(vm_id, service, send_buffer) \
do { \
struct hf_vcpu_run_return run_res; \
+ uint32_t msg_length = strlen(service); \
\
/* \
* Let the service configure its mailbox and wait for a \
@@ -281,8 +284,11 @@
ASSERT_EQ(run_res.sleep.ns, HF_SLEEP_INDEFINITE); \
\
/* Send the selected service to run and let it be handled. */ \
- memcpy(send_buffer, service, strlen(service)); \
- ASSERT_EQ(hf_mailbox_send(vm_id, strlen(service), false), 0); \
+ memcpy(send_buffer->payload, service, msg_length); \
+ spci_message_init(send_buffer, msg_length, vm_id, \
+ hf_vm_get_id()); \
+ \
+ ASSERT_EQ(spci_msg_send(0), 0); \
run_res = hf_vcpu_run(vm_id, 0); \
ASSERT_EQ(run_res.code, HF_VCPU_RUN_YIELD); \
} while (0)