summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2023-01-06 04:12:54 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2023-01-13 18:45:30 +0300
commit2970052481b9f93e1849f5d4a1065e9fafc8d662 (patch)
treef1d7e02398baa94bfd0c84a25a361c1c62d8530f
parent2bf934aadcac310810cc4fa120d1b576cae7e9da (diff)
downloadlinux-2970052481b9f93e1849f5d4a1065e9fafc8d662.tar.xz
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: 1e08ec4a130e ("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>
-rw-r--r--arch/x86/kvm/lapic.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index dca87bb6dd1a..9c0554bae3b1 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -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,