HV: init vcpu affinity of SOS VM when launch VMs

Previously the initialization of SOS vCPUs is done by sanitize_vm_config()
before call launch_vms(), once sanitize_vm_config() is moved to pre-build,
we need to do the initialization in launch_vms();

Tracked-On: #5077

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Victor Sun 2020-07-16 14:45:41 +08:00 committed by wenlingz
parent 731e9182d6
commit e7d0c20709
2 changed files with 12 additions and 4 deletions

View File

@ -155,9 +155,7 @@ bool sanitize_vm_config(void)
} }
break; break;
case SOS_VM: case SOS_VM:
/* Deduct pcpus of PRE_LAUNCHED_VMs */ if ((vm_config->severity != (uint8_t)SEVERITY_SOS) ||
vm_config->cpu_affinity = ALL_CPUS_MASK ^ pre_launch_pcpu_bitmap;
if ((vm_config->cpu_affinity == 0UL) || (vm_config->severity != (uint8_t)SEVERITY_SOS) ||
((vm_config->guest_flags & GUEST_FLAG_LAPIC_PASSTHROUGH) != 0U)) { ((vm_config->guest_flags & GUEST_FLAG_LAPIC_PASSTHROUGH) != 0U)) {
ret = false; ret = false;
} }

View File

@ -766,12 +766,22 @@ void prepare_vm(uint16_t vm_id, struct acrn_vm_config *vm_config)
void launch_vms(uint16_t pcpu_id) void launch_vms(uint16_t pcpu_id)
{ {
uint16_t vm_id; uint16_t vm_id;
uint64_t pre_vm_cpu_affinity = 0UL;
struct acrn_vm_config *vm_config; struct acrn_vm_config *vm_config;
for (vm_id = 0U; vm_id < CONFIG_MAX_VM_NUM; vm_id++) { for (vm_id = 0U; vm_id < CONFIG_MAX_VM_NUM; vm_id++) {
vm_config = get_vm_config(vm_id); vm_config = get_vm_config(vm_id);
if ((vm_config->load_order == SOS_VM) || (vm_config->load_order == PRE_LAUNCHED_VM)) { if ((vm_config->load_order == SOS_VM) || (vm_config->load_order == PRE_LAUNCHED_VM)) {
if (vm_config->load_order == SOS_VM) { if (vm_config->load_order == PRE_LAUNCHED_VM) {
pre_vm_cpu_affinity |= vm_config->cpu_affinity;
} else if (vm_config->load_order == SOS_VM) {
/* Deduct pcpus of PRE_LAUNCHED_VMs */
vm_config->cpu_affinity = ALL_CPUS_MASK ^ pre_vm_cpu_affinity;
if (vm_config->cpu_affinity == 0UL) {
/* in case physical cores are not all up as expected */
pr_err("no vCPUs for SOS VM (vm id: %d)", vm_id);
break;
}
sos_vm_ptr = &vm_array[vm_id]; sos_vm_ptr = &vm_array[vm_id];
} }