Re: [PATCH 1/4] PCI / ACPI: Identify external PCI devices

2018-11-15 Thread Mika Westerberg
On Thu, Nov 15, 2018 at 09:00:54PM +0200, Mika Westerberg wrote: > On Thu, Nov 15, 2018 at 05:46:08PM +, Lorenzo Pieralisi wrote: > > Do you really need to parse it if the dev->is_thunderbolt check is enough ? > > Yes, we need to parse it one way or another. dev->is_thunderbolt is > based on

Re: [PATCH 1/9] mm: Introduce new vm_insert_range API

2018-11-15 Thread Matthew Wilcox
On Fri, Nov 16, 2018 at 11:00:30AM +0530, Souptick Joarder wrote: > On Thu, Nov 15, 2018 at 11:44 PM Randy Dunlap wrote: > > On 11/15/18 7:45 AM, Souptick Joarder wrote: > > What is the opposite of vm_insert_range() or even of vm_insert_page()? > > or is there no need for that? > > There is no

Re: [PATCH v4 7/7] iommu/virtio: Add event queue

2018-11-15 Thread Auger Eric
Hi Jean, On 11/15/18 5:52 PM, Jean-Philippe Brucker wrote: > The event queue offers a way for the device to report access faults from > endpoints. It is implemented on virtqueue #1. Whenever the host needs to > signal a fault, it fills one of the buffers offered by the guest and > interrupts it.

Re: [PATCH v4 5/7] iommu: Add virtio-iommu driver

2018-11-15 Thread Auger Eric
Hi Jean, On 11/15/18 5:52 PM, Jean-Philippe Brucker wrote: > The virtio IOMMU is a para-virtualized device, allowing to send IOMMU > requests such as map/unmap over virtio transport without emulating page > tables. This implementation handles ATTACH, DETACH, MAP and UNMAP > requests. > > The

Re: [PATCH 1/9] mm: Introduce new vm_insert_range API

2018-11-15 Thread Souptick Joarder
On Thu, Nov 15, 2018 at 11:44 PM Randy Dunlap wrote: > > On 11/15/18 7:45 AM, Souptick Joarder wrote: > > Previouly drivers have their own way of mapping range of > > kernel pages/memory into user vma and this was done by > > invoking vm_insert_page() within a loop. > > > > As this pattern is

Re: [PATCH 1/2] csky, h8300, riscv: remove leftovers

2018-11-15 Thread Palmer Dabbelt
On Fri, 09 Nov 2018 01:00:07 PST (-0800), Christoph Hellwig wrote: There has been no for a long time, which also means there is no point in using it from asm-generic. Signed-off-by: Christoph Hellwig --- arch/csky/include/asm/Kbuild | 1 - arch/h8300/include/asm/Kbuild | 1 -

Re: [PATCH v4 6/8] vfio/mdev: Add iommu place holders in mdev_device

2018-11-15 Thread Lu Baolu
Hi, On 11/16/18 5:31 AM, Kirti Wankhede wrote: On 11/7/2018 7:18 AM, Lu Baolu wrote: Hi Alex, On 11/7/18 7:53 AM, Alex Williamson wrote: On Mon,  5 Nov 2018 15:34:06 +0800 Lu Baolu wrote: A parent device might create different types of mediated devices. For example, a mediated device

Re: [PATCH v4 6/8] vfio/mdev: Add iommu place holders in mdev_device

2018-11-15 Thread Kirti Wankhede
On 11/7/2018 7:18 AM, Lu Baolu wrote: > Hi Alex, > > On 11/7/18 7:53 AM, Alex Williamson wrote: >> On Mon,  5 Nov 2018 15:34:06 +0800 >> Lu Baolu wrote: >> >>> A parent device might create different types of mediated >>> devices. For example, a mediated device could be created >>> by the

Re: move the arm arch_dma_alloc implementation to common code

2018-11-15 Thread Robin Murphy
On 2018-11-15 11:50 am, Will Deacon wrote: On Fri, Nov 09, 2018 at 08:52:38AM +0100, Christoph Hellwig wrote: Can I get a quick review from the arm64 folks? I think it should be fine there as it basically is a code move, but an additional pair or two of eyes always helps to weed out bugs. I

Re: move the arm arch_dma_alloc implementation to common code

2018-11-15 Thread Will Deacon
On Fri, Nov 09, 2018 at 08:52:38AM +0100, Christoph Hellwig wrote: > Can I get a quick review from the arm64 folks? I think it should > be fine there as it basically is a code move, but an additional pair > or two of eyes always helps to weed out bugs. I reviewed the arm64 parts, but it would be

Re: [PATCH 4/9] dma-mapping: move the arm64 ncoherent alloc/free support to common code

2018-11-15 Thread Will Deacon
Hi Christoph, Minor nit: typo in the subject "ncoherent". On Mon, Nov 05, 2018 at 01:19:26PM +0100, Christoph Hellwig wrote: > The arm64 codebase to implement coherent dma allocation for architectures > with non-coherent DMA is a good start for a generic implementation, given > that is uses the

RE: [PATCH 1/4] PCI / ACPI: Identify external PCI devices

2018-11-15 Thread Mario.Limonciello
> -Original Message- > From: Mika Westerberg > Sent: Thursday, November 15, 2018 1:01 PM > To: Lorenzo Pieralisi > Cc: Lukas Wunner; iommu@lists.linux-foundation.org; Joerg Roedel; David > Woodhouse; Lu Baolu; Ashok Raj; Bjorn Helgaas; Rafael J. Wysocki; Jacob jun > Pan; > Andreas

Re: [PATCH 1/4] PCI / ACPI: Identify external PCI devices

2018-11-15 Thread Mika Westerberg
On Thu, Nov 15, 2018 at 08:27:41PM +0100, Lukas Wunner wrote: > On Thu, Nov 15, 2018 at 09:10:26PM +0200, Mika Westerberg wrote: > > I was thinking we could cover all these with is_external filling them > > based on the _DSD or some other means in the kernel. > > > > We would then deal all such

Re: [PATCH 1/4] PCI / ACPI: Identify external PCI devices

2018-11-15 Thread Lukas Wunner
On Thu, Nov 15, 2018 at 09:10:26PM +0200, Mika Westerberg wrote: > I was thinking we could cover all these with is_external filling them > based on the _DSD or some other means in the kernel. > > We would then deal all such devices as "untrusted" by default. Tinfoil hat on, even internal devices

Re: [PATCH 1/4] PCI / ACPI: Identify external PCI devices

2018-11-15 Thread Mika Westerberg
On Thu, Nov 15, 2018 at 07:58:13PM +0200, Yehezkel Bernat wrote: > From what I know, there are more devices that suffer from similar security > issues like Thunderbolt, e.g. FireWire [1]. > My assumption is that the same protection may be applied to such devices too, > even if currently it sounds

Re: [PATCH 1/4] PCI / ACPI: Identify external PCI devices

2018-11-15 Thread Mika Westerberg
On Thu, Nov 15, 2018 at 05:46:08PM +, Lorenzo Pieralisi wrote: > Do you really need to parse it if the dev->is_thunderbolt check is enough ? Yes, we need to parse it one way or another. dev->is_thunderbolt is based on heuristics which do not apply anymore when the thing gets integrated in the

Re: [PATCH 1/9] mm: Introduce new vm_insert_range API

2018-11-15 Thread Randy Dunlap
On 11/15/18 7:45 AM, Souptick Joarder wrote: > Previouly drivers have their own way of mapping range of > kernel pages/memory into user vma and this was done by > invoking vm_insert_page() within a loop. > > As this pattern is common across different drivers, it can > be generalized by creating a

Re: [PATCH 1/4] PCI / ACPI: Identify external PCI devices

2018-11-15 Thread Yehezkel Bernat
On Thu, Nov 15, 2018 at 7:46 PM Lorenzo Pieralisi wrote: > > On Thu, Nov 15, 2018 at 02:16:27PM +0200, Mika Westerberg wrote: > > On Thu, Nov 15, 2018 at 01:07:36PM +0100, Lukas Wunner wrote: > > > On Thu, Nov 15, 2018 at 01:37:37PM +0200, Mika Westerberg wrote: > > > > On Thu, Nov 15, 2018 at

Re: [PATCH 1/4] PCI / ACPI: Identify external PCI devices

2018-11-15 Thread Lorenzo Pieralisi
On Thu, Nov 15, 2018 at 02:16:27PM +0200, Mika Westerberg wrote: > On Thu, Nov 15, 2018 at 01:07:36PM +0100, Lukas Wunner wrote: > > On Thu, Nov 15, 2018 at 01:37:37PM +0200, Mika Westerberg wrote: > > > On Thu, Nov 15, 2018 at 11:13:56AM +, Lorenzo Pieralisi wrote: > > > > I have strong

[PATCH v4 4/7] PCI: OF: Initialize dev->fwnode appropriately

2018-11-15 Thread Jean-Philippe Brucker
For PCI devices that have an OF node, set the fwnode as well. This way drivers that rely on fwnode don't need the special case described by commit f94277af03ea ("of/platform: Initialise dev->fwnode appropriately"). Acked-by: Bjorn Helgaas Signed-off-by: Jean-Philippe Brucker ---

[PATCH v4 3/7] of: Allow the iommu-map property to omit untranslated devices

2018-11-15 Thread Jean-Philippe Brucker
In PCI root complex nodes, the iommu-map property describes the IOMMU that translates each endpoint. On some platforms, the IOMMU itself is presented as a PCI endpoint (e.g. AMD IOMMU and virtio-iommu). This isn't supported by the current OF driver, which expects all endpoints to have an IOMMU.

[PATCH v4 6/7] iommu/virtio: Add probe request

2018-11-15 Thread Jean-Philippe Brucker
When the device offers the probe feature, send a probe request for each device managed by the IOMMU. Extract RESV_MEM information. When we encounter a MSI doorbell region, set it up as a IOMMU_RESV_MSI region. This will tell other subsystems that there is no need to map the MSI doorbell in the

[PATCH v4 7/7] iommu/virtio: Add event queue

2018-11-15 Thread Jean-Philippe Brucker
The event queue offers a way for the device to report access faults from endpoints. It is implemented on virtqueue #1. Whenever the host needs to signal a fault, it fills one of the buffers offered by the guest and interrupts it. Signed-off-by: Jean-Philippe Brucker ---

[PATCH v4 5/7] iommu: Add virtio-iommu driver

2018-11-15 Thread Jean-Philippe Brucker
The virtio IOMMU is a para-virtualized device, allowing to send IOMMU requests such as map/unmap over virtio transport without emulating page tables. This implementation handles ATTACH, DETACH, MAP and UNMAP requests. The bulk of the code transforms calls coming from the IOMMU API into

[PATCH v4 2/7] dt-bindings: virtio: Add virtio-pci-iommu node

2018-11-15 Thread Jean-Philippe Brucker
Some systems implement virtio-iommu as a PCI endpoint. The operating system needs to discover the relationship between IOMMU and masters long before the PCI endpoint gets probed. Add a PCI child node to describe the virtio-iommu device. The virtio-pci-iommu is conceptually split between a PCI

[PATCH v4 0/7] Add virtio-iommu driver

2018-11-15 Thread Jean-Philippe Brucker
Implement the virtio-iommu driver, following specification v0.8 [1]. Changes since v3 [2]: * Rebase onto v4.20-rc2. Patch 3 now touches drivers/of/base.c instead of drivers/pci/of.c, since the map_rid() function has moved. * Removed the request timeout, that depended on DEBUG. * Other small

[PATCH v4 1/7] dt-bindings: virtio-mmio: Add IOMMU description

2018-11-15 Thread Jean-Philippe Brucker
The nature of a virtio-mmio node is discovered by the virtio driver at probe time. However the DMA relation between devices must be described statically. When a virtio-mmio node is a virtio-iommu device, it needs an "#iommu-cells" property as specified by bindings/iommu/iommu.txt. Otherwise, the

Re: [PATCH v3 6/7] iommu/virtio: Add probe request

2018-11-15 Thread Jean-Philippe Brucker
Fixed all of these, thanks Jean On 15/11/2018 13:20, Auger Eric wrote: > Hi Jean, > On 10/12/18 4:59 PM, Jean-Philippe Brucker wrote: >> When the device offers the probe feature, send a probe request for each >> device managed by the IOMMU. Extract RESV_MEM information. When we >> encounter a

Re: [PATCH 7/7] vfio/type1: Remove map_try_harder() code path

2018-11-15 Thread Joerg Roedel
Hi Alex, On Fri, Nov 09, 2018 at 09:23:29AM -0700, Alex Williamson wrote: > Cool, glad to see this finally fixed. My "should be fixed soon" > comment turned out to be a little optimistic with the fix finally > coming 5 years later. We could of course keep this code as it really > doesn't harm

[PATCH 6/9] iommu/dma-iommu.c: Convert to use vm_insert_range

2018-11-15 Thread Souptick Joarder
Convert to use vm_insert_range() to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox --- drivers/iommu/dma-iommu.c | 12 ++-- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/dma-iommu.c

[PATCH 1/9] mm: Introduce new vm_insert_range API

2018-11-15 Thread Souptick Joarder
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking vm_insert_page() within a loop. As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.

[PATCH 0/9] Use vm_insert_range

2018-11-15 Thread Souptick Joarder
Previouly drivers have their own way of mapping range of kernel pages/memory into user vma and this was done by invoking vm_insert_page() within a loop. As this pattern is common across different drivers, it can be generalized by creating a new function and use it across the drivers.

Re: [PATCH v3 6/7] iommu/virtio: Add probe request

2018-11-15 Thread Auger Eric
Hi Jean, On 10/12/18 4:59 PM, Jean-Philippe Brucker wrote: > When the device offers the probe feature, send a probe request for each > device managed by the IOMMU. Extract RESV_MEM information. When we > encounter a MSI doorbell region, set it up as a IOMMU_RESV_MSI region. > This will tell other

Re: [PATCH 1/4] PCI / ACPI: Identify external PCI devices

2018-11-15 Thread Mika Westerberg
On Thu, Nov 15, 2018 at 01:07:36PM +0100, Lukas Wunner wrote: > On Thu, Nov 15, 2018 at 01:37:37PM +0200, Mika Westerberg wrote: > > On Thu, Nov 15, 2018 at 11:13:56AM +, Lorenzo Pieralisi wrote: > > > I have strong objections to the way these bindings have been forced upon > > > everybody; if

Re: [PATCH 1/4] PCI / ACPI: Identify external PCI devices

2018-11-15 Thread Lukas Wunner
On Thu, Nov 15, 2018 at 01:37:37PM +0200, Mika Westerberg wrote: > On Thu, Nov 15, 2018 at 11:13:56AM +, Lorenzo Pieralisi wrote: > > I have strong objections to the way these bindings have been forced upon > > everybody; if that's the way *generic* ACPI bindings are specified I > > wonder why

Re: [PATCH 1/4] PCI / ACPI: Identify external PCI devices

2018-11-15 Thread Mika Westerberg
On Thu, Nov 15, 2018 at 11:13:56AM +, Lorenzo Pieralisi wrote: > I have strong objections to the way these bindings have been forced upon > everybody; if that's the way *generic* ACPI bindings are specified I > wonder why there still exists an ACPI specification and related working > group. >

Re: [PATCH 1/4] PCI / ACPI: Identify external PCI devices

2018-11-15 Thread Lorenzo Pieralisi
On Thu, Nov 15, 2018 at 12:22:39PM +0200, Mika Westerberg wrote: > On Tue, Nov 13, 2018 at 11:45:36AM +, Lorenzo Pieralisi wrote: > > On Tue, Nov 13, 2018 at 01:27:00PM +0200, Mika Westerberg wrote: > > > > [...] > > > > > > To be frank the concept (and Microsoft _DSD bindings) seems a bit

Re: [PATCH 1/4] PCI / ACPI: Identify external PCI devices

2018-11-15 Thread Mika Westerberg
On Tue, Nov 13, 2018 at 11:45:36AM +, Lorenzo Pieralisi wrote: > On Tue, Nov 13, 2018 at 01:27:00PM +0200, Mika Westerberg wrote: > > [...] > > > > To be frank the concept (and Microsoft _DSD bindings) seems a bit vague > > > and not thoroughly defined and I would question its detection at >

Re: [PATCH v3 2/7] dt-bindings: virtio: Add virtio-pci-iommu node

2018-11-15 Thread Auger Eric
Hi Jean, On 10/12/18 4:59 PM, Jean-Philippe Brucker wrote: > Some systems implement virtio-iommu as a PCI endpoint. The operating > systems needs to discover the relationship between IOMMU and masters long s/systems/system > before the PCI endpoint gets probed. Add a PCI child node to describe

Re: [PATCH v3 1/7] dt-bindings: virtio-mmio: Add IOMMU description

2018-11-15 Thread Auger Eric
Hi Jean, On 10/12/18 4:59 PM, Jean-Philippe Brucker wrote: > The nature of a virtio-mmio node is discovered by the virtio driver at > probe time. However the DMA relation between devices must be described > statically. When a virtio-mmio node is a virtio-iommu device, it needs an > "#iommu-cells"