feat(rmmd): add RMM_ALLOCATE_MEMORY SMC handler

At the moment any memory required by an R-EL2 hypervisor (RMM) needs to
be known at compile time: that sets the size of the .data and .bss
segments. Some resources depend on the particular machine this will be
running on, the prime example is TF-RMM's granule array, which needs to
know the maximum memory supported beforehand. Other data structures
might depend on the number of CPU cores.

To provide more flexibility, but keep the memory footprint as small as
possible, let's introduce some (limited) memory allocation SMC. Any RMM
implementation can ask EL3 for some memory, and would get the physical
address of a usable chunk of memory back. This is supposed to happen at
RMM boot time, so before the RMM concluded the boot phase with the
RMM_BOOT_COMPLETE SMC call. Also there is no provision to free memory
again, this would not be needed for the use case of sizing platform
resources, and avoids the complexity of a full-fledged memory allocator.

Another important motivation for this feature is Live Firmware
Activation, which would require to keep some state alive between
different instances of the RMM. This is achieved by adding an ID tag to
memory allocations. Subsequent requests using a previously used tag
would return the very same memory location, with the existing content.
TF-RMM would use that for the granule array and the VMID array, for a
start.

Add the new RMM_ALLOCATE_MEMORY command to the realm-EL3 SMC interface,
both in code and documentation. The actual memory allocator is very
simple: it will just pick the next matching chunk of memory from the top
end of the RMM carveout, keeping track of the tags on the way.
This way the memory allocation will grow down from the end of the
carveout, in a stack-like fashion, until it reaches the end of the RMM
payload, located at the beginning of the carveout.

This patch just provides the call, at this point there is no obligation
to use the feature, although future TF-RMM versions would rely on it.

Change-Id: I096ac8870ee38f44e18850779fcae829a43a8fd1
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
9 files changed