fix: add size to partition_info_get response
The FF-A 1.1 EAC0 specification (Table 13.35) now requires that for
an FFA_SUCCESS response to FFA_PARTITION_INFO_GET the x3/w3 register
contains the size of the partition information descriptors when the
count flag is not set. Implement this in the handler and update the
tests to check this is correctly done.
Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: I9f1efde183a6cc755c0096c75c43ccf0039b26b2
diff --git a/src/api.c b/src/api.c
index 407ca50..019b719 100644
--- a/src/api.c
+++ b/src/api.c
@@ -364,7 +364,8 @@
{
struct vm *vm = vm_locked.vm;
uint32_t version = vm->ffa_version;
- uint32_t size;
+ uint32_t partition_info_size;
+ uint32_t buffer_size;
if (msg_receiver_busy(vm_locked, NULL, false)) {
/*
@@ -378,8 +379,9 @@
if (version == MAKE_FFA_VERSION(1, 0)) {
struct ffa_partition_info_v1_0 *recv_mailbox = vm->mailbox.recv;
- size = sizeof(struct ffa_partition_info_v1_0) * vm_count;
- if (size > HF_MAILBOX_SIZE) {
+ partition_info_size = sizeof(struct ffa_partition_info_v1_0);
+ buffer_size = partition_info_size * vm_count;
+ if (buffer_size > HF_MAILBOX_SIZE) {
dlog_error(
"Partition information does not fit in the "
"VM's RX "
@@ -398,8 +400,9 @@
}
} else {
- size = sizeof(partitions[0]) * vm_count;
- if (size > HF_MAILBOX_SIZE) {
+ partition_info_size = sizeof(struct ffa_partition_info);
+ buffer_size = partition_info_size * vm_count;
+ if (buffer_size > HF_MAILBOX_SIZE) {
dlog_error(
"Partition information does not fit in the "
"VM's RX "
@@ -409,18 +412,24 @@
/* Populate the VM's RX buffer with the partition information.
*/
- memcpy_s(vm->mailbox.recv, HF_MAILBOX_SIZE, partitions, size);
+ memcpy_s(vm->mailbox.recv, HF_MAILBOX_SIZE, partitions,
+ buffer_size);
}
- vm->mailbox.recv_size = size;
+ vm->mailbox.recv_size = buffer_size;
/* Sender is Hypervisor in the normal world (TEE in secure world). */
vm->mailbox.recv_sender = HF_VM_ID_BASE;
vm->mailbox.recv_func = FFA_PARTITION_INFO_GET_32;
vm->mailbox.state = MAILBOX_STATE_READ;
- /* Return the count of partition information descriptors in w2. */
- return (struct ffa_value){.func = FFA_SUCCESS_32, .arg2 = vm_count};
+ /*
+ * Return the count of partition information descriptors in w2
+ * and the size of the descriptors in w3.
+ */
+ return (struct ffa_value){.func = FFA_SUCCESS_32,
+ .arg2 = vm_count,
+ .arg3 = partition_info_size};
}
struct ffa_value api_ffa_partition_info_get(struct vcpu *current,