From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754181AbcIOPZl (ORCPT ); Thu, 15 Sep 2016 11:25:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54256 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751519AbcIOPZR (ORCPT ); Thu, 15 Sep 2016 11:25:17 -0400 Date: Thu, 15 Sep 2016 17:25:13 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Joerg Roedel , David Gilbert Subject: Re: [PATCH] kvm: x86: correctly reset dest_map->vector when restoring LAPIC state Message-ID: <20160915152513.GD17296@potion> References: <1473889712-13785-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1473889712-13785-1-git-send-email-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 15 Sep 2016 15:25:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2016-09-14 23:48+0200, Paolo Bonzini: > When userspace sends KVM_SET_LAPIC, KVM schedules a check between > the vCPU's IRR and ISR and the IOAPIC redirection table, in order > to re-establish the IOAPIC's dest_map (the list of CPUs servicing > the real-time clock interrupt with the corresponding vectors). > > However, __rtc_irq_eoi_tracking_restore_one was forgetting to > set dest_map->vectors. Because of this, the IOAPIC did not process > the real-time clock interrupt EOI, ioapic->rtc_status.pending_eoi > got stuck at a non-zero value, and further RTC interrupts were > reported to userspace as coalesced. > > Fixes: 9e4aabe2bb3454c83dac8139cf9974503ee044db > Fixes: 4d99ba898dd0c521ca6cdfdde55c9b58aea3cb3d > Cc: Joerg Roedel > Cc: David Gilbert > Cc: Radim Krčmář > Signed-off-by: Paolo Bonzini > --- Nice catch, Reviewed-by: Radim Krčmář (It is sad that the RTC EOI tracking exists ...) > arch/x86/kvm/ioapic.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c > index 5f42d038fcb4..c7220ba94aa7 100644 > --- a/arch/x86/kvm/ioapic.c > +++ b/arch/x86/kvm/ioapic.c > @@ -109,6 +109,7 @@ static void __rtc_irq_eoi_tracking_restore_one(struct kvm_vcpu *vcpu) > { > bool new_val, old_val; > struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic; > + struct dest_map *dest_map = &ioapic->rtc_status.dest_map; > union kvm_ioapic_redirect_entry *e; > > e = &ioapic->redirtbl[RTC_GSI]; > @@ -117,16 +118,17 @@ static void __rtc_irq_eoi_tracking_restore_one(struct kvm_vcpu *vcpu) > return; > > new_val = kvm_apic_pending_eoi(vcpu, e->fields.vector); > - old_val = test_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map.map); > + old_val = test_bit(vcpu->vcpu_id, dest_map->map); > > if (new_val == old_val) > return; > > if (new_val) { > - __set_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map.map); > + __set_bit(vcpu->vcpu_id, dest_map->map); > + dest_map->vectors[vcpu->vcpu_id] = e->fields.vector; > ioapic->rtc_status.pending_eoi++; > } else { > - __clear_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map.map); > + __clear_bit(vcpu->vcpu_id, dest_map->map); > ioapic->rtc_status.pending_eoi--; > rtc_status_pending_eoi_check_valid(ioapic); > } > -- > 1.8.3.1 >