fix(ff-a): partitions boot order
Partitions have the "boot-order" field in their partitions manifest,
that is meant to be used to dictate the order in which SPs are
initialized.
Partitions were being booted from higher to lower of their respective
"boot-order" value. The correct behavior should be from lower to
higher.
Change-Id: I040070f76166d914690b05d568aac9cfce2af713
Signed-off-by: J-Alves <joao.alves@arm.com>
diff --git a/inc/hf/manifest.h b/inc/hf/manifest.h
index 97364b7..c045432 100644
--- a/inc/hf/manifest.h
+++ b/inc/hf/manifest.h
@@ -30,7 +30,8 @@
/** Mask for getting read/write/execute permission */
#define MM_PERM_MASK 0x7
-#define DEFAULT_BOOT_ORDER 0x0
+/* Highest possible value for the boot-order field. */
+#define DEFAULT_BOOT_ORDER 0xFFFF
enum run_time_el {
EL1 = 0,
diff --git a/src/vm.c b/src/vm.c
index b2ab680..43a52f2 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -395,7 +395,7 @@
current = first_boot_vm;
- while (current != NULL && current->boot_order >= vm->boot_order) {
+ while (current != NULL && current->boot_order <= vm->boot_order) {
previous = current;
current = current->next_boot;
}
diff --git a/src/vm_test.cc b/src/vm_test.cc
index e0fc89e..d64b7d1 100644
--- a/src/vm_test.cc
+++ b/src/vm_test.cc
@@ -54,9 +54,9 @@
struct mpool ppool;
public:
- static bool BootOrderBiggerThan(struct_vm *vm1, struct_vm *vm2)
+ static bool BootOrderSmallerThan(struct_vm *vm1, struct_vm *vm2)
{
- return vm1->boot_order > vm2->boot_order;
+ return vm1->boot_order < vm2->boot_order;
}
};
@@ -95,7 +95,7 @@
* The "boot_list" is expected to be empty.
*/
EXPECT_TRUE(vm_init_next(1, &ppool, &vm_cur, false));
- vm_cur->boot_order = 1;
+ vm_cur->boot_order = 3;
vm_update_boot(vm_cur);
expected_final_order.push_back(vm_cur);
@@ -103,7 +103,7 @@
/* Insertion at the head of the boot list */
EXPECT_TRUE(vm_init_next(1, &ppool, &vm_cur, false));
- vm_cur->boot_order = 3;
+ vm_cur->boot_order = 1;
vm_update_boot(vm_cur);
expected_final_order.push_back(vm_cur);
@@ -135,8 +135,8 @@
EXPECT_EQ(expected_final_order.size(), vm_get_count())
<< "Something went wrong with the test itself...\n";
- /* Sort "expected_final_order" by "boot_order" field */
- expected_final_order.sort(vm::BootOrderBiggerThan);
+ /* Sort VMs from lower to higher "boot_order" field.*/
+ expected_final_order.sort(vm::BootOrderSmallerThan);
std::list<struct_vm *>::iterator it;
for (it = expected_final_order.begin(), vm_cur = vm_get_first_boot();
diff --git a/test/vmapi/ffa_secure_partitions/partition_manifest_services_secondary_sp.dts b/test/vmapi/ffa_secure_partitions/partition_manifest_services_secondary_sp.dts
index 13b2ba1..436ba96 100644
--- a/test/vmapi/ffa_secure_partitions/partition_manifest_services_secondary_sp.dts
+++ b/test/vmapi/ffa_secure_partitions/partition_manifest_services_secondary_sp.dts
@@ -22,6 +22,6 @@
entrypoint-offset = <0x1000>;
xlat-granule = <0>; /* 4KiB */
messaging-method = <0>; /* Direct messaging only */
- boot-order = <3>; /* This should be the highest priority partition */
+ boot-order = <3>;
notification-support; /* Receipt of notifications. */
};
diff --git a/test/vmapi/ffa_secure_partitions/partition_manifest_services_sp.dts b/test/vmapi/ffa_secure_partitions/partition_manifest_services_sp.dts
index 1e34f7a..01c2c64 100644
--- a/test/vmapi/ffa_secure_partitions/partition_manifest_services_sp.dts
+++ b/test/vmapi/ffa_secure_partitions/partition_manifest_services_sp.dts
@@ -22,6 +22,6 @@
entrypoint-offset = <0x1000>;
xlat-granule = <0>; /* 4KiB */
messaging-method = <0>; /* Direct messaging only */
- boot-order = <2>; /* This should be the highest priority partition */
+ boot-order = <1>; /* This should be the highest priority partition */
notification-support; /* Receipt of notifications. */
};