hv: vlapic: use physical APIC IDs as vLAPIC IDs for pre-launched and post-launched VMs

In current code, ACRN uses physical APIC IDs as vLAPIC IDs for SOS,
and vCPU ids (contiguous) as vLAPIC IDs for pre-Launched and post-Launched VMs.

Using vCPU ids as vLAPIC IDs for pre-Launched and post-Launched VMs
would result in wrong CPU and cache topologies showing in the guest VMs,
and could adversely affect performance if the guest VM chooses to detect
CPU and cache topologies and optimize its behavior accordingly.

Uses physical APIC IDs as vLAPIC IDs (and related CPU/cache topology enumeration
CPUIDs passthrough) will replicate the host CPU and cache topologies in pre-Launched
and post-Launched VMs.

Tracked-On: #6020
Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
This commit is contained in:
dongshen 2021-05-19 15:39:20 -07:00 committed by wenlingz
parent 6428ca8f5b
commit f332ef15b2

View File

@ -2200,16 +2200,8 @@ void vlapic_create(struct acrn_vcpu *vcpu, uint16_t pcpu_id)
vlapic_init_timer(vlapic);
if (is_sos_vm(vcpu->vm)) {
/*
* For SOS_VM type, pLAPIC IDs need to be used because
* host ACPI tables are passthru to SOS.
* Get APIC ID sequence format from cpu_storage
*/
/* Set vLAPIC ID to be same as pLAPIC ID */
vlapic->vapic_id = per_cpu(lapic_id, pcpu_id);
} else {
vlapic->vapic_id = (uint32_t)vcpu->vcpu_id;
}
dev_dbg(DBG_LEVEL_VLAPIC, "vlapic APIC ID : 0x%04x", vlapic->vapic_id);
}