KVM: x86: fix x2apic logical address matching
authorRadim Krčmář <rkrcmar@redhat.com>
Thu, 29 Jan 2015 21:48:51 +0000 (22:48 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 30 Jan 2015 11:26:46 +0000 (12:26 +0100)
We cannot hit the bug now, but future patches will expose this path.

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/lapic.c

index 99c536597332d6e888bde7881b358bf5f92c4799..555956c3c473e10350776b9cc2015270d561a5f6 100644 (file)
@@ -599,7 +599,8 @@ static bool kvm_apic_match_logical_addr(struct kvm_lapic *apic, u32 mda)
        logical_id = kvm_apic_get_reg(apic, APIC_LDR);
 
        if (apic_x2apic_mode(apic))
-               return (logical_id & mda) != 0;
+               return ((logical_id >> 16) == (mda >> 16))
+                      && (logical_id & mda & 0xffff) != 0;
 
        logical_id = GET_APIC_LOGICAL_ID(logical_id);