Commit 29700524 authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: x86: Disable APIC logical map if vCPUs are aliased in logical mode

Disable the optimized APIC logical map if multiple vCPUs are aliased to
the same logical ID.  Architecturally, all CPUs whose logical ID matches
the MDA are supposed to receive the interrupt; overwriting existing map
entries can result in missed IPIs.

Fixes: 1e08ec4a ("KVM: optimize apic interrupt delivery")
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20230106011306.85230-22-seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 2bf934aa
...@@ -346,11 +346,12 @@ void kvm_recalculate_apic_map(struct kvm *kvm) ...@@ -346,11 +346,12 @@ void kvm_recalculate_apic_map(struct kvm *kvm)
if (!mask) if (!mask)
continue; continue;
if (!is_power_of_2(mask)) { ldr = ffs(mask) - 1;
if (!is_power_of_2(mask) || cluster[ldr]) {
new->logical_mode = KVM_APIC_MODE_MAP_DISABLED; new->logical_mode = KVM_APIC_MODE_MAP_DISABLED;
continue; continue;
} }
cluster[ffs(mask) - 1] = apic; cluster[ldr] = apic;
} }
out: out:
old = rcu_dereference_protected(kvm->arch.apic_map, old = rcu_dereference_protected(kvm->arch.apic_map,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment