Skip to content

Commit

Permalink
KVM: x86: Disable APIC logical map if vCPUs are aliased in logical mode
Browse files Browse the repository at this point in the history
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: 1e08ec4 ("KVM: optimize apic interrupt delivery")
Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20230106011306.85230-22-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Sean Christopherson authored and Paolo Bonzini committed Jan 13, 2023
1 parent 2bf934a commit 2970052
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions arch/x86/kvm/lapic.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,12 @@ void kvm_recalculate_apic_map(struct kvm *kvm)
if (!mask)
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;
continue;
}
cluster[ffs(mask) - 1] = apic;
cluster[ldr] = apic;
}
out:
old = rcu_dereference_protected(kvm->arch.apic_map,
Expand Down

0 comments on commit 2970052

Please sign in to comment.