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/api.c b/src/api.c
index d131656..46d8a88 100644
--- a/src/api.c
+++ b/src/api.c
@@ -1196,12 +1196,14 @@
struct vcpu_locked current_locked;
struct vm *vm = current->vm;
struct ffa_value return_code;
+ bool is_from_secure_world =
+ (current->vm->id & HF_VM_ID_WORLD_MASK) != 0;
/*
* The primary VM will receive messages as a status code from running
* vCPUs and must not call this function.
*/
- if (vm->id == HF_PRIMARY_VM_ID) {
+ if (!is_from_secure_world && vm->id == HF_PRIMARY_VM_ID) {
return ffa_error(FFA_NOT_SUPPORTED);
}
@@ -1243,8 +1245,13 @@
goto out;
}
- /* Switch back to primary VM to block. */
- {
+ if (is_from_secure_world) {
+ /* Return to other world if caller is a SP. */
+ *next = api_switch_to_other_world(
+ current, (struct ffa_value){.func = FFA_MSG_WAIT_32},
+ VCPU_STATE_BLOCKED_MAILBOX);
+ } else {
+ /* Switch back to primary VM to block. */
struct ffa_value run_return = {
.func = FFA_MSG_WAIT_32,
.arg1 = ffa_vm_vcpu(vm->id, vcpu_index(current)),