Skip to content

Commit

Permalink
vm_arm: add pcpu list for core pinning
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Alex Pavey authored and chrisguikema committed Feb 1, 2024
1 parent 64690e8 commit 8ac18f0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/VM_Arm/configurations/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 { \
Expand Down
20 changes: 19 additions & 1 deletion components/VM_Arm/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8ac18f0

Please sign in to comment.