Skip to content

Commit

Permalink
libsel4vm: start a vcpu even if assigned a pcpu
Browse files Browse the repository at this point in the history
Previously the target_cpu member was being used to determine if a vcpu
was started in conjunction with the is_vcpu_online function. This is
unneccessary and has been repurposed to keep track of whether or not the
vcpu has been previously assigned a pcpu or not.

Signed-off-by: Alex Pavey <[email protected]>
  • Loading branch information
Alex Pavey authored and Alex Pavey committed Nov 17, 2022
1 parent 0efa6ac commit f3d10f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libsel4vm/src/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int vm_assign_vcpu_target(vm_vcpu_t *vcpu, int target_cpu)
return -1;
}
vm_vcpu_t *target_vcpu = vm_vcpu_for_target_cpu(vcpu->vm, target_cpu);
if (target_vcpu) {
if (target_vcpu && (target_vcpu != vcpu)) {
ZF_LOGE("Failed to assign target cpu - A VCPU is already assigned to core %d", target_cpu);
return -1;
}
Expand Down
9 changes: 8 additions & 1 deletion libsel4vmmplatsupport/src/arch/arm/psci.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,19 @@ int handle_psci(vm_vcpu_t *vcpu, seL4_Word fn_number, bool convention)
ZF_LOGE("[vCPU %u] no unused physical core left", vcpu->vcpu_id);
smc_set_return_value(&regs, PSCI_INTERNAL_FAILURE);
}
} else {
} else if ((target_vcpu->target_cpu >= 0) && (target_vcpu->target_cpu < CONFIG_MAX_NUM_NODES)) {
/* Assign vcpu to physical cpu specified in config */
if (is_vcpu_online(target_vcpu)) {
smc_set_return_value(&regs, PSCI_ALREADY_ON);
} else if (start_new_vcpu(target_vcpu, entry_point_address, context_id, target_vcpu->target_cpu) == 0) {
smc_set_return_value(&regs, PSCI_SUCCESS);
} else {
ZF_LOGE("[vCPU %u] could not start vCPU", vcpu->vcpu_id);
smc_set_return_value(&regs, PSCI_INTERNAL_FAILURE);
}
} else {
ZF_LOGE("[vCPU %u] invalid target CPU %d", vcpu->vcpu_id, target_vcpu->target_cpu);
smc_set_return_value(&regs, PSCI_INTERNAL_FAILURE);
}

break;
Expand Down

0 comments on commit f3d10f7

Please sign in to comment.