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..b527d07b 100644 --- a/components/VM_Arm/src/main.c +++ b/components/VM_Arm/src/main.c @@ -1262,6 +1262,7 @@ 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) { @@ -1270,8 +1271,26 @@ static int main_continued(void) } } + 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; } diff --git a/templates/seL4VMParameters.template.c b/templates/seL4VMParameters.template.c index 7b7ce070..158df21c 100644 --- a/templates/seL4VMParameters.template.c +++ b/templates/seL4VMParameters.template.c @@ -124,3 +124,19 @@ const vm_config_t vm_config = { /*- endif -*/ }; + +/*- if 'pcpus' in config.keys() -*/ + /*- for c in config.get('pcpus') -*/ +#if (/*? c ?*/ >= CONFIG_MAX_NUM_NODES) +#error "Invalid CPU number /*? c ?*/ in PCPU list of /*? me.name ?*/" +#endif + /*- endfor -*/ +/*- endif -*/ + +int get_instance_size_pcpus_list(void) { +/*- if 'pcpus' in config.keys() -*/ + return /*? len(config.get('pcpus')) ?*/; +/*- else -*/ + return 0; +/*- endif -*/ +} diff --git a/templates/seL4VMParameters.template.h b/templates/seL4VMParameters.template.h index ab30b5e6..b7d52501 100644 --- a/templates/seL4VMParameters.template.h +++ b/templates/seL4VMParameters.template.h @@ -42,3 +42,5 @@ typedef struct { } vm_config_t; extern const vm_config_t vm_config; + +int get_instance_size_pcpus_list(void);