From f332ef15b25242d3ba37c8484b7e4ac935b8722d Mon Sep 17 00:00:00 2001 From: dongshen Date: Wed, 19 May 2021 15:39:20 -0700 Subject: [PATCH] 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 Signed-off-by: dongshen --- hypervisor/arch/x86/guest/vlapic.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/hypervisor/arch/x86/guest/vlapic.c b/hypervisor/arch/x86/guest/vlapic.c index a7f6c5396..870f4f0b0 100644 --- a/hypervisor/arch/x86/guest/vlapic.c +++ b/hypervisor/arch/x86/guest/vlapic.c @@ -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 - */ - vlapic->vapic_id = per_cpu(lapic_id, pcpu_id); - } else { - vlapic->vapic_id = (uint32_t)vcpu->vcpu_id; - } + /* Set vLAPIC ID to be same as pLAPIC ID */ + vlapic->vapic_id = per_cpu(lapic_id, pcpu_id); dev_dbg(DBG_LEVEL_VLAPIC, "vlapic APIC ID : 0x%04x", vlapic->vapic_id); }