Re: [REGRESSION] Recent swiotlb DMA_FROM_DEVICE fixes break ath9k-based AP

2022-03-23 Thread Christoph Hellwig
On Wed, Mar 23, 2022 at 08:54:08PM +, Robin Murphy wrote: > I'll admit I still never quite grasped the reason for also adding the > override to swiotlb_sync_single_for_device() in aa6f8dcbab47, but I think > by that point we were increasingly tired and confused and starting to >

RE: [PATCH RFC 04/12] kernel/user: Allow user::locked_vm to be usable for iommufd

2022-03-23 Thread Tian, Kevin
> From: Jason Wang > Sent: Thursday, March 24, 2022 11:51 AM > > > > > > > > In the end vfio type1 will be replaced by iommufd compat layer. With > > that goal in mind iommufd has to inherit type1 behaviors. > > So the compatibility should be provided by the compat layer instead of > the core

Re: [PATCH RFC 04/12] kernel/user: Allow user::locked_vm to be usable for iommufd

2022-03-23 Thread Jason Wang
On Thu, Mar 24, 2022 at 11:15 AM Tian, Kevin wrote: > > > From: Jason Wang > > Sent: Thursday, March 24, 2022 10:57 AM > > > > On Thu, Mar 24, 2022 at 10:42 AM Tian, Kevin wrote: > > > > > > > From: Jason Wang > > > > Sent: Thursday, March 24, 2022 10:28 AM > > > > > > > > On Thu, Mar 24, 2022

RE: [PATCH RFC 04/12] kernel/user: Allow user::locked_vm to be usable for iommufd

2022-03-23 Thread Tian, Kevin
> From: Jason Wang > Sent: Thursday, March 24, 2022 10:57 AM > > On Thu, Mar 24, 2022 at 10:42 AM Tian, Kevin wrote: > > > > > From: Jason Wang > > > Sent: Thursday, March 24, 2022 10:28 AM > > > > > > On Thu, Mar 24, 2022 at 10:12 AM Tian, Kevin > wrote: > > > > > > > > > From: Jason

RE: [PATCH RFC 07/12] iommufd: Data structure to provide IOVA to PFN mapping

2022-03-23 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Thursday, March 24, 2022 2:16 AM > > On Tue, Mar 22, 2022 at 04:15:44PM -0600, Alex Williamson wrote: > > > > +int iopt_access_pages(struct io_pagetable *iopt, unsigned long iova, > > > + unsigned long length, struct page **out_pages, bool write) >

Re: [PATCH] iommu/dma: Explicitly sort PCI DMA windows

2022-03-23 Thread dann frazier
On Wed, Mar 23, 2022 at 07:55:23PM -0500, Rob Herring wrote: > On Wed, Mar 23, 2022 at 5:15 PM dann frazier > wrote: > > > > On Wed, Mar 23, 2022 at 09:49:04AM +, Marc Zyngier wrote: > > > On Tue, 22 Mar 2022 17:27:36 +, > > > Robin Murphy wrote: > > > > > > > > Originally, creating the

Re: [PATCH RFC 04/12] kernel/user: Allow user::locked_vm to be usable for iommufd

2022-03-23 Thread Jason Wang
On Thu, Mar 24, 2022 at 10:42 AM Tian, Kevin wrote: > > > From: Jason Wang > > Sent: Thursday, March 24, 2022 10:28 AM > > > > On Thu, Mar 24, 2022 at 10:12 AM Tian, Kevin wrote: > > > > > > > From: Jason Gunthorpe > > > > Sent: Wednesday, March 23, 2022 12:15 AM > > > > > > > > On Tue, Mar

RE: [PATCH RFC 04/12] kernel/user: Allow user::locked_vm to be usable for iommufd

2022-03-23 Thread Tian, Kevin
> From: Jason Wang > Sent: Thursday, March 24, 2022 10:28 AM > > On Thu, Mar 24, 2022 at 10:12 AM Tian, Kevin wrote: > > > > > From: Jason Gunthorpe > > > Sent: Wednesday, March 23, 2022 12:15 AM > > > > > > On Tue, Mar 22, 2022 at 09:29:23AM -0600, Alex Williamson wrote: > > > > > > > I'm

Re: [PATCH RFC 04/12] kernel/user: Allow user::locked_vm to be usable for iommufd

2022-03-23 Thread Jason Wang
On Thu, Mar 24, 2022 at 10:12 AM Tian, Kevin wrote: > > > From: Jason Gunthorpe > > Sent: Wednesday, March 23, 2022 12:15 AM > > > > On Tue, Mar 22, 2022 at 09:29:23AM -0600, Alex Williamson wrote: > > > > > I'm still picking my way through the series, but the later compat > > > interface

RE: [PATCH RFC 04/12] kernel/user: Allow user::locked_vm to be usable for iommufd

2022-03-23 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, March 23, 2022 12:15 AM > > On Tue, Mar 22, 2022 at 09:29:23AM -0600, Alex Williamson wrote: > > > I'm still picking my way through the series, but the later compat > > interface doesn't mention this difference as an outstanding issue. > > Doesn't this

Re: [PATCH v2 2/2] PCI: hv: Propagate coherence from VMbus device to PCI device

2022-03-23 Thread Boqun Feng
On Wed, Mar 23, 2022 at 01:31:12PM -0700, Michael Kelley wrote: > PCI pass-thru devices in a Hyper-V VM are represented as a VMBus > device and as a PCI device. The coherence of the VMbus device is > set based on the VMbus node in ACPI, but the PCI device has no > ACPI node and defaults to not

Re: [PATCH] iommu/dma: Explicitly sort PCI DMA windows

2022-03-23 Thread Rob Herring
On Tue, Mar 22, 2022 at 12:27 PM Robin Murphy wrote: > > Originally, creating the dma_ranges resource list in pre-sorted fashion > was the simplest and most efficient way to enforce the order required by > iova_reserve_pci_windows(). However since then at least one PCI host > driver is now

Re: [PATCH] iommu/dma: Explicitly sort PCI DMA windows

2022-03-23 Thread Rob Herring
On Wed, Mar 23, 2022 at 5:15 PM dann frazier wrote: > > On Wed, Mar 23, 2022 at 09:49:04AM +, Marc Zyngier wrote: > > On Tue, 22 Mar 2022 17:27:36 +, > > Robin Murphy wrote: > > > > > > Originally, creating the dma_ranges resource list in pre-sorted fashion > > > was the simplest and

Re: [PATCH RFC 11/12] iommufd: vfio container FD ioctl compatibility

2022-03-23 Thread Jason Gunthorpe via iommu
On Wed, Mar 23, 2022 at 04:51:25PM -0600, Alex Williamson wrote: > My overall question here would be whether we can actually achieve a > compatibility interface that has sufficient feature transparency that we > can dump vfio code in favor of this interface, or will there be enough > niche use

Re: [PATCH RFC 08/12] iommufd: IOCTLs for the io_pagetable

2022-03-23 Thread Jason Gunthorpe via iommu
On Wed, Mar 23, 2022 at 05:34:18PM -0300, Jason Gunthorpe wrote: > Stated another way, any platform that wires dev_is_dma_coherent() to > true, like all x86 does, must support IOMMU_CACHE and report > IOMMU_CAP_CACHE_COHERENCY for every iommu_domain the platform > supports. The platform obviously

Re: [PATCH RFC 11/12] iommufd: vfio container FD ioctl compatibility

2022-03-23 Thread Alex Williamson
On Fri, 18 Mar 2022 14:27:36 -0300 Jason Gunthorpe wrote: > iommufd can directly implement the /dev/vfio/vfio container IOCTLs by > mapping them into io_pagetable operations. Doing so allows the use of > iommufd by symliking /dev/vfio/vfio to /dev/iommufd. Allowing VFIO to > SET_CONTAINER using

Re: [PATCH] iommu/dma: Explicitly sort PCI DMA windows

2022-03-23 Thread dann frazier
On Wed, Mar 23, 2022 at 09:49:04AM +, Marc Zyngier wrote: > On Tue, 22 Mar 2022 17:27:36 +, > Robin Murphy wrote: > > > > Originally, creating the dma_ranges resource list in pre-sorted fashion > > was the simplest and most efficient way to enforce the order required by > >

Re: [REGRESSION] Recent swiotlb DMA_FROM_DEVICE fixes break ath9k-based AP

2022-03-23 Thread Robin Murphy
On 2022-03-23 19:16, Linus Torvalds wrote: On Wed, Mar 23, 2022 at 12:06 PM Robin Murphy wrote: On 2022-03-23 17:27, Linus Torvalds wrote: I'm assuming that the ath9k issue is that it gives DMA mapping a big enough area to handle any possible packet size, and just expects - quite reasonably

Re: [PATCH RFC 08/12] iommufd: IOCTLs for the io_pagetable

2022-03-23 Thread Jason Gunthorpe via iommu
On Wed, Mar 23, 2022 at 02:04:46PM -0600, Alex Williamson wrote: > On Wed, 23 Mar 2022 16:34:39 -0300 > Jason Gunthorpe wrote: > > > On Wed, Mar 23, 2022 at 01:10:38PM -0600, Alex Williamson wrote: > > > On Fri, 18 Mar 2022 14:27:33 -0300 > > > Jason Gunthorpe wrote: > > > > > > > +static

[PATCH v2 2/2] PCI: hv: Propagate coherence from VMbus device to PCI device

2022-03-23 Thread Michael Kelley via iommu
PCI pass-thru devices in a Hyper-V VM are represented as a VMBus device and as a PCI device. The coherence of the VMbus device is set based on the VMbus node in ACPI, but the PCI device has no ACPI node and defaults to not hardware coherent. This results in extra software coherence management

[PATCH v2 1/2] Drivers: hv: vmbus: Propagate VMbus coherence to each VMbus device

2022-03-23 Thread Michael Kelley via iommu
VMbus synthetic devices are not represented in the ACPI DSDT -- only the top level VMbus device is represented. As a result, on ARM64 coherence information in the _CCA method is not specified for synthetic devices, so they default to not hardware coherent. Drivers for some of these synthetic

[PATCH v2 0/2] Fix coherence for VMbus and PCI pass-thru devices in Hyper-V VM

2022-03-23 Thread Michael Kelley via iommu
Hyper-V VMs have VMbus synthetic devices and PCI pass-thru devices that are added dynamically via the VMbus protocol and are not represented in the ACPI DSDT. Only the top level VMbus node exists in the DSDT. As such, on ARM64 these devices don't pick up coherence information and default to not

Re: [PATCH RFC 08/12] iommufd: IOCTLs for the io_pagetable

2022-03-23 Thread Alex Williamson
On Wed, 23 Mar 2022 16:34:39 -0300 Jason Gunthorpe wrote: > On Wed, Mar 23, 2022 at 01:10:38PM -0600, Alex Williamson wrote: > > On Fri, 18 Mar 2022 14:27:33 -0300 > > Jason Gunthorpe wrote: > > > > > +static int conv_iommu_prot(u32 map_flags) > > > +{ > > > + int iommu_prot; > > > + > > > +

Re: [PATCH RFC 08/12] iommufd: IOCTLs for the io_pagetable

2022-03-23 Thread Jason Gunthorpe via iommu
On Wed, Mar 23, 2022 at 01:10:38PM -0600, Alex Williamson wrote: > On Fri, 18 Mar 2022 14:27:33 -0300 > Jason Gunthorpe wrote: > > > +static int conv_iommu_prot(u32 map_flags) > > +{ > > + int iommu_prot; > > + > > + /* > > +* We provide no manual cache coherency ioctls to userspace and

Re: [REGRESSION] Recent swiotlb DMA_FROM_DEVICE fixes break ath9k-based AP

2022-03-23 Thread Linus Torvalds
On Wed, Mar 23, 2022 at 12:06 PM Robin Murphy wrote: > > On 2022-03-23 17:27, Linus Torvalds wrote: > > > > I'm assuming that the ath9k issue is that it gives DMA mapping a big > > enough area to handle any possible packet size, and just expects - > > quite reasonably - smaller packets to only

Re: [PATCH RFC 08/12] iommufd: IOCTLs for the io_pagetable

2022-03-23 Thread Alex Williamson
On Fri, 18 Mar 2022 14:27:33 -0300 Jason Gunthorpe wrote: > +static int conv_iommu_prot(u32 map_flags) > +{ > + int iommu_prot; > + > + /* > + * We provide no manual cache coherency ioctls to userspace and most > + * architectures make the CPU ops for cache flushing privileged.

Re: [REGRESSION] Recent swiotlb DMA_FROM_DEVICE fixes break ath9k-based AP

2022-03-23 Thread Robin Murphy
On 2022-03-23 17:27, Linus Torvalds wrote: On Wed, Mar 23, 2022 at 12:19 AM Oleksandr Natalenko wrote: The following upstream commits: aa6f8dcbab47 swiotlb: rework "fix info leak with DMA_FROM_DEVICE" ddbd89deb7d3 swiotlb: fix info leak with DMA_FROM_DEVICE break ath9k-based Wi-Fi access

Re: [PATCH RFC 07/12] iommufd: Data structure to provide IOVA to PFN mapping

2022-03-23 Thread Jason Gunthorpe via iommu
On Tue, Mar 22, 2022 at 04:15:44PM -0600, Alex Williamson wrote: > > +static struct iopt_area * > > +iopt_alloc_area(struct io_pagetable *iopt, struct iopt_pages *pages, > > + unsigned long iova, unsigned long start_byte, > > + unsigned long length, int iommu_prot, unsigned

Re: [PATCH RFC 10/12] iommufd: Add kAPI toward external drivers

2022-03-23 Thread Jason Gunthorpe via iommu
On Wed, Mar 23, 2022 at 12:10:01PM -0600, Alex Williamson wrote: > > +EXPORT_SYMBOL_GPL(iommufd_bind_pci_device); > > I'm stumped why this needs to be PCI specific. Anything beyond the RID > comment? Please enlighten. Thanks, The way it turned out in the end it is not for a good reason any

Re: [PATCH RFC 10/12] iommufd: Add kAPI toward external drivers

2022-03-23 Thread Alex Williamson
On Fri, 18 Mar 2022 14:27:35 -0300 Jason Gunthorpe wrote: > +/** > + * iommufd_bind_pci_device - Bind a physical device to an iommu fd > + * @fd: iommufd file descriptor. > + * @pdev: Pointer to a physical PCI device struct > + * @id: Output ID number to return to userspace for this device > + *

Re: [REGRESSION] Recent swiotlb DMA_FROM_DEVICE fixes break ath9k-based AP

2022-03-23 Thread Linus Torvalds
On Wed, Mar 23, 2022 at 12:19 AM Oleksandr Natalenko wrote: > > The following upstream commits: > > aa6f8dcbab47 swiotlb: rework "fix info leak with DMA_FROM_DEVICE" > ddbd89deb7d3 swiotlb: fix info leak with DMA_FROM_DEVICE > > break ath9k-based Wi-Fi access point for me. The AP emits beacons,

Re: [PATCH RFC 05/12] iommufd: PFN handling for iopt_pages

2022-03-23 Thread Jason Gunthorpe via iommu
On Wed, Mar 23, 2022 at 04:37:50PM +0100, Niklas Schnelle wrote: > > +/* > > + * This holds a pinned page list for multiple areas of IO address space. > > The > > + * pages always originate from a linear chunk of userspace VA. Multiple > > + * io_pagetable's, through their iopt_area's, can share

RE: [PATCH v8 05/11] ACPI/IORT: Add a helper to retrieve RMR memory regions

2022-03-23 Thread Shameerali Kolothum Thodi via iommu
> -Original Message- > From: Robin Murphy [mailto:robin.mur...@arm.com] > Sent: 22 March 2022 19:09 > To: Shameerali Kolothum Thodi ; > linux-arm-ker...@lists.infradead.org; linux-a...@vger.kernel.org; > iommu@lists.linux-foundation.org > Cc: j...@solid-run.com; Linuxarm ; >

RE: [PATCH v8 02/11] iommu: Introduce a union to struct iommu_resv_region

2022-03-23 Thread Shameerali Kolothum Thodi via iommu
> -Original Message- > From: Robin Murphy [mailto:robin.mur...@arm.com] > Sent: 22 March 2022 18:27 > To: Shameerali Kolothum Thodi ; > linux-arm-ker...@lists.infradead.org; linux-a...@vger.kernel.org; > iommu@lists.linux-foundation.org > Cc: Linuxarm ; lorenzo.pieral...@arm.com; >

Re: [PATCH RFC 05/12] iommufd: PFN handling for iopt_pages

2022-03-23 Thread Niklas Schnelle
On Fri, 2022-03-18 at 14:27 -0300, Jason Gunthorpe wrote: > The top of the data structure provides an IO Address Space (IOAS) that is > similar to a VFIO container. The IOAS allows map/unmap of memory into > ranges of IOVA called iopt_areas. Domains and in-kernel users (like VFIO > mdevs) can be

Re: [PATCH] iommu/arm: Expose ARM SMMUv3 related registers via sysfs

2022-03-23 Thread Miguel Luis
> On 23 Mar 2022, at 12:40, Robin Murphy wrote: > > On 2022-03-23 12:54, Miguel Luis wrote: >> Allows userspace to check for SMMUv3 features. > > What will userspace do with that information? > > It hardly matters what fancy new features might be present, if the kernel > and/or the

Re: [PATCH] iommu/arm: Expose ARM SMMUv3 related registers via sysfs

2022-03-23 Thread Robin Murphy
On 2022-03-23 12:54, Miguel Luis wrote: Allows userspace to check for SMMUv3 features. What will userspace do with that information? It hardly matters what fancy new features might be present, if the kernel and/or the abstracted interfaces available to userspace aren't using them. Any

[PATCH] iommu/arm: Expose ARM SMMUv3 related registers via sysfs

2022-03-23 Thread Miguel Luis
Allows userspace to check for SMMUv3 features. Expose the following RO registers related to ARM SMMUv3 via sysfs: SMMU_IDR0 SMMU_IDR1 SMMU_IDR2 SMMU_IDR3 SMMU_IDR4 SMMU_IDR5 SMMU_IDR6 SMMU_IIDR SMMU_AIDR # find /sys | grep arm-iommu

Re: [REGRESSION] Recent swiotlb DMA_FROM_DEVICE fixes break ath9k-based AP

2022-03-23 Thread Kalle Valo
Adding regressions list so that this can be tracked properly, including the full report below. Oleksandr Natalenko writes: > Hello. > > The following upstream commits: > > aa6f8dcbab47 swiotlb: rework "fix info leak with DMA_FROM_DEVICE" > ddbd89deb7d3 swiotlb: fix info leak with

[REGRESSION] Recent swiotlb DMA_FROM_DEVICE fixes break ath9k-based AP

2022-03-23 Thread Oleksandr Natalenko via iommu
Hello. The following upstream commits: aa6f8dcbab47 swiotlb: rework "fix info leak with DMA_FROM_DEVICE" ddbd89deb7d3 swiotlb: fix info leak with DMA_FROM_DEVICE break ath9k-based Wi-Fi access point for me. The AP emits beacons, but no client can connect to it, either from the very beginning,

Re: [PATCH] iommu/dma: Explicitly sort PCI DMA windows

2022-03-23 Thread Marc Zyngier
On Tue, 22 Mar 2022 17:27:36 +, Robin Murphy wrote: > > Originally, creating the dma_ranges resource list in pre-sorted fashion > was the simplest and most efficient way to enforce the order required by > iova_reserve_pci_windows(). However since then at least one PCI host > driver is now

Re: [PATCH v4 1/2] PCI: Rename "pci_dev->untrusted" to "pci_dev->poses_dma_risk"

2022-03-23 Thread Mika Westerberg
On Tue, Mar 22, 2022 at 01:09:55PM -0700, Rajat Jain wrote: > On Tue, Mar 22, 2022 at 4:12 AM Rafael J. Wysocki wrote: > > > > On Tue, Mar 22, 2022 at 10:02 AM Christoph Hellwig > > wrote: > > > > > > On Sat, Mar 19, 2022 at 11:29:05PM -0700, Rajat Jain wrote: > > > > Rename the field to make