Re: [PATCH v7 11/11] iommu/vt-d: Add svm/sva invalidate function

2020-02-14 Thread Jacob Pan
Hi Eric, Thanks for the review, I somehow missed it, my apologies. See comments below. On Tue, 12 Nov 2019 11:28:37 +0100 Auger Eric wrote: > Hi Jacob, > > On 10/24/19 9:55 PM, Jacob Pan wrote: > > When Shared Virtual Address (SVA) is enabled for a guest OS via > > vIOMMU, we need to provide

Re: [PATCH V9 06/10] iommu/vt-d: Add svm/sva invalidate function

2020-02-14 Thread Jacob Pan
On Wed, 12 Feb 2020 14:13:37 +0100 Auger Eric wrote: > Hi Jacob, > > On 1/29/20 7:01 AM, Jacob Pan wrote: > > When Shared Virtual Address (SVA) is enabled for a guest OS via > > vIOMMU, we need to provide invalidation support at IOMMU API and > > driver level. This patch adds Intel VT-d

Re: [PATCH V9 05/10] iommu/vt-d: Support flushing more translation cache types

2020-02-14 Thread Jacob Pan
Hi Eric, On Wed, 12 Feb 2020 13:55:25 +0100 Auger Eric wrote: > Hi Jacob, > > On 1/29/20 7:01 AM, Jacob Pan wrote: > > When Shared Virtual Memory is exposed to a guest via vIOMMU, > > scalable IOTLB invalidation may be passed down from outside IOMMU > > subsystems. This patch adds invalidation

[RFC PATCH] iommu/iova: Add a best-fit algorithm

2020-02-14 Thread Isaac J. Manjarres
From: Liam Mark Using the best-fit algorithm, instead of the first-fit algorithm, may reduce fragmentation when allocating IOVAs. Signed-off-by: Isaac J. Manjarres --- drivers/iommu/dma-iommu.c | 17 +++ drivers/iommu/iova.c | 73 +--

[RFC PATCH] iommu/dma: Allow drivers to reserve an iova range

2020-02-14 Thread Isaac J. Manjarres
From: Liam Mark Some devices have a memory map which contains gaps or holes. In order for the device to have as much IOVA space as possible, allow its driver to inform the DMA-IOMMU layer that it should not allocate addresses from these holes. Change-Id:

[PATCH] iommu/arm-smmu: fix module name for parameters

2020-02-14 Thread Li Yang
Commit cd221bd24ff5 ("iommu/arm-smmu: Allow building as a module") introduced a side effect that changed the module name from arm-smmu to arm-smmu-mod. This breaks the users of kernel parameters for the driver (e.g. arm-smmu.disable_bypass). This patch changes the module name for parameters back

Re: arm-smmu.1.auto: Unhandled context fault starting with 5.4-rc1

2020-02-14 Thread Robin Murphy
Hi Jerry, On 2020-02-14 8:13 pm, Jerry Snitselaar wrote: Hi Will, On a gigabyte system with Cavium CN8xx, when doing a fio test against an nvme drive we are seeing the following: [  637.161194] arm-smmu arm-smmu.1.auto: Unhandled context fault: fsr=0x8402, iova=0x8010003f6000,

arm-smmu.1.auto: Unhandled context fault starting with 5.4-rc1

2020-02-14 Thread Jerry Snitselaar
Hi Will, On a gigabyte system with Cavium CN8xx, when doing a fio test against an nvme drive we are seeing the following: [ 637.161194] arm-smmu arm-smmu.1.auto: Unhandled context fault: fsr=0x8402, iova=0x8010003f6000, fsynr=0x70091, cbfrsynra=0x9000, cb=7 [ 637.174329] arm-smmu

Re: arm64 iommu groups issue

2020-02-14 Thread Robin Murphy
On 14/02/2020 2:09 pm, John Garry wrote: @@ -2420,6 +2421,10 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)   /* Set up MSI IRQ domain */   pci_set_msi_domain(dev); +    parent = dev->dev.parent; +    if (parent && parent->bus == _bus_type) +   

Re: [PATCH 2/3] PCI: Add DMA configuration for virtual platforms

2020-02-14 Thread Robin Murphy
On 14/02/2020 4:04 pm, Jean-Philippe Brucker wrote: Hardware platforms usually describe the IOMMU topology using either device-tree pointers or vendor-specific ACPI tables. For virtual platforms that don't provide a device-tree, the virtio-iommu device contains a description of the endpoints it

Re: [PATCH 3/3] iommu/virtio: Enable x86 support

2020-02-14 Thread Robin Murphy
On 14/02/2020 4:04 pm, Jean-Philippe Brucker wrote: With the built-in topology description in place, x86 platforms can now use the virtio-iommu. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git

Re: [PATCH v2] iommu/vt-d: consider real PCI device when checking if mapping is needed

2020-02-14 Thread Derrick, Jonathan
Hi Daniel, sorry for the delay On Fri, 2020-02-14 at 17:02 +0800, Daniel Drake wrote: > From: Jon Derrick > > The PCI devices handled by intel-iommu may have a DMA requester on > another bus, such as VMD subdevices needing to use the VMD endpoint. > > The real DMA device is now used for the

[PATCH] iommu/virtio: Build virtio-iommu as module

2020-02-14 Thread Jean-Philippe Brucker
From: Jean-Philippe Brucker Now that the infrastructure changes are in place, enable virtio-iommu to be built as a module. Remove the redundant pci_request_acs() call, since it's not exported but is already invoked during DMA setup. Signed-off-by: Jean-Philippe Brucker --- This conflicts with

[PATCH AUTOSEL 4.4 072/100] iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE

2020-02-14 Thread Sasha Levin
From: Will Deacon [ Upstream commit d71e01716b3606a6648df7e5646ae12c75babde4 ] If, for some bizarre reason, the compiler decided to split up the write of STE DWORD 0, we could end up making a partial structure valid. Although this probably won't happen, follow the example of the

[PATCH AUTOSEL 4.9 102/141] iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE

2020-02-14 Thread Sasha Levin
From: Will Deacon [ Upstream commit d71e01716b3606a6648df7e5646ae12c75babde4 ] If, for some bizarre reason, the compiler decided to split up the write of STE DWORD 0, we could end up making a partial structure valid. Although this probably won't happen, follow the example of the

[PATCH AUTOSEL 4.14 131/186] iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE

2020-02-14 Thread Sasha Levin
From: Will Deacon [ Upstream commit d71e01716b3606a6648df7e5646ae12c75babde4 ] If, for some bizarre reason, the compiler decided to split up the write of STE DWORD 0, we could end up making a partial structure valid. Although this probably won't happen, follow the example of the

[PATCH AUTOSEL 4.19 214/252] iommu/vt-d: Remove unnecessary WARN_ON_ONCE()

2020-02-14 Thread Sasha Levin
From: Lu Baolu [ Upstream commit 857f081426e5aa38313426c13373730f1345fe95 ] Address field in device TLB invalidation descriptor is qualified by the S field. If S field is zero, a single page at page address specified by address [63:12] is requested to be invalidated. If S field is set, the

[PATCH AUTOSEL 4.19 143/252] iommu/arm-smmu-v3: Populate VMID field for CMDQ_OP_TLBI_NH_VA

2020-02-14 Thread Sasha Levin
From: Shameer Kolothum [ Upstream commit 935d43ba272e0001f8ef446a3eff15d8175cb11b ] CMDQ_OP_TLBI_NH_VA requires VMID and this was missing since commit 1c27df1c0a82 ("iommu/arm-smmu: Use correct address mask for CMD_TLBI_S2_IPA"). Add it back. Fixes: 1c27df1c0a82 ("iommu/arm-smmu: Use correct

[PATCH AUTOSEL 4.19 177/252] iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE

2020-02-14 Thread Sasha Levin
From: Will Deacon [ Upstream commit d71e01716b3606a6648df7e5646ae12c75babde4 ] If, for some bizarre reason, the compiler decided to split up the write of STE DWORD 0, we could end up making a partial structure valid. Although this probably won't happen, follow the example of the

[PATCH AUTOSEL 4.19 019/252] iommu/vt-d: Fix off-by-one in PASID allocation

2020-02-14 Thread Sasha Levin
From: Jacob Pan [ Upstream commit 39d630e332144028f56abba83d94291978e72df1 ] PASID allocator uses IDR which is exclusive for the end of the allocation range. There is no need to decrement pasid_max. Fixes: af39507305fb ("iommu/vt-d: Apply global PASID in SVA") Reported-by: Eric Auger

[PATCH AUTOSEL 5.4 395/459] iommu/vt-d: Remove unnecessary WARN_ON_ONCE()

2020-02-14 Thread Sasha Levin
From: Lu Baolu [ Upstream commit 857f081426e5aa38313426c13373730f1345fe95 ] Address field in device TLB invalidation descriptor is qualified by the S field. If S field is zero, a single page at page address specified by address [63:12] is requested to be invalidated. If S field is set, the

[PATCH AUTOSEL 5.4 322/459] iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE

2020-02-14 Thread Sasha Levin
From: Will Deacon [ Upstream commit d71e01716b3606a6648df7e5646ae12c75babde4 ] If, for some bizarre reason, the compiler decided to split up the write of STE DWORD 0, we could end up making a partial structure valid. Although this probably won't happen, follow the example of the

[PATCH AUTOSEL 5.4 271/459] iommu/arm-smmu-v3: Populate VMID field for CMDQ_OP_TLBI_NH_VA

2020-02-14 Thread Sasha Levin
From: Shameer Kolothum [ Upstream commit 935d43ba272e0001f8ef446a3eff15d8175cb11b ] CMDQ_OP_TLBI_NH_VA requires VMID and this was missing since commit 1c27df1c0a82 ("iommu/arm-smmu: Use correct address mask for CMD_TLBI_S2_IPA"). Add it back. Fixes: 1c27df1c0a82 ("iommu/arm-smmu: Use correct

[PATCH AUTOSEL 5.4 253/459] iommu/vt-d: Match CPU and IOMMU paging mode

2020-02-14 Thread Sasha Levin
From: Jacob Pan [ Upstream commit 79db7e1b4cf2a006f556099c13de3b12970fc6e3 ] When setting up first level page tables for sharing with CPU, we need to ensure IOMMU can support no less than the levels supported by the CPU. It is not adequate, as in the current code, to set up 5-level paging in

[PATCH 0/3] virtio-iommu on non-devicetree platforms

2020-02-14 Thread Jean-Philippe Brucker
Add topology description to the virtio-iommu driver and enable x86 platforms. Since the RFC [1] I've mostly given up on ACPI tables, since the internal discussions seem to have reached a dead end. The built-in topology description presented here isn't ideal, but it is simple to implement and

[PATCH 1/3] iommu/virtio: Add topology description to virtio-iommu config space

2020-02-14 Thread Jean-Philippe Brucker
Platforms without device-tree do not currently have a method for describing the vIOMMU topology. Provide a topology description embedded into the virtio device. Use PCI FIXUP to probe the config space early, because we need to discover the topology before any DMA configuration takes place, and

[PATCH 3/3] iommu/virtio: Enable x86 support

2020-02-14 Thread Jean-Philippe Brucker
With the built-in topology description in place, x86 platforms can now use the virtio-iommu. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index

[PATCH AUTOSEL 5.4 254/459] iommu/vt-d: Avoid sending invalid page response

2020-02-14 Thread Sasha Levin
From: Jacob Pan [ Upstream commit 5f75585e19cc7018bf2016aa771632081ee2f313 ] Page responses should only be sent when last page in group (LPIG) or private data is present in the page request. This patch avoids sending invalid descriptors. Fixes: 5d308fc1ecf53 ("iommu/vt-d: Add 256-bit

[PATCH AUTOSEL 5.4 220/459] iommu/amd: Check feature support bit before accessing MSI capability registers

2020-02-14 Thread Sasha Levin
From: Suravee Suthikulpanit [ Upstream commit 813071438e83d338ba5cfe98b3b26c890dc0a6c0 ] The IOMMU MMIO access to MSI capability registers is available only if the EFR[MsiCapMmioSup] is set. Current implementation assumes this bit is set if the EFR[XtSup] is set, which might not be the case.

[PATCH AUTOSEL 5.4 221/459] iommu/amd: Only support x2APIC with IVHD type 11h/40h

2020-02-14 Thread Sasha Levin
From: Suravee Suthikulpanit [ Upstream commit 966b753cf3969553ca50bacd2b8c4ddade5ecc9e ] Current implementation for IOMMU x2APIC support makes use of the MMIO access to MSI capability block registers, which requires checking EFR[MsiCapMmioSup]. However, only IVHD type 11h/40h contain the

[PATCH AUTOSEL 5.4 196/459] PCI: Add nr_devfns parameter to pci_add_dma_alias()

2020-02-14 Thread Sasha Levin
From: James Sewart [ Upstream commit 09298542cd891b43778db1f65aa3613aa5a562eb ] Add a "nr_devfns" parameter to pci_add_dma_alias() so it can be used to create DMA aliases for a range of devfns. [bhelgaas: incorporate nr_devfns fix from James, update quirk_pex_vca_alias() and setup_aliases()]

[PATCH AUTOSEL 5.4 045/459] iommu/vt-d: Fix off-by-one in PASID allocation

2020-02-14 Thread Sasha Levin
From: Jacob Pan [ Upstream commit 39d630e332144028f56abba83d94291978e72df1 ] PASID allocator uses IDR which is exclusive for the end of the allocation range. There is no need to decrement pasid_max. Fixes: af39507305fb ("iommu/vt-d: Apply global PASID in SVA") Reported-by: Eric Auger

[PATCH AUTOSEL 5.5 459/542] iommu/vt-d: Remove unnecessary WARN_ON_ONCE()

2020-02-14 Thread Sasha Levin
From: Lu Baolu [ Upstream commit 857f081426e5aa38313426c13373730f1345fe95 ] Address field in device TLB invalidation descriptor is qualified by the S field. If S field is zero, a single page at page address specified by address [63:12] is requested to be invalidated. If S field is set, the

[PATCH AUTOSEL 5.5 458/542] iommu/vt-d: Mark firmware tainted if RMRR fails sanity check

2020-02-14 Thread Sasha Levin
From: Barret Rhoden [ Upstream commit f5a68bb0752e0cf77c06f53f72258e7beb41381b ] RMRR entries describe memory regions that are DMA targets for devices outside the kernel's control. RMRR entries that fail the sanity check are pointing to regions of memory that the firmware did not tell the

[PATCH AUTOSEL 5.5 370/542] iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE

2020-02-14 Thread Sasha Levin
From: Will Deacon [ Upstream commit d71e01716b3606a6648df7e5646ae12c75babde4 ] If, for some bizarre reason, the compiler decided to split up the write of STE DWORD 0, we could end up making a partial structure valid. Although this probably won't happen, follow the example of the

[PATCH AUTOSEL 5.5 312/542] iommu/arm-smmu-v3: Populate VMID field for CMDQ_OP_TLBI_NH_VA

2020-02-14 Thread Sasha Levin
From: Shameer Kolothum [ Upstream commit 935d43ba272e0001f8ef446a3eff15d8175cb11b ] CMDQ_OP_TLBI_NH_VA requires VMID and this was missing since commit 1c27df1c0a82 ("iommu/arm-smmu: Use correct address mask for CMD_TLBI_S2_IPA"). Add it back. Fixes: 1c27df1c0a82 ("iommu/arm-smmu: Use correct

[PATCH AUTOSEL 5.5 291/542] iommu/vt-d: Match CPU and IOMMU paging mode

2020-02-14 Thread Sasha Levin
From: Jacob Pan [ Upstream commit 79db7e1b4cf2a006f556099c13de3b12970fc6e3 ] When setting up first level page tables for sharing with CPU, we need to ensure IOMMU can support no less than the levels supported by the CPU. It is not adequate, as in the current code, to set up 5-level paging in

[PATCH AUTOSEL 5.5 292/542] iommu/vt-d: Avoid sending invalid page response

2020-02-14 Thread Sasha Levin
From: Jacob Pan [ Upstream commit 5f75585e19cc7018bf2016aa771632081ee2f313 ] Page responses should only be sent when last page in group (LPIG) or private data is present in the page request. This patch avoids sending invalid descriptors. Fixes: 5d308fc1ecf53 ("iommu/vt-d: Add 256-bit

[PATCH AUTOSEL 5.5 255/542] iommu/amd: Only support x2APIC with IVHD type 11h/40h

2020-02-14 Thread Sasha Levin
From: Suravee Suthikulpanit [ Upstream commit 966b753cf3969553ca50bacd2b8c4ddade5ecc9e ] Current implementation for IOMMU x2APIC support makes use of the MMIO access to MSI capability block registers, which requires checking EFR[MsiCapMmioSup]. However, only IVHD type 11h/40h contain the

[PATCH AUTOSEL 5.5 256/542] iommu/iova: Silence warnings under memory pressure

2020-02-14 Thread Sasha Levin
From: Qian Cai [ Upstream commit 944c9175397476199d4dd1028d87ddc582c35ee8 ] When running heavy memory pressure workloads, this 5+ old system is throwing endless warnings below because disk IO is too slow to recover from swapping. Since the volume from alloc_iova_fast() could be large, once it

[PATCH AUTOSEL 5.5 254/542] iommu/amd: Check feature support bit before accessing MSI capability registers

2020-02-14 Thread Sasha Levin
From: Suravee Suthikulpanit [ Upstream commit 813071438e83d338ba5cfe98b3b26c890dc0a6c0 ] The IOMMU MMIO access to MSI capability registers is available only if the EFR[MsiCapMmioSup] is set. Current implementation assumes this bit is set if the EFR[XtSup] is set, which might not be the case.

[PATCH AUTOSEL 5.5 051/542] iommu/vt-d: Fix off-by-one in PASID allocation

2020-02-14 Thread Sasha Levin
From: Jacob Pan [ Upstream commit 39d630e332144028f56abba83d94291978e72df1 ] PASID allocator uses IDR which is exclusive for the end of the allocation range. There is no need to decrement pasid_max. Fixes: af39507305fb ("iommu/vt-d: Apply global PASID in SVA") Reported-by: Eric Auger

Re: arm64 iommu groups issue

2020-02-14 Thread John Garry
@@ -2420,6 +2421,10 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) /* Set up MSI IRQ domain */ pci_set_msi_domain(dev); +    parent = dev->dev.parent; +    if (parent && parent->bus == _bus_type) +    device_link_add(>dev, parent, DL_FLAG_AUTOPROBE_CONSUMER);

Re: [PATCH v2] iommu/vt-d: consider real PCI device when checking if mapping is needed

2020-02-14 Thread Lu Baolu
Hi, On 2020/2/14 17:02, Daniel Drake wrote: From: Jon Derrick The PCI devices handled by intel-iommu may have a DMA requester on another bus, such as VMD subdevices needing to use the VMD endpoint. The real DMA device is now used for the DMA mapping, but one case was missed earlier: if the

[PATCH 1/1] iommu/amd: Fix the configuration of GCR3 table root pointer

2020-02-14 Thread Adrian Huang
From: Adrian Huang The SPA of the GCR3 table root pointer[51:31] masks 20 bits. However, this requires 21 bits (Please see the AMD IOMMU specification). This leads to the potential failure when the bit 51 of SPA of the GCR3 table root pointer is 1'. Signed-off-by: Adrian Huang ---

[PATCH v2] iommu/vt-d: consider real PCI device when checking if mapping is needed

2020-02-14 Thread Daniel Drake
From: Jon Derrick The PCI devices handled by intel-iommu may have a DMA requester on another bus, such as VMD subdevices needing to use the VMD endpoint. The real DMA device is now used for the DMA mapping, but one case was missed earlier: if the VMD device (and hence subdevices too) are under