Message ID | 1363929845-29005-5-git-send-email-yang.z.zhang@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Il 22/03/2013 06:24, Yang Zhang ha scritto: > +static void rtc_irq_restore(struct kvm_ioapic *ioapic) > +{ > + struct kvm_vcpu *vcpu; > + int vector, i, pending_eoi = 0; > + > + if (RTC_GSI != 8) Please set it to -1U if not x86, and do if (RTC_GSI >= IOAPIC_NUM_PINS) return; here. Paolo > + return; > + -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Il 22/03/2013 06:24, Yang Zhang ha scritto: > + vector = ioapic->redirtbl[RTC_GSI].fields.vector; > + kvm_for_each_vcpu(i, vcpu, ioapic->kvm) { > + if (kvm_apic_pending_eoi(vcpu, vector)) { > + pending_eoi++; > + set_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map); Also, __set_bit. If I understand correctly, dest_map is protected by the ioapic spinlock. Paolo > + } > + } > + ioapic->rtc_status.pending_eoi = pending_eoi; -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Paolo Bonzini wrote on 2013-03-26: > Il 22/03/2013 06:24, Yang Zhang ha scritto: >> +static void rtc_irq_restore(struct kvm_ioapic *ioapic) >> +{ >> + struct kvm_vcpu *vcpu; >> + int vector, i, pending_eoi = 0; >> + >> + if (RTC_GSI != 8) > > Please set it to -1U if not x86, and do > > if (RTC_GSI >= IOAPIC_NUM_PINS) > return; > here. Sure. It is more reasonable. Best regards, Yang -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Paolo Bonzini wrote on 2013-03-26: > Il 22/03/2013 06:24, Yang Zhang ha scritto: >> + vector = ioapic->redirtbl[RTC_GSI].fields.vector; >> + kvm_for_each_vcpu(i, vcpu, ioapic->kvm) { >> + if (kvm_apic_pending_eoi(vcpu, vector)) { >> + pending_eoi++; >> + set_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map); > > Also, __set_bit. If I understand correctly, dest_map is protected by > the ioapic spinlock. Yes, I already see it and changed it in version 7. Best regards, Yang -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index d7915a1..7c17e82 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -94,6 +94,14 @@ static inline int apic_test_vector(int vec, void *bitmap) return test_bit(VEC_POS(vec), (bitmap) + REG_POS(vec)); } +bool kvm_apic_pending_eoi(struct kvm_vcpu *vcpu, int vector) +{ + struct kvm_lapic *apic = vcpu->arch.apic; + + return apic_test_vector(vector, apic->regs + APIC_ISR) || + apic_test_vector(vector, apic->regs + APIC_IRR); +} + static inline void apic_set_vector(int vec, void *bitmap) { set_bit(VEC_POS(vec), (bitmap) + REG_POS(vec)); diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index 967519c..004d2ad 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h @@ -170,4 +170,6 @@ static inline bool kvm_apic_has_events(struct kvm_vcpu *vcpu) return vcpu->arch.apic->pending_events; } +bool kvm_apic_pending_eoi(struct kvm_vcpu *vcpu, int vector); + #endif diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index 8664812..3897305 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c @@ -90,6 +90,30 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic, return result; } +static void rtc_irq_reset(struct kvm_ioapic *ioapic) +{ + ioapic->rtc_status.pending_eoi = 0; + bitmap_zero(ioapic->rtc_status.dest_map, KVM_MAX_VCPUS); +} + +static void rtc_irq_restore(struct kvm_ioapic *ioapic) +{ + struct kvm_vcpu *vcpu; + int vector, i, pending_eoi = 0; + + if (RTC_GSI != 8) + return; + + vector = ioapic->redirtbl[RTC_GSI].fields.vector; + kvm_for_each_vcpu(i, vcpu, ioapic->kvm) { + if (kvm_apic_pending_eoi(vcpu, vector)) { + pending_eoi++; + set_bit(vcpu->vcpu_id, ioapic->rtc_status.dest_map); + } + } + ioapic->rtc_status.pending_eoi = pending_eoi; +} + static int ioapic_service(struct kvm_ioapic *ioapic, unsigned int idx) { union kvm_ioapic_redirect_entry *pent; @@ -431,6 +455,7 @@ void kvm_ioapic_reset(struct kvm_ioapic *ioapic) ioapic->ioregsel = 0; ioapic->irr = 0; ioapic->id = 0; + rtc_irq_reset(ioapic); update_handled_vectors(ioapic); } @@ -496,6 +521,7 @@ int kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state) spin_lock(&ioapic->lock); memcpy(ioapic, state, sizeof(struct kvm_ioapic_state)); update_handled_vectors(ioapic); + rtc_irq_restore(ioapic); kvm_ioapic_make_eoibitmap_request(kvm); spin_unlock(&ioapic->lock); return 0;