FF-A: Booting SPs according to 'boot-order'
Secure Hafnium boots partitions according to boot-order in the manifest.
In this patch:
- Added manifest parsing of "boot-order", and populated VM structure
with it;
- Added the field "next_boot" to the VM structure, in order to create a
boot list that is sorted by the "boot-order";
- The root of the list points to the highest priority VM;
- Booting consists on traversing the list upon use of MSG_WAIT
interface from the highest priority VMs;
- After traversing the whole boot list, returns execution to SPMD;
- "manifest_Test.cc" updated to include "boot-order" field in
tests to the partition manifest;
- "vm_test.cc" updated to include unit test for the main logic of this
patch.
Change-Id: I43adf90447eed3bc24c8eb2ccb8eb979b471f3c3
Signed-off-by: J-Alves <Joao.Alves@arm.com>
diff --git a/src/vm.c b/src/vm.c
index fbbdc9f..96e1212 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -21,6 +21,7 @@
static struct vm vms[MAX_VMS];
static struct vm other_world;
static ffa_vm_count_t vm_count;
+static struct vm *first_boot_vm;
struct vm *vm_init(ffa_vm_id_t id, ffa_vcpu_count_t vcpu_count,
struct mpool *ppool)
@@ -292,3 +293,41 @@
vm_unmap(vm_locked, layout_data_begin(), layout_data_end(),
ppool);
}
+
+/**
+ * Gets the first partition to boot, according to Boot Protocol from FFA spec.
+ */
+struct vm *vm_get_first_boot(void)
+{
+ return first_boot_vm;
+}
+
+/**
+ * Insert in boot list, sorted by `boot_order` parameter in the vm structure
+ * and rooted in `first_boot_vm`.
+ */
+void vm_update_boot(struct vm *vm)
+{
+ struct vm *current = NULL;
+ struct vm *previous = NULL;
+
+ if (first_boot_vm == NULL) {
+ first_boot_vm = vm;
+ return;
+ }
+
+ current = first_boot_vm;
+
+ while (current != NULL && current->boot_order >= vm->boot_order) {
+ previous = current;
+ current = current->next_boot;
+ }
+
+ if (previous != NULL) {
+ previous->next_boot = vm;
+ } else {
+ first_boot_vm = vm;
+ }
+
+ vm->next_boot = current;
+}