VHE: Tests: Allow FF-A partitions to be loaded by hafnium in NWd

This patch makes changes so that partitions (EL0 host applications or
VMs) can be marked as an FF-A partition in their manifests and still be
loaded. Today's design assumes that if a partition is an FF-A partition,
it is pre-loaded by some other entity and hafnium does not need to load.
This works well for the FVP where either trusted firmware or FVP command
line options can be used to load FF-A partitions in memory prior to
running code. On qemu, this capability does not exist today.
To provide this ability in qemu, we can modify hftest.py and other test
infrastructure to do the same thing as FVP and pre-load FF-A partitions
into memory, but this patch uses a different approach. Here, we add a
new flag that can be added in the hafnium/spmc manifest that indicates
to hafnium that the partition and its manifest still need to be loaded
from the initrd, like normal.
When a partition is not an FF-A partition (marked by is_ffa_partition in
the manifest), the loading rules of hafnium remain unchanged. When a
partition is marked as an FF-A partition, it can either be
pre-loaded (hyp_loaded not in manifest) or it can be explicitly loaded
from the initrd by specifying hyp_loaded in the manifest for hafnium.
Note that qemu currently only supports normal world, so this new field
(hyp_loaded) is not expected to be used in the secure world.
This patch also uses this new feature for all the normal world EL0
partition tests so that they can be marked as FF-A partitions and still
be loaded by the hypervisor like normal.

With this change, the main use case that is enabled is that an FF-A
partition (EL1 VMs and EL0 host applications) can be loaded on qemu.
Also  the partition manifest can be compliant with FF-A, without having
to extend or pollute hafniums default hypervisor manifest to include
fields such as execution-ctx-count, memory regions etc.

Signed-off-by: Raghu Krishnamurthy <raghu.ncstate@gmail.com>
Change-Id: If98eb9b6cbd14fc30d6d4e78d2d260a6beb97aa9
diff --git a/inc/hf/arch/plat/ffa.h b/inc/hf/arch/plat/ffa.h
index 4428174..ee2a3cc 100644
--- a/inc/hf/arch/plat/ffa.h
+++ b/inc/hf/arch/plat/ffa.h
@@ -9,6 +9,7 @@
 #pragma once
 
 #include "hf/ffa.h"
+#include "hf/manifest.h"
 #include "hf/vcpu.h"
 #include "hf/vm.h"
 
@@ -226,3 +227,9 @@
 					 const uint32_t flags,
 					 struct ffa_partition_info *partitions,
 					 ffa_vm_count_t *ret_count);
+
+void plat_ffa_parse_partition_manifest(struct mm_stage1_locked stage1_locked,
+				       paddr_t fdt_addr,
+				       size_t fdt_allocated_size,
+				       const struct manifest_vm *manifest_vm,
+				       struct mpool *ppool);
diff --git a/inc/hf/manifest.h b/inc/hf/manifest.h
index c045432..b77a09d 100644
--- a/inc/hf/manifest.h
+++ b/inc/hf/manifest.h
@@ -9,6 +9,7 @@
 #pragma once
 
 #include "hf/addr.h"
+#include "hf/fdt.h"
 #include "hf/ffa.h"
 #include "hf/memiter.h"
 #include "hf/string.h"
@@ -187,6 +188,7 @@
 	struct string kernel_filename;
 	struct smc_whitelist smc_whitelist;
 	bool is_ffa_partition;
+	bool is_hyp_loaded;
 	struct partition_manifest partition;
 
 	union {
@@ -241,6 +243,9 @@
 					struct memiter *manifest_fdt,
 					struct mpool *ppool);
 
+enum manifest_return_code parse_ffa_manifest(struct fdt *fdt,
+					     struct manifest_vm *vm);
+enum manifest_return_code sanity_check_ffa_manifest(struct manifest_vm *vm);
 void manifest_dump(struct manifest_vm *vm);
 
 const char *manifest_strerror(enum manifest_return_code ret_code);