VHE: Add support for a VM to be EL0 partition
Added a boolean and updated VM initialization APIs to take a parameter
that indicates that a given VM is really an EL0 FF-A partition.
Note that it is odd to associate EL0 partitions with a VM, however, all
of hafnium code base deals with VMs and vCPUs and the path of least
resistance to support EL0 partitions (S-EL0 SPs mainly) is to model an
EL0 partition as a "lightweight" VM with 1 VCPU (since all S-EL0
partitions are UP migratable per the FF-A 1.0 spec).
While the FF-A spec really only calls out S-EL0 partitions, there is no
technical reason it cannot be supported in the normal world too.
However, the main expected use case for EL0 partitions in the normal
world would be for testing/verification.
Change-Id: I67cb85bed1f324704e0cc0766563839a07a949af
Signed-off-by: Raghu Krishnamurthy <raghu.ncstate@gmail.com>
diff --git a/src/load.c b/src/load.c
index 4521e1a..b700c59 100644
--- a/src/load.c
+++ b/src/load.c
@@ -200,6 +200,9 @@
paddr_t primary_end = pa_add(primary_begin, RSIZE_MAX);
+ /* Primary VM must be a VM */
+ CHECK(manifest_vm->sp.run_time_el == EL1);
+
/*
* Load the kernel if a filename is specified in the VM manifest.
* For an FF-A partition, kernel_filename is undefined indicating
@@ -214,7 +217,7 @@
}
}
- if (!vm_init_next(MAX_CPUS, ppool, &vm)) {
+ if (!vm_init_next(MAX_CPUS, ppool, &vm, false)) {
dlog_error("Unable to initialise primary VM.\n");
return false;
}
@@ -421,8 +424,15 @@
return false;
}
}
+ /*
+ * An S-EL0 partition must contain only 1 vCPU (UP migratable) per the
+ * FF-A 1.0 spec.
+ */
+ CHECK(manifest_vm->sp.run_time_el != S_EL0 ||
+ manifest_vm->secondary.vcpu_count == 1);
- if (!vm_init_next(manifest_vm->secondary.vcpu_count, ppool, &vm)) {
+ if (!vm_init_next(manifest_vm->secondary.vcpu_count, ppool, &vm,
+ (manifest_vm->sp.run_time_el == S_EL0))) {
dlog_error("Unable to initialise VM.\n");
return false;
}
@@ -683,7 +693,7 @@
* -TrustZone (or the SPMC) when running the Hypervisor
* -the Hypervisor when running TZ/SPMC
*/
- other_world_vm = vm_init(HF_OTHER_WORLD_ID, MAX_CPUS, ppool);
+ other_world_vm = vm_init(HF_OTHER_WORLD_ID, MAX_CPUS, ppool, false);
CHECK(other_world_vm != NULL);
for (i = 0; i < MAX_CPUS; i++) {