Re: [PATCH v4 5/9] dmapool: rename fields in dma_page

2018-11-12 Thread Matthew Wilcox
On Mon, Nov 12, 2018 at 10:44:02AM -0500, Tony Battersby wrote: > Rename fields in 'struct dma_page' in preparation for moving them into > 'struct page'. No functional changes. > > in_use -> dma_in_use > offset -> dma_free_off > > Signed-off-by: Tony Battersby Acked-by: Matthew Wilcox

Re: [PATCH v4 4/9] dmapool: improve scalability of dma_pool_alloc

2018-11-12 Thread Matthew Wilcox
On Mon, Nov 12, 2018 at 10:43:25AM -0500, Tony Battersby wrote: > dma_pool_alloc() scales poorly when allocating a large number of pages > because it does a linear scan of all previously-allocated pages before > allocating a new one. Improve its scalability by maintaining a separate > list of

Re: [PATCH 06/10] swiotlb: use swiotlb_map_page in swiotlb_map_sg_attrs

2018-11-12 Thread John Stultz
On Thu, Nov 8, 2018 at 11:49 PM, Christoph Hellwig wrote: > On Tue, Nov 06, 2018 at 05:27:14PM -0800, John Stultz wrote: >> But at that point if I just re-apply "swiotlb: use swiotlb_map_page in >> swiotlb_map_sg_attrs", I reproduce the hangs. >> >> Any suggestions for how to further debug what

Re: [PATCH 06/10] swiotlb: use swiotlb_map_page in swiotlb_map_sg_attrs

2018-11-12 Thread John Stultz
On Mon, Nov 12, 2018 at 4:07 PM, John Stultz wrote: > On Thu, Nov 8, 2018 at 11:49 PM, Christoph Hellwig wrote: >> On Tue, Nov 06, 2018 at 05:27:14PM -0800, John Stultz wrote: >>> But at that point if I just re-apply "swiotlb: use swiotlb_map_page in >>> swiotlb_map_sg_attrs", I reproduce the

Re: [PATCH v4 1/9] dmapool: fix boundary comparison

2018-11-12 Thread Matthew Wilcox
On Mon, Nov 12, 2018 at 10:41:34AM -0500, Tony Battersby wrote: > Fixes: e34f44b3517f ("pool: Improve memory usage for devices which can't > cross boundaries") > Signed-off-by: Tony Battersby Acked-by: Matthew Wilcox ___ iommu mailing list

Re: [PATCH v4 2/9] dmapool: remove checks for dev == NULL

2018-11-12 Thread Matthew Wilcox
On Mon, Nov 12, 2018 at 10:42:12AM -0500, Tony Battersby wrote: > dmapool originally tried to support pools without a device because > dma_alloc_coherent() supports allocations without a device. But nobody > ended up using dma pools without a device, so the current checks in > dmapool.c for

Re: [PATCH v4 3/9] dmapool: cleanup dma_pool_destroy

2018-11-12 Thread Matthew Wilcox
On Mon, Nov 12, 2018 at 10:42:48AM -0500, Tony Battersby wrote: > Remove a small amount of code duplication between dma_pool_destroy() and > pool_free_page() in preparation for adding more code without having to > duplicate it. No functional changes. > > Signed-off-by: Tony Battersby Acked-by:

Re: [PATCH v4 6/9] dmapool: improve scalability of dma_pool_free

2018-11-12 Thread Matthew Wilcox
On Mon, Nov 12, 2018 at 10:44:40AM -0500, Tony Battersby wrote: > dma_pool_free() scales poorly when the pool contains many pages because > pool_find_page() does a linear scan of all allocated pages. Improve its > scalability by replacing the linear scan with virt_to_page() and storing > dmapool

Re: [RFC] iommu/vt-d: Group and domain relationship

2018-11-12 Thread James Sewart via iommu
Hey Jacob, > On 9 Nov 2018, at 19:09, Jacob Pan wrote: > > On Thu, 8 Nov 2018 11:30:04 + > James Sewart mailto:jamessew...@arista.com>> wrote: > >> Hey, >> >>> On 8 Nov 2018, at 01:42, Lu Baolu wrote: >>> >>> Hi, >>> >>> On 11/8/18 1:55 AM, James Sewart wrote: Hey, > On 7

Re: [PATCH v4 0/9] mpt3sas and dmapool scalability

2018-11-12 Thread Matthew Wilcox
On Mon, Nov 12, 2018 at 10:40:57AM -0500, Tony Battersby wrote: > I posted v3 on August 7. Nobody acked or merged the patches, and then > I got too busy with other stuff to repost until now. Thanks for resending. They were in my pile of things to look at, but that's an ever-growing pile. > I

Re: [PATCH v4 9/9] dmapool: debug: prevent endless loop in case of corruption

2018-11-12 Thread Matthew Wilcox
On Mon, Nov 12, 2018 at 10:46:35AM -0500, Tony Battersby wrote: > Prevent a possible endless loop with DMAPOOL_DEBUG enabled if a buggy > driver corrupts DMA pool memory. > > Signed-off-by: Tony Battersby I like it! Also, here you're using blks_per_alloc in a way which isn't normally in the

Re: [PATCH v4 7/9] dmapool: cleanup integer types

2018-11-12 Thread Matthew Wilcox
On Mon, Nov 12, 2018 at 10:45:21AM -0500, Tony Battersby wrote: > To represent the size of a single allocation, dmapool currently uses > 'unsigned int' in some places and 'size_t' in other places. Standardize > on 'unsigned int' to reduce overhead, but use 'size_t' when counting all > the blocks

Re: [PATCH] iommu: arm-smmu: Set SCTLR.HUPCF bit

2018-11-12 Thread Will Deacon
On Fri, Nov 09, 2018 at 01:01:55PM -0500, Rob Clark wrote: > On Mon, Oct 29, 2018 at 3:09 PM Will Deacon wrote: > > On Thu, Sep 27, 2018 at 06:46:07PM -0400, Rob Clark wrote: > > > We seem to need to set either this or CFCFG (stall), otherwise gpu > > > faults trigger problems with other

Re: [PATCH] amd/iommu: Fix Guest Virtual APIC Log Tail Address Register

2018-11-12 Thread j...@8bytes.org
On Mon, Nov 12, 2018 at 12:26:30PM +, Suthikulpanit, Suravee wrote: > From: Filippo Sironi > > This register should have been programmed with the physical address > of the memory location containing the shadow tail pointer for > the guest virtual APIC log instead of the base address. > >

Re: [RFC] mm: Replace all open encodings for NUMA_NO_NODE

2018-11-12 Thread Anshuman Khandual
On 11/12/2018 02:13 PM, Hans Verkuil wrote: > On 11/12/2018 03:41 AM, Anshuman Khandual wrote: >> At present there are multiple places where invalid node number is encoded >> as -1. Even though implicitly understood it is always better to have macros >> in there. Replace these open encodings

[PATCH] amd/iommu: Fix Guest Virtual APIC Log Tail Address Register

2018-11-12 Thread Suthikulpanit, Suravee
From: Filippo Sironi This register should have been programmed with the physical address of the memory location containing the shadow tail pointer for the guest virtual APIC log instead of the base address. Fixes: 8bda0cfbdc1a ('iommu/amd: Detect and initialize guest vAPIC log') Signed-off-by:

Re: [PATCH v2 1/1] iommu/vtd: Cleanup dma_remapping.h header

2018-11-12 Thread Joerg Roedel
On Mon, Nov 12, 2018 at 02:40:08PM +0800, Lu Baolu wrote: > arch/x86/kernel/tboot.c| 2 +- > drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 +- > drivers/gpu/drm/i915/intel_display.c | 2 +- > drivers/gpu/drm/vmwgfx/vmwgfx_drv.c| 2 +- >

Re: [PATCH v4 8/9] dmapool: improve accuracy of debug statistics

2018-11-12 Thread Matthew Wilcox
On Mon, Nov 12, 2018 at 10:45:58AM -0500, Tony Battersby wrote: > +++ linux/mm/dmapool.c2018-08-06 17:52:53.0 -0400 > @@ -61,6 +61,7 @@ struct dma_pool { /* the pool */ > struct device *dev; > unsigned int allocation; > unsigned int boundary; > +

Re: [RFC PATCH 2/6] drivers core: Add I/O ASID allocator

2018-11-12 Thread Joerg Roedel
Hi Jean-Philippe, On Fri, Oct 19, 2018 at 07:11:54PM +0100, Jean-Philippe Brucker wrote: > The allocator doesn't really belong in drivers/iommu because some > drivers would like to allocate PASIDs for devices that aren't managed by > an IOMMU, using the same ID space as IOMMU. It doesn't really

Re: [RFC PATCH 0/6] Auxiliary IOMMU domains and Arm SMMUv3

2018-11-12 Thread j...@8bytes.org
Hi Jean-Philippe, On Thu, Nov 08, 2018 at 06:29:42PM +, Jean-Philippe Brucker wrote: > (1) My initial approach would have been to use the same page tables for > the default_domain and this new domain, but it might be precisely what > you were trying to avoid with this new proposal: a device

[PATCH v4 9/9] dmapool: debug: prevent endless loop in case of corruption

2018-11-12 Thread Tony Battersby
Prevent a possible endless loop with DMAPOOL_DEBUG enabled if a buggy driver corrupts DMA pool memory. Signed-off-by: Tony Battersby --- --- linux/mm/dmapool.c.orig 2018-08-06 17:52:53.0 -0400 +++ linux/mm/dmapool.c 2018-08-06 17:53:31.0 -0400 @@ -454,17 +454,39 @@ void

[PATCH v4 8/9] dmapool: improve accuracy of debug statistics

2018-11-12 Thread Tony Battersby
The "total number of blocks in pool" debug statistic currently does not take the boundary value into account, so it diverges from the "total number of blocks in use" statistic when a boundary is in effect. Add a calculation for the number of blocks per allocation that takes the boundary into

[PATCH v4 4/9] dmapool: improve scalability of dma_pool_alloc

2018-11-12 Thread Tony Battersby
dma_pool_alloc() scales poorly when allocating a large number of pages because it does a linear scan of all previously-allocated pages before allocating a new one. Improve its scalability by maintaining a separate list of pages that have free blocks ready to (re)allocate. In big O notation, this

[PATCH v4 6/9] dmapool: improve scalability of dma_pool_free

2018-11-12 Thread Tony Battersby
dma_pool_free() scales poorly when the pool contains many pages because pool_find_page() does a linear scan of all allocated pages. Improve its scalability by replacing the linear scan with virt_to_page() and storing dmapool private data directly in 'struct page', thereby eliminating 'struct

[PATCH v4 7/9] dmapool: cleanup integer types

2018-11-12 Thread Tony Battersby
To represent the size of a single allocation, dmapool currently uses 'unsigned int' in some places and 'size_t' in other places. Standardize on 'unsigned int' to reduce overhead, but use 'size_t' when counting all the blocks in the entire pool. Signed-off-by: Tony Battersby --- This puts an

[PATCH v4 5/9] dmapool: rename fields in dma_page

2018-11-12 Thread Tony Battersby
Rename fields in 'struct dma_page' in preparation for moving them into 'struct page'. No functional changes. in_use -> dma_in_use offset -> dma_free_off Signed-off-by: Tony Battersby --- --- linux/mm/dmapool.c.orig 2018-08-03 17:46:13.0 -0400 +++ linux/mm/dmapool.c 2018-08-03

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

2018-11-12 Thread Mika Westerberg
Recent systems shipping Windows 10 version 1803 or later may support IOMMU based DMA protection. This means that the platform utilizes IOMMU to prevent DMA attacks over externally exposed PCIe root ports (typically Thunderbolt ports) The system BIOS marks these PCIe root ports as being externally

[PATCH 0/4] PCI / iommu / thunderbolt: IOMMU based DMA protection

2018-11-12 Thread Mika Westerberg
Hi all, Recent systems shipping with Windows 10 version 1803 or newer may be utilizing IOMMU to prevent DMA attacks via Thunderbolt ports. This is different from the previous security level based scheme because the connected device cannot access system memory outside of the regions allocated for

[PATCH 3/4] iommu/vt-d: Do not enable ATS for external devices

2018-11-12 Thread Mika Westerberg
Currently Linux automatically enables ATS (Address Translation Service) for any device that supports it (and IOMMU is turned on). ATS is used to accelerate DMA access as the device can cache translations locally so there is no need to do full translation on IOMMU side. However, as pointed out in

[PATCH 4/4] thunderbolt: Export IOMMU based DMA protection support to userspace

2018-11-12 Thread Mika Westerberg
Recent systems shipping with Windows 10 version 1803 or later may support a feature called Kernel DMA protection [1]. In practice this means that Thunderbolt connected devices are placed behind an IOMMU during the whole time it is connected (including during boot) making Thunderbolt security

[PATCH 2/4] iommu/vt-d: Force IOMMU on for platform opt in hint

2018-11-12 Thread Mika Westerberg
From: Lu Baolu Intel VT-d spec added a new DMA_CTRL_PLATFORM_OPT_IN_FLAG flag in DMAR ACPI table for BIOS to report compliance about platform initiated DMA restricted to RMRR ranges when transferring control to the OS. The OS treats this as a hint that the IOMMU should be enabled to prevent DMA

[PATCH v4 2/9] dmapool: remove checks for dev == NULL

2018-11-12 Thread Tony Battersby
dmapool originally tried to support pools without a device because dma_alloc_coherent() supports allocations without a device. But nobody ended up using dma pools without a device, so the current checks in dmapool.c for pool->dev == NULL are both insufficient and causing bloat. Remove them.

[PATCH v4 0/9] mpt3sas and dmapool scalability

2018-11-12 Thread Tony Battersby
I posted v3 on August 7. Nobody acked or merged the patches, and then I got too busy with other stuff to repost until now. The only change since v3: *) Dropped patch #10 (the mpt3sas patch) since the mpt3sas maintainers didn't show any interest. I believe these patches are ready for merging.

[PATCH v4 1/9] dmapool: fix boundary comparison

2018-11-12 Thread Tony Battersby
Fix the boundary comparison when constructing the list of free blocks for the case that 'size' is a power of two. Since 'boundary' is also a power of two, that would make 'boundary' a multiple of 'size', in which case a single block would never cross the boundary. This bug would cause some of

[PATCH v4 3/9] dmapool: cleanup dma_pool_destroy

2018-11-12 Thread Tony Battersby
Remove a small amount of code duplication between dma_pool_destroy() and pool_free_page() in preparation for adding more code without having to duplicate it. No functional changes. Signed-off-by: Tony Battersby --- --- linux/mm/dmapool.c.orig 2018-08-02 09:59:15.0 -0400 +++

Re: [PATCH 0/4] PCI / iommu / thunderbolt: IOMMU based DMA protection

2018-11-12 Thread Lukas Wunner
On Mon, Nov 12, 2018 at 07:06:24PM +0300, Mika Westerberg wrote: > Recent systems shipping with Windows 10 version 1803 or newer may be > utilizing IOMMU to prevent DMA attacks via Thunderbolt ports. This is > different from the previous security level based scheme because the > connected device

Re: [PATCH 0/4] PCI / iommu / thunderbolt: IOMMU based DMA protection

2018-11-12 Thread Yehezkel Bernat
On Mon, Nov 12, 2018 at 8:12 PM Lukas Wunner wrote: > > On Mon, Nov 12, 2018 at 07:06:24PM +0300, Mika Westerberg wrote: > > Recent systems shipping with Windows 10 version 1803 or newer may be > > utilizing IOMMU to prevent DMA attacks via Thunderbolt ports. This is > > different from the

Re: [PATCH 2/4] iommu/vt-d: Force IOMMU on for platform opt in hint

2018-11-12 Thread Raj, Ashok
On Mon, Nov 12, 2018 at 11:09:00AM -0700, Alex Williamson wrote: > On Mon, 12 Nov 2018 19:06:26 +0300 > Mika Westerberg wrote: > > > From: Lu Baolu > > > > Intel VT-d spec added a new DMA_CTRL_PLATFORM_OPT_IN_FLAG flag > > in DMAR ACPI table for BIOS to report compliance about platform > >

Re: [RFC] mm: Replace all open encodings for NUMA_NO_NODE

2018-11-12 Thread Hans Verkuil
On 11/12/2018 03:41 AM, Anshuman Khandual wrote: > At present there are multiple places where invalid node number is encoded > as -1. Even though implicitly understood it is always better to have macros > in there. Replace these open encodings for an invalid node number with the > global macro

Re: [PATCH 4/4] thunderbolt: Export IOMMU based DMA protection support to userspace

2018-11-12 Thread Yehezkel Bernat
On Mon, Nov 12, 2018 at 6:06 PM Mika Westerberg wrote: > > Recent systems shipping with Windows 10 version 1803 or later may > support a feature called Kernel DMA protection [1]. In practice this > means that Thunderbolt connected devices are placed behind an IOMMU > during the whole time it is

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

2018-11-12 Thread Lukas Wunner
On Mon, Nov 12, 2018 at 07:06:25PM +0300, Mika Westerberg wrote: > --- a/drivers/pci/probe.c > +++ b/drivers/pci/probe.c > @@ -1378,6 +1378,27 @@ static void set_pcie_thunderbolt(struct pci_dev *dev) > } > } > > +static void set_pcie_external(struct pci_dev *dev) > +{ > + struct

Re: [PATCH 3/4] iommu/vt-d: Do not enable ATS for external devices

2018-11-12 Thread Raj, Ashok
On Mon, Nov 12, 2018 at 07:06:27PM +0300, Mika Westerberg wrote: > Currently Linux automatically enables ATS (Address Translation Service) > for any device that supports it (and IOMMU is turned on). ATS is used to > accelerate DMA access as the device can cache translations locally so > there is

Re: [PATCH v4 2/9] dmapool: remove checks for dev == NULL

2018-11-12 Thread John Garry
On 12/11/2018 15:42, Tony Battersby wrote: dmapool originally tried to support pools without a device because dma_alloc_coherent() supports allocations without a device. But nobody ended up using dma pools without a device, so the current checks in dmapool.c for pool->dev == NULL are both

Re: [PATCH 2/4] iommu/vt-d: Force IOMMU on for platform opt in hint

2018-11-12 Thread Raj, Ashok
On Mon, Nov 12, 2018 at 07:06:26PM +0300, Mika Westerberg wrote: > From: Lu Baolu > > Intel VT-d spec added a new DMA_CTRL_PLATFORM_OPT_IN_FLAG flag > in DMAR ACPI table for BIOS to report compliance about platform > initiated DMA restricted to RMRR ranges when transferring control > to the OS.

Re: [PATCH 2/4] iommu/vt-d: Force IOMMU on for platform opt in hint

2018-11-12 Thread Alex Williamson
On Mon, 12 Nov 2018 19:06:26 +0300 Mika Westerberg wrote: > From: Lu Baolu > > Intel VT-d spec added a new DMA_CTRL_PLATFORM_OPT_IN_FLAG flag > in DMAR ACPI table for BIOS to report compliance about platform > initiated DMA restricted to RMRR ranges when transferring control > to the OS. The

RE: [PATCH 4/4] thunderbolt: Export IOMMU based DMA protection support to userspace

2018-11-12 Thread Mario.Limonciello
> -Original Message- > From: Mika Westerberg > Sent: Monday, November 12, 2018 10:06 AM > To: iommu@lists.linux-foundation.org > Cc: Joerg Roedel; David Woodhouse; Lu Baolu; Ashok Raj; Bjorn Helgaas; Rafael > J. > Wysocki; Jacob jun Pan; Andreas Noever; Michael Jamet; Yehezkel Bernat;

Re: [PATCH v4 2/9] dmapool: remove checks for dev == NULL

2018-11-12 Thread Tony Battersby
On 11/12/18 11:32 AM, John Garry wrote: > On 12/11/2018 15:42, Tony Battersby wrote: >> dmapool originally tried to support pools without a device because >> dma_alloc_coherent() supports allocations without a device. But nobody >> ended up using dma pools without a device, so the current checks