[PATCH 14/15] swiotlb: remove swiotlb_init_with_tbl and swiotlb_init_late_with_tbl

2022-03-14 Thread Christoph Hellwig
No users left. Signed-off-by: Christoph Hellwig --- include/linux/swiotlb.h | 2 - kernel/dma/swiotlb.c| 85 +++-- 2 files changed, 30 insertions(+), 57 deletions(-) diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h index

[PATCH 07/15] x86: remove the IOMMU table infrastructure

2022-03-14 Thread Christoph Hellwig
The IOMMU table tries to separate the different IOMMUs into different backends, but actually requires various cross calls. Rewrite the code to do the generic swiotlb/swiotlb-xen setup directly in pci-dma.c and then just call into the IOMMU drivers. Signed-off-by: Christoph Hellwig ---

[PATCH 09/15] swiotlb: make the swiotlb_init interface more useful

2022-03-14 Thread Christoph Hellwig
Pass a bool to pass if swiotlb needs to be enabled based on the addressing needs and replace the verbose argument with a set of flags, including one to force enable bounce buffering. Note that this patch removes the possibility to force xen-swiotlb use using swiotlb=force on the command line on

[PATCH 15/15] x86: remove cruft from

2022-03-14 Thread Christoph Hellwig
gets pulled in by all drivers using the DMA API. Remove x86 internal variables and unnecessary includes from it. Signed-off-by: Christoph Hellwig --- arch/x86/include/asm/dma-mapping.h | 11 --- arch/x86/include/asm/iommu.h | 2 ++ 2 files changed, 2 insertions(+), 11

[PATCH 12/15] swiotlb: provide swiotlb_init variants that remap the buffer

2022-03-14 Thread Christoph Hellwig
To shared more code between swiotlb and xen-swiotlb, offer a swiotlb_init_remap interface and add a remap callback to swiotlb_init_late that will allow Xen to remap the buffer the buffer without duplicating much of the logic. Signed-off-by: Christoph Hellwig --- arch/x86/pci/sta2x11-fixup.c |

[PATCH 13/15] swiotlb: merge swiotlb-xen initialization into swiotlb

2022-03-14 Thread Christoph Hellwig
Reuse the generic swiotlb initialization for xen-swiotlb. For ARM/ARM64 this works trivially, while for x86 xen_swiotlb_fixup needs to be passed as the remap argument to swiotlb_init_remap/swiotlb_init_late. Signed-off-by: Christoph Hellwig --- arch/arm/xen/mm.c | 21 +++---

[PATCH 05/15] arm/xen: don't check for xen_initial_domain() in xen_create_contiguous_region

2022-03-14 Thread Christoph Hellwig
From: Stefano Stabellini It used to be that Linux enabled swiotlb-xen when running a dom0 on ARM. Since f5079a9a2a31 "xen/arm: introduce XENFEAT_direct_mapped and XENFEAT_not_direct_mapped", Linux detects whether to enable or disable swiotlb-xen based on the new feature flags:

[PATCH 06/15] MIPS/octeon: use swiotlb_init instead of open coding it

2022-03-14 Thread Christoph Hellwig
Use the generic swiotlb initialization helper instead of open coding it. Signed-off-by: Christoph Hellwig Acked-by: Thomas Bogendoerfer --- arch/mips/cavium-octeon/dma-octeon.c | 15 ++- arch/mips/pci/pci-octeon.c | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-)

[PATCH 08/15] x86: centralize setting SWIOTLB_FORCE when guest memory encryption is enabled

2022-03-14 Thread Christoph Hellwig
Move enabling SWIOTLB_FORCE for guest memory encryption into common code. Signed-off-by: Christoph Hellwig --- arch/x86/kernel/cpu/mshyperv.c | 8 arch/x86/kernel/pci-dma.c | 8 arch/x86/mm/mem_encrypt_amd.c | 3 --- 3 files changed, 8 insertions(+), 11 deletions(-)

[PATCH 10/15] swiotlb: add a SWIOTLB_ANY flag to lift the low memory restriction

2022-03-14 Thread Christoph Hellwig
Power SVM wants to allocate a swiotlb buffer that is not restricted to low memory for the trusted hypervisor scheme. Consolidate the support for this into the swiotlb_init interface by adding a new flag. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/svm.h | 4

[PATCH 11/15] swiotlb: pass a gfp_mask argument to swiotlb_init_late

2022-03-14 Thread Christoph Hellwig
Let the caller chose a zone to allocate from. This will be used later on by the xen-swiotlb initialization on arm. Signed-off-by: Christoph Hellwig Reviewed-by: Anshuman Khandual --- arch/x86/pci/sta2x11-fixup.c | 2 +- include/linux/swiotlb.h | 2 +- kernel/dma/swiotlb.c | 7

[PATCH 03/15] swiotlb: simplify swiotlb_max_segment

2022-03-14 Thread Christoph Hellwig
Remove the bogus Xen override that was usually larger than the actual size and just calculate the value on demand. Note that swiotlb_max_segment still doesn't make sense as an interface and should eventually be removed. Signed-off-by: Christoph Hellwig Reviewed-by: Anshuman Khandual ---

[PATCH 02/15] swiotlb: make swiotlb_exit a no-op if SWIOTLB_FORCE is set

2022-03-14 Thread Christoph Hellwig
If force bouncing is enabled we can't release the buffers. Signed-off-by: Christoph Hellwig Reviewed-by: Anshuman Khandual --- kernel/dma/swiotlb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 908eac2527cb1..af9d257501a64 100644 ---

[PATCH 04/15] swiotlb: rename swiotlb_late_init_with_default_size

2022-03-14 Thread Christoph Hellwig
swiotlb_late_init_with_default_size is an overly verbose name that doesn't even catch what the function is doing, given that the size is not just a default but the actual requested size. Rename it to swiotlb_init_late. Signed-off-by: Christoph Hellwig Reviewed-by: Anshuman Khandual ---

[PATCH] iommu/amd: Remove redundant check

2022-03-14 Thread Vasant Hegde via iommu
smatch static checker warning: drivers/iommu/amd/init.c:1989 amd_iommu_init_pci() warn: duplicate check 'ret' (previous on line 1978) Reported-by: Dan Carpenter Fixes: 06687a03805e ("iommu/amd: Improve error handling for amd_iommu_init_pci") Signed-off-by: Vasant Hegde ---

[PATCH 01/15] dma-direct: use is_swiotlb_active in dma_direct_map_page

2022-03-14 Thread Christoph Hellwig
Use the more specific is_swiotlb_active check instead of checking the global swiotlb_force variable. Signed-off-by: Christoph Hellwig Reviewed-by: Anshuman Khandual --- kernel/dma/direct.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/dma/direct.h

cleanup swiotlb initialization v5

2022-03-14 Thread Christoph Hellwig
Hi all, this series tries to clean up the swiotlb initialization, including that of swiotlb-xen. To get there is also removes the x86 iommu table infrastructure that massively obsfucates the initialization path. Git tree: git://git.infradead.org/users/hch/misc.git swiotlb-init-cleanup

Re: [PATCH v8 00/11] ACPI/IORT: Support for IORT RMR node

2022-03-14 Thread Ard Biesheuvel
On Mon, 14 Mar 2022 at 11:37, Eric Auger wrote: > > Hi Robin > > On 3/11/22 11:34 AM, Robin Murphy wrote: > > On 2022-03-11 08:19, Eric Auger wrote: > >> Hi guys, > >> > >> On 2/21/22 4:43 PM, Shameer Kolothum wrote: > >>> Hi, > >>> > >>> Since we now have an updated verion[0] of IORT spec(E.d)

Re: [PATCH v8 00/11] ACPI/IORT: Support for IORT RMR node

2022-03-14 Thread Lorenzo Pieralisi
On Mon, Mar 14, 2022 at 11:43:51AM +0100, Ard Biesheuvel wrote: > On Mon, 14 Mar 2022 at 11:37, Eric Auger wrote: > > > > Hi Robin > > > > On 3/11/22 11:34 AM, Robin Murphy wrote: > > > On 2022-03-11 08:19, Eric Auger wrote: > > >> Hi guys, > > >> > > >> On 2/21/22 4:43 PM, Shameer Kolothum

Re: [PATCH v8 00/11] ACPI/IORT: Support for IORT RMR node

2022-03-14 Thread Eric Auger
Hi Robin On 3/11/22 11:34 AM, Robin Murphy wrote: > On 2022-03-11 08:19, Eric Auger wrote: >> Hi guys, >> >> On 2/21/22 4:43 PM, Shameer Kolothum wrote: >>> Hi, >>> >>> Since we now have an updated verion[0] of IORT spec(E.d) which >>> addresses the memory attributes issues discussed here [1],

[PATCH v4 10/32] s390/pci: stash dtsm and maxstbl

2022-03-14 Thread Matthew Rosato
Store information about what IOAT designation types are supported by underlying hardware as well as the largest store block size allowed. These values will be needed by passthrough. Reviewed-by: Niklas Schnelle Reviewed-by: Pierre Morel Reviewed-by: Christian Borntraeger Signed-off-by: Matthew

[PATCH v4 09/32] s390/pci: export some routines related to RPCIT processing

2022-03-14 Thread Matthew Rosato
KVM will re-use dma_walk_cpu_trans to walk the host shadow table and will also need to be able to call zpci_refresh_trans to re-issue a RPCIT. Reviewed-by: Niklas Schnelle Reviewed-by: Pierre Morel Acked-by: Christian Borntraeger Signed-off-by: Matthew Rosato --- arch/s390/pci/pci_dma.c | 1

[PATCH v4 11/32] s390/pci: add helper function to find device by handle

2022-03-14 Thread Matthew Rosato
Intercepted zPCI instructions will specify the desired function via a function handle. Add a routine to find the device with the specified handle. Acked-by: Niklas Schnelle Reviewed-by: Christian Borntraeger Reviewed-by: Eric Farman Reviewed-by: Pierre Morel Signed-off-by: Matthew Rosato

[PATCH v4 08/32] s390/pci: stash associated GISA designation

2022-03-14 Thread Matthew Rosato
For passthrough devices, we will need to know the GISA designation of the guest if interpretation facilities are to be used. Setup to stash this in the zdev and set a default of 0 (no GISA designation) for now; a subsequent patch will set a valid GISA designation for passthrough devices. Also,

[PATCH v4 12/32] s390/pci: get SHM information from list pci

2022-03-14 Thread Matthew Rosato
KVM will need information on the special handle mask used to indicate emulated devices. In order to obtain this, a new type of list pci call must be made to gather the information. Extend clp_list_pci_req to also fetch the model-dependent-data field that holds this mask. Reviewed-by: Niklas

[PATCH v4 18/32] iommu/s390: add support for IOMMU_DOMAIN_KVM

2022-03-14 Thread Matthew Rosato
Add an alternate domain ops for type IOMMU_DOMAIN_KVM. This type is intended for use when KVM is managing the IOMMU domain on behalf of a VM. Mapping can only be performed once a KVM is registered with the domain as well as a guest IOTA (address translation anchor). The map operation is

[PATCH v4 17/32] KVM: s390: pci: add basic kvm_zdev structure

2022-03-14 Thread Matthew Rosato
This structure will be used to carry kvm passthrough information related to zPCI devices. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/kvm_pci.h | 27 +++ arch/s390/include/asm/pci.h | 3 +++ arch/s390/kvm/Makefile | 1 + arch/s390/kvm/pci.c

[PATCH v4 19/32] KVM: s390: pci: do initial setup for AEN interpretation

2022-03-14 Thread Matthew Rosato
Initial setup for Adapter Event Notification Interpretation for zPCI passthrough devices. Specifically, allocate a structure for forwarding of adapter events and pass the address of this structure to firmware. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/pci.h | 4 +

[PATCH v4 14/32] iommu: introduce iommu_domain_alloc_type and the KVM type

2022-03-14 Thread Matthew Rosato
s390x will introduce an additional domain type that is used for managing IOMMU owned by KVM. Define the type here and add an interface for allocating a specified type vs the default type. Signed-off-by: Matthew Rosato --- drivers/iommu/iommu.c | 7 +++ include/linux/iommu.h | 12

[PATCH v4 13/32] s390/pci: return status from zpci_refresh_trans

2022-03-14 Thread Matthew Rosato
Current callers of zpci_refresh_trans don't need to interrogate the status returned from the underlying instructions. However, a subsequent patch will add a KVM caller that needs this information. Add a new argument to zpci_refresh_trans to pass the address of a status byte and update existing

[PATCH v4 15/32] vfio: introduce KVM-owned IOMMU type

2022-03-14 Thread Matthew Rosato
s390x will introduce a new IOMMU domain type where the mappings are managed by KVM rather than in response to userspace mapping ioctls. Allow for specifying this type on the VFIO_SET_IOMMU ioctl and triggering the appropriate iommu interface for overriding the default domain. Signed-off-by:

[PATCH v4 16/32] vfio-pci/zdev: add function handle to clp base capability

2022-03-14 Thread Matthew Rosato
The function handle is a system-wide unique identifier for a zPCI device. It is used as input for various zPCI operations. Signed-off-by: Matthew Rosato --- drivers/vfio/pci/vfio_pci_zdev.c | 5 +++-- include/uapi/linux/vfio_zdev.h | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-)

[PATCH v4 20/32] KVM: s390: pci: enable host forwarding of Adapter Event Notifications

2022-03-14 Thread Matthew Rosato
In cases where interrupts are not forwarded to the guest via firmware, KVM is responsible for ensuring delivery. When an interrupt presents with the forwarding bit, we must process the forwarding tables until all interrupts are delivered. Signed-off-by: Matthew Rosato ---

Re: [PATCH v4 00/32] KVM: s390: enable zPCI for interpretive execution

2022-03-14 Thread Matthew Rosato
On 3/14/22 3:44 PM, Matthew Rosato wrote: Note: A few patches in this series are dependent on Baolu's IOMMU domain ops split, which is currently in the next branch of linux-iommu. This series applies on top: https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git Enable interpretive

Re: [PATCH v4 29/32] vfio-pci/zdev: add DTSM to clp group capability

2022-03-14 Thread Jason Gunthorpe via iommu
On Mon, Mar 14, 2022 at 03:44:48PM -0400, Matthew Rosato wrote: > The DTSM, or designation type supported mask, indicates what IOAT formats > are available to the guest. For an interpreted device, userspace will not > know what format(s) the IOAT assist supports, so pass it via the > capability

[PATCH v4 00/32] KVM: s390: enable zPCI for interpretive execution

2022-03-14 Thread Matthew Rosato
Note: A few patches in this series are dependent on Baolu's IOMMU domain ops split, which is currently in the next branch of linux-iommu. This series applies on top:

[PATCH v4 28/32] KVM: s390: add KVM_S390_ZPCI_OP to manage guest zPCI devices

2022-03-14 Thread Matthew Rosato
The KVM_S390_ZPCI_OP ioctl provides a series of operations that can be invoked to manage hardware-assisted virtualization features for s390x PCI passthrough. Signed-off-by: Matthew Rosato --- Documentation/virt/kvm/api.rst | 60 ++ arch/s390/kvm/kvm-s390.c | 26

[PATCH v4 22/32] KVM: s390: pci: routines for (dis)associating zPCI devices with a KVM

2022-03-14 Thread Matthew Rosato
These routines will be wired into a KVM ioctl, to be issued from userspace to (dis)associate a specific zPCI device with the issuing KVM. This will create/delete a relationship between KVM, zPCI device and the associated IOMMU domain for the device. Signed-off-by: Matthew Rosato ---

[PATCH v4 24/32] KVM: s390: pci: provide routines for enabling/disabling interrupt forwarding

2022-03-14 Thread Matthew Rosato
These routines will be wired into a kvm ioctl in order to respond to requests to enable / disable a device for Adapter Event Notifications / Adapter Interuption Forwarding. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/kvm_pci.h | 2 + arch/s390/kvm/pci.c | 201

[PATCH v4 25/32] KVM: s390: pci: provide routines for enabling/disabling IOAT assist

2022-03-14 Thread Matthew Rosato
These routines will be wired into a kvm ioctl in orer to respond to requests to enable / disable a device for PCI I/O Address Translation assistance via a KVM-managed IOMMU. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/kvm_pci.h | 2 ++ arch/s390/kvm/pci.c | 25

[PATCH v4 26/32] KVM: s390: pci: handle refresh of PCI translations

2022-03-14 Thread Matthew Rosato
Add a routine that will perform a shadow operation between a guest and host IOAT. A subsequent patch will invoke this in response to an 04 RPCIT instruction intercept. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/kvm_pci.h | 1 + arch/s390/kvm/pci.c | 31

[PATCH v4 21/32] KVM: s390: mechanism to enable guest zPCI Interpretation

2022-03-14 Thread Matthew Rosato
The guest must have access to certain facilities in order to allow interpretive execution of zPCI instructions and adapter event notifications. However, there are some cases where a guest might disable interpretation -- provide a mechanism via which we can defer enabling the associated zPCI

[PATCH v4 23/32] KVM: s390: pci: provide routines for enabling/disabling interpretation

2022-03-14 Thread Matthew Rosato
These routines will be wired into a kvm ioctl in order to respond to requests to enable / disable a device for zPCI Load/Store intepretation. The first time such a request is received, enable the necessary facilities for the guest. Signed-off-by: Matthew Rosato --- arch/s390/kvm/pci.c | 86

[PATCH v4 27/32] KVM: s390: intercept the rpcit instruction

2022-03-14 Thread Matthew Rosato
For faster handling of PCI translation refreshes, intercept in KVM and call the associated handler. Signed-off-by: Matthew Rosato --- arch/s390/kvm/priv.c | 46 1 file changed, 46 insertions(+) diff --git a/arch/s390/kvm/priv.c

Re: [PATCH v4 14/32] iommu: introduce iommu_domain_alloc_type and the KVM type

2022-03-14 Thread Jason Gunthorpe via iommu
On Mon, Mar 14, 2022 at 03:44:33PM -0400, Matthew Rosato wrote: > s390x will introduce an additional domain type that is used for > managing IOMMU owned by KVM. Define the type here and add an > interface for allocating a specified type vs the default type. > > Signed-off-by: Matthew Rosato >

[PATCH v4 29/32] vfio-pci/zdev: add DTSM to clp group capability

2022-03-14 Thread Matthew Rosato
The DTSM, or designation type supported mask, indicates what IOAT formats are available to the guest. For an interpreted device, userspace will not know what format(s) the IOAT assist supports, so pass it via the capability chain. Since the value belongs to the Query PCI Function Group clp,

[PATCH v4 31/32] MAINTAINERS: additional files related kvm s390 pci passthrough

2022-03-14 Thread Matthew Rosato
Add entries from the s390 kvm subdirectory related to pci passthrough. Acked-by: Christian Borntraeger Signed-off-by: Matthew Rosato --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index e127c2fb08a7..6c76eb66b10a 100644 --- a/MAINTAINERS +++

[PATCH v4 30/32] KVM: s390: introduce CPU feature for zPCI Interpretation

2022-03-14 Thread Matthew Rosato
KVM_S390_VM_CPU_FEAT_ZPCI_INTERP relays whether zPCI interpretive execution is possible based on the available hardware facilities. Signed-off-by: Matthew Rosato --- arch/s390/include/uapi/asm/kvm.h | 1 + arch/s390/kvm/kvm-s390.c | 6 ++ 2 files changed, 7 insertions(+) diff --git

[PATCH v4 32/32] MAINTAINERS: update s390 IOMMU entry

2022-03-14 Thread Matthew Rosato
Use wildcard to pick up new parts added by KVM domain support. Signed-off-by: Matthew Rosato --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 6c76eb66b10a..d803f490eafb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16867,7

Re: [PATCH v4 22/32] KVM: s390: pci: routines for (dis)associating zPCI devices with a KVM

2022-03-14 Thread Jason Gunthorpe via iommu
On Mon, Mar 14, 2022 at 03:44:41PM -0400, Matthew Rosato wrote: > +int kvm_s390_pci_zpci_start(struct kvm *kvm, struct zpci_dev *zdev) > +{ > + struct vfio_device *vdev; > + struct pci_dev *pdev; > + int rc; > + > + rc = kvm_s390_pci_dev_open(zdev); > + if (rc) > +

[PATCH v4 01/32] s390/sclp: detect the zPCI load/store interpretation facility

2022-03-14 Thread Matthew Rosato
Detect the zPCI Load/Store Interpretation facility. Reviewed-by: Eric Farman Reviewed-by: Christian Borntraeger Reviewed-by: Claudio Imbrenda Signed-off-by: Matthew Rosato --- arch/s390/include/asm/sclp.h | 1 + drivers/s390/char/sclp_early.c | 1 + 2 files changed, 2 insertions(+) diff

[PATCH v4 05/32] s390/airq: pass more TPI info to airq handlers

2022-03-14 Thread Matthew Rosato
A subsequent patch will introduce an airq handler that requires additional TPI information beyond directed vs floating, so pass the entire tpi_info structure via the handler. Only pci actually uses this information today, for the other airq handlers this is effectively a no-op. Reviewed-by: Eric

[PATCH v4 04/32] s390/sclp: detect the AISI facility

2022-03-14 Thread Matthew Rosato
Detect the Adapter Interruption Suppression Interpretation facility. Reviewed-by: Eric Farman Reviewed-by: Christian Borntraeger Reviewed-by: Claudio Imbrenda Signed-off-by: Matthew Rosato --- arch/s390/include/asm/sclp.h | 1 + drivers/s390/char/sclp_early.c | 1 + 2 files changed, 2

[PATCH v4 06/32] s390/airq: allow for airq structure that uses an input vector

2022-03-14 Thread Matthew Rosato
When doing device passthrough where interrupts are being forwarded from host to guest, we wish to use a pinned section of guest memory as the vector (the same memory used by the guest as the vector). To accomplish this, add a new parameter for airq_iv_create which allows passing an existing vector

[PATCH v4 03/32] s390/sclp: detect the AENI facility

2022-03-14 Thread Matthew Rosato
Detect the Adapter Event Notification Interpretation facility. Reviewed-by: Eric Farman Reviewed-by: Christian Borntraeger Reviewed-by: Claudio Imbrenda Signed-off-by: Matthew Rosato --- arch/s390/include/asm/sclp.h | 1 + drivers/s390/char/sclp_early.c | 1 + 2 files changed, 2

[PATCH v4 07/32] s390/pci: externalize the SIC operation controls and routine

2022-03-14 Thread Matthew Rosato
A subsequent patch will be issuing SIC from KVM -- export the necessary routine and make the operation control definitions available from a header. Because the routine will now be exported, let's rename __zpci_set_irq_ctrl to zpci_set_irq_ctrl and get rid of the zero'd iib wrapper function of the

[PATCH v4 02/32] s390/sclp: detect the AISII facility

2022-03-14 Thread Matthew Rosato
Detect the Adapter Interruption Source ID Interpretation facility. Reviewed-by: Eric Farman Reviewed-by: Christian Borntraeger Reviewed-by: Claudio Imbrenda Signed-off-by: Matthew Rosato --- arch/s390/include/asm/sclp.h | 1 + drivers/s390/char/sclp_early.c | 1 + 2 files changed, 2

Re: [PATCH v4 15/32] vfio: introduce KVM-owned IOMMU type

2022-03-14 Thread Jason Gunthorpe via iommu
On Mon, Mar 14, 2022 at 03:44:34PM -0400, Matthew Rosato wrote: > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index 9394aa9444c1..0bec97077d61 100644 > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -77,6 +77,7 @@ struct vfio_iommu { > bool

Re: [PATCH 13/15] swiotlb: merge swiotlb-xen initialization into swiotlb

2022-03-14 Thread Stefano Stabellini
On Mon, 14 Mar 2022, Christoph Hellwig wrote: > Reuse the generic swiotlb initialization for xen-swiotlb. For ARM/ARM64 > this works trivially, while for x86 xen_swiotlb_fixup needs to be passed > as the remap argument to swiotlb_init_remap/swiotlb_init_late. > > Signed-off-by: Christoph Hellwig

Re: [PATCH v8 00/11] Fix BUG_ON in vfio_iommu_group_notifier()

2022-03-14 Thread Jason Gunthorpe via iommu
On Tue, Mar 08, 2022 at 01:44:10PM +0800, Lu Baolu wrote: > Hi folks, > > The iommu group is the minimal isolation boundary for DMA. Devices in > a group can access each other's MMIO registers via peer to peer DMA > and also need share the same I/O address space. Joerg, are we good for the

Re: [PATCH v4 15/32] vfio: introduce KVM-owned IOMMU type

2022-03-14 Thread Alex Williamson
On Mon, 14 Mar 2022 15:44:34 -0400 Matthew Rosato wrote: > s390x will introduce a new IOMMU domain type where the mappings are > managed by KVM rather than in response to userspace mapping ioctls. Allow > for specifying this type on the VFIO_SET_IOMMU ioctl and triggering the > appropriate

Re: [PATCH v4 15/32] vfio: introduce KVM-owned IOMMU type

2022-03-14 Thread Jason Gunthorpe via iommu
On Mon, Mar 14, 2022 at 04:50:33PM -0600, Alex Williamson wrote: > > +/* > > + * The KVM_IOMMU type implies that the hypervisor will control the mappings > > + * rather than userspace > > + */ > > +#define VFIO_KVM_IOMMU 11 > > Then why is this hosted in the type1 code that

Re: [PATCH 12/15] swiotlb: provide swiotlb_init variants that remap the buffer

2022-03-14 Thread Boris Ostrovsky
On 3/14/22 3:31 AM, Christoph Hellwig wrote: -void __init swiotlb_init(bool addressing_limit, unsigned int flags) +void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags, + int (*remap)(void *tlb, unsigned long nslabs)) { - size_t bytes =

Re: [PATCH 13/15] swiotlb: merge swiotlb-xen initialization into swiotlb

2022-03-14 Thread Boris Ostrovsky
On 3/14/22 3:31 AM, Christoph Hellwig wrote: - static void __init pci_xen_swiotlb_init(void) { if (!xen_initial_domain() && !x86_swiotlb_enable) return; x86_swiotlb_enable = true; - xen_swiotlb = true; - xen_swiotlb_init_early(); +

[PATCH v2 5/8] iommu: Add PASID support for DMA mapping API users

2022-03-14 Thread Jacob Pan
DMA mapping API is the de facto standard for in-kernel DMA. It operates on a per device/RID basis which is not PASID-aware. Some modern devices such as Intel Data Streaming Accelerator, PASID is required for certain work submissions. To allow such devices use DMA mapping API, we need the

[PATCH v2 0/8] Enable PASID for DMA API users

2022-03-14 Thread Jacob Pan
Some modern accelerators such as Intel's Data Streaming Accelerator (DSA) require PASID in DMA requests to be operational. Specifically, the work submissions with ENQCMD on shared work queues require PASIDs. The use cases include both user DMA with shared virtual addressing (SVA) and in-kernel DMA

[PATCH v2 2/8] iommu: Add attach/detach_dev_pasid domain ops

2022-03-14 Thread Jacob Pan
From: Lu Baolu An IOMMU domain represents an address space which can be attached by devices that perform DMA within a domain. However, for platforms with PASID capability the domain attachment needs be handled at device+PASID level. There can be multiple PASIDs within a device and multiple

[PATCH v2 6/8] dmaengine: idxd: Use DMA API for in-kernel DMA with PASID

2022-03-14 Thread Jacob Pan
The current in-kernel supervisor PASID support is based on the SVM/SVA machinery in SVA lib. The binding between a kernel PASID and kernel mapping has many flaws. See discussions in the link below. This patch enables in-kernel DMA by switching from SVA lib to the standard DMA mapping APIs. Since

[PATCH v2 9/9] dmaengine: idxd: separate user and kernel pasid enabling

2022-03-14 Thread Jacob Pan
From: Dave Jiang The idxd driver always gated the pasid enabling under a single knob and this assumption is incorrect. The pasid used for kernel operation can be independently toggled and has no dependency on the user pasid (and vice versa). Split the two so they are independent "enabled" flags.

[PATCH v2 4/8] iommu/vt-d: Use device_pasid attach op for RID2PASID

2022-03-14 Thread Jacob Pan
With the availability of a generic device-PASID-domain attachment API, there's no need to special case RID2PASID. Use the API to replace duplicated code. Signed-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 18 ++ 1 file changed, 2 insertions(+), 16 deletions(-) diff

[PATCH v2 1/8] iommu: Assign per device max PASID

2022-03-14 Thread Jacob Pan
From: Lu Baolu PCIe spec defines Max PASID Width per-device. Since a PASID is only used with IOMMU enabled, this patch introduces a PASID max variable on the per-device IOMMU data. It will be used for limiting PASID allocation in that PASID table is per-device. Signed-off-by: Lu Baolu

[PATCH v2 3/8] iommu/vt-d: Implement device_pasid domain attach ops

2022-03-14 Thread Jacob Pan
On VT-d platforms with scalable mode enabled, devices issue DMA requests with PASID need to attach to the correct IOMMU domains. The attach operation involves the following: - programming the PASID into device's PASID table - tracking device domain and the PASID relationship - managing IOTLB and

[PATCH v2 7/8] iommu/vt-d: Delete supervisor/kernel SVA

2022-03-14 Thread Jacob Pan
In-kernel DMA with PASID should use DMA API now, remove supervisor PASID SVA support. Remove special cases in bind mm and page request service. Signed-off-by: Jacob Pan --- drivers/iommu/intel/svm.c | 42 --- 1 file changed, 8 insertions(+), 34 deletions(-)

[PATCH v2 8/8] iommu: Remove unused driver data in sva_bind_device

2022-03-14 Thread Jacob Pan
No one is using drvdata for sva_bind_device after kernel SVA support is removed from VT-d driver. Remove the drvdata parameter as well. Signed-off-by: Jacob Pan --- drivers/dma/idxd/cdev.c | 2 +- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 2 +-

Re: [PATCH 14/15] swiotlb: remove swiotlb_init_with_tbl and swiotlb_init_late_with_tbl

2022-03-14 Thread Boris Ostrovsky
On 3/14/22 3:31 AM, Christoph Hellwig wrote: @@ -314,6 +293,7 @@ void __init swiotlb_init(bool addressing_limit, unsigned int flags) int swiotlb_init_late(size_t size, gfp_t gfp_mask, int (*remap)(void *tlb, unsigned long nslabs)) { + struct io_tlb_mem *mem =