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 Alex Pavey committed Nov 11, 2022
1 parent 379f2cf commit 175709b
Show file tree
Hide file tree
Showing 2 changed files with 23 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
23 changes: 22 additions & 1 deletion components/VM_Arm/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1173,8 +1173,29 @@ 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;
}
Expand Down

0 comments on commit 175709b

Please sign in to comment.