[PATCH v10 06/13] iommu/smmuv3: Implement attach/detach_pasid_table

2020-03-20 Thread Eric Auger
On attach_pasid_table() we program STE S1 related info set by the guest into the actual physical STEs. At minimum we need to program the context descriptor GPA and compute whether the stage1 is translated/bypassed or aborted. Signed-off-by: Eric Auger --- v7 -> v8: - remove smmu->features

[PATCH v10 01/13] iommu: Introduce attach/detach_pasid_table API

2020-03-20 Thread Eric Auger
table information. A generic iommu_pasid_table_config struct is introduced in a new iommu.h uapi header. This is going to be used by the VFIO user API. Signed-off-by: Jean-Philippe Brucker Signed-off-by: Liu, Yi L Signed-off-by: Ashok Raj Signed-off-by: Jacob Pan Signed-off-by: Eric Auger

[PATCH v10 04/13] iommu/smmuv3: Dynamically allocate s1_cfg and s2_cfg

2020-03-20 Thread Eric Auger
ff-by: Eric Auger --- drivers/iommu/arm-smmu-v3.c | 94 - 1 file changed, 52 insertions(+), 42 deletions(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 3d726e97934f..8b3083c5f27b 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/dr

[PATCH v10 05/13] iommu/smmuv3: Get prepared for nested stage support

2020-03-20 Thread Eric Auger
nested mode, only stage 2 is "finalized" as the host does not own/configure the stage 1 context descriptor; guest does. Signed-off-by: Eric Auger --- v7 -> v8: - rebase on 8be39a1a04c1 iommu/arm-smmu-v3: Add a master->domain pointer - restore live checks for not nested cases and

[PATCH v10 02/13] iommu: Introduce bind/unbind_guest_msi

2020-03-20 Thread Eric Auger
similarly a single virtual doorbell mapping gets registered (1 single virtual doorbell is used on guest as well). Signed-off-by: Eric Auger --- v7 -> v8: - dummy iommu_unbind_guest_msi turned into a void function v6 -> v7: - remove the device handle parameter. - Add comments saying t

[PATCH v10 03/13] iommu/arm-smmu-v3: Maintain a SID->device structure

2020-03-20 Thread Eric Auger
From: Jean-Philippe Brucker When handling faults from the event or PRI queue, we need to find the struct device associated to a SID. Add a rb_tree to keep track of SIDs. Signed-off-by: Eric Auger Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 112

[PATCH v10 00/13] SMMUv3 Nested Stage Setup (IOMMU part)

2020-03-20 Thread Eric Auger
reporting API: use VFIO_PCI_DMA_FAULT_IRQ_INDEX to set the eventfd and expose the faults through an mmappable fault region v1 -> v2: - Added the fault reporting capability - asid properly passed on invalidation (fix assignment of multiple devices) - see individual change logs for more info Er

[PATCH v4] iommu: fix KASAN use-after-free in iommu_insert_resv_region

2019-11-26 Thread Eric Auger
In case the new region gets merged into another one, the nr list node is freed. Checking its type while completing the merge algorithm leads to a use-after-free. Use new->type instead. Fixes: 4dbd258ff63e ("iommu: Revisit iommu_insert_resv_region() implementation") Signed-off-b

[PATCH v3] iommu: fix KASAN use-after-free in iommu_insert_resv_region

2019-11-26 Thread Eric Auger
In case the new region gets merged into another one, the nr list node is freed. Checking its type while completing the merge algorithm leads to a use-after-free. Use new->type instead. Fixes: 4dbd258ff63e ("iommu: Revisit iommu_insert_resv_region() implementation") Signed-off-b

[PATCH v2] iommu: fix KASAN use-after-free in iommu_insert_resv_region

2019-11-25 Thread Eric Auger
Store the new region type in a variable. In case the new region gets merged into another one, the new node is freed and nr shall not be used anymore. Fixes: 4dbd258ff63e ("iommu: Revisit iommu_insert_resv_region() implementation") Signed-off-by: Eric Auger Reported-by: Qian Cai

[PATCH] iommu: fix KASAN use-after-free in iommu_insert_resv_region

2019-11-25 Thread Eric Auger
Store the new region type in a variable. In case the new region gets merged into another one, the new node is freed and nr shall not be used anymore. Fixes: 4dbd258ff63e ("iommu: Revisit iommu_insert_resv_region() implementation") Signed-off-by: Eric Auger Reported-by: Qian Cai

[PATCH] iommu/vt-d: Fix QI_DEV_IOTLB_PFSID and QI_DEV_EIOTLB_PFSID macros

2019-11-08 Thread Eric Auger
("iommu/vt-d: Add definitions for PFSID") Signed-off-by: Eric Auger --- include/linux/intel-iommu.h | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h index ed11ef594378..6d8bf4bdf240 100644 --- a/include/l

[PATCH v3] iommu: revisit iommu_insert_resv_region() implementation

2019-08-21 Thread Eric Auger
file"). Signed-off-by: Eric Auger --- v2 -> v3: - use LIST_HEAD(stack) - remove found local variables v1 -> v2: - adapt the algo so that we don't need to move elements of other types to different list and sort by address and then by type --- drive

[PATCH v2] iommu: revisit iommu_insert_resv_region() implementation

2019-08-01 Thread Eric Auger
file"). Signed-off-by: Eric Auger --- v1 -> v2: - adapt the algo so that we don't need to move elements of other types to different list and sort by address and then by type --- drivers/iommu/iommu.c | 107 +++--- 1 file changed, 59 insertion

[PATCH] iommu: revisit iommu_insert_resv_region() implementation

2019-07-30 Thread Eric Auger
ed by type and within a type they are sorted by start address. Signed-off-by: Eric Auger --- --- drivers/iommu/iommu.c | 96 ++- 1 file changed, 50 insertions(+), 46 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 0c

[PATCH v2] dma-mapping: Use dma_get_mask in dma_addressing_limited

2019-07-22 Thread Eric Auger
We currently have cases where the dma_addressing_limited() gets called with dma_mask unset. This causes a NULL pointer dereference. Use dma_get_mask() accessor to prevent the crash. Fixes: b866455423e0 ("dma-mapping: add a dma_addressing_limited helper") Signed-off-by: Eric Auger ---

[PATCH 1/2] dma-mapping: Protect dma_addressing_limited against NULL dma_mask

2019-07-22 Thread Eric Auger
dma_addressing_limited() should not be called on a device with a NULL dma_mask. If this occurs let's WARN_ON_ONCE and immediately return. Existing call sites are updated separately. Fixes: b866455423e0 ("dma-mapping: add a dma_addressing_limited helper") Signed-off-by: Eric Auger

[PATCH 2/2] virtio/virtio_ring: Fix the dma_max_mapping_size call

2019-07-22 Thread Eric Auger
Do not call dma_max_mapping_size for devices that have no DMA mask set, otherwise we can hit a NULL pointer dereference. This occurs when a virtio-blk-pci device is protected with a virtual IOMMU. Fixes: e6d6dd6c875e ("virtio: Introduce virtio_max_dma_size()") Signed-off-by:

[PATCH 0/2] Fix NULL pointer dereference with virtio-blk-pci and virtual IOMMU

2019-07-22 Thread Eric Auger
dma_addressing_limited() if the dma_mask is NULL. Eric Auger (2): dma-mapping: Protect dma_addressing_limited against NULL dma_mask virtio/virtio_ring: Fix the dma_max_mapping_size call drivers/virtio/virtio_ring.c | 2 +- include/linux/dma-mapping.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions

[PATCH] dma-mapping: Protect dma_addressing_limited against NULL dma_mask

2019-07-22 Thread Eric Auger
There are cases when the helper gets called when the dma_mask is NULL. This is observed when running virtio-block-pci devices protected by a virtual IOMMU. Guest crashes with NULL pointer dereference. Fixes: b866455423e0 ("dma-mapping: add a dma_addressing_limited helper") Signed-of

[PATCH v9 06/11] vfio/pci: Allow to mmap the fault queue

2019-07-11 Thread Eric Auger
The DMA FAULT region contains the fault ring buffer. There is benefit to let the userspace mmap this area. Expose this mmappable area through a sparse mmap entry and implement the mmap operation. Signed-off-by: Eric Auger --- v8 -> v9: - remove unused index local variable

[PATCH v9 02/11] vfio: VFIO_IOMMU_CACHE_INVALIDATE

2019-07-11 Thread Eric Auger
E ioctl with aims at propagating guest stage1 IOMMU cache invalidations to the host. Signed-off-by: Liu, Yi L Signed-off-by: Eric Auger --- v8 -> v9: - change the ioctl ID v6 -> v7: - Use iommu_capsule struct - renamed vfio_iommu_for_each_dev into vfio_iommu_lookup_dev due to c

[PATCH v9 11/11] vfio: Document nested stage control

2019-07-11 Thread Eric Auger
The VFIO API was enhanced to support nested stage control: a bunch of new iotcls, one DMA FAULT region and an associated specific IRQ. Let's document the process to follow to set up nested mode. Signed-off-by: Eric Auger --- v8 -> v9: - new names for SET_MSI_BINDING and SET_PASID_TAB

[PATCH v9 09/11] vfio/pci: Add framework for custom interrupt indices

2019-07-11 Thread Eric Auger
Implement IRQ capability chain infrastructure. All interrupt indexes beyond VFIO_PCI_NUM_IRQS are handled as extended interrupts. They are registered with a specific type/subtype and supported flags. Signed-off-by: Eric Auger --- drivers/vfio/pci/vfio_pci.c | 100

[PATCH v9 08/11] vfio: Add new IRQ for DMA fault reporting

2019-07-11 Thread Eric Auger
Add a new IRQ type/subtype to get notification on nested stage DMA faults. Signed-off-by: Eric Auger --- include/uapi/linux/vfio.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index b53714ae02c5..58607809e81a 100644 --- a/include

[PATCH v9 10/11] vfio/pci: Register and allow DMA FAULT IRQ signaling

2019-07-11 Thread Eric Auger
Register the VFIO_IRQ_TYPE_NESTED/VFIO_IRQ_SUBTYPE_DMA_FAULT IRQ that allows to signal a nested mode DMA fault. Signed-off-by: Eric Auger --- drivers/vfio/pci/vfio_pci.c | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b

[PATCH v9 07/11] vfio: Use capability chains to handle device specific irq

2019-07-11 Thread Eric Auger
From: Tina Zhang Caps the number of irqs with fixed indexes and uses capability chains to chain device specific irqs. Signed-off-by: Tina Zhang Signed-off-by: Eric Auger [Eric: Put cap_offset at the end of the vfio_irq_info struct, remove GFX IRQ at the moment and remove any reference to this

[PATCH v9 05/11] vfio/pci: Register an iommu fault handler

2019-07-11 Thread Eric Auger
Register an IOMMU fault handler which records faults in the DMA FAULT region ring buffer. In a subsequent patch, we will add the signaling of a specific eventfd to allow the userspace to be notified whenever a new fault as shown up. Signed-off-by: Eric Auger --- v8 -> v9: - handler now ta

[PATCH v9 04/11] vfio/pci: Add VFIO_REGION_TYPE_NESTED region type

2019-07-11 Thread Eric Auger
records. Signed-off-by: Eric Auger --- v8 -> v9: - Use a single region instead of a prod/cons region v4 -> v5 - check cons is not null in vfio_pci_check_cons_fault v3 -> v4: - use 2 separate regions, respectively in read and write modes - add the version capability --- drivers/vfio/pci/v

[PATCH v9 03/11] vfio: VFIO_IOMMU_SET_MSI_BINDING

2019-07-11 Thread Eric Auger
This patch adds the VFIO_IOMMU_SET_MSI_BINDING ioctl which aim to (un)register the guest MSI binding to the host. This latter then can use those stage 1 bindings to build a nested stage binding targeting the physical MSIs. Signed-off-by: Eric Auger --- v8 -> v9: - merge VFIO_IOMMU_BIND_

[PATCH v9 01/11] vfio: VFIO_IOMMU_SET_PASID_TABLE

2019-07-11 Thread Eric Auger
From: "Liu, Yi L" This patch adds an VFIO_IOMMU_SET_PASID_TABLE ioctl which aims to pass the virtual iommu guest configuration to the host. This latter takes the form of the so-called PASID table. Signed-off-by: Jacob Pan Signed-off-by: Liu, Yi L Signed-off-by: Eric Auger --

[PATCH v9 00/11] SMMUv3 Nested Stage Setup (VFIO part)

2019-07-11 Thread Eric Auger
- asid properly passed on invalidation (fix assignment of multiple devices) - see individual change logs for more info Eric Auger (8): vfio: VFIO_IOMMU_SET_MSI_BINDING vfio/pci: Add VFIO_REGION_TYPE_NESTED region type vfio/pci: Register an iommu fault handler vfio/pci: Allow to mmap the

[PATCH v9 14/14] iommu/smmuv3: Report non recoverable faults

2019-07-11 Thread Eric Auger
When a stage 1 related fault event is read from the event queue, let's propagate it to potential external fault listeners, ie. users who registered a fault handler. Signed-off-by: Eric Auger --- v8 -> v9: - adapt to the removal of IOMMU_FAULT_UNRECOV_PERM_VALID: only

[PATCH v9 13/14] iommu/smmuv3: Implement bind/unbind_guest_msi

2019-07-11 Thread Eric Auger
The bind/unbind_guest_msi() callbacks check the domain is NESTED and redirect to the dma-iommu implementation. Signed-off-by: Eric Auger --- v6 -> v7: - remove device handle argument --- drivers/iommu/arm-smmu-v3.c | 43 + 1 file changed, 43 inserti

[PATCH v9 11/14] iommu/smmuv3: Nested mode single MSI doorbell per domain enforcement

2019-07-11 Thread Eric Auger
correct physical doorbell. So let's forbid this situation. Signed-off-by: Eric Auger --- drivers/iommu/arm-smmu-v3.c | 41 + 1 file changed, 41 insertions(+) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 9b4654e2f25c..d0f6680

[PATCH v9 09/14] iommu/smmuv3: Implement cache_invalidate

2019-07-11 Thread Eric Auger
Implement domain-selective and page-selective IOTLB invalidations. Signed-off-by: Eric Auger --- v7 -> v8: - ASID based invalidation using iommu_inv_pasid_info - check ARCHID/PASID flags in addr based invalidation - use __arm_smmu_tlb_inv_context and __arm_smmu_tlb_inv_range_nosync v6 -&

[PATCH v9 12/14] iommu/smmuv3: Enforce incompatibility between nested mode and HW MSI regions

2019-07-11 Thread Eric Auger
Nested mode currently is not compatible with HW MSI reserved regions. Indeed MSI transactions targeting this MSI doorbells bypass the SMMU. Let's check nested mode is not attempted in such configuration. Signed-off-by: Eric Auger --- drivers/iommu/arm-smmu-v3.c | 23 +

[PATCH v9 10/14] dma-iommu: Implement NESTED_MSI cookie

2019-07-11 Thread Eric Auger
ectly mapped through both stages. Nested mode is not compatible with HW MSI regions as in that case gDB and hDB should have a 1-1 mapping. This check will be done when attaching each device to the IOMMU domain. Signed-off-by: Eric Auger --- v7 -> v8: - correct iommu_dma_(un)bind

[PATCH v9 07/14] iommu/smmuv3: Implement attach/detach_pasid_table

2019-07-11 Thread Eric Auger
On attach_pasid_table() we program STE S1 related info set by the guest into the actual physical STEs. At minimum we need to program the context descriptor GPA and compute whether the stage1 is translated/bypassed or aborted. Signed-off-by: Eric Auger --- v7 -> v8: - remove smmu->features

[PATCH v9 06/14] iommu/smmuv3: Get prepared for nested stage support

2019-07-11 Thread Eric Auger
nested mode, only stage 2 is "finalized" as the host does not own/configure the stage 1 context descriptor; guest does. Signed-off-by: Eric Auger --- v7 -> v8: - rebase on 8be39a1a04c1 iommu/arm-smmu-v3: Add a master->domain pointer - restore live checks for not nested cases and

[PATCH v9 08/14] iommu/smmuv3: Introduce __arm_smmu_tlb_inv_asid/s1_range_nosync

2019-07-11 Thread Eric Auger
Introduce helpers to invalidate a given asid/vmid or invalidate address ranges associated to a given asid/vmid. S1 helpers will be used to invalidate stage 1 caches upon userspace request, in nested mode. Signed-off-by: Eric Auger --- --- drivers/iommu/arm-smmu-v3.c | 98

[PATCH v9 03/14] iommu: Introduce bind/unbind_guest_msi

2019-07-11 Thread Eric Auger
similarly a single virtual doorbell mapping gets registered (1 single virtual doorbell is used on guest as well). Signed-off-by: Eric Auger --- v7 -> v8: - dummy iommu_unbind_guest_msi turned into a void function v6 -> v7: - remove the device handle parameter. - Add comments saying t

[PATCH v9 05/14] iommu/smmuv3: Dynamically allocate s1_cfg and s2_cfg

2019-07-11 Thread Eric Auger
In preparation for the introduction of nested configuration let's turn s1_cfg and s2_cfg fields into pointers which are dynamically allocated depending on the smmu_domain stage. In nested mode, s1_cfg will only be allocated when setting up S1 translation. Signed-off-by: Eric Auger --- dr

[PATCH v9 04/14] iommu/arm-smmu-v3: Maintain a SID->device structure

2019-07-11 Thread Eric Auger
From: Jean-Philippe Brucker When handling faults from the event or PRI queue, we need to find the struct device associated to a SID. Add a rb_tree to keep track of SIDs. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 134 ++-- 1 file chan

[PATCH v9 00/14] SMMUv3 Nested Stage Setup (IOMMU part)

2019-07-11 Thread Eric Auger
e eventfd and expose the faults through an mmappable fault region v1 -> v2: - Added the fault reporting capability - asid properly passed on invalidation (fix assignment of multiple devices) - see individual change logs for more info Eric Auger (11): iommu: Introduce bind/unbind_guest_msi

[PATCH v9 02/14] iommu: Introduce cache_invalidate API

2019-07-11 Thread Eric Auger
L Signed-off-by: Jacob Pan Signed-off-by: Ashok Raj Signed-off-by: Eric Auger Signed-off-by: Jean-Philippe Brucker --- v8 -> v9: - swap archid/pasid field description in kernel-doc comments Signed-off-by: Eric Auger --- drivers/iommu/iommu.c | 10 include/linux/iommu

[PATCH v9 01/14] iommu: Introduce attach/detach_pasid_table API

2019-07-11 Thread Eric Auger
table information. A generic iommu_pasid_table_config struct is introduced in a new iommu.h uapi header. This is going to be used by the VFIO user API. Signed-off-by: Jean-Philippe Brucker Signed-off-by: Liu, Yi L Signed-off-by: Ashok Raj Signed-off-by: Jacob Pan Signed-off-by: Eric Auger

[PATCH v6 6/7] iommu: Introduce IOMMU_RESV_DIRECT_RELAXABLE reserved memory regions

2019-06-02 Thread Eric Auger
PA space. With this new reserved region type we will be able to use iommu_get_group_resv_regions() to enumerate the IOVA space that is usable through the IOMMU API without introducing regressions with respect to existing device assignment use cases (USB and IGD). Signed-off-by: Eric Auger ---

[PATCH v6 5/7] iommu/vt-d: Handle PCI bridge RMRR device scopes in intel_iommu_get_resv_regions

2019-06-02 Thread Eric Auger
In the case the RMRR device scope is a PCI-PCI bridge, let's check the device belongs to the PCI sub-hierarchy. Fixes: 0659b8dc45a6 ("iommu/vt-d: Implement reserved region get/put callbacks") Signed-off-by: Eric Auger Reviewed-by: Lu Baolu --- v5 -> v6: - Added Lu's

[PATCH v6 4/7] iommu/vt-d: Handle RMRR with PCI bridge device scopes

2019-06-02 Thread Eric Auger
se in device_has_rmrr. Fixes: ea2447f700ca ("intel-iommu: Prevent devices with RMRRs from being placed into SI Domain") Signed-off-by: Eric Auger Reviewed-by: Lu Baolu --- v5 -> v6: - added Lu's R-b v1 -> v2: - is_downstream_to_pci_bridge helper introduced in a separate patch --- d

[PATCH v6 7/7] iommu/vt-d: Differentiate relaxable and non relaxable RMRRs

2019-06-02 Thread Eric Auger
level of reserved memory regions. This will be exploitable by VFIO to define the usable IOVA range and detect potential conflicts between the guest physical address space and host reserved regions. Signed-off-by: Eric Auger Reviewed-by: Lu Baolu --- v5 -> v6: - added Lu's R-b - minor

[PATCH v6 3/7] iommu/vt-d: Introduce is_downstream_to_pci_bridge helper

2019-06-02 Thread Eric Auger
Several call sites are about to check whether a device belongs to the PCI sub-hierarchy of a candidate PCI-PCI bridge. Introduce an helper to perform that check. Signed-off-by: Eric Auger Reviewed-by: Lu Baolu --- v5 -> v6: - fix kerneldoc comment as suggested by Christoph - added Lu&#x

[PATCH v6 0/7] RMRR related fixes and enhancements

2019-06-02 Thread Eric Auger
i_bridge() in a separate patch, change param names and add kerneldoc comment - add 6,7 Eric Auger (7): iommu: Fix a leak in iommu_insert_resv_region iommu/vt-d: Duplicate iommu_resv_region objects per device list iommu/vt-d: Introduce is_downstream_to_pci_bridge helper iommu/vt-d: Han

[PATCH v6 2/7] iommu/vt-d: Duplicate iommu_resv_region objects per device list

2019-06-02 Thread Eric Auger
c45a6 ("iommu/vt-d: Implement reserved region get/put callbacks") Signed-off-by: Eric Auger Reviewed-by: Lu Baolu --- v5 -> v6: - added space between | operands - dmar_global_lock down_read/up_read instead of write - added Lu's R-b v4 -> v5 - replace rcu-lock by the dmar_glob

[PATCH v6 1/7] iommu: Fix a leak in iommu_insert_resv_region

2019-06-02 Thread Eric Auger
In case we expand an existing region, we unlink this latter and insert the larger one. In that case we should free the original region after the insertion. Also we can immediately return. Fixes: 6c65fb318e8b ("iommu: iommu_get_group_resv_regions") Signed-off-by: Eric Auger --- dri

[PATCH v5 4/7] iommu/vt-d: Handle RMRR with PCI bridge device scopes

2019-05-28 Thread Eric Auger
se in device_has_rmrr. Fixes: ea2447f700ca ("intel-iommu: Prevent devices with RMRRs from being placed into SI Domain") Signed-off-by: Eric Auger --- v1 -> v2: - is_downstream_to_pci_bridge helper introduced in a separate patch --- drivers/iommu/intel-iommu.c | 3 ++- 1 file changed, 2 inserti

[PATCH v5 7/7] iommu/vt-d: Differentiate relaxable and non relaxable RMRRs

2019-05-28 Thread Eric Auger
level of reserved memory regions. This will be exploitable by VFIO to define the usable IOVA range and detect potential conflicts between the guest physical address space and host reserved regions. Signed-off-by: Eric Auger --- v3 -> v4: - introduce device_rmrr_is_relaxable and reshuffle the

[PATCH v5 3/7] iommu/vt-d: Introduce is_downstream_to_pci_bridge helper

2019-05-28 Thread Eric Auger
Several call sites are about to check whether a device belongs to the PCI sub-hierarchy of a candidate PCI-PCI bridge. Introduce an helper to perform that check. Signed-off-by: Eric Auger --- drivers/iommu/intel-iommu.c | 37 + 1 file changed, 29 insertions

[PATCH v5 6/7] iommu: Introduce IOMMU_RESV_DIRECT_RELAXABLE reserved memory regions

2019-05-28 Thread Eric Auger
PA space. With this new reserved region type we will be able to use iommu_get_group_resv_regions() to enumerate the IOVA space that is usable through the IOMMU API without introducing regressions with respect to existing device assignment use cases (USB and IGD). Signed-off-by: Eric Auger ---

[PATCH v5 5/7] iommu/vt-d: Handle PCI bridge RMRR device scopes in intel_iommu_get_resv_regions

2019-05-28 Thread Eric Auger
In the case the RMRR device scope is a PCI-PCI bridge, let's check the device belongs to the PCI sub-hierarchy. Fixes: 0659b8dc45a6 ("iommu/vt-d: Implement reserved region get/put callbacks") Signed-off-by: Eric Auger --- drivers/iommu/intel-iommu.c | 3 ++- 1 file changed, 2 i

[PATCH v5 2/7] iommu/vt-d: Duplicate iommu_resv_region objects per device list

2019-05-28 Thread Eric Auger
c45a6 ("iommu/vt-d: Implement reserved region get/put callbacks") Signed-off-by: Eric Auger --- v4 -> v5 - replace rcu-lock by the dmar_global_lock --- drivers/iommu/intel-iommu.c | 34 +- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/d

[PATCH v5 1/7] iommu: Fix a leak in iommu_insert_resv_region

2019-05-28 Thread Eric Auger
In case we expand an existing region, we unlink this latter and insert the larger one. In that case we should free the original region after the insertion. Also we can immediately return. Fixes: 6c65fb318e8b ("iommu: iommu_get_group_resv_regions") Signed-off-by: Eric Auger --- dri

[PATCH v5 0/7] RMRR related fixes and enhancements

2019-05-28 Thread Eric Auger
I found a leak in this function, hence the new first patch v2 -> v3: s/||/&& in iommu_group_create_direct_mappings v1 -> v2: - introduce is_downstream_to_pci_bridge() in a separate patch, change param names and add kerneldoc comment - add 6,7 Eric Auger (7): iommu: Fix a le

[PATCH v4 3/8] iommu/vt-d: Duplicate iommu_resv_region objects per device list

2019-05-27 Thread Eric Auger
) Signed-off-by: Eric Auger --- drivers/iommu/intel-iommu.c | 31 --- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 2be36dff189a..590a0e78d11d 100644 --- a/drivers/iommu/intel-iommu.c +++

[PATCH v4 8/8] iommu/vt-d: Differentiate relaxable and non relaxable RMRRs

2019-05-27 Thread Eric Auger
level of reserved memory regions. This will be exploitable by VFIO to define the usable IOVA range and detect potential conflicts between the guest physical address space and host reserved regions. Signed-off-by: Eric Auger --- v3 -> v4: - introduce device_rmrr_is_relaxable and reshuffle the

[PATCH v4 5/8] iommu/vt-d: Handle RMRR with PCI bridge device scopes

2019-05-27 Thread Eric Auger
se in device_has_rmrr. Fixes: ea2447f700ca ("intel-iommu: Prevent devices with RMRRs from being placed into SI Domain") Signed-off-by: Eric Auger --- v1 -> v2: - is_downstream_to_pci_bridge helper introduced in a separate patch --- drivers/iommu/intel-iommu.c | 3 ++- 1 file changed, 2 inserti

[PATCH v4 4/8] iommu/vt-d: Introduce is_downstream_to_pci_bridge helper

2019-05-27 Thread Eric Auger
Several call sites are about to check whether a device belongs to the PCI sub-hierarchy of a candidate PCI-PCI bridge. Introduce an helper to perform that check. Signed-off-by: Eric Auger --- drivers/iommu/intel-iommu.c | 37 + 1 file changed, 29 insertions

[PATCH v4 7/8] iommu: Introduce IOMMU_RESV_DIRECT_RELAXABLE reserved memory regions

2019-05-27 Thread Eric Auger
PA space. With this new reserved region type we will be able to use iommu_get_group_resv_regions() to enumerate the IOVA space that is usable through the IOMMU API without introducing regressions with respect to existing device assignment use cases (USB and IGD). Signed-off-by: Eric Auger ---

[PATCH v4 6/8] iommu/vt-d: Handle PCI bridge RMRR device scopes in intel_iommu_get_resv_regions

2019-05-27 Thread Eric Auger
In the case the RMRR device scope is a PCI-PCI bridge, let's check the device belongs to the PCI sub-hierarchy. Fixes: 0659b8dc45a6 ("iommu/vt-d: Implement reserved region get/put callbacks") Signed-off-by: Eric Auger --- drivers/iommu/intel-iommu.c | 3 ++- 1 file changed, 2 i

[PATCH v4 1/8] iommu: Fix a leak in iommu_insert_resv_region

2019-05-27 Thread Eric Auger
In case we expand an existing region, we unlink this latter and insert the larger one. In that case we should free the original region after the insertion. Also we can immediately return. Fixes: 6c65fb318e8b ("iommu: iommu_get_group_resv_regions") Signed-off-by: Eric Auger --- dri

[PATCH v4 0/8] RMRR related fixes and enhancements

2019-05-27 Thread Eric Auger
wnstream_to_pci_bridge() in a separate patch, change param names and add kerneldoc comment - add 6,7 Eric Auger (8): iommu: Fix a leak in iommu_insert_resv_region iommu: Pass a GFP flag parameter to iommu_alloc_resv_region() iommu/vt-d: Duplicate iommu_resv_region objects per device l

[PATCH v4 2/8] iommu: Pass a GFP flag parameter to iommu_alloc_resv_region()

2019-05-27 Thread Eric Auger
We plan to call iommu_alloc_resv_region in a non preemptible section. Pass a GFP flag to the function and update all the call sites. Signed-off-by: Eric Auger --- drivers/acpi/arm64/iort.c | 3 ++- drivers/iommu/amd_iommu.c | 7 --- drivers/iommu/arm-smmu-v3.c | 2 +- drivers/iommu/arm

[PATCH v8 29/29] vfio: Document nested stage control

2019-05-26 Thread Eric Auger
New iotcls were introduced to pass information about guest stage1 to the host through VFIO. Let's document the nested stage control. Signed-off-by: Eric Auger --- v2 -> v3: - document the new fault API v1 -> v2: - use the new ioctl names - add doc related to fault handling --- Do

[PATCH v8 23/29] vfio: VFIO_IOMMU_CACHE_INVALIDATE

2019-05-26 Thread Eric Auger
E ioctl with aims at propagating guest stage1 IOMMU cache invalidations to the host. Signed-off-by: Liu, Yi L Signed-off-by: Eric Auger --- v6 -> v7: - Use iommu_capsule struct - renamed vfio_iommu_for_each_dev into vfio_iommu_lookup_dev due to checkpatch error related to for_each_dev suffix

[PATCH v8 27/29] vfio_pci: Allow to mmap the fault queue

2019-05-26 Thread Eric Auger
The Producer Fault region contains the fault queue in the second page. There is benefit to let the userspace mmap this area. So let's expose this mmappable area through a sparse mmap entry and implement the mmap operation. Signed-off-by: Eric Auger --- drivers/vfio/pci/vfio_pci.c

[PATCH v8 28/29] vfio-pci: Add VFIO_PCI_DMA_FAULT_IRQ_INDEX

2019-05-26 Thread Eric Auger
Add a new VFIO_PCI_DMA_FAULT_IRQ_INDEX index. This allows to set/unset an eventfd that will be triggered when DMA translation faults are detected at physical level when the nested mode is used. Signed-off-by: Eric Auger --- drivers/vfio/pci/vfio_pci.c | 3 +++ drivers/vfio/pci

[PATCH v8 22/29] vfio: VFIO_IOMMU_ATTACH/DETACH_PASID_TABLE

2019-05-26 Thread Eric Auger
From: "Liu, Yi L" This patch adds VFIO_IOMMU_ATTACH/DETACH_PASID_TABLE ioctl which aims to pass/withdraw the virtual iommu guest configuration to/from the VFIO driver downto to the iommu subsystem. Signed-off-by: Jacob Pan Signed-off-by: Liu, Yi L Signed-off-by: Eric Auger --

[PATCH v8 24/29] vfio: VFIO_IOMMU_BIND/UNBIND_MSI

2019-05-26 Thread Eric Auger
This patch adds the VFIO_IOMMU_BIND/UNBIND_MSI ioctl which aim to pass/withdraw the guest MSI binding to/from the host. Signed-off-by: Eric Auger --- v6 -> v7: - removed the dev arg v3 -> v4: - add UNBIND - unwind on BIND error v2 -> v3: - adapt to new proto of bind_guest_msi - dir

[PATCH v8 26/29] vfio-pci: Register an iommu fault handler

2019-05-26 Thread Eric Auger
This patch registers a fault handler which records faults in a circular buffer and then signals an eventfd. This buffer is exposed within the fault region. Signed-off-by: Eric Auger --- v3 -> v4: - move iommu_unregister_device_fault_handler to vfio_pci_release --- drivers/vfio/pci/vfio_pc

[PATCH v8 25/29] vfio-pci: Add a new VFIO_REGION_TYPE_NESTED region type

2019-05-26 Thread Eric Auger
cannot return a comprehensive set of information inside the prod header (entry size and number of entries in the fault queue). Signed-off-by: Eric Auger --- v4 -> v5 - check cons is not null in vfio_pci_check_cons_fault v3 -> v4: - use 2 separate regions, respectively in read and write

[PATCH v8 18/29] iommu/smmuv3: Nested mode single MSI doorbell per domain enforcement

2019-05-26 Thread Eric Auger
correct physical doorbell. So let's forbid this situation. Signed-off-by: Eric Auger --- drivers/iommu/arm-smmu-v3.c | 41 + 1 file changed, 41 insertions(+) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index b4813f23f302..31d8028

[PATCH v8 19/29] iommu/smmuv3: Enforce incompatibility between nested mode and HW MSI regions

2019-05-26 Thread Eric Auger
Nested mode currently is not compatible with HW MSI reserved regions. Indeed MSI transactions targeting this MSI doorbells bypass the SMMU. Let's check nested mode is not attempted in such configuration. Signed-off-by: Eric Auger --- drivers/iommu/arm-smmu-v3.c | 23 +

[PATCH v8 20/29] iommu/smmuv3: Implement bind/unbind_guest_msi

2019-05-26 Thread Eric Auger
The bind/unbind_guest_msi() callbacks check the domain is NESTED and redirect to the dma-iommu implementation. Signed-off-by: Eric Auger --- v6 -> v7: - remove device handle argument --- drivers/iommu/arm-smmu-v3.c | 43 + 1 file changed, 43 inserti

[PATCH v8 21/29] iommu/smmuv3: Report non recoverable faults

2019-05-26 Thread Eric Auger
When a stage 1 related fault event is read from the event queue, let's propagate it to potential external fault listeners, ie. users who registered a fault handler. Signed-off-by: Eric Auger --- v8 -> v9: - adapt to the removal of IOMMU_FAULT_UNRECOV_PERM_VALID: only

[PATCH v8 17/29] dma-iommu: Implement NESTED_MSI cookie

2019-05-26 Thread Eric Auger
ectly mapped through both stages. Nested mode is not compatible with HW MSI regions as in that case gDB and hDB should have a 1-1 mapping. This check will be done when attaching each device to the IOMMU domain. Signed-off-by: Eric Auger --- v7 -> v8: - correct iommu_dma_(un)bind

[PATCH v8 13/29] iommu/smmuv3: Get prepared for nested stage support

2019-05-26 Thread Eric Auger
nested mode, only stage 2 is "finalized" as the host does not own/configure the stage 1 context descriptor; guest does. Signed-off-by: Eric Auger --- v7 -> v8: - rebase on 8be39a1a04c1 iommu/arm-smmu-v3: Add a master->domain pointer - restore live checks for not nested cases and

[PATCH v8 14/29] iommu/smmuv3: Implement attach/detach_pasid_table

2019-05-26 Thread Eric Auger
On attach_pasid_table() we program STE S1 related info set by the guest into the actual physical STEs. At minimum we need to program the context descriptor GPA and compute whether the stage1 is translated/bypassed or aborted. Signed-off-by: Eric Auger --- v7 -> v8: - remove smmu->features

[PATCH v8 12/29] iommu/smmuv3: Dynamically allocate s1_cfg and s2_cfg

2019-05-26 Thread Eric Auger
In preparation for the introduction of nested configuration let's turn s1_cfg and s2_cfg fields into pointers which are dynamically allocated depending on the smmu_domain stage. In nested mode, s1_cfg will only be allocated when setting up S1 translation. Signed-off-by: Eric Auger --- dr

[PATCH v8 15/29] iommu/smmuv3: Introduce __arm_smmu_tlb_inv_asid/s1_range_nosync

2019-05-26 Thread Eric Auger
Introduce helpers to invalidate a given asid/vmid or invalidate address ranges associated to a given asid/vmid. S1 helpers will be used to invalidate stage 1 caches upon userspace request, in nested mode. Signed-off-by: Eric Auger --- --- drivers/iommu/arm-smmu-v3.c | 98

[PATCH v8 16/29] iommu/smmuv3: Implement cache_invalidate

2019-05-26 Thread Eric Auger
Implement domain-selective and page-selective IOTLB invalidations. Signed-off-by: Eric Auger --- v7 -> v8: - ASID based invalidation using iommu_inv_pasid_info - check ARCHID/PASID flags in addr based invalidation - use __arm_smmu_tlb_inv_context and __arm_smmu_tlb_inv_range_nosync v6 -&

[PATCH v8 11/29] iommu/arm-smmu-v3: Maintain a SID->device structure

2019-05-26 Thread Eric Auger
From: Jean-Philippe Brucker When handling faults from the event or PRI queue, we need to find the struct device associated to a SID. Add a rb_tree to keep track of SIDs. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 134 ++-- 1 file chan

[PATCH v8 09/29] iommu: Introduce cache_invalidate API

2019-05-26 Thread Eric Auger
L Signed-off-by: Jacob Pan Signed-off-by: Ashok Raj Signed-off-by: Eric Auger Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/iommu.c | 10 include/linux/iommu.h | 14 + include/uapi/linux/iommu.h | 110 + 3 files changed, 134

[PATCH v8 08/29] iommu: Introduce attach/detach_pasid_table API

2019-05-26 Thread Eric Auger
table information. A generic iommu_pasid_table_config struct is introduced in a new iommu.h uapi header. This is going to be used by the VFIO user API. Signed-off-by: Jean-Philippe Brucker Signed-off-by: Liu, Yi L Signed-off-by: Ashok Raj Signed-off-by: Jacob Pan Signed-off-by: Eric Auger

[PATCH v8 10/29] iommu: Introduce bind/unbind_guest_msi

2019-05-26 Thread Eric Auger
similarly a single virtual doorbell mapping gets registered (1 single virtual doorbell is used on guest as well). Signed-off-by: Eric Auger --- v7 -> v8: - dummy iommu_unbind_guest_msi turned into a void function v6 -> v7: - remove the device handle parameter. - Add comments saying t

[PATCH v8 04/29] iommu: Add recoverable fault reporting

2019-05-26 Thread Eric Auger
From: Jean-Philippe Brucker Some IOMMU hardware features, for example PCI's PRI and Arm SMMU's Stall, enable recoverable I/O page faults. Allow IOMMU drivers to report PRI Page Requests and Stall events through the new fault reporting API. The consumer of the fault can be either an I/O page fault

[PATCH v8 07/29] iommu: Use device fault trace event

2019-05-26 Thread Eric Auger
From: Jacob Pan For performance and debugging purposes, these trace events help analyzing device faults that interact with IOMMU subsystem. E.g. IOMMU::00:0a.0 type=2 reason=0 addr=0x007ff000 pasid=1 group=1 last=0 prot=1 Signed-off-by: Jacob Pan [JPB: removed invalidate event, that

[PATCH v8 02/29] iommu: Introduce device fault data

2019-05-26 Thread Eric Auger
care about non internal faults that are likely to be reported to an external subsystem. Signed-off-by: Jacob Pan Signed-off-by: Jean-Philippe Brucker Signed-off-by: Liu, Yi L Signed-off-by: Ashok Raj Signed-off-by: Eric Auger --- include/linux/iommu.h | 44 ++ include/uapi

[PATCH v8 00/29] SMMUv3 Nested Stage Setup

2019-05-26 Thread Eric Auger
DEX to set the eventfd and expose the faults through an mmappable fault region v1 -> v2: - Added the fault reporting capability - asid properly passed on invalidation (fix assignment of multiple devices) - see individual change logs for more info Eric Auger (17): iommu: Introduce bind/u

[PATCH v8 06/29] trace/iommu: Add sva trace events

2019-05-26 Thread Eric Auger
From: Jean-Philippe Brucker For development only, trace I/O page faults and responses. Signed-off-by: Jacob Pan [JPB: removed the invalidate trace event, that will be added later] Signed-off-by: Jean-Philippe Brucker --- include/trace/events/iommu.h | 87

[PATCH v8 03/29] iommu: Introduce device fault report API

2019-05-26 Thread Eric Auger
led faults will come later. Signed-off-by: Jacob Pan Signed-off-by: Ashok Raj Signed-off-by: Jean-Philippe Brucker Signed-off-by: Eric Auger --- drivers/iommu/iommu.c | 127 +- include/linux/iommu.h | 33 ++- 2 files changed, 157 insertions(+), 3

<    1   2   3   4   5   6   7   8   9   10   >