public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Feng Wu <feng.wu@intel.com>
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
Subject: Re: [PATCH v6 11/16] KVM: Implement IRQ bypass consumer callbacks for x86
Date: Wed, 12 Aug 2015 14:17:59 -0600	[thread overview]
Message-ID: <1439410679.4023.537.camel@redhat.com> (raw)
In-Reply-To: <1439273038-59463-12-git-send-email-feng.wu@intel.com>

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 <feng.wu@intel.com>
> ---
>  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 <linux/perf_event.h>
>  #include <linux/pvclock_gtod.h>
>  #include <linux/clocksource.h>
> +#include <linux/irqbypass.h>
>  
>  #include <asm/pvclock-abi.h>
>  #include <asm/desc.h>
> 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 <linux/pci.h>
>  #include <linux/timekeeper_internal.h>
>  #include <linux/pvclock_gtod.h>
> +#include <linux/kvm_irqfd.h>
> +#include <linux/irqbypass.h>
>  #include <trace/events/kvm.h>
>  
>  #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);




  reply	other threads:[~2015-08-12 20:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-11  6:03 [PATCH v6 00/16] Add VT-d Posted-Interrupts support Feng Wu
2015-08-11  6:03 ` [PATCH v6 01/16] KVM: Extend struct pi_desc for VT-d Posted-Interrupts Feng Wu
2015-08-11  6:03 ` [PATCH v6 02/16] KVM: Add some helper functions for Posted-Interrupts Feng Wu
2015-08-11  6:03 ` [PATCH v6 03/16] KVM: Define a new interface kvm_intr_is_single_vcpu() Feng Wu
2015-08-11  6:03 ` [PATCH v6 04/16] KVM: Get Posted-Interrupts descriptor address from 'struct kvm_vcpu' Feng Wu
2015-08-11  6:03 ` [PATCH v6 05/16] KVM: Add interfaces to control PI outside vmx Feng Wu
2015-08-11  6:03 ` [PATCH v6 06/16] KVM: Make struct kvm_irq_routing_table accessible Feng Wu
2015-08-11  6:03 ` [PATCH v6 07/16] KVM: make kvm_set_msi_irq() public Feng Wu
2015-08-11  6:03 ` [PATCH v6 08/16] vfio: Select IRQ_BYPASS_MANAGER for vfio PCI devices Feng Wu
2015-08-11  6:03 ` [PATCH v6 09/16] vfio: Register/unregister irq_bypass_producer Feng Wu
2015-08-11  6:03 ` [PATCH v6 10/16] KVM: x86: Update IRTE for posted-interrupts Feng Wu
2015-08-11  6:03 ` [PATCH v6 11/16] KVM: Implement IRQ bypass consumer callbacks for x86 Feng Wu
2015-08-12 20:17   ` Alex Williamson [this message]
2015-08-11  6:03 ` [PATCH v6 12/16] KVM: Add an arch specific hooks in 'struct kvm_kernel_irqfd' Feng Wu
2015-08-11  6:03 ` [PATCH v6 13/16] KVM: Update Posted-Interrupts Descriptor when vCPU is preempted Feng Wu
2015-08-11  6:03 ` [PATCH v6 14/16] KVM: Update Posted-Interrupts Descriptor when vCPU is blocked Feng Wu
2015-08-11  6:03 ` [PATCH v6 15/16] KVM: Warn if 'SN' is set during posting interrupts by software Feng Wu
2015-08-11  6:03 ` [PATCH v6 16/16] iommu/vt-d: Add a command line parameter for VT-d posted-interrupts Feng Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1439410679.4023.537.camel@redhat.com \
    --to=alex.williamson@redhat.com \
    --cc=eric.auger@linaro.org \
    --cc=feng.wu@intel.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox