fix(ff-a): use cpu buffers in partition discovery
The handling of FFA_PARTITION_INFO_GET(_REGS) was using
a buffer for partition information.
The buffer was meant to hold the partition information
for all SPs - including logical SPs.
The buffer didn't cater for the support of multiple UUIDs.
Currently, there is the assumption that all information
should fit into a single RX buffer. CPU buffer is of the same
size as the mailbox.
Instead of statically defining a small buffer in the stack,
reuse the local buffer of the CPU handling the call.
The CPUs buffer are of the same size as the RX buffer.
Applied equivalent changes to both FFA_PARTITION_INFO_GET
and FFA_PARTITION_INFO_GET_REGS.
For FFA_PARTITION_INFO_GET_REGS, the return of information
is done via registers.
However, it still inherited the restrictions to
FFA_PARTITION_INFO_GET.
With the present approach, there is still the chance for
the limit of the buffer to be hit. However, current
buffer size is expect to suffice for known integrations.
In such case, the interfaces will simply return with an error.
Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: I266262b5f3964693e983efb45603013e568e84b4
diff --git a/src/cpu.c b/src/cpu.c
index 6ff6e69..507a5a9 100644
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -16,6 +16,7 @@
#include "hf/check.h"
#include "hf/dlog.h"
#include "hf/list.h"
+#include "hf/types.h"
#include "vmapi/hf/call.h"
@@ -38,10 +39,11 @@
* TOCTOU issues while Hafnium performs actions on information that would
* otherwise be re-writable by the VM.
*
- * Each buffer is owned by a single CPU. Can be used when handling FF-A memory
- * management ABIs, and FF-A Indirect Messaging.
+ * Each buffer is owned by a single CPU. Can be used when handling FF-A
+ * messages, from and to the SPMC. E.g. FF-A memory sharing, indirect messaging
+ * and partition info get.
*/
-alignas(PAGE_SIZE) static uint8_t cpu_message_buffer[MAX_CPUS][PAGE_SIZE];
+alignas(PAGE_SIZE) static uint8_t cpu_message_buffer[MAX_CPUS][HF_MAILBOX_SIZE];
uint8_t *cpu_get_buffer(struct cpu *c)
{