[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 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 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

[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 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 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

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 4/7] PCI: Modify resource_alignment to support multiple devices

2016-03-18 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 0/7] vfio-pci: Allow to mmap sub-page MMIO BARs and MSI-X table

2016-03-18 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 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 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-18 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 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 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 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

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 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

[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 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 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 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 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 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

[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 +

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 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 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 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 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 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 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 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 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 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 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

[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

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 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 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 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 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(+)

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

2016-05-02 Thread Yongji Xie
On 2016/5/3 10:59, Tian, Kevin wrote: From: Yongji Xie Sent: Wednesday, April 27, 2016 8:22 PM 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. This will cause some performance issues

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

2016-05-03 Thread Yongji Xie
On 2016/5/3 14:11, Tian, Kevin wrote: From: Yongji Xie [mailto:xyj...@linux.vnet.ibm.com] Sent: Tuesday, May 03, 2016 1:52 PM + + if (!(res->start & ~PAGE_MASK)) { + /* +* Add shadow resource for sub-page bar who

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

2016-05-30 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 v2 2/4] PCI: Do not Use IORESOURCE_STARTALIGN to identify bridge resources

2016-05-30 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 v2 0/4] PCI: Add support for enforcing all MMIO BARs not to share PAGE_SIZE

2016-05-30 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. Changelog v2: - Ignore enforced alignment to VF BARs on pci_reassigndev_resource_alignment() Yongji Xie (4): PCI: Ignore resource_alig

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

2016-05-30 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 v2 4/4] PCI: Add support for enforcing all MMIO BARs to be page aligned

2016-05-30 Thread Yongji Xie
ld not be applied to VFs whose BARs are always page aligned and should be never reassigned according to SRIOV spec. Signed-off-by: Yongji Xie --- Documentation/kernel-parameters.txt |2 ++ arch/powerpc/include/asm/pci.h |2 ++ drivers/pci/pci.c

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

2016-06-01 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

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

2016-06-01 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 +

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

2016-06-01 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. Changelog v2: - Ignore enforced alignment to VF BARs on pci_reassigndev_resource_alignment() Yongji Xie (4): PCI: Ignore resource_alig

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

2016-06-01 Thread Yongji Xie
ld not be applied to VFs whose BARs are always page aligned and should be never reassigned according to SRIOV spec. Signed-off-by: Yongji Xie --- Documentation/kernel-parameters.txt |2 ++ arch/powerpc/include/asm/pci.h |2 ++ drivers/pci/pci.c

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

2016-06-01 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

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

2016-06-20 Thread Yongji Xie
On 2016/6/21 9:50, Bjorn Helgaas wrote: On Thu, Jun 02, 2016 at 01:46:49PM +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: [RESEND PATCH v2 3/4] PCI: Add a new option for resource_alignment to reassign alignment

2016-06-20 Thread Yongji Xie
On 2016/6/21 9:57, Bjorn Helgaas wrote: On Thu, Jun 02, 2016 at 01:46:50PM +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

Re: [RESEND PATCH v2 1/4] PCI: Ignore resource_alignment if PCI_PROBE_ONLY was set\\

2016-06-20 Thread Yongji Xie
On 2016/6/21 9:43, Bjorn Helgaas wrote: On Thu, Jun 02, 2016 at 01:46:48PM +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

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

2016-06-20 Thread Yongji Xie
On 2016/6/21 10:26, Bjorn Helgaas wrote: On Thu, Jun 02, 2016 at 01:46:51PM +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

Re: [RESEND PATCH v2 1/4] PCI: Ignore resource_alignment if PCI_PROBE_ONLY was set\\

2016-06-21 Thread Yongji Xie
On 2016/6/21 10:16, Yongji Xie wrote: On 2016/6/21 9:43, Bjorn Helgaas wrote: On Thu, Jun 02, 2016 at 01:46:48PM +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

[PATCH v3 7/7] PCI: Add a macro to set default alignment for all PCI devices

2016-06-30 Thread Yongji Xie
fault on some platforms such as PowerNV platform which would easily see those sub-page BARs because of its 64K page. To achieve that, we add a macro PCIBIOS_DEFAULT_ALIGNMENT to set default alignment for all PCI devices and define it on PowerNV platform. Signed-off-by: Yongji Xie --- arch/powerpc/incl

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

2016-06-30 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 v3 6/7] PCI: Add support for enforcing all MMIO BARs to be page aligned

2016-06-30 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. Signed-off-by: Yongji Xie --- Documentation/kernel-parameters.txt |2 ++ drivers/pci/pci.c | 60 --- 2 files changed,

[PATCH v3 3/7] PCI: Do not disable memory decoding in pci_reassigndev_resource_alignment()

2016-06-30 Thread Yongji Xie
obing. Signed-off-by: Yongji Xie --- drivers/pci/pci.c |8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 6ae02de..6241cfc 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4820,7 +4820,6 @@

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

2016-06-30 Thread Yongji Xie
g 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_alignment() Yongji Xie (7): PCI: Ignore enforced alignment when kernel uses existing firmware setup PCI: Ignore

[PATCH v3 5/7] PCI: Do not use IORESOURCE_STARTALIGN to identify bridge resources

2016-06-30 Thread Yongji Xie
quot;. In this patch, we try to use a more robust way to identify bridge 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 10064

[PATCH v3 1/7] PCI: Ignore enforced alignment when kernel uses existing firmware setup

2016-06-30 Thread Yongji Xie
d not re-allocated. Signed-off-by: Yongji Xie --- drivers/pci/pci.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index c8b4dbd..be8f72c 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4760,6 +4760,13 @@ static resource_s

[PATCH v3 2/7] PCI: Ignore enforced alignment to VF BARs

2016-06-30 Thread Yongji Xie
ngless and will release the allocated resources which leads to a bug. Signed-off-by: Yongji Xie --- drivers/pci/pci.c |4 1 file changed, 4 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index be8f72c..6ae02de 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -

Re: [PATCH v3 1/7] PCI: Ignore enforced alignment when kernel uses existing firmware setup

2016-06-30 Thread Yongji Xie
Hi Gavin, On 2016/7/1 8:28, Gavin Shan wrote: On Thu, Jun 30, 2016 at 06:53:07PM +0800, Yongji Xie wrote: PCI resources allocator will use firmware setup and not try to reassign resource when PCI_PROBE_ONLY or IORESOURCE_PCI_FIXED is set. The enforced alignment in

Re: [PATCH v3 2/7] PCI: Ignore enforced alignment to VF BARs

2016-06-30 Thread Yongji Xie
Hi Gavin, On 2016/7/1 8:39, Gavin Shan wrote: On Thu, Jun 30, 2016 at 06:53:08PM +0800, Yongji Xie wrote: VF BARs are read-only zeroes according to SRIOV spec, the normal way(writing BARs) of allocating resources wouldn't be applied to VFs. The VFs' resources would be allocated when

Re: [PATCH v3 2/7] PCI: Ignore enforced alignment to VF BARs

2016-06-30 Thread Yongji Xie
Hi Gavin, On 2016/7/1 14:05, Gavin Shan wrote: On Fri, Jul 01, 2016 at 01:27:17PM +0800, Yongji Xie wrote: On Thu, Jun 30, 2016 at 06:53:08PM +0800, Yongji Xie wrote: VF BARs are read-only zeroes according to SRIOV spec, the normal way(writing BARs) of allocating resources wouldn'

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

2016-06-30 Thread Yongji Xie
Hi Gavin, On 2016/7/1 10:25, Gavin Shan wrote: On Thu, Jun 30, 2016 at 06:53:10PM +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

Re: [PATCH v3 5/7] PCI: Do not use IORESOURCE_STARTALIGN to identify bridge resources

2016-07-01 Thread Yongji Xie
Hi Gavin, On 2016/7/1 10:34, Gavin Shan wrote: On Thu, Jun 30, 2016 at 06:53:11PM +0800, Yongji Xie wrote: Now we use the IORESOURCE_STARTALIGN to identify bridge resources in __assign_resources_sorted(). That's quite fragile. We may also set flag IORESOURCE_STARTALIGN for SR-IOV resourc

Re: [PATCH v3 3/7] PCI: Do not disable memory decoding in pci_reassigndev_resource_alignment()

2016-07-01 Thread Yongji Xie
Hi Gavin, On 2016/7/1 8:50, Gavin Shan wrote: On Thu, Jun 30, 2016 at 06:53:09PM +0800, Yongji Xie wrote: We should not disable memory decoding when we reassign alignment in pci_reassigndev_resource_alignment(). It's meaningless and have some side effect. For example, some fixup func

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

2016-07-11 Thread Yongji Xie
Hi Bjorn, Any comment on V3? Thanks, Yongji On 2016/6/30 18:53, Yongji Xie wrote: This series aims to add an option for PCI resource allocator to force BARs not to share PAGE_SIZE. This would make sense to VFIO driver. Because current VFIO implementation disallows to mmap sub-page(size

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