[PATCH v6 11/16] KVM: Implement IRQ bypass consumer callbacks for x86

2015-08-10 Thread Feng Wu
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/k

[PATCH v6 13/16] KVM: Update Posted-Interrupts Descriptor when vCPU is preempted

2015-08-10 Thread Feng Wu
This patch updates the Posted-Interrupts Descriptor when vCPU is preempted. sched out: - Set 'SN' to suppress furture non-urgent interrupts posted for the vCPU. sched in: - Clear 'SN' - Change NDST if vCPU is scheduled to a different CPU - Set 'NV' to POSTED_INTR_VECTOR Signed-off-by: Feng Wu -

[PATCH v6 16/16] iommu/vt-d: Add a command line parameter for VT-d posted-interrupts

2015-08-10 Thread Feng Wu
Enable VT-d Posted-Interrtups and add a command line parameter for it. Signed-off-by: Feng Wu --- Documentation/kernel-parameters.txt | 1 + drivers/iommu/irq_remapping.c | 12 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Documentation/kernel-parameters.txt

[PATCH v6 10/16] KVM: x86: Update IRTE for posted-interrupts

2015-08-10 Thread Feng Wu
This patch adds the routine to update IRTE for posted-interrupts when guest changes the interrupt configuration. Signed-off-by: Feng Wu --- arch/x86/kvm/x86.c | 73 ++ 1 file changed, 73 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86

[PATCH v6 12/16] KVM: Add an arch specific hooks in 'struct kvm_kernel_irqfd'

2015-08-10 Thread Feng Wu
This patch adds an arch specific hooks 'arch_update' in 'struct kvm_kernel_irqfd'. On Intel side, it is used to update the IRTE when VT-d posted-interrupts is used. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/x86.c | 5 + include/linux/kvm_h

[PATCH v6 15/16] KVM: Warn if 'SN' is set during posting interrupts by software

2015-08-10 Thread Feng Wu
Currently, we don't support urgent interrupt, all interrupts are recognized as non-urgent interrupt, so we cannot post interrupts when 'SN' is set. If the vcpu is in guest mode, it cannot have been scheduled out, and that's the only case when SN is set currently, warning if SN is set. Signed-off-

[PATCH v6 07/16] KVM: make kvm_set_msi_irq() public

2015-08-10 Thread Feng Wu
Make kvm_set_msi_irq() public, we can use this function outside. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 4 arch/x86/kvm/irq_comm.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kv

[PATCH v6 08/16] vfio: Select IRQ_BYPASS_MANAGER for vfio PCI devices

2015-08-10 Thread Feng Wu
Enable irq bypass manager for vfio PCI devices. Signed-off-by: Feng Wu --- drivers/vfio/pci/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig index 579d83b..02912f1 100644 --- a/drivers/vfio/pci/Kconfig +++ b/drivers/vfio/pci/Kconfig

[PATCH v6 09/16] vfio: Register/unregister irq_bypass_producer

2015-08-10 Thread Feng Wu
This patch adds the registration/unregistration of an irq_bypass_producer for MSI/MSIx on vfio pci devices. v6: - Make the add_consumer and del_consumer callbacks static - Remove pointless INIT_LIST_HEAD to 'vdev->ctx[vector].producer.node)' - Use dev_info instead of WARN_ON() when irq_bypass_regi

[PATCH v6 14/16] KVM: Update Posted-Interrupts Descriptor when vCPU is blocked

2015-08-10 Thread Feng Wu
This patch updates the Posted-Interrupts Descriptor when vCPU is blocked. pre-block: - Add the vCPU to the blocked per-CPU list - Set 'NV' to POSTED_INTR_WAKEUP_VECTOR post-block: - Remove the vCPU from the per-CPU list Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 3 + arch/x

[PATCH v6 04/16] KVM: Get Posted-Interrupts descriptor address from 'struct kvm_vcpu'

2015-08-10 Thread Feng Wu
Define an interface to get PI descriptor address from the vCPU structure. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/vmx.c | 11 +++ 2 files changed, 13 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/k

[PATCH v6 05/16] KVM: Add interfaces to control PI outside vmx

2015-08-10 Thread Feng Wu
This patch adds pi_clear_sn and pi_set_sn to struct kvm_x86_ops, so we can set/clear SN outside vmx. Signed-off-by: Feng Wu --- arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/vmx.c | 13 + 2 files changed, 16 insertions(+) diff --git a/arch/x86/include/asm/kvm_h

[PATCH v6 00/16] Add VT-d Posted-Interrupts support

2015-08-10 Thread Feng Wu
VT-d Posted-Interrupts is an enhancement to CPU side Posted-Interrupt. With VT-d Posted-Interrupts enabled, external interrupts from direct-assigned devices can be delivered to guests without VMM intervention when guest is running in non-root mode. You can find the VT-d Posted-Interrtups Spec. in

[PATCH v6 06/16] KVM: Make struct kvm_irq_routing_table accessible

2015-08-10 Thread Feng Wu
Move struct kvm_irq_routing_table from irqchip.c to kvm_host.h, so we can use it outside of irqchip.c. Signed-off-by: Feng Wu --- include/linux/kvm_host.h | 14 ++ virt/kvm/irqchip.c | 10 -- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/linux

[PATCH v6 03/16] KVM: Define a new interface kvm_intr_is_single_vcpu()

2015-08-10 Thread Feng Wu
This patch defines a new interface kvm_intr_is_single_vcpu(), which can returns whether the interrupt is for single-CPU or not. It is used by VT-d PI, since now we only support single-CPU interrupts, For lowest-priority interrupts, if user configures it via /proc/irq or uses irqbalance to make it

[PATCH v6 01/16] KVM: Extend struct pi_desc for VT-d Posted-Interrupts

2015-08-10 Thread Feng Wu
Extend struct pi_desc for VT-d Posted-Interrupts. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 83b7b5c..271dd70 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/

[PATCH v6 02/16] KVM: Add some helper functions for Posted-Interrupts

2015-08-10 Thread Feng Wu
This patch adds some helper functions to manipulate the Posted-Interrupts Descriptor. Signed-off-by: Feng Wu --- arch/x86/kvm/vmx.c | 26 ++ 1 file changed, 26 insertions(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 271dd70..316f9bf 100644 --- a/arch/x86

Re: [PATCH v2 00/11] PCI: Fix ATS deadlock

2015-08-10 Thread Yinghai Lu
On Mon, Aug 10, 2015 at 10:33 AM, Bjorn Helgaas wrote: ... > Huh, I don't see anything obvious there. Where does it hang? Boot? > Driver attach? Can you give me any hints, or maybe try the attached patch? > Is there anything funny about those particular devices? Maybe some > "lspci -vv" output

RE: [PATCH v4 09/12] iommu/vt-d: implement (un)map_peer_resource

2015-08-10 Thread William Davis
On Monday, August 10, 2015 12:02 PM, Bjorn Helgaas wrote: > On Wed, Jul 22, 2015 at 04:39:54PM -0500, Will Davis wrote: > > Implement 'map_peer_resource' for the Intel IOMMU driver. Simply translate > > the resource to a physical address and route it to the same handlers used > > by the 'map_page'

Re: [PATCH v2 00/11] PCI: Fix ATS deadlock

2015-08-10 Thread Bjorn Helgaas
On Thu, Aug 06, 2015 at 06:06:34PM -0700, Yinghai Lu wrote: > On Thu, Aug 6, 2015 at 9:03 AM, Yinghai Lu wrote: > > On Wed, Jul 29, 2015 at 9:07 AM, Bjorn Helgaas wrote: > >>> > >>> Bjorn Helgaas (11): > >>> iommu/vt-d: Cache PCI ATS state and Invalidate Queue Depth > >>> PCI: Allocat

Re: [PATCH v4 07/12] pci: expose pci_find_host_bridge()

2015-08-10 Thread Bjorn Helgaas
On Wed, Jul 22, 2015 at 04:39:52PM -0500, Will Davis wrote: > This function takes a struct pci_bus * and returns the associated struct > pci_host_bridge * upstream. Nits: for the PCI parts, please run "git log --oneline" and make yours match the style of the previous history. Same for the changel

Re: [PATCH v4 09/12] iommu/vt-d: implement (un)map_peer_resource

2015-08-10 Thread Bjorn Helgaas
On Wed, Jul 22, 2015 at 04:39:54PM -0500, Will Davis wrote: > Implement 'map_peer_resource' for the Intel IOMMU driver. Simply translate > the resource to a physical address and route it to the same handlers used > by the 'map_page' API. > > This allows a device to map another's resource, to enabl

Re: [PATCH v4 10/12] pci: add pci_find_common_upstream_dev()

2015-08-10 Thread Bjorn Helgaas
On Wed, Jul 22, 2015 at 04:39:55PM -0500, Will Davis wrote: > Adds an interface to find the first device which is upstream of both > devices. > > Signed-off-by: Will Davis > --- > drivers/pci/search.c | 25 + > include/linux/pci.h | 2 ++ > 2 files changed, 27 insertion

Re: [PATCH v4 00/12] DMA-API/PCI map_peer_resource support for peer-to-peer

2015-08-10 Thread Will Davis
> Hi, > > This is the fourth version of a patchset to add the DMA APIs necessary to > map and unmap a PCI device's BAR to and from another PCI device's IOVA > domain. This enables PCI peer-to-peer traffic on x86 platforms where an > IOMMU is enabled (this requires that peer-to-peer traffic be supp