[PATCH] iommu: arm-smmu-v3: make of_device_ids const

2017-06-22 Thread Arvind Yadav
of_device_ids are not supposed to change at runtime. All functions working with of_device_ids provided by work with const of_device_ids. So mark the non-const structs as const. Signed-off-by: Arvind Yadav --- drivers/iommu/arm-smmu-v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) dif

[PATCH] iommu: arm-smmu: Handle return of iommu_device_register.

2017-06-22 Thread Arvind Yadav
iommu_device_register can fail here and we must check its return value. Signed-off-by: Arvind Yadav --- drivers/iommu/arm-smmu-v3.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 7d3f08a..182eb38 100644 --- a/drivers/iommu/ar

[PATCH] iommu: amd_iommu_init: constify amd_iommu_group.

2017-06-22 Thread Arvind Yadav
File size before: textdata bss dec hex filename 143231840 353 165164084 drivers/iommu/amd_iommu_init.o File size After adding 'const': textdata bss dec hex filename 143791776 353 16508407c drivers/iommu/amd_iommu_init.o Signed-

[PATCH] iommu/amd_iommu_init: Handle return of iommu_device_register/iommu_device_sysfs_add

2017-06-22 Thread Arvind Yadav
iommu_device_register and iommu_device_sysfs_add can fail here and we must check its return value. Signed-off-by: Arvind Yadav --- drivers/iommu/amd_iommu_init.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_

[PATCH] iommu: intel-iommu: constify intel_dma_ops and intel_iommu_group

2017-06-22 Thread Arvind Yadav
File size before: textdata bss dec hex filename 32765 7581824 353478a13 drivers/iommu/intel-iommu.o File size After adding 'const': textdata bss dec hex filename 32989 5341824 353478a13 drivers/iommu/intel-iommu.o Signed-off-by

Re: [PATCH v1 3/3] iommu/amd: Optimize the IOMMU queue flush

2017-06-22 Thread Joerg Roedel
On Wed, Jun 21, 2017 at 05:09:31PM -0400, Jan Vesely wrote: > On Wed, 2017-06-21 at 12:01 -0500, Tom Lendacky wrote: > > On 6/21/2017 11:20 AM, Jan Vesely wrote: > > > Hi Arindam, > > > > > > has this patch been replaced by Joerg's "[PATCH 0/7] iommu/amd: > > > Optimize iova queue flushing" series

Re: [PATCH v7 26/36] x86/CPU/AMD: Make the microcode level available earlier in the boot

2017-06-22 Thread Borislav Petkov
On Fri, Jun 16, 2017 at 01:54:47PM -0500, Tom Lendacky wrote: > Move the setting of the cpuinfo_x86.microcode field from amd_init() to > early_amd_init() so that it is available earlier in the boot process. This > avoids having to read MSR_AMD64_PATCH_LEVEL directly during early boot. > > Signed-o

[PATCH] iommu/intel-iommu: Handle return of iommu_device_register/iommu_device_sysfs_add

2017-06-22 Thread Arvind Yadav
iommu_device_register and iommu_device_sysfs_add can fail here and we must check its return value. Signed-off-by: Arvind Yadav --- drivers/iommu/intel-iommu.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu

Re: [PATCH v7 17/36] efi: Update efi_mem_type() to return an error rather than 0

2017-06-22 Thread Matt Fleming
On Fri, 16 Jun, at 01:53:06PM, Tom Lendacky wrote: > The efi_mem_type() function currently returns a 0, which maps to > EFI_RESERVED_TYPE, if the function is unable to find a memmap entry for > the supplied physical address. Returning EFI_RESERVED_TYPE implies that > a memmap entry exists, when it

[PATCH] iommu/amd: Free already flushed ring-buffer entries before full-check

2017-06-22 Thread Joerg Roedel
From: Joerg Roedel To benefit from IOTLB flushes on other CPUs we have to free the already flushed IOVAs from the ring-buffer before we do the queue_ring_full() check. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-)

Re: [PATCH v7 27/36] iommu/amd: Allow the AMD IOMMU to work with memory encryption

2017-06-22 Thread Borislav Petkov
On Fri, Jun 16, 2017 at 01:54:59PM -0500, Tom Lendacky wrote: > The IOMMU is programmed with physical addresses for the various tables > and buffers that are used to communicate between the device and the > driver. When the driver allocates this memory it is encrypted. In order > for the IOMMU to a

Re: [PATCH v7 16/36] efi: Add an EFI table address match function

2017-06-22 Thread Matt Fleming
On Fri, 16 Jun, at 01:52:53PM, Tom Lendacky wrote: > Add a function that will determine if a supplied physical address matches > the address of an EFI table. > > Reviewed-by: Borislav Petkov > Signed-off-by: Tom Lendacky > --- > drivers/firmware/efi/efi.c | 33

Re: [PATCH v7 18/36] x86/efi: Update EFI pagetable creation to work with SME

2017-06-22 Thread Matt Fleming
On Fri, 16 Jun, at 01:53:17PM, Tom Lendacky wrote: > When SME is active, pagetable entries created for EFI need to have the > encryption mask set as necessary. > > When the new pagetable pages are allocated they are mapped encrypted. So, > update the efi_pgt value that will be used in cr3 to inclu

Re: [PATCH v7 19/36] x86/mm: Add support to access boot related data in the clear

2017-06-22 Thread Matt Fleming
On Fri, 16 Jun, at 01:53:26PM, Tom Lendacky wrote: > Boot data (such as EFI related data) is not encrypted when the system is > booted because UEFI/BIOS does not run with SME active. In order to access > this data properly it needs to be mapped decrypted. > > Update early_memremap() to provide an

[PATCH v9 0/3] Cavium ThunderX2 SMMUv3 errata workarounds

2017-06-22 Thread Geetha sowjanya
Cavium ThunderX2 SMMUv3 implementation has two Silicon Erratas. 1. Errata ID #74 SMMU register alias Page 1 is not implemented 2. Errata ID #126 SMMU doesnt support unique IRQ lines and also MSI for gerror, eventq and cmdq-sync The following patchset does software workaround for these two

[PATCH v9 3/3] iommu/arm-smmu-v3: Add workaround for Cavium ThunderX2 erratum #126

2017-06-22 Thread Geetha sowjanya
From: Geetha Sowjanya Cavium ThunderX2 SMMU doesn't support MSI and also doesn't have unique irq lines for gerror, eventq and cmdq-sync. New named irq "combined" is set as a errata workaround, which allows to share the irq line by register single irq handler for all the interrupts. Signed-off-b

[PATCH v9 1/3] ACPI/IORT: Fixup SMMUv3 resource size for Cavium ThunderX2 SMMUv3 model

2017-06-22 Thread Geetha sowjanya
From: Linu Cherian Cavium ThunderX2 implementation doesn't support second page in SMMU register space. Hence, resource size is set as 64k for this model. Signed-off-by: Linu Cherian Signed-off-by: Geetha Sowjanya --- drivers/acpi/arm64/iort.c | 15 ++- 1 files changed, 14 insert

[PATCH v9 2/3] iommu/arm-smmu-v3: Add workaround for Cavium ThunderX2 erratum #74

2017-06-22 Thread Geetha sowjanya
From: Linu Cherian Cavium ThunderX2 SMMU implementation doesn't support page 1 register space and PAGE0_REGS_ONLY option is enabled as an errata workaround. This option when turned on, replaces all page 1 offsets used for EVTQ_PROD/CONS, PRIQ_PROD/CONS register access with page 0 offsets. SMMU r

Re: [PATCH v1 3/3] iommu/amd: Optimize the IOMMU queue flush

2017-06-22 Thread Jan Vesely
On Thu, 2017-06-22 at 11:20 +0200, Joerg Roedel wrote: > On Wed, Jun 21, 2017 at 05:09:31PM -0400, Jan Vesely wrote: > > On Wed, 2017-06-21 at 12:01 -0500, Tom Lendacky wrote: > > > On 6/21/2017 11:20 AM, Jan Vesely wrote: > > > > Hi Arindam, > > > > > > > > has this patch been replaced by Joerg's

[PATCH v2 1/8] iommu/io-pgtable-arm-v7s: Check table PTEs more precisely

2017-06-22 Thread Robin Murphy
Whilst we don't support the PXN bit at all, so should never encounter a level 1 section or supersection PTE with it set, it would still be wise to check both table type bits to resolve any theoretical ambiguity. Signed-off-by: Robin Murphy --- v2: No change drivers/iommu/io-pgtable-arm-v7s.c |

[PATCH v2 0/8] io-pgtable lock removal

2017-06-22 Thread Robin Murphy
The feedback has been promising, so v2 is just a final update to cover a handful of memory ordering and cosmetic tweaks that came up when Will and I went through this offline. Thanks, Robin. Robin Murphy (8): iommu/io-pgtable-arm-v7s: Check table PTEs more precisely iommu/io-pgtable-arm: Imp

[PATCH v2 2/8] iommu/io-pgtable-arm: Improve split_blk_unmap

2017-06-22 Thread Robin Murphy
The current split_blk_unmap implementation suffers from some inscrutable pointer trickery for creating the tables to replace the block entry, but more than that it also suffers from hideous inefficiency. For example, the most pathological case of unmapping a level 3 page from a level 1 block will a

[PATCH v2 3/8] iommu/io-pgtable-arm-v7s: Refactor split_blk_unmap

2017-06-22 Thread Robin Murphy
Whilst the short-descriptor format's split_blk_unmap implementation has no need to be recursive, it followed the pattern of the LPAE version anyway for the sake of consistency. With the latter now reworked for both efficiency and future scalability improvements, tweak the former similarly, not leas

[PATCH v2 5/8] iommu/io-pgtable-arm: Support lockless operation

2017-06-22 Thread Robin Murphy
For parallel I/O with multiple concurrent threads servicing the same device (or devices, if several share a domain), serialising page table updates becomes a massive bottleneck. On reflection, though, we don't strictly need to do that - for valid IOMMU API usage, there are in fact only two races th

[PATCH v2 4/8] iommu/io-pgtable: Introduce explicit coherency

2017-06-22 Thread Robin Murphy
Once we remove the serialising spinlock, a potential race opens up for non-coherent IOMMUs whereby a caller of .map() can be sure that cache maintenance has been performed on their new PTE, but will have no guarantee that such maintenance for table entries above it has actually completed (e.g. if a

[PATCH v2 6/8] iommu/io-pgtable-arm-v7s: Support lockless operation

2017-06-22 Thread Robin Murphy
Mirroring the LPAE implementation, rework the v7s code to be robust against concurrent operations. The same two potential races exist, and are solved in the same manner, with the fixed 2-level structure making life ever so slightly simpler. What complicates matters compared to LPAE, however, is la

[PATCH v2 7/8] iommu/arm-smmu: Remove io-pgtable spinlock

2017-06-22 Thread Robin Murphy
With the io-pgtable code now robust against (valid) races, we no longer need to serialise all operations with a lock. This might make broken callers who issue concurrent operations on overlapping addresses go even more wrong than before, but hey, they already had little hope of useful or determinis

[PATCH v2 8/8] iommu/arm-smmu-v3: Remove io-pgtable spinlock

2017-06-22 Thread Robin Murphy
As for SMMUv2, take advantage of io-pgtable's newfound tolerance for concurrency. Unfortunately in this case the command queue lock remains a point of serialisation for the unmap path, but there may be a little more we can do to ameliorate that in future. Signed-off-by: Robin Murphy --- v2: No c

Re: [PATCH v7 27/36] iommu/amd: Allow the AMD IOMMU to work with memory encryption

2017-06-22 Thread Tom Lendacky
On 6/22/2017 5:56 AM, Borislav Petkov wrote: On Fri, Jun 16, 2017 at 01:54:59PM -0500, Tom Lendacky wrote: The IOMMU is programmed with physical addresses for the various tables and buffers that are used to communicate between the device and the driver. When the driver allocates this memory it i

Re: [PATCH v9 3/3] iommu/arm-smmu-v3: Add workaround for Cavium ThunderX2 erratum #126

2017-06-22 Thread Will Deacon
Hi Geetha, On Thu, Jun 22, 2017 at 05:35:38PM +0530, Geetha sowjanya wrote: > From: Geetha Sowjanya > > Cavium ThunderX2 SMMU doesn't support MSI and also doesn't have unique irq > lines for gerror, eventq and cmdq-sync. > > New named irq "combined" is set as a errata workaround, which allows t

Re: [PATCH v9 0/3] Cavium ThunderX2 SMMUv3 errata workarounds

2017-06-22 Thread Will Deacon
On Thu, Jun 22, 2017 at 05:35:35PM +0530, Geetha sowjanya wrote: > Cavium ThunderX2 SMMUv3 implementation has two Silicon Erratas. > 1. Errata ID #74 >SMMU register alias Page 1 is not implemented > 2. Errata ID #126 >SMMU doesnt support unique IRQ lines and also MSI for gerror, >eventq

Re: [PATCH v9 0/3] Cavium ThunderX2 SMMUv3 errata workarounds

2017-06-22 Thread Will Deacon
On Thu, Jun 22, 2017 at 07:22:57PM +0100, Will Deacon wrote: > On Thu, Jun 22, 2017 at 05:35:35PM +0530, Geetha sowjanya wrote: > > Cavium ThunderX2 SMMUv3 implementation has two Silicon Erratas. > > 1. Errata ID #74 > >SMMU register alias Page 1 is not implemented > > 2. Errata ID #126 > >

Re: [Devel] [PATCH v9 0/3] Cavium ThunderX2 SMMUv3 errata workarounds

2017-06-22 Thread Robert Richter
On 22.06.17 19:58:22, Will Deacon wrote: > On Thu, Jun 22, 2017 at 07:22:57PM +0100, Will Deacon wrote: > > On Thu, Jun 22, 2017 at 05:35:35PM +0530, Geetha sowjanya wrote: > > > Cavium ThunderX2 SMMUv3 implementation has two Silicon Erratas. > > > 1. Errata ID #74 > > >SMMU register alias Page

Re: [Devel] [PATCH v9 0/3] Cavium ThunderX2 SMMUv3 errata workarounds

2017-06-22 Thread Lorenzo Pieralisi
On Thu, Jun 22, 2017 at 09:35:35PM +0200, Robert Richter wrote: > On 22.06.17 19:58:22, Will Deacon wrote: > > On Thu, Jun 22, 2017 at 07:22:57PM +0100, Will Deacon wrote: > > > On Thu, Jun 22, 2017 at 05:35:35PM +0530, Geetha sowjanya wrote: > > > > Cavium ThunderX2 SMMUv3 implementation has two S

Re: new dma-mapping tree, was Re: clean up and modularize arch dma_mapping interface V2

2017-06-22 Thread Stephen Rothwell
Hi all, On Wed, 21 Jun 2017 15:32:39 +0200 Marek Szyprowski wrote: > > On 2017-06-20 15:16, Christoph Hellwig wrote: > > On Tue, Jun 20, 2017 at 11:04:00PM +1000, Stephen Rothwell wrote: > >> git://git.linaro.org/people/mszyprowski/linux-dma-mapping.git#dma-mapping-next > >> > >> Contacts: Mar

Re: [PATCH v1 3/3] iommu/amd: Optimize the IOMMU queue flush

2017-06-22 Thread Joerg Roedel
On Thu, Jun 22, 2017 at 11:13:09AM -0400, Jan Vesely wrote: > It looks like I tested different patches. > linux-4.10.17 with both > "iommu/amd: Optimize iova queue flushing" This patch isn't in my tree and will not go upstream. > and > "iommu/amd: Disable previously enabled IOMMUs at boot" This

Re: [RFC 1/9] iommu: Introduce bind_pasid_table API function

2017-06-22 Thread Alex Williamson
On Wed, 14 Jun 2017 15:22:55 -0700 Jacob Pan wrote: > Virtual IOMMU was proposed to support Shared Virtual Memory (SVM) use > case in the guest: > https://lists.gnu.org/archive/html/qemu-devel/2016-11/msg05311.html > > As part of the proposed architecture, when a SVM capable PCI > device is assi

Re: [RFC 2/9] iommu/vt-d: add bind_pasid_table function

2017-06-22 Thread Alex Williamson
On Wed, 14 Jun 2017 15:22:56 -0700 Jacob Pan wrote: > Add Intel VT-d ops to the generic iommu_bind_pasid_table API > functions. > > The primary use case is for direct assignment of SVM capable > device. Originated from emulated IOMMU in the guest, the request goes > through many layers (e.g. VFI

Re: [RFC 4/9] iommu/vt-d: Add iommu do invalidate function

2017-06-22 Thread Alex Williamson
On Wed, 14 Jun 2017 15:22:58 -0700 Jacob Pan wrote: > This patch adds Intel VT-d specific function to implement > iommu_do_invalidate API. > > The use case is for supporting caching structure invalidation > of assigned SVM capable devices. Emulated IOMMU exposes queue > invalidation capability a

Re: [RFC 3/9] iommu: Introduce iommu do invalidate API function

2017-06-22 Thread Alex Williamson
On Wed, 14 Jun 2017 15:22:57 -0700 Jacob Pan wrote: > From: "Liu, Yi L" > > When a SVM capable device is assigned to a guest, the first level page > tables are owned by the guest and the guest PASID table pointer is > linked to the device context entry of the physical IOMMU. > > Host IOMMU dri

Re: [RFC 5/9] iommu: Introduce fault notifier API

2017-06-22 Thread Alex Williamson
On Wed, 14 Jun 2017 15:22:59 -0700 Jacob Pan wrote: > Traditionally, device specific faults are detected and handled within > their own device drivers. When IOMMU is enabled, faults such as DMA > related transactions are detected by IOMMU. There is no generic > reporting mechanism to report fault

Re: [RFC 8/9] iommu/intel-svm: notify page request to guest

2017-06-22 Thread Alex Williamson
On Wed, 14 Jun 2017 15:23:02 -0700 Jacob Pan wrote: > If the source device of a page request has its PASID table pointer > bond to a guest, the first level page tables are owned by the guest. > In this case, we shall let guest OS to manage page fault. > > This patch uses the IOMMU fault notifica

Re: [RFC 6/9] iommu/vt-d: track device with pasid table bond to a guest

2017-06-22 Thread Alex Williamson
On Wed, 14 Jun 2017 15:23:00 -0700 Jacob Pan wrote: > When PASID table pointer of an assigned device is bond to a guest, s/bond/bound/ > the first level page tables are managed by the guest. However, only > host/physical IOMMU can detect fault events, e.g. page requests. > Therefore, we need to

Re: [RFC 7/9] iommu/dmar: notify unrecoverable faults

2017-06-22 Thread Alex Williamson
On Wed, 14 Jun 2017 15:23:01 -0700 Jacob Pan wrote: > Currently, when device DMA faults are detected by IOMMU the fault > reasons are printed but the offending device is not notified. > This patch allows device drivers to be optionally notified for fault > conditions when device specific handling

Re: [Devel] [PATCH v9 0/3] Cavium ThunderX2 SMMUv3 errata workarounds

2017-06-22 Thread Robert Richter
On 22.06.17 22:04:37, Lorenzo Pieralisi wrote: > On Thu, Jun 22, 2017 at 09:35:35PM +0200, Robert Richter wrote: > > On 22.06.17 19:58:22, Will Deacon wrote: > > > On Thu, Jun 22, 2017 at 07:22:57PM +0100, Will Deacon wrote: > > > > On Thu, Jun 22, 2017 at 05:35:35PM +0530, Geetha sowjanya wrote: >

[PATCH] iommu/arm-smmu-v3, acpi: Add temporary Cavium SMMU-V3 IORT model number definitions

2017-06-22 Thread Robert Richter
On 23.06.17 06:55:41, Robert Richter wrote: > On 22.06.17 22:04:37, Lorenzo Pieralisi wrote: > > On Thu, Jun 22, 2017 at 09:35:35PM +0200, Robert Richter wrote: > > > On 22.06.17 19:58:22, Will Deacon wrote: > > > > On Thu, Jun 22, 2017 at 07:22:57PM +0100, Will Deacon wrote: > > > > > On Thu, Jun

Re: [PATCH v2 5/8] iommu/io-pgtable-arm: Support lockless operation

2017-06-22 Thread Linu Cherian
Robin, Was trying to understand the new changes. Had few questions on arm_lpae_install_table. On Thu Jun 22, 2017 at 04:53:54PM +0100, Robin Murphy wrote: > For parallel I/O with multiple concurrent threads servicing the same > device (or devices, if several share a domain), serialising page ta

[PATCH v9 3/3] iommu/arm-smmu-v3: Add workaround for Cavium ThunderX2 erratum #126

2017-06-22 Thread Geetha sowjanya
From: Geetha Sowjanya Cavium ThunderX2 SMMU doesn't support MSI and also doesn't have unique irq lines for gerror, eventq and cmdq-sync. New named irq "combined" is set as a errata workaround, which allows to share the irq line by register single irq handler for all the interrupts. Signed-off-b

Re: [PATCH v9 3/3] iommu/arm-smmu-v3: Add workaround for Cavium ThunderX2 erratum #126

2017-06-22 Thread Geetha Akula
On Thu, Jun 22, 2017 at 11:52 PM, Will Deacon wrote: > Hi Geetha, > > On Thu, Jun 22, 2017 at 05:35:38PM +0530, Geetha sowjanya wrote: >> From: Geetha Sowjanya >> >> Cavium ThunderX2 SMMU doesn't support MSI and also doesn't have unique irq >> lines for gerror, eventq and cmdq-sync. >> >> New nam