Fill in message attributes for messages to primary VM too.
Bug: 132420445
Change-Id: I88d92d021b04234c3027bd2dc41c3965d5751d11
diff --git a/src/api.c b/src/api.c
index 4db97dd..19cbbd1 100644
--- a/src/api.c
+++ b/src/api.c
@@ -903,7 +903,7 @@
* with the help of the primary VM.
*/
static void deliver_msg(struct vm_locked to, struct vm_locked from,
- uint32_t size, struct vcpu *current, struct vcpu **next)
+ struct vcpu *current, struct vcpu **next)
{
struct spci_value primary_ret = {
.func = SPCI_MSG_SEND_32,
@@ -916,7 +916,8 @@
* Only tell the primary VM the size if the message is for it,
* to avoid leaking data about messages for other VMs.
*/
- primary_ret.arg3 = size;
+ primary_ret.arg3 = to.vm->mailbox.recv_size;
+ primary_ret.arg4 = to.vm->mailbox.recv_attributes;
to.vm->mailbox.state = MAILBOX_STATE_READ;
*next = api_switch_to_primary(current, primary_ret,
@@ -1064,8 +1065,7 @@
ret = (struct spci_value){.func = SPCI_SUCCESS_32};
}
- deliver_msg(vm_to_from_lock.vm1, vm_to_from_lock.vm2, size, current,
- next);
+ deliver_msg(vm_to_from_lock.vm1, vm_to_from_lock.vm2, current, next);
out:
vm_unlock(&vm_to_from_lock.vm1);
diff --git a/test/vmapi/primary_with_secondaries/memory_sharing.c b/test/vmapi/primary_with_secondaries/memory_sharing.c
index bbd1c92..7723b4f 100644
--- a/test/vmapi/primary_with_secondaries/memory_sharing.c
+++ b/test/vmapi/primary_with_secondaries/memory_sharing.c
@@ -510,6 +510,8 @@
/* Have the memory be given. */
run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_attributes(run_res),
+ SPCI_MSG_SEND_LEGACY_MEMORY);
/* Check the memory was cleared. */
memory_region = spci_get_memory_region(mb.recv);
@@ -540,6 +542,8 @@
/* Have the memory be lent. */
run_res = spci_run(SERVICE_VM1, 0);
EXPECT_EQ(run_res.func, SPCI_MSG_SEND_32);
+ EXPECT_EQ(spci_msg_send_attributes(run_res),
+ SPCI_MSG_SEND_LEGACY_MEMORY);
/* Check the memory was cleared. */
memory_region = spci_get_memory_region(mb.recv);