Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions libsel4vm/src/arch/arm/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@ int vm_create_vcpu_arch(vm_t *vm, vm_vcpu_t *vcpu)
vcpu->vcpu_arch.unhandled_vcpu_callback = NULL;
vcpu->vcpu_arch.unhandled_vcpu_callback_cookie = NULL;

#if CONFIG_MAX_NUM_NODES > 1
if (seL4_TCB_SetAffinity(vcpu->tcb.tcb.cptr, vcpu->vcpu_id)) {
err = -1;
}
#endif /* CONFIG_MAX_NUM_NODES > 1 */

#ifdef CONFIG_DEBUG_BUILD
char vcpu_name[32];
snprintf(vcpu_name, sizeof(vcpu_name), "%s:%d", vm->vm_name, vcpu->vcpu_id);
Expand Down
2 changes: 1 addition & 1 deletion libsel4vm/src/arch/arm/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ int vcpu_start(vm_vcpu_t *vcpu)
*/
vmpidr_val = BIT(24) | BIT(31);
} else {
vmpidr_val = vcpu->target_cpu;
vmpidr_val = vcpu->vcpu_id;
}
err = vm_set_arm_vcpu_reg(vcpu, vmpidr_reg, vmpidr_val);
if (err) {
Expand Down
11 changes: 10 additions & 1 deletion libsel4vm/src/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,19 @@ 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;
}

#if CONFIG_MAX_NUM_NODES > 1
int err = seL4_TCB_SetAffinity(vcpu->tcb.tcb.cptr, target_cpu);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think to commit is ok. But it makes this generic code now, how do other architectures cope with this change then? Do we gave to change something in the x86 VMM part also?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe vm_assign_vcpu_target is currently only used by ARM

if (err) {
ZF_LOGE("[vCPU %u] Failed to set vCPU affinity to %d", vcpu->vcpu_id, target_cpu);
return -1;
}
#endif /* CONFIG_MAX_NUM_NODES > 1 */

vcpu->target_cpu = target_cpu;
return 0;
}
9 changes: 8 additions & 1 deletion libsel4vmmplatsupport/src/arch/arm/psci.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,19 @@ int handle_psci(vm_vcpu_t *vcpu, seL4_UserContext *regs, seL4_Word fn_number, bo
} else {
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