mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 05:30:24 +00:00
hv: dynamically configure CPU affinity through hypercall
- add a new member cpu_affinity to struct acrn_create_vm, so that acrn-dm is able to assign CPU affinity through HC_CREATE_VM hypercall. - if vm_create.cpu_affinity is zero, hypervisor launches the VM with the statically configured CPU affinity. Tracked-On: #4616 Signed-off-by: Zide Chen <zide.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
467539441b
commit
0805eb9a56
@ -166,9 +166,22 @@ int32_t hcall_create_vm(struct acrn_vm *vm, uint64_t param)
|
|||||||
/* Filter out the bits should not set by DM and then assign it to guest_flags */
|
/* Filter out the bits should not set by DM and then assign it to guest_flags */
|
||||||
vm_config->guest_flags |= (cv.vm_flag & DM_OWNED_GUEST_FLAG_MASK);
|
vm_config->guest_flags |= (cv.vm_flag & DM_OWNED_GUEST_FLAG_MASK);
|
||||||
|
|
||||||
/* GUEST_FLAG_RT must be set if we have GUEST_FLAG_LAPIC_PASSTHROUGH set in guest_flags */
|
/* post-launched VM is allowed to choose pCPUs from vm_config->cpu_affinity_bitmap only */
|
||||||
if (((vm_config->guest_flags & GUEST_FLAG_LAPIC_PASSTHROUGH) != 0U)
|
if ((cv.cpu_affinity & ~(vm_config->cpu_affinity_bitmap)) != 0UL) {
|
||||||
&& ((vm_config->guest_flags & GUEST_FLAG_RT) == 0U)) {
|
pr_err("%s: Post-launch VM can't share PCPU with Pre-launch VM!", __func__);
|
||||||
|
} else {
|
||||||
|
/* DM could overwrite the statically configured PCPU bitmap */
|
||||||
|
if (bitmap_weight(cv.cpu_affinity) != 0U) {
|
||||||
|
vm_config->vcpu_num = bitmap_weight(cv.cpu_affinity);
|
||||||
|
vm_config->cpu_affinity_bitmap = cv.cpu_affinity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GUEST_FLAG_RT must be set if we have GUEST_FLAG_LAPIC_PASSTHROUGH
|
||||||
|
* set in guest_flags
|
||||||
|
*/
|
||||||
|
if (((vm_config->guest_flags & GUEST_FLAG_LAPIC_PASSTHROUGH) != 0UL)
|
||||||
|
&& ((vm_config->guest_flags & GUEST_FLAG_RT) == 0UL)) {
|
||||||
pr_err("Wrong guest flags 0x%lx\n", vm_config->guest_flags);
|
pr_err("Wrong guest flags 0x%lx\n", vm_config->guest_flags);
|
||||||
} else {
|
} else {
|
||||||
if (create_vm(vm_id, vm_config, &target_vm) != 0) {
|
if (create_vm(vm_id, vm_config, &target_vm) != 0) {
|
||||||
@ -184,6 +197,7 @@ int32_t hcall_create_vm(struct acrn_vm *vm, uint64_t param)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -360,8 +360,15 @@ struct acrn_create_vm {
|
|||||||
|
|
||||||
uint64_t req_buf;
|
uint64_t req_buf;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The least significant set bit is the PCPU # the VCPU 0 maps to;
|
||||||
|
* second set least significant bit is the PCPU # the VCPU 1 maps to;
|
||||||
|
* and so on...
|
||||||
|
*/
|
||||||
|
uint64_t cpu_affinity;
|
||||||
|
|
||||||
/** Reserved for future use*/
|
/** Reserved for future use*/
|
||||||
uint8_t reserved2[16];
|
uint8_t reserved2[8];
|
||||||
} __aligned(8);
|
} __aligned(8);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user