diff --git a/components/VM_Arm/configurations/vm.h b/components/VM_Arm/configurations/vm.h index 8e15dec2..f5916fa7 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 cf591e4d..57c85456 100644 --- a/components/VM_Arm/src/main.c +++ b/components/VM_Arm/src/main.c @@ -1262,16 +1262,34 @@ static int main_continued(void) vm_vcpu_t *new_vcpu = create_vmm_plat_vcpu(&vm, VM_PRIO - 1); assert(new_vcpu); } + if (vm_config.generate_dtb) { err = fdt_generate_plat_vcpu_node(&vm, gen_dtb_buf); if (err) { ZF_LOGE("Couldn't generate plat_vcpu_node (%d)", err); return -1; } + + 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; }