Add new argument to hf_mailbox_send.
We don't do anything with it yet, but adding it in a separate patch
reduces the mix of functionality and refactor in the next patch.
Change-Id: I24cbd4d35c4cf9e4985a72d336a68c496c9cc2be
diff --git a/driver/linux b/driver/linux
index e75db9d..dbfc903 160000
--- a/driver/linux
+++ b/driver/linux
@@ -1 +1 @@
-Subproject commit e75db9d5030f29707901aac011bacf6ffd1f0d1b
+Subproject commit dbfc903c59ac42cee2b343b0d42dfd67097fd66f
diff --git a/inc/hf/api.h b/inc/hf/api.h
index 1bf9c92..9c86cbf 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -31,9 +31,8 @@
struct vcpu **next);
int64_t api_vm_configure(ipaddr_t send, ipaddr_t recv,
const struct vcpu *current);
-
-int64_t api_mailbox_send(uint32_t vm_id, size_t size, struct vcpu *current,
- struct vcpu **next);
+int64_t api_mailbox_send(uint32_t vm_id, size_t size, bool notify,
+ struct vcpu *current, struct vcpu **next);
struct hf_mailbox_receive_return api_mailbox_receive(bool block,
struct vcpu *current,
struct vcpu **next);
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index 6466b15..3922f7a 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -105,6 +105,9 @@
/**
* Copies data from the sender's send buffer to the recipient's receive buffer.
*
+ * If the recipient's receive buffer is busy, it can optionally register the
+ * caller to be notified when the recipient's receive buffer becomes available.
+ *
* Returns -1 on failure, and on success either:
* - 0, if the caller is a secondary VM
* - the ID of the vCPU to run to receive the message, if the caller is the
@@ -112,9 +115,9 @@
* - HF_INVALID_VCPU if the caller is the primary VM and no vCPUs on the target
* VM are currently waiting to receive a message.
*/
-static inline int64_t hf_mailbox_send(uint32_t vm_id, size_t size)
+static inline int64_t hf_mailbox_send(uint32_t vm_id, size_t size, bool notify)
{
- return hf_call(HF_MAILBOX_SEND, vm_id, size, 0);
+ return hf_call(HF_MAILBOX_SEND, vm_id, size, notify);
}
/**
diff --git a/src/api.c b/src/api.c
index 74c45c7..004122f 100644
--- a/src/api.c
+++ b/src/api.c
@@ -405,9 +405,12 @@
/**
* Copies data from the sender's send buffer to the recipient's receive buffer
* and notifies the recipient.
+ *
+ * If the recipient's receive buffer is busy, it can optionally register the
+ * caller to be notified when the recipient's receive buffer becomes available.
*/
-int64_t api_mailbox_send(uint32_t vm_id, size_t size, struct vcpu *current,
- struct vcpu **next)
+int64_t api_mailbox_send(uint32_t vm_id, size_t size, bool notify,
+ struct vcpu *current, struct vcpu **next)
{
struct vm *from = current->vm;
struct vm *to;
@@ -415,6 +418,8 @@
uint16_t vcpu;
int64_t ret;
+ (void)notify;
+
/* Limit the size of transfer. */
if (size > HF_MAILBOX_SIZE) {
return -1;
diff --git a/src/arch/aarch64/handler.c b/src/arch/aarch64/handler.c
index c43759e..a875d00 100644
--- a/src/arch/aarch64/handler.c
+++ b/src/arch/aarch64/handler.c
@@ -278,7 +278,7 @@
case HF_MAILBOX_SEND:
ret.user_ret =
- api_mailbox_send(arg1, arg2, current(), &ret.new);
+ api_mailbox_send(arg1, arg2, arg3, current(), &ret.new);
break;
case HF_MAILBOX_RECEIVE:
diff --git a/test/hftest/inc/hftest_impl.h b/test/hftest/inc/hftest_impl.h
index 3d4a44a..fa9e4c7 100644
--- a/test/hftest/inc/hftest_impl.h
+++ b/test/hftest/inc/hftest_impl.h
@@ -255,7 +255,7 @@
\
/* 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)), 0); \
+ ASSERT_EQ(hf_mailbox_send(vm_id, strlen(service), false), 0); \
run_res = hf_vcpu_run(vm_id, 0); \
ASSERT_EQ(run_res.code, HF_VCPU_RUN_YIELD); \
} while (0)
diff --git a/test/vmapi/primary_with_secondaries/services/check_state.c b/test/vmapi/primary_with_secondaries/services/check_state.c
index 402e584..10063c5 100644
--- a/test/vmapi/primary_with_secondaries/services/check_state.c
+++ b/test/vmapi/primary_with_secondaries/services/check_state.c
@@ -27,7 +27,7 @@
int64_t res;
do {
- res = hf_mailbox_send(vm_id, size);
+ res = hf_mailbox_send(vm_id, size, false);
} while (res == -1);
}
diff --git a/test/vmapi/primary_with_secondaries/services/echo.c b/test/vmapi/primary_with_secondaries/services/echo.c
index 8ec08f6..3c38f3f 100644
--- a/test/vmapi/primary_with_secondaries/services/echo.c
+++ b/test/vmapi/primary_with_secondaries/services/echo.c
@@ -27,6 +27,6 @@
struct hf_mailbox_receive_return res = hf_mailbox_receive(true);
memcpy(SERVICE_SEND_BUFFER(), SERVICE_RECV_BUFFER(), res.size);
hf_mailbox_clear();
- hf_mailbox_send(res.vm_id, res.size);
+ hf_mailbox_send(res.vm_id, res.size, false);
}
}
diff --git a/test/vmapi/primary_with_secondaries/services/interruptible.c b/test/vmapi/primary_with_secondaries/services/interruptible.c
index 879567b..b43a583 100644
--- a/test/vmapi/primary_with_secondaries/services/interruptible.c
+++ b/test/vmapi/primary_with_secondaries/services/interruptible.c
@@ -39,7 +39,7 @@
buffer[8] = '0' + interrupt_id / 10;
buffer[9] = '0' + interrupt_id % 10;
memcpy(SERVICE_SEND_BUFFER(), buffer, size);
- hf_mailbox_send(HF_PRIMARY_VM_ID, size);
+ hf_mailbox_send(HF_PRIMARY_VM_ID, size, false);
}
/**
diff --git a/test/vmapi/primary_with_secondaries/services/relay.c b/test/vmapi/primary_with_secondaries/services/relay.c
index 41cd77d..d90e029 100644
--- a/test/vmapi/primary_with_secondaries/services/relay.c
+++ b/test/vmapi/primary_with_secondaries/services/relay.c
@@ -48,6 +48,6 @@
/* Send the message to the next stage. */
memcpy(SERVICE_SEND_BUFFER(), next_message, next_message_size);
hf_mailbox_clear();
- hf_mailbox_send(next_vm_id, next_message_size);
+ hf_mailbox_send(next_vm_id, next_message_size, false);
}
}
diff --git a/test/vmapi/primary_with_secondaries/with_services.c b/test/vmapi/primary_with_secondaries/with_services.c
index 2ffa40c..a282ee4 100644
--- a/test/vmapi/primary_with_secondaries/with_services.c
+++ b/test/vmapi/primary_with_secondaries/with_services.c
@@ -77,7 +77,7 @@
/* Set the message, echo it and check it didn't change. */
memcpy(mb.send, message, sizeof(message));
- EXPECT_EQ(hf_mailbox_send(SERVICE_VM0, sizeof(message)), 0);
+ EXPECT_EQ(hf_mailbox_send(SERVICE_VM0, sizeof(message), false), 0);
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));
@@ -105,7 +105,8 @@
/* Set the message, echo it and check it didn't change. */
next_permutation(message, sizeof(message) - 1);
memcpy(mb.send, message, sizeof(message));
- EXPECT_EQ(hf_mailbox_send(SERVICE_VM0, sizeof(message)), 0);
+ EXPECT_EQ(hf_mailbox_send(SERVICE_VM0, sizeof(message), false),
+ 0);
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));
@@ -143,7 +144,8 @@
memcpy(chain, message, sizeof(message));
EXPECT_EQ(hf_mailbox_send(
SERVICE_VM0,
- sizeof(message) + (2 * sizeof(uint32_t))),
+ sizeof(message) + (2 * sizeof(uint32_t)),
+ false),
0);
}
@@ -181,7 +183,7 @@
/* Set the message, echo it and wait for a response. */
memcpy(mb.send, message, sizeof(message));
- EXPECT_EQ(hf_mailbox_send(SERVICE_VM0, sizeof(message)), 0);
+ EXPECT_EQ(hf_mailbox_send(SERVICE_VM0, sizeof(message), false), 0);
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));
@@ -293,7 +295,7 @@
/* Now send a message to the secondary. */
memcpy(mb.send, message, sizeof(message));
- EXPECT_EQ(hf_mailbox_send(SERVICE_VM0, sizeof(message)), 0);
+ EXPECT_EQ(hf_mailbox_send(SERVICE_VM0, sizeof(message), false), 0);
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));
@@ -328,7 +330,7 @@
* expect the response from the interrupt we sent before.
*/
memcpy(mb.send, message, sizeof(message));
- EXPECT_EQ(hf_mailbox_send(SERVICE_VM0, sizeof(message)), 0);
+ EXPECT_EQ(hf_mailbox_send(SERVICE_VM0, sizeof(message), false), 0);
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));