Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752609AbbHLUSF (ORCPT ); Wed, 12 Aug 2015 16:18:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34601 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751968AbbHLUSB (ORCPT ); Wed, 12 Aug 2015 16:18:01 -0400 Message-ID: <1439410679.4023.537.camel@redhat.com> Subject: Re: [PATCH v6 11/16] KVM: Implement IRQ bypass consumer callbacks for x86 From: Alex Williamson To: Feng Wu Cc: pbonzini@redhat.com, joro@8bytes.org, mtosatti@redhat.com, eric.auger@linaro.org, kvm@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Date: Wed, 12 Aug 2015 14:17:59 -0600 In-Reply-To: <1439273038-59463-12-git-send-email-feng.wu@intel.com> References: <1439273038-59463-1-git-send-email-feng.wu@intel.com> <1439273038-59463-12-git-send-email-feng.wu@intel.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3607 Lines: 114 On Tue, 2015-08-11 at 14:03 +0800, Feng Wu wrote: > Implement the following callbacks for x86: > > - kvm_arch_irq_bypass_add_producer > - kvm_arch_irq_bypass_del_producer > - kvm_arch_irq_bypass_stop: dummy callback > - kvm_arch_irq_bypass_resume: dummy callback > > and set CONFIG_HAVE_KVM_IRQ_BYPASS for x86. > > Signed-off-by: Feng Wu > --- > arch/x86/include/asm/kvm_host.h | 1 + > arch/x86/kvm/Kconfig | 1 + > arch/x86/kvm/x86.c | 39 +++++++++++++++++++++++++++++++++++++++ > 3 files changed, 41 insertions(+) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index 82d0709..3038c1b 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include > > #include > #include > diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig > index c951d44..b90776f 100644 > --- a/arch/x86/kvm/Kconfig > +++ b/arch/x86/kvm/Kconfig > @@ -30,6 +30,7 @@ config KVM > select HAVE_KVM_IRQCHIP > select HAVE_KVM_IRQFD > select IRQ_BYPASS_MANAGER > + select HAVE_KVM_IRQ_BYPASS > select HAVE_KVM_IRQ_ROUTING > select HAVE_KVM_EVENTFD > select KVM_APIC_ARCHITECTURE > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 8f09a76..8df7b0d 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -50,6 +50,8 @@ > #include > #include > #include > +#include > +#include > #include > > #define CREATE_TRACE_POINTS > @@ -8321,6 +8323,43 @@ out: > return ret; > } > > +int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons, > + struct irq_bypass_producer *prod) > +{ > + struct kvm_kernel_irqfd *irqfd = > + container_of(cons, struct kvm_kernel_irqfd, consumer); > + > + irqfd->producer = prod; > + > + return kvm_arch_update_pi_irte(irqfd->kvm, prod->irq, irqfd->gsi, 1); > +} > + > +void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons, > + struct irq_bypass_producer *prod) > +{ > + int ret; > + struct kvm_kernel_irqfd *irqfd = > + container_of(cons, struct kvm_kernel_irqfd, consumer); > + > + irqfd->producer = NULL; > + > + /* > + * When producer of consumer is unregistered, we change back to > + * remapped mode, so we can re-use the current implementation > + * when the irq is masked/disabed or the consumer side (KVM > + * int this case doesn't want to receive the interrupts. > + */ > + ret = kvm_arch_update_pi_irte(irqfd->kvm, prod->irq, irqfd->gsi, 0); > + WARN_ON(ret); > +} Some tracing support would be nice here so we have some way to determine whether we've made a successful connection. > + > +void kvm_arch_irq_bypass_stop(struct irq_bypass_consumer *cons) > +{ > +} > +void kvm_arch_irq_bypass_start(struct irq_bypass_consumer *cons) > +{ > +} Can't we define a common version of these with __attribute__((weak)) so that archs that don't need them don't need to add this cruft? > + > EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_exit); > EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_inj_virq); > EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_page_fault); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/