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/vm.c b/src/vm.c
index 116de09..cb7873f 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -24,12 +24,13 @@
static struct vm *first_boot_vm;
struct vm *vm_init(ffa_vm_id_t id, ffa_vcpu_count_t vcpu_count,
- struct mpool *ppool)
+ struct mpool *ppool, bool el0_partition)
{
uint32_t i;
struct vm *vm;
if (id == HF_OTHER_WORLD_ID) {
+ CHECK(el0_partition == false);
vm = &other_world;
} else {
uint16_t vm_index = id - HF_VM_ID_OFFSET;
@@ -49,6 +50,7 @@
vm->vcpu_count = vcpu_count;
vm->mailbox.state = MAILBOX_STATE_EMPTY;
atomic_init(&vm->aborting, false);
+ vm->el0_partition = el0_partition;
if (!mm_vm_init(&vm->ptable, ppool)) {
return NULL;
@@ -70,14 +72,15 @@
}
bool vm_init_next(ffa_vcpu_count_t vcpu_count, struct mpool *ppool,
- struct vm **new_vm)
+ struct vm **new_vm, bool el0_partition)
{
if (vm_count >= MAX_VMS) {
return false;
}
/* Generate IDs based on an offset, as low IDs e.g., 0, are reserved */
- *new_vm = vm_init(vm_count + HF_VM_ID_OFFSET, vcpu_count, ppool);
+ *new_vm = vm_init(vm_count + HF_VM_ID_OFFSET, vcpu_count, ppool,
+ el0_partition);
if (*new_vm == NULL) {
return false;
}