[RFC PATCH v4 0/7] vfio-pci: Allow to mmap sub-page MMIO BARs and MSI-X table

2016-03-06 Thread Yongji Xie
FIO_DEVICE_FLAGS_PCI_PAGE_ALIGNED VFIO_DEVICE_FLAGS_PCI_MSIX_MMAP - Add a Kconfig option to support for mmapping MSI-X table. [1] http://www.spinics.net/lists/kvm/msg127812.html Yongji Xie (7): PCI: Add a new option for resource_alignment to reassign alignment PCI: Use IORESOURCE_WINDOW to identify bridge resources

[RFC PATCH v4 1/7] PCI: Add a new option for resource_alignment to reassign alignment

2016-03-06 Thread Yongji Xie
When using resource_alignment kernel parameter, the current implement reassigns the alignment by changing resources' size which can potentially break some drivers. So this patch adds a new option "noresize" for the parameter to solve this problem. Signed-off-by: Yongji Xie ---

[RFC PATCH v4 2/7] PCI: Use IORESOURCE_WINDOW to identify bridge resources

2016-03-06 Thread Yongji Xie
patch replaces IORESOURCE_STARTALIGN with IORESOURCE_WINDOW. Signed-off-by: Yongji Xie --- drivers/pci/setup-bus.c | 21 - 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 7796d0a..4ff10ca 100644 --- a/dr

[RFC PATCH v4 5/7] vfio-pci: Allow to mmap sub-page MMIO BARs if the mmio page is exclusive

2016-03-06 Thread Yongji Xie
th other BARs. Signed-off-by: Yongji Xie --- drivers/vfio/pci/vfio_pci.c |7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 1ce1d36..49d7a69 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/p

[RFC PATCH v4 4/7] PCI: Modify resource_alignment to support multiple devices

2016-03-06 Thread Yongji Xie
mmio page would not be shared with other BARs. Signed-off-by: Yongji Xie --- Documentation/kernel-parameters.txt |2 + drivers/pci/pci.c | 90 ++- include/linux/pci.h |4 ++ 3 files changed, 85 insertions(+), 11 deleti

[RFC PATCH v4 6/7] vfio-pci: Allow to mmap MSI-X table if IOMMU_CAP_INTR_REMAP was set

2016-03-06 Thread Yongji Xie
Current vfio-pci implementation disallows to mmap MSI-X table in case that user get to touch this directly. But we should allow to mmap these MSI-X tables if IOMMU supports interrupt remapping which can ensure that a given pci device can only shoot the MSIs assigned for it. Signed-off-by: Yongji

[RFC PATCH v4 7/7] powerpc/powernv/pci-ioda: Add IOMMU_CAP_INTR_REMAP for IODA host bridge

2016-03-06 Thread Yongji Xie
This patch adds IOMMU_CAP_INTR_REMAP for IODA host bridge so that we can mmap MSI-X table in vfio driver. Signed-off-by: Yongji Xie --- arch/powerpc/platforms/powernv/pci-ioda.c | 17 + 1 file changed, 17 insertions(+) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b

[RFC PATCH v4 3/7] PCI: Ignore resource_alignment if PCI_PROBE_ONLY was set

2016-03-06 Thread Yongji Xie
use firmware setup and not to reassign any resources. To solve this problem, this patch ignores resource_alignment if PCI_PROBE_ONLY was set. Signed-off-by: Yongji Xie --- Documentation/kernel-parameters.txt |2 ++ drivers/pci/probe.c |3 ++- 2 files changed, 4 insertions

Re: [RFC PATCH v4 1/7] PCI: Add a new option for resource_alignment to reassign alignment

2016-03-09 Thread Yongji Xie
On 2016/3/10 10:19, Alexey Kardashevskiy wrote: On 03/07/2016 06:48 PM, Yongji Xie wrote: When using resource_alignment kernel parameter, the current implement reassigns the alignment by changing resources' size which can potentially break some drivers. How can this possibly break any d

Re: [RFC PATCH v4 0/7] vfio-pci: Allow to mmap sub-page MMIO BARs and MSI-X table

2016-03-16 Thread Yongji Xie
Ping. On 2016/3/7 15:48, Yongji Xie wrote: Current vfio-pci implementation disallows to mmap sub-page(size < PAGE_SIZE) MMIO BARs and MSI-X table. This is because sub-page BARs' mmio page may be shared with other BARs and MSI-X table should not be accessed directly from the guest for

Re: [RFC PATCH v4 7/7] powerpc/powernv/pci-ioda: Add IOMMU_CAP_INTR_REMAP for IODA host bridge

2016-03-18 Thread Yongji Xie
On 2016/3/17 0:32, Alex Williamson wrote: On Mon, 7 Mar 2016 15:48:38 +0800 Yongji Xie wrote: This patch adds IOMMU_CAP_INTR_REMAP for IODA host bridge so that we can mmap MSI-X table in vfio driver. Signed-off-by: Yongji Xie --- arch/powerpc/platforms/powernv/pci-ioda.c | 17

Re: [RFC PATCH v4 4/7] PCI: Modify resource_alignment to support multiple devices

2016-03-19 Thread Yongji Xie
On 2016/3/17 0:30, Alex Williamson wrote: On Mon, 7 Mar 2016 15:48:35 +0800 Yongji Xie wrote: When vfio passthrough a PCI device of which MMIO BARs are smaller than PAGE_SIZE, guest will not handle the mmio accesses to the BARs which leads to mmio emulations in host. This is because vfio

Re: [RFC PATCH v4 4/7] PCI: Modify resource_alignment to support multiple devices

2016-03-19 Thread Yongji Xie
On 2016/3/17 20:40, Alex Williamson wrote: On Thu, 17 Mar 2016 19:28:34 +0800 Yongji Xie wrote: On 2016/3/17 0:30, Alex Williamson wrote: On Mon, 7 Mar 2016 15:48:35 +0800 Yongji Xie wrote: When vfio passthrough a PCI device of which MMIO BARs are smaller than PAGE_SIZE, guest will not

Re: [RFC PATCH v4 0/7] vfio-pci: Allow to mmap sub-page MMIO BARs and MSI-X table

2016-03-19 Thread Yongji Xie
On 2016/3/16 22:10, Bjorn Helgaas wrote: On Wed, Mar 16, 2016 at 06:51:56PM +0800, Yongji Xie wrote: Ping. This is mainly VFIO stuff, and Alex had some security concerns, so I'm not going to spend much time looking at this until he's satisfied. When I do, I'll be look

Re: [RFC PATCH v4 3/7] PCI: Ignore resource_alignment if PCI_PROBE_ONLY was set

2016-03-19 Thread Yongji Xie
On 2016/3/17 0:31, Alex Williamson wrote: On Mon, 7 Mar 2016 15:48:34 +0800 Yongji Xie wrote: The resource_alignment will releases memory resources allocated by firmware so that kernel can reassign new resources later on. But this will cause the problem that no resources can be allocated by

Re: [RFC PATCH v4 7/7] powerpc/powernv/pci-ioda: Add IOMMU_CAP_INTR_REMAP for IODA host bridge

2016-03-19 Thread Yongji Xie
On 2016/3/17 20:48, Alex Williamson wrote: On Thu, 17 Mar 2016 19:38:29 +0800 Yongji Xie wrote: On 2016/3/17 0:32, Alex Williamson wrote: On Mon, 7 Mar 2016 15:48:38 +0800 Yongji Xie wrote: This patch adds IOMMU_CAP_INTR_REMAP for IODA host bridge so that we can mmap MSI-X table in

Re: [RFC PATCH v4 6/7] vfio-pci: Allow to mmap MSI-X table if IOMMU_CAP_INTR_REMAP was set

2016-03-19 Thread Yongji Xie
On 2016/3/17 0:31, Alex Williamson wrote: [cc+ Eric, Will] On Mon, 7 Mar 2016 15:48:37 +0800 Yongji Xie wrote: Current vfio-pci implementation disallows to mmap MSI-X table in case that user get to touch this directly. But we should allow to mmap these MSI-X tables if IOMMU supports

Re: [RFC PATCH v4 5/7] vfio-pci: Allow to mmap sub-page MMIO BARs if the mmio page is exclusive

2016-03-19 Thread Yongji Xie
On 2016/3/17 0:30, Alex Williamson wrote: On Mon, 7 Mar 2016 15:48:36 +0800 Yongji Xie wrote: Current vfio-pci implementation disallows to mmap sub-page(size < PAGE_SIZE) MMIO BARs because these BARs' mmio page may be shared with other BARs. But we should allow to mmap these sub-p

[RFC v5 0/7] vfio-pci: Allow to mmap sub-page MMIO BARs and MSI-X table

2016-04-05 Thread Yongji Xie
stead of doing it on PPC64 arch code. - Remove flags: VFIO_DEVICE_FLAGS_PCI_PAGE_ALIGNED VFIO_DEVICE_FLAGS_PCI_MSIX_MMAP - Add a Kconfig option to support for mmapping MSI-X table. [1] http://www.spinics.net/lists/kvm/msg127812.html Yongji Xie (7): PCI: Ignore resource_alignment if PCI_PROBE_ONLY was set PCI: D

[RFC v5 1/7] PCI: Ignore resource_alignment if PCI_PROBE_ONLY was set

2016-04-05 Thread Yongji Xie
use firmware setup and not to reassign any resources. To solve this problem, this patch ignores resource_alignment if PCI_PROBE_ONLY was set. Signed-off-by: Yongji Xie --- drivers/pci/pci.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index

[RFC v5 2/7] PCI: Do not Use IORESOURCE_STARTALIGN to identify bridge resources

2016-04-05 Thread Yongji Xie
ridge resources. Signed-off-by: Yongji Xie --- drivers/pci/setup-bus.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 7796d0a..bffcf1e 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -391,6 +

[RFC v5 3/7] PCI: Add a new option for resource_alignment to reassign alignment

2016-04-05 Thread Yongji Xie
t;noresize" for the parameter to solve this problem. Signed-off-by: Yongji Xie --- Documentation/kernel-parameters.txt |5 - drivers/pci/pci.c | 37 +-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Docum

[RFC v5 4/7] PCI: Add support for enforcing all MMIO BARs to be page aligned

2016-04-05 Thread Yongji Xie
lignment of all MMIO BARs to be at least PAGE_SIZE so that one BAR's mmio page would not be shared with other BARs. And we also define a macro PCIBIOS_MIN_ALIGNMENT to enable this automatically on PPC64 platform which can easily hit this issue because its PAGE_SIZE is 64KB. Signe

[RFC v5 5/7] vfio-pci: Allow to mmap sub-page MMIO BARs if the mmio page is exclusive

2016-04-05 Thread Yongji Xie
will never be assigned into the hole. So we add shadow resources and put them into the hole in this patch. With these two guarantees, I think it should be safe to mmap sub-page BAR. Signed-off-by: Yongji Xie --- drivers/vfio/pci/vfio_pci.c | 58 +

[RFC v5 7/7] vfio-pci: Allow to mmap MSI-X table if interrupt remapping is supported

2016-04-05 Thread Yongji Xie
This patch enables mmapping MSI-X tables if hardware supports interrupt remapping which can ensure that a given pci device can only shoot the MSIs assigned for it. Signed-off-by: Yongji Xie --- drivers/vfio/pci/vfio_pci.c |9 +++-- drivers/vfio/pci/vfio_pci_private.h |1

[RFC v5 6/7] PCI: Add a new bit to pci_bus_flags to indicate interrupt remapping

2016-04-05 Thread Yongji Xie
is capability, like this patch does. Compared with IOMMU_CAP_INTR_REMAP, this flag is more common. Any arch can set/use this easily. And it can provide a better granularity (pci_bus_type -> pci_bus). [1] http://www.spinics.net/lists/kvm/msg130262.html Signed-off-by: Yongji Xie --- arch/powerpc/p

Re: [RFC v5 2/7] PCI: Do not Use IORESOURCE_STARTALIGN to identify bridge resources

2016-04-05 Thread Yongji Xie
On 2016/4/6 8:55, Gavin Shan wrote: On Tue, Apr 05, 2016 at 09:43:30PM +0800, Yongji Xie wrote: Now we use the IORESOURCE_STARTALIGN to identify bridge resources in __assign_resources_sorted(). That's quite fragile. We can't make sure that the PCI devices' resourc

Re: [RFC v5 1/7] PCI: Ignore resource_alignment if PCI_PROBE_ONLY was set

2016-04-05 Thread Yongji Xie
On 2016/4/6 8:48, Gavin Shan wrote: On Tue, Apr 05, 2016 at 09:43:29PM +0800, Yongji Xie wrote: The resource_alignment will releases memory resources allocated by firmware so that kernel can reassign new resources later on. But this will cause the problem that no resources can be allocated by

Re: [RFC v5 3/7] PCI: Add a new option for resource_alignment to reassign alignment

2016-04-05 Thread Yongji Xie
On 2016/4/6 9:43, Gavin Shan wrote: On Tue, Apr 05, 2016 at 09:43:31PM +0800, Yongji Xie wrote: When using resource_alignment kernel parameter, the current implement reassigns the alignment by changing resources' size which can potentially break some drivers. For example, the driver use

Re: [RFC v5 6/7] PCI: Add a new bit to pci_bus_flags to indicate interrupt remapping

2016-04-05 Thread Yongji Xie
On 2016/4/6 8:11, Gavin Shan wrote: On Tue, Apr 05, 2016 at 09:46:43PM +0800, Yongji Xie wrote: I'm trying to find a proper way to indicate the capability of interrupt remapping on PPC64 because we need this to determine whether it is safe to mmap MSI-X table in VFIO driver. There

Re: [RFC v5 7/7] vfio-pci: Allow to mmap MSI-X table if interrupt remapping is supported

2016-04-05 Thread Yongji Xie
On 2016/4/6 8:00, Gavin Shan wrote: On Tue, Apr 05, 2016 at 09:46:44PM +0800, Yongji Xie wrote: This patch enables mmapping MSI-X tables if hardware supports interrupt remapping which can ensure that a given pci device can only shoot the MSIs assigned for it. Signed-off-by: Yongji Xie

Re: [RFC v5 7/7] vfio-pci: Allow to mmap MSI-X table if interrupt remapping is supported

2016-04-07 Thread Yongji Xie
On 2016/4/6 22:45, Alex Williamson wrote: On Tue, 5 Apr 2016 21:46:44 +0800 Yongji Xie wrote: This patch enables mmapping MSI-X tables if hardware supports interrupt remapping which can ensure that a given pci device can only shoot the MSIs assigned for it. Signed-off-by: Yongji Xie

Re: [RFC v5 7/7] vfio-pci: Allow to mmap MSI-X table if interrupt remapping is supported

2016-04-08 Thread Yongji Xie
Hi Eric, On 2016/4/7 22:23, Eric Auger wrote: Hi Yongji, On 04/07/2016 01:38 PM, Yongji Xie wrote: On 2016/4/6 22:45, Alex Williamson wrote: On Tue, 5 Apr 2016 21:46:44 +0800 Yongji Xie wrote: This patch enables mmapping MSI-X tables if hardware supports interrupt remapping which can

Re: [RFC v5 7/7] vfio-pci: Allow to mmap MSI-X table if interrupt remapping is supported

2016-04-08 Thread Yongji Xie
Hi Eric, On 2016/4/8 17:10, Eric Auger wrote: Hi Yongji, On 04/08/2016 10:14 AM, Yongji Xie wrote: Hi Eric, On 2016/4/7 22:23, Eric Auger wrote: Hi Yongji, On 04/07/2016 01:38 PM, Yongji Xie wrote: On 2016/4/6 22:45, Alex Williamson wrote: On Tue, 5 Apr 2016 21:46:44 +0800 Yongji Xie wrote

[RFC v6 00/10] vfio-pci: Allow to mmap sub-page MMIO BARs and MSI-X table

2016-04-18 Thread Yongji Xie
parameter to enforce all MMIO BARs to be page aligned on PCI core code instead of doing it on PPC64 arch code. - Remove flags: VFIO_DEVICE_FLAGS_PCI_PAGE_ALIGNED [1] http://www.spinics.net/lists/kvm/msg127812.html [2] http://www.spinics.net/lists/kvm/msg130256.html Yongji Xie (10): PCI: Ignore

[RFC v6 01/10] PCI: Ignore resource_alignment if PCI_PROBE_ONLY was set

2016-04-18 Thread Yongji Xie
use firmware setup and not to reassign any resources. To solve this problem, this patch ignores resource_alignment if PCI_PROBE_ONLY was set. Signed-off-by: Yongji Xie --- drivers/pci/pci.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index

[RFC v6 03/10] PCI: Add a new option for resource_alignment to reassign alignment

2016-04-18 Thread Yongji Xie
ption "noresize" for the parameter to solve this problem. Signed-off-by: Yongji Xie --- Documentation/kernel-parameters.txt |5 - drivers/pci/pci.c | 35 +-- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Docum

[RFC v6 04/10] PCI: Add support for enforcing all MMIO BARs to be page aligned

2016-04-18 Thread Yongji Xie
lignment of all MMIO BARs to be at least PAGE_SIZE so that one BAR's mmio page would not be shared with other BARs. And we also define a macro PCIBIOS_MIN_ALIGNMENT to enable this automatically on PPC64 platform which can easily hit this issue because its PAGE_SIZE is 64KB. Signe

[RFC v6 02/10] PCI: Do not Use IORESOURCE_STARTALIGN to identify bridge resources

2016-04-18 Thread Yongji Xie
ridge resources. Signed-off-by: Yongji Xie --- drivers/pci/setup-bus.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 7796d0a..45fc484 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -391,6 +

[RFC v6 05/10] vfio-pci: Allow to mmap sub-page MMIO BARs if the mmio page is exclusive

2016-04-18 Thread Yongji Xie
will never be assigned into the hole. So we add shadow resources and put them into the hole in this patch. With these two guarantees, I think it should be safe to mmap sub-page BAR. Signed-off-by: Yongji Xie --- drivers/vfio/pci/vfio_pci.c | 58 +

[RFC v6 06/10] PCI: Add a new PCI_BUS_FLAGS_MSI_REMAP flag

2016-04-18 Thread Yongji Xie
sg130256.html Signed-off-by: Yongji Xie --- include/linux/pci.h |1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index 27df4a6..d619228 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -193,6 +193,7 @@ typedef unsigned short _

[RFC v6 07/10] iommu: Set PCI_BUS_FLAGS_MSI_REMAP if IOMMU have capability of IRQ remapping

2016-04-18 Thread Yongji Xie
. Signed-off-by: Yongji Xie --- drivers/iommu/iommu.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 0e3b009..5d2b6f6 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -813,6 +813,16 @@ struct iommu_group

[RFC v6 08/10] PCI: Set PCI_BUS_FLAGS_MSI_REMAP if MSI controller supports IRQ remapping

2016-04-18 Thread Yongji Xie
. [1] http://www.spinics.net/lists/kvm/msg130256.html Signed-off-by: Yongji Xie --- drivers/pci/msi.c | 12 drivers/pci/probe.c |3 +++ include/linux/msi.h |6 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index

[RFC v6 09/10] pci-ioda: Set PCI_BUS_FLAGS_MSI_REMAP for IODA host bridge

2016-04-18 Thread Yongji Xie
Any IODA host bridge have the capability of IRQ remapping. So we set PCI_BUS_FLAGS_MSI_REMAP when this kind of host birdge is detected. Signed-off-by: Yongji Xie --- arch/powerpc/platforms/powernv/pci-ioda.c |8 1 file changed, 8 insertions(+) diff --git a/arch/powerpc/platforms

[RFC v6 10/10] vfio-pci: Allow to mmap MSI-X table if interrupt remapping is supported

2016-04-18 Thread Yongji Xie
: Yongji Xie --- drivers/vfio/pci/vfio_pci.c |7 +-- drivers/vfio/pci/vfio_pci_rdwr.c |3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index dc1779c..b08abe0 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b

Re: [RFC v6 06/10] PCI: Add a new PCI_BUS_FLAGS_MSI_REMAP flag

2016-04-19 Thread Yongji Xie
On 2016/4/18 19:30, David Laight wrote: From: Yongji Xie Sent: 18 April 2016 11:59 We introduce a new pci_bus_flags, PCI_BUS_FLAGS_MSI_REMAP which indicates all devices on the bus are protected by the hardware which supports IRQ remapping(intel naming). This flag will be used to know whether

Re: [RFC v6 00/10] vfio-pci: Allow to mmap sub-page MMIO BARs and MSI-X table

2016-04-25 Thread Yongji Xie
Hi Alex, Any comment? Thanks, Yongji On 2016/4/18 18:53, Yongji Xie wrote: Current vfio-pci implementation disallows to mmap sub-page(size < PAGE_SIZE) MMIO BARs and MSI-X table. This is because sub-page BARs' mmio page may be shared with other BARs and MSI-X table should not be

Re: [RFC v6 04/10] PCI: Add support for enforcing all MMIO BARs to be page aligned

2016-04-25 Thread Yongji Xie
On 2016/4/26 13:41, Alexey Kardashevskiy wrote: On 04/18/2016 08:56 PM, Yongji Xie wrote: When vfio passthrough a PCI device of which MMIO BARs are smaller than PAGE_SIZE, guest will not handle the mmio accesses to the BARs which leads to mmio emulations in host. This is because vfio will not

Re: [RFC v6 00/10] vfio-pci: Allow to mmap sub-page MMIO BARs and MSI-X table

2016-04-26 Thread Yongji Xie
On 2016/4/27 0:40, Alex Williamson wrote: On Mon, 25 Apr 2016 18:05:53 +0800 Yongji Xie wrote: Hi Alex, Any comment? TBH, I shuffled this to the bottom of the review pile because you're depending on a patch series for ARM MSI mapping that's still very much in flux. You've

[PATCH 1/4] PCI: Ignore resource_alignment if PCI_PROBE_ONLY was set

2016-04-27 Thread Yongji Xie
use firmware setup and not to reassign any resources. To solve this problem, this patch ignores resource_alignment if PCI_PROBE_ONLY was set. Signed-off-by: Yongji Xie --- drivers/pci/pci.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index

[PATCH 0/4] PCI: Add support for enforcing all MMIO BARs not to share PAGE_SIZE

2016-04-27 Thread Yongji Xie
PCI BARs; patch 4 modified resource_alignment to support syntax which can be used to enforce the alignment of all MMIO BARs to be at least PAGE_SIZE. Yongji Xie (4): PCI: Ignore resource_alignment if PCI_PROBE_ONLY was set PCI: Do not Use IORESOURCE_STARTALIGN to identify bridge resources PCI: A

[PATCH 2/4] PCI: Do not Use IORESOURCE_STARTALIGN to identify bridge resources

2016-04-27 Thread Yongji Xie
ridge resources. Signed-off-by: Yongji Xie --- drivers/pci/setup-bus.c |9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 55641a3..216ddbc 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -390,6 +

[PATCH 4/4] PCI: Add support for enforcing all MMIO BARs to be page aligned

2016-04-27 Thread Yongji Xie
to enforce the alignment of all MMIO BARs to be at least PAGE_SIZE so that one BAR's mmio page would not be shared with other BARs. And we also define a macro PCIBIOS_MIN_ALIGNMENT to enable this automatically on PPC64 platform which can easily hit this issue because its PAGE_SIZE is 64KB. S

[PATCH 3/4] PCI: Add a new option for resource_alignment to reassign alignment

2016-04-27 Thread Yongji Xie
ption "noresize" for the parameter to solve this problem. Signed-off-by: Yongji Xie --- Documentation/kernel-parameters.txt |5 - drivers/pci/pci.c | 35 +-- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Docum

[PATCH] vfio-pci: Allow to mmap sub-page MMIO BARs if the mmio page is exclusive

2016-04-27 Thread Yongji Xie
shadow resource to reserve the remaind of the page which hot-add device's BAR might be assigned into. Signed-off-by: Yongji Xie --- drivers/vfio/pci/vfio_pci.c | 58 ++- drivers/vfio/pci/vfio_pci_private.h |8 + 2 files changed, 59 insertions(+)

[PATCH 2/5] iommu: Set PCI_BUS_FLAGS_MSI_REMAP if IOMMU have capability of IRQ remapping

2016-04-27 Thread Yongji Xie
. Signed-off-by: Yongji Xie --- drivers/iommu/iommu.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 0e3b009..5d2b6f6 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -813,6 +813,16 @@ struct iommu_group

[PATCH 0/5] vfio-pci: Add support for mmapping MSI-X table

2016-04-27 Thread Yongji Xie
we introduce a new bus_flags PCI_BUS_FLAGS_MSI_REMAP to test this capability on PCI side for different archs. The patch 3 are based on the proposed patchset[1]. [1] http://www.spinics.net/lists/kvm/msg130256.html Yongji Xie (5): PCI: Add a new PCI_BUS_FLAGS_MSI_REMAP flag iommu: Set

[PATCH 1/5] PCI: Add a new PCI_BUS_FLAGS_MSI_REMAP flag

2016-04-27 Thread Yongji Xie
ists/kvm/msg130256.html Signed-off-by: Yongji Xie --- include/linux/pci.h |1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index 27df4a6..d619228 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -193,6 +193,7 @@ typedef unsigned short _

[PATCH 5/5] vfio-pci: Allow to mmap MSI-X table if interrupt remapping is supported

2016-04-27 Thread Yongji Xie
: Yongji Xie --- drivers/vfio/pci/vfio_pci.c |7 +-- drivers/vfio/pci/vfio_pci_rdwr.c |3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 98059df..7eba77d 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b

[PATCH 4/5] pci-ioda: Set PCI_BUS_FLAGS_MSI_REMAP for IODA host bridge

2016-04-27 Thread Yongji Xie
Any IODA host bridge have the capability of IRQ remapping. So we set PCI_BUS_FLAGS_MSI_REMAP when this kind of host birdge is detected. Signed-off-by: Yongji Xie --- arch/powerpc/platforms/powernv/pci-ioda.c |8 1 file changed, 8 insertions(+) diff --git a/arch/powerpc/platforms

[PATCH 3/5] PCI: Set PCI_BUS_FLAGS_MSI_REMAP if MSI controller supports IRQ remapping

2016-04-27 Thread Yongji Xie
. [1] http://www.spinics.net/lists/kvm/msg130256.html Signed-off-by: Yongji Xie --- drivers/pci/msi.c | 12 drivers/pci/probe.c |3 +++ include/linux/msi.h |6 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index

[RFC PATCH 0/3] vfio-pci: Allow to mmap sub-page MMIO BARs and MSI-X table on PPC64 platform

2015-12-11 Thread Yongji Xie
tl to indicate that platform support all PCI BARs are page aligned. - Add support for a VFIO-PCI ioctl to indicate that platform support mmapping MSI-X table. Yongji Xie (3): powerpc/pci: Enforce all MMIO BARs to be page aligned vfio-pci: Allow to mmap sub-page MMIO BA

[RFC PATCH 1/3] powerpc/pci: Enforce all MMIO BARs to be page aligned

2015-12-11 Thread Yongji Xie
ned-off-by: Yongji Xie --- arch/powerpc/kernel/pci-common.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 0f7a60f..6989e0f 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/

[RFC PATCH 2/3] vfio-pci: Allow to mmap sub-page MMIO BARs if all MMIO BARs are page aligned

2015-12-11 Thread Yongji Xie
ed with other BARs. This patch adds support for this case and we also add a VFIO_DEVICE_FLAGS_PCI_PAGE_ALIGNED flag to notify userspace that platform supports all MMIO BARs to be page aligned. Signed-off-by: Yongji Xie --- drivers/vfio/pci/vfio_pci.c | 10 +- dri

[RFC PATCH 3/3] vfio-pci: Allow to mmap MSI-X table if EEH is supported

2015-12-11 Thread Yongji Xie
userspace that it's safe to mmap MSI-X table. Signed-off-by: Yongji Xie --- drivers/vfio/pci/vfio_pci.c |5 - drivers/vfio/pci/vfio_pci_private.h |5 + include/uapi/linux/vfio.h |2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/vfi

Re: [RFC PATCH 2/3] vfio-pci: Allow to mmap sub-page MMIO BARs if all MMIO BARs are page aligned

2015-12-17 Thread yongji xie
On 2015/12/17 4:04, Alex Williamson wrote: On Fri, 2015-12-11 at 16:53 +0800, Yongji Xie wrote: Current vfio-pci implementation disallows to mmap sub-page(size < PAGE_SIZE) MMIO BARs because these BARs' mmio page may be shared with other BARs. But we should allow to mmap these sub-p

Re: [RFC PATCH 3/3] vfio-pci: Allow to mmap MSI-X table if EEH is supported

2015-12-17 Thread yongji xie
On 2015/12/17 4:14, Alex Williamson wrote: On Fri, 2015-12-11 at 16:53 +0800, Yongji Xie wrote: Current vfio-pci implementation disallows to mmap MSI-X table in case that user get to touch this directly. However, EEH mechanism could ensure that a given pci device can only shoot the MSIs

Re: [RFC PATCH 2/3] vfio-pci: Allow to mmap sub-page MMIO BARs if all MMIO BARs are page aligned

2015-12-18 Thread yongji xie
On 2015/12/18 5:46, Alex Williamson wrote: On Thu, 2015-12-17 at 18:26 +0800, yongji xie wrote: On 2015/12/17 4:04, Alex Williamson wrote: On Fri, 2015-12-11 at 16:53 +0800, Yongji Xie wrote: Current vfio-pci implementation disallows to mmap sub-page(size < PAGE_SIZE) MMIO BARs beca

[RFC PATCH v2 0/3] vfio-pci: Allow to mmap sub-page MMIO BARs and MSI-X table on PPC64 platform

2015-12-31 Thread Yongji Xie
64 arch code. - Remove flags: VFIO_DEVICE_FLAGS_PCI_PAGE_ALIGNED VFIO_DEVICE_FLAGS_PCI_MSIX_MMAP - Add a Kconfig option to support for mmapping MSI-X table. [1] https://lkml.org/lkml/2015/11/23/748 Yongji Xie (3): PCI: Add support for enforcing all MMIO BARs to be page aligned vfio-pci: Allow to mmap sub-pag

[RFC PATCH v2 1/3] PCI: Add support for enforcing all MMIO BARs to be page aligned

2015-12-31 Thread Yongji Xie
because its PAGE_SIZE is 64KB. Signed-off-by: Yongji Xie --- Documentation/kernel-parameters.txt |4 arch/powerpc/include/asm/pci.h | 11 +++ drivers/pci/pci.c | 17 + drivers/pci/pci.h |7 ++- include/linux/pci.h

[RFC PATCH v2 3/3] vfio-pci: Allow to mmap MSI-X table if EEH is supported

2015-12-31 Thread Yongji Xie
upport for mmapping MSI-X table. Signed-off-by: Yongji Xie --- drivers/vfio/pci/Kconfig|4 drivers/vfio/pci/vfio_pci.c |6 -- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig index 02912f1..67b0a2c 100644 ---

[RFC PATCH v2 2/3] vfio-pci: Allow to mmap sub-page MMIO BARs if all MMIO BARs are page aligned

2015-12-31 Thread Yongji Xie
AGE_SIZE. Signed-off-by: Yongji Xie --- drivers/vfio/pci/vfio_pci.c |7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 7e9f497..09b3805 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @

Re: [RFC PATCH v2 1/3] PCI: Add support for enforcing all MMIO BARs to be page aligned

2016-01-05 Thread Yongji Xie
On 2016/1/5 4:47, Alex Williamson wrote: On Thu, 2015-12-31 at 16:50 +0800, Yongji Xie wrote: When vfio passthrough a PCI device of which MMIO BARs are smaller than PAGE_SIZE, guest will not handle the mmio accesses to the BARs which leads to mmio emulations in host. This is because vfio will

Re: [RFC PATCH v2 3/3] vfio-pci: Allow to mmap MSI-X table if EEH is supported

2016-01-06 Thread Yongji Xie
On 2016/1/5 5:42, Benjamin Herrenschmidt wrote: On Mon, 2016-01-04 at 14:07 -0700, Alex Williamson wrote: On Thu, 2015-12-31 at 16:50 +0800, Yongji Xie wrote: Current vfio-pci implementation disallows to mmap MSI-X table in case that user get to touch this directly. However, EEH mechanism can

[RFC PATCH v3 0/5] vfio-pci: Allow to mmap sub-page MMIO BARs and MSI-X table on PPC64 platform

2016-01-14 Thread Yongji Xie
ion to support for mmapping MSI-X table. [1] https://lkml.org/lkml/2015/11/23/748 Yongji Xie (5): PCI: Add support for enforcing all MMIO BARs to be page aligned vfio-pci: Allow to mmap sub-page MMIO BARs if the mmio page is exclusive PCI: Add host bridge attribute to indicate filtering of MS

[RFC PATCH v3 2/5] vfio-pci: Allow to mmap sub-page MMIO BARs if the mmio page is exclusive

2016-01-14 Thread Yongji Xie
th other BARs. Signed-off-by: Yongji Xie --- drivers/vfio/pci/vfio_pci.c |7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 7e9f497..11fd0f0 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/p

[RFC PATCH v3 1/5] PCI: Add support for enforcing all MMIO BARs to be page aligned

2016-01-14 Thread Yongji Xie
issue because its PAGE_SIZE is 64KB. Note that the kernel parameter won't works if kernel doesn't do resources reallocation. Signed-off-by: Yongji Xie --- Documentation/kernel-parameters.txt |5 + arch/powerpc/include/asm/pci.h | 11 +++ dr

[RFC PATCH v3 3/5] PCI: Add host bridge attribute to indicate filtering of MSIs is supported

2016-01-14 Thread Yongji Xie
To support this case, this patch adds a pci_host_bridge attribute to indicate if this PCI host bridge supports filtering of MSIs. Signed-off-by: Yongji Xie --- drivers/pci/host-bridge.c |6 ++ include/linux/pci.h |3 +++ 2 files changed, 9 insertions(+) diff --git a/driver

[RFC PATCH v3 4/5] powerpc/powernv/pci-ioda: Enable msi_filtered bit for any IODA host bridge

2016-01-14 Thread Yongji Xie
This patch enables msi_filtered bit for any IODA host bridge. Signed-off-by: Yongji Xie --- arch/powerpc/platforms/powernv/pci-ioda.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 414fd1a

[RFC PATCH v3 5/5] vfio-pci: Allow to mmap MSI-X table if host bridge supports filtering of MSIs

2016-01-14 Thread Yongji Xie
Current vfio-pci implementation disallows to mmap MSI-X table in case that user get to touch this directly. But we should allow to mmap these MSI-X tables if the PCI host bridge supports filtering of MSIs. Signed-off-by: Yongji Xie --- drivers/vfio/pci/vfio_pci.c |6 -- 1 file changed

Re: [RFC PATCH v3 3/5] PCI: Add host bridge attribute to indicate filtering of MSIs is supported

2016-01-20 Thread Yongji Xie
On 2016/1/16 1:24, David Laight wrote: From: Yongji Xie Sent: 15 January 2016 07:06 MSI-X tables are not allowed to be mmapped in vfio-pci driver in case that user get to touch this directly. This will cause some performance issues when when PCI adapters have critical registers in the same

Re: [RFC PATCH v3 0/5] vfio-pci: Allow to mmap sub-page MMIO BARs and MSI-X table on PPC64 platform

2016-01-28 Thread Yongji Xie
Ping... Alex, any comment? Regards, Yongji Xie On 2016/1/15 15:06, Yongji Xie wrote: Current vfio-pci implementation disallows to mmap sub-page(size < PAGE_SIZE) MMIO BARs and MSI-X table. This is because sub-page BARs' mmio page may be shared with other BARs and MSI-X table shoul

Re: [RFC PATCH v3 1/5] PCI: Add support for enforcing all MMIO BARs to be page aligned

2016-01-29 Thread Yongji Xie
On 2016/1/29 6:46, Alex Williamson wrote: On Fri, 2016-01-15 at 15:06 +0800, Yongji Xie wrote: When vfio passthrough a PCI device of which MMIO BARs are smaller than PAGE_SIZE, guest will not handle the mmio accesses to the BARs which leads to mmio emulations in host. This is because vfio

Re: [RFC PATCH v3 3/5] PCI: Add host bridge attribute to indicate filtering of MSIs is supported

2016-01-29 Thread Yongji Xie
On 2016/1/29 6:46, Alex Williamson wrote: On Fri, 2016-01-15 at 15:06 +0800, Yongji Xie wrote: MSI-X tables are not allowed to be mmapped in vfio-pci driver in case that user get to touch this directly. This will cause some performance issues when when PCI adapters have critical registers in

Re: [RFC PATCH v3 5/5] vfio-pci: Allow to mmap MSI-X table if host bridge supports filtering of MSIs

2016-01-29 Thread Yongji Xie
On 2016/1/29 6:46, Alex Williamson wrote: On Fri, 2016-01-15 at 15:06 +0800, Yongji Xie wrote: Current vfio-pci implementation disallows to mmap MSI-X table in case that user get to touch this directly. But we should allow to mmap these MSI-X tables if the PCI host bridge supports filtering

Re: [RFC PATCH v3 1/5] PCI: Add support for enforcing all MMIO BARs to be page aligned

2016-02-01 Thread Yongji Xie
On 2016/1/30 3:01, Alex Williamson wrote: On Fri, 2016-01-29 at 18:37 +0800, Yongji Xie wrote: On 2016/1/29 6:46, Alex Williamson wrote: On Fri, 2016-01-15 at 15:06 +0800, Yongji Xie wrote: When vfio passthrough a PCI device of which MMIO BARs are smaller than PAGE_SIZE, guest will not handle

Re: [RFC PATCH v3 3/5] PCI: Add host bridge attribute to indicate filtering of MSIs is supported

2016-02-01 Thread Yongji Xie
On 2016/1/30 3:05, Alex Williamson wrote: - Original Message - On 2016/1/29 6:46, Alex Williamson wrote: On Fri, 2016-01-15 at 15:06 +0800, Yongji Xie wrote: MSI-X tables are not allowed to be mmapped in vfio-pci driver in case that user get to touch this directly. This will cause

Re: [PATCH v9 2/3] PCI: Add a macro to set default alignment for all PCI devices

2017-03-25 Thread Yongji Xie
On Thu, Mar 23, 2017 at 03:53:42PM -0500, Bjorn Helgaas wrote: > Hi Yongji, > > On Wed, Feb 15, 2017 at 02:45:05PM +0800, Yongji Xie wrote: >> When vfio passthroughs a PCI device of which MMIO BARs are >> smaller than PAGE_SIZE, guest will not handle the mmio >> accesses

Re: [PATCH v9 3/3] PCI: Don't extend device's size when using default alignment for all devices

2017-03-25 Thread Yongji Xie
On Thu, Mar 23, 2017 at 04:55:58PM -0500, Bjorn Helgaas wrote: > > On Wed, Feb 15, 2017 at 02:45:06PM +0800, Yongji Xie wrote: >> Currently we reassign the alignment by extending resources' size in >> pci_reassigndev_resource_alignment(). This could potentially break &

[PATCH v10 0/4] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE

2017-04-10 Thread Yongji Xie
Code style improvements Changelog v3: - Ignore enforced alignment to fixed BARs - Fix issue that disabling memory decoding when reassigning the alignment - Only enable default alignment on PowerNV platform Changelog v2: - Ignore enforced alignment to VF BARs on pci_reassigndev_resource_alignme

[PATCH v10 1/4] PCI: A fix for caculating bridge window's size and alignment

2017-04-10 Thread Yongji Xie
In case that one device's alignment is greater than its size, we may get an incorrect size and alignment for its bus's memory window in pbus_size_mem(). This patch fixes this case. Signed-off-by: Yongji Xie --- drivers/pci/setup-bus.c |4 ++-- 1 file changed, 2 insertions(+), 2

[PATCH v10 2/4] PCI: Add pcibios_default_alignment() for arch-specific alignment control

2017-04-10 Thread Yongji Xie
alignment for all PCI devices. An arch can override it to force the PCI core to place memory BARs on their own pages. Signed-off-by: Yongji Xie --- drivers/pci/pci.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 7904d02

[PATCH v10 3/4] powerpc/powernv: Override pcibios_default_alignment() to force PCI devices to be page aligned

2017-04-10 Thread Yongji Xie
This overrides pcibios_default_alignment() to set default alignment to PAGE_SIZE for all PCI devices on PowerNV platform. Thus sub-page BARs would not share a page and could be mapped into guest when VFIO passthrough them. Signed-off-by: Yongji Xie --- arch/powerpc/include/asm/machdep.h

[PATCH v10 4/4] PCI: Don't extend device's size when using default alignment for all devices

2017-04-10 Thread Yongji Xie
risk in this case. So this patch tries to use START_ALIGNMENT to identify the resource's alignment without extending the size when the alignment reassigning is caused by the default alignment. Signed-off-by: Yongji Xie --- drivers/pci/pci.c | 34 -- 1 file

Re: [PATCH v10 4/4] PCI: Don't extend device's size when using default alignment for all devices

2017-04-17 Thread Yongji Xie
2017-04-15 6:54 GMT+08:00 Bjorn Helgaas : > On Mon, Apr 10, 2017 at 07:58:14PM +0800, Yongji Xie wrote: > > Currently we reassign the alignment by extending resources' size in > > pci_reassigndev_resource_alignment(). This could potentially break > > some drivers when t

Re: [PATCH v11 2/7] PCI: A fix for caculating bridge window's size and alignment

2017-04-17 Thread Yongji Xie
Hi Yinghai, On 18 April 2017 at 05:45, Yinghai Lu wrote: > On Mon, Apr 17, 2017 at 2:36 PM, Bjorn Helgaas wrote: >> From: Yongji Xie >> >> In case that one device's alignment is greater than its size, >> we may get an incorrect size and alignment for its bus

Re: [PATCH v11 4/7] powerpc/powernv: Override pcibios_default_alignment() to force PCI devices to be page aligned

2017-04-18 Thread Yongji Xie
On 19 April 2017 at 09:47, Michael Ellerman wrote: > Bjorn Helgaas writes: > >> On Mon, Apr 17, 2017 at 4:36 PM, Bjorn Helgaas wrote: >>> From: Yongji Xie >>> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c >>> b/arch/powerpc/platforms/po

[PATCH v8 0/3] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE

2017-01-19 Thread Yongji Xie
ecoding when reassigning the alignment - Only enable default alignment on PowerNV platform Changelog v2: - Ignore enforced alignment to VF BARs on pci_reassigndev_resource_alignment() Yongji Xie (3): PCI: Ignore requested alignment for IOV BARs PCI: Make sure the driver could get correct BAR size f

[PATCH v8 1/3] PCI: Ignore requested alignment for IOV BARs

2017-01-19 Thread Yongji Xie
ff-by: Yongji Xie Reviewed-by: Gavin Shan --- drivers/pci/pci.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index a881c0d..220c31e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -5084,7 +5084,7 @@

[PATCH v8 2/3] PCI: Make sure the driver could get correct BAR size from pci_resource_len()

2017-01-19 Thread Yongji Xie
nd if we need the allocated size, resource_size()(or we can introuce a new helper function) can be used to get it. Signed-off-by: Yongji Xie --- drivers/pci/pci.c |1 + include/linux/pci.h |6 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/

  1   2   >