From eadf2e896c31e427c082971fa094b681b51e5862 Mon Sep 17 00:00:00 2001 From: Alex Pavey Date: Mon, 11 Jan 2021 11:24:31 -0500 Subject: [PATCH] vm_arm: add pcpu list for core pinning Adds a pcpu list to the VM_Arm component to allow pinning of vcpus to specific physical cpus within a CAmkES configuration. Signed-off-by: Alex Pavey --- components/VM_Arm/configurations/vm.h | 1 + components/VM_Arm/src/main.c | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/components/VM_Arm/configurations/vm.h b/components/VM_Arm/configurations/vm.h index e7ab78c4..0dffa2b8 100644 --- a/components/VM_Arm/configurations/vm.h +++ b/components/VM_Arm/configurations/vm.h @@ -65,6 +65,7 @@ provides VMDTBPassthrough dtb; \ attribute int base_prio; \ attribute int num_vcpus = 1; \ + attribute int pcpus[] = []; \ attribute int num_extra_frame_caps; \ attribute int extra_frame_map_address; \ attribute { \ diff --git a/components/VM_Arm/src/main.c b/components/VM_Arm/src/main.c index e577d0bd..10cfd744 100644 --- a/components/VM_Arm/src/main.c +++ b/components/VM_Arm/src/main.c @@ -1173,8 +1173,27 @@ int main_continued(void) vm_vcpu_t *new_vcpu = create_vmm_plat_vcpu(&vm, VM_PRIO - 1); assert(new_vcpu); } + + int pcpu_assignments = 0; + if (get_instance_size_pcpus_list() < NUM_VCPUS) { + pcpu_assignments = get_instance_size_pcpus_list(); + } else { + pcpu_assignments = NUM_VCPUS; + } + /* Assign vcpus to explicit pcpus */ + for (int j = 0; j < pcpu_assignments; j++) { + vm.vcpus[j]->target_cpu = pcpus[j]; + } + vm_vcpu_t *vm_vcpu = vm.vcpus[BOOT_VCPU]; - err = vm_assign_vcpu_target(vm_vcpu, 0); + + /* Use affinity as boot core if pcpus are not specified */ + if (0 == pcpu_assignments) { + err = vm_assign_vcpu_target(vm_vcpu, get_instance_affinity()); + } else { + err = vm_assign_vcpu_target(vm_vcpu, vm_vcpu->target_cpu); + } + if (err) { return -1; }