From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH v3 3/4] KVM: x86: Add EOI exit bitmap inference Date: Wed, 03 Jun 2015 11:16:16 +0200 Message-ID: <556EC5E0.2050703@redhat.com> References: <1433289107-20638-1-git-send-email-srutherford@google.com> <1433289107-20638-3-git-send-email-srutherford@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit To: Steve Rutherford , kvm@vger.kernel.org Return-path: Received: from mail-wg0-f48.google.com ([74.125.82.48]:35771 "EHLO mail-wg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752604AbbFCJQV (ORCPT ); Wed, 3 Jun 2015 05:16:21 -0400 Received: by wgme6 with SMTP id e6so3660102wgm.2 for ; Wed, 03 Jun 2015 02:16:19 -0700 (PDT) In-Reply-To: <1433289107-20638-3-git-send-email-srutherford@google.com> Sender: kvm-owner@vger.kernel.org List-ID: On 03/06/2015 01:51, Steve Rutherford wrote: > +static inline void kvm_arch_irq_routing_update(struct kvm *kvm) > +{ > +} Please add the static inline to all arches instead of putting it in #ifndef __KVM_HAVE_IOAPIC. It's not related to the existence of an ioapic. > > +void kvm_arch_irq_routing_update(struct kvm *kvm) > +{ > + struct kvm_ioapic *ioapic = kvm->arch.vioapic; > + > + if (ioapic) > + return; > + if (!lapic_in_kernel(kvm)) > + return; > + kvm_make_scan_ioapic_request(kvm); > +} > + It's weird to have a function in ioapic.c that only does something if you _do not_ have an ioapic. :) > + > +void kvm_scan_ioapic_routes(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap) This must stay in arch/x86/kvm/. I'd put both of these in irq_comm.c. Then you do not need kvm_arch_nr_userspace_ioapic_pins anymore. Paolo > +{ > + struct kvm *kvm = vcpu->kvm; > + struct kvm_kernel_irq_routing_entry *entry; > + struct kvm_irq_routing_table *table; > + u32 i, nr_ioapic_pins; > + int idx; > + > + /* kvm->irq_routing must be read after clearing > + * KVM_SCAN_IOAPIC. */ > + smp_mb(); > + idx = srcu_read_lock(&kvm->irq_srcu); > + table = kvm->irq_routing; > + nr_ioapic_pins = min_t(u32, table->nr_rt_entries, > + kvm_arch_nr_userspace_ioapic_pins(kvm)); > + for (i = 0; i < nr_ioapic_pins; ++i) { > + hlist_for_each_entry(entry, &table->map[i], link) { > + u32 dest_id, dest_mode; > + > + if (entry->type != KVM_IRQ_ROUTING_MSI) > + continue; > + dest_id = (entry->msi.address_lo >> 12) & 0xff; > + dest_mode = (entry->msi.address_lo >> 2) & 0x1; > + if (kvm_apic_match_dest(vcpu, NULL, 0, dest_id, > + dest_mode)) { > + u32 vector = entry->msi.data & 0xff; > + > + __set_bit(vector, > + (unsigned long *) eoi_exit_bitmap); > + } > + } > + } > + srcu_read_unlock(&kvm->irq_srcu, idx); > +}