linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL] Please pull IOMMUFD subsystem changes
@ 2022-12-12 18:30 Jason Gunthorpe
  2022-12-14 18:04 ` pr-tracker-bot
  0 siblings, 1 reply; 31+ messages in thread
From: Jason Gunthorpe @ 2022-12-12 18:30 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

[-- Attachment #1: Type: text/plain, Size: 23403 bytes --]

Hi Linus,

This is the first PR for a new char device called 'iommufd'. This has
been in discussions for about two years now, while attempts to
implement the needed features have been tried since as far back as
2017. In January a group of us sat down and actually made it.

It may seem strange that a lowlevel, seemingly internal, function like
the iommu would have a user API. However, for performance, it has
become quite popular to setup virtual machines so that HW (eg
networking/storage devices) can have direct DMA into the virtual
machine memory itself. To achieve this requires special programming of
the IOMMU HW.

Further, we have advanced PCI features like Process Address Space ID
(PASID) and Page Request Interface (PRI) that rely on the IOMMU HW to
implement them. In particular PASID & PRI are used to create something
called Shared Virtual Addressing (SVA or SVM) where DMA from a device
can be directly delivered to a process virtual memory address by
having the IOMMU HW directly walk the CPU's page table for the
process, and trigger faults for DMA to non-present pages.

Naturally people would like to have virtualized versions of all of
this. A vIOMMU driver that can implement vPASID and vPRI to achieve
vSVA within a VM.

Thus, we get to iommufd. It is a uAPI to allow something like qemu to
have some direct control over the IOMMU to implement, in userspace, a
vIOMMU device emulation that can provide all these services to the
IOMMU driver running in the VM. Like KVM this is done in a general way
where we delegate functionality to userspace and if the userspace is
something like qemu then it will compose that functionality into an
emulated vIOMMU device. iommufd itself doesn't interact with
virtualization or KVM.

This PR is the starting point, it just gets all the infrastructure
setup so that it is as good as VFIO is right now. We see a broad need
for extended
features, some being highly IOMMU device specific:

 - Binding iommu_domain's to PASID/SSID
 - Userspace IO page tables, for ARM, x86 and S390
 - Kernel bypassed invalidation of user page tables
 - Re-use of the KVM page table in the IOMMU
 - Dirty page tracking in the IOMMU
 - Runtime Increase/Decrease of IOPTE size
 - PRI support with faults resolved in userspace

Currently vfio provides the uAPI for iommu HW, but its ioctl design
has reached a difficult point to evolve further, and has developed a
small wishlist of changes. Worse, it is tied to VFIO, and other
subystems working with direct VM DMA, like VPDA, were cloning the
iommu control with their own IOCTLs.

Background
==========

The built-in kdocs are rendered here, and make an good backgrounder, along
with the main cover letter:

 https://docs.kernel.org/next/userspace-api/iommufd.html
 https://lore.kernel.org/kvm/0-v6-a196d26f289e+11787-iommufd_jgg@nvidia.com/

Eric and Yi gave a nice presentation at KVM forum on the history and qemu side
of the project:

 https://youtu.be/PlEzLywexHE

A group discussion at LPC, though the AV is troubled enough it is not
so
good:

 https://youtu.be/tHNhegCD2tU

And a few older, related, conference presentations:

 Some AMD IOMMU HW features:
   https://static.sched.com/hosted_files/kvmforum2021/da/vIOMMU%20KVM%20Forum%202021%20-%20v4.pdf

 Sharing the KVM page table with the IOMMU
   https://static.sched.com/hosted_files/kvmforum2021/a3/KVM_2021_sharing_TDP_IOMMU.pdf

 Earlier approach for nested translation/userspace page tables on ARM:
   https://archive.fosdem.org/2019/schedule/event/vai_iommu_implementation_using_hw_nested_paging/attachments/slides/2915/export/events/attachments/vai_iommu_implementation_using_hw_nested_paging/slides/2915/fosdem19_viommu_nested_mode.

The PR
======

This PR is following about 300 patches already merged that have been
restructuring parts of the iommu subsystem, VFIO, and all its
drivers. The large amount of preparatory work is the main reason why
this has been such a challenging task.

As for this PR, it is organized into parts:

 - First is a shared branch with Joerg that gets the necessary iommu
   subsystem rework required.

 - Second is the "generic iommufd" basic char dev. This is at the
   level of near functional equivalence to the current VFIO interface.

 - Third is a series to make VFIO able to use iommufd.

 - Fourth is some VFIO patches that have become conflict entangled
   with this work, but were otherwise completed this cycle.

 - Finally a few small fixup patches from late review on the mailing
   list after the commits had been frozen.

The next cycle(s) will see additional functionality land in iommufd,
and completion of the VFIO rework which will finally bring the new
features people have been seeking.

The bulk of the PR has been in linux-next since next-20221102, it
comes with a fairly complete selftest, and separately syzkaller
descriptions were created and run against the full uAPI with
reasonable coverage results. These are now pushed to syzbot and are
running continuously.

Several people have contributed directly to this work: Eric Auger,
Joao Martins, Kevin Tian, Lu Baolu, Nicolin Chen, Yi L Liu. Many more
have participated in the discussions that lead here, and provided
ideas. Thanks to all!

Merge Conflicts
===============

Finally, there are some interactions with other trees. Everything was
fine until rc8 then all these conflicts appeared :(

Trivial compile time failure with Greg's work to add const-ness:

  https://lore.kernel.org/r/20221206132153.074fff0c@canb.auug.org.au

--- a/drivers/vfio/group.c
+++ b/drivers/vfio/group.c
@@ -827,7 +827,7 @@ bool vfio_file_has_dev(struct file *file, struct vfio_device *device)
 }
 EXPORT_SYMBOL_GPL(vfio_file_has_dev);

-static char *vfio_devnode(struct device *dev, umode_t *mode)
+static char *vfio_devnode(const struct device *dev, umode_t *mode)
 {
        return kasprintf(GFP_KERNEL, "vfio/%s", dev_name(dev));
 }

There are more ugly problems with VFIO that we didn't manage to avoid:

 https://lore.kernel.org/r/20221206125542.52ea97a7@canb.auug.org.au

And another one that Stephen hasn't written about yet. I've created a
'for-linus-iommufd-merged' tag with my resolution against Alex's
current tree and a diff is included the end of this email.

Though I don't think there will be a merge, compile, or functional
problem, changes to gup.c going through Andrew's mm tree want the
changes below. I will send a patch for this during rc1.

diff --git a/drivers/iommu/iommufd/pages.c b/drivers/iommu/iommufd/pages.c
index 429fa3b0a239cd..12c93b7bf15793 100644
--- a/drivers/iommu/iommufd/pages.c
+++ b/drivers/iommu/iommufd/pages.c
@@ -707,12 +707,9 @@ static void pfn_reader_user_init(struct pfn_reader_user *user,
 	user->upages_end = 0;
 	user->locked = -1;

-	if (pages->writable) {
-		user->gup_flags = FOLL_LONGTERM | FOLL_WRITE;
-	} else {
-		/* Still need to break COWs on read */
-		user->gup_flags = FOLL_LONGTERM | FOLL_FORCE | FOLL_WRITE;
-	}
+	user->gup_flags = FOLL_LONGTERM;
+	if (pages->writable)
+		user->gup_flags |= FOLL_WRITE;
 }

 static void pfn_reader_user_destroy(struct pfn_reader_user *user,
@@ -782,13 +779,9 @@ static int pfn_reader_user_pin(struct pfn_reader_user *user,
 			mmap_read_lock(pages->source_mm);
 			user->locked = 1;
 		}
-		/*
-		 * FIXME: last NULL can be &pfns->locked once the GUP patch
-		 * is merged.
-		 */
 		rc = pin_user_pages_remote(pages->source_mm, uptr, npages,
 					   user->gup_flags, user->upages, NULL,
-					   NULL);
+					   &user->locked);
 	}
 	if (rc <= 0) {
 		if (WARN_ON(!rc))

Thanks,
Jason

The tag for-linus-iommufd-merged with my merge resolution to your tree is also available to pull.

The following changes since commit b7b275e60bcd5f89771e865a8239325f86d9927d:

  Linux 6.1-rc7 (2022-11-27 13:31:48 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

for you to fetch changes up to d6c55c0a20e5059abdde81713ddf6324a946eb3c:

  iommufd: Change the order of MSI setup (2022-12-09 15:24:30 -0400)

----------------------------------------------------------------
iommufd for 6.2

iommufd is the user API to control the IOMMU subsystem as it relates to
managing IO page tables that point at user space memory.

It takes over from drivers/vfio/vfio_iommu_type1.c (aka the VFIO
container) which is the VFIO specific interface for a similar idea.

We see a broad need for extended features, some being highly IOMMU device
specific:
 - Binding iommu_domain's to PASID/SSID
 - Userspace IO page tables, for ARM, x86 and S390
 - Kernel bypassed invalidation of user page tables
 - Re-use of the KVM page table in the IOMMU
 - Dirty page tracking in the IOMMU
 - Runtime Increase/Decrease of IOPTE size
 - PRI support with faults resolved in userspace

Many of these HW features exist to support VM use cases - for instance the
combination of PASID, PRI and Userspace IO Page Tables allows an
implementation of DMA Shared Virtual Addressing (vSVA) within a
guest. Dirty tracking enables VM live migration with SRIOV devices and
PASID support allow creating "scalable IOV" devices, among other things.

As these features are fundamental to a VM platform they need to be
uniformly exposed to all the driver families that do DMA into VMs, which
is currently VFIO and VDPA.

----------------------------------------------------------------
Jason Gunthorpe (36):
      iommu: Add IOMMU_CAP_ENFORCE_CACHE_COHERENCY
      interval-tree: Add a utility to iterate over spans in an interval tree
      scripts/kernel-doc: support EXPORT_SYMBOL_NS_GPL() with -export
      iommufd: File descriptor, context, kconfig and makefiles
      kernel/user: Allow user_struct::locked_vm to be usable for iommufd
      iommufd: PFN handling for iopt_pages
      iommufd: Algorithms for PFN storage
      iommufd: Data structure to provide IOVA to PFN mapping
      iommufd: IOCTLs for the io_pagetable
      iommufd: Add a HW pagetable object
      iommufd: Add kAPI toward external drivers for physical devices
      iommufd: Add kAPI toward external drivers for kernel access
      iommufd: vfio container FD ioctl compatibility
      iommufd: Add kernel support for testing iommufd
      iommufd: Add some fault injection points
      iommufd: Add additional invariant assertions
      iommufd: Add a selftest
      Merge patch series "IOMMUFD Generic interface"
      vfio: Move vfio_device driver open/close code to a function
      vfio: Move vfio_device_assign_container() into vfio_device_first_open()
      vfio: Rename vfio_device_assign/unassign_container()
      vfio: Use IOMMU_CAP_ENFORCE_CACHE_COHERENCY for vfio_file_enforced_coherent()
      vfio-iommufd: Allow iommufd to be used in place of a container fd
      vfio-iommufd: Support iommufd for physical VFIO devices
      vfio-iommufd: Support iommufd for emulated VFIO devices
      vfio: Move container related MODULE_ALIAS statements into container.c
      vfio: Make vfio_container optionally compiled
      iommufd: Allow iommufd to supply /dev/vfio/vfio
      Merge patch series "Connect VFIO to IOMMUFD"
      Merge tag 'v6.1-rc7' into iommufd.git for-next
      vfio: Simplify vfio_create_group()
      vfio: Move the sanity check of the group to vfio_create_group()
      Merge patch series "Move group specific code into group.c"
      iommufd: Fix comment typos
      iommufd: Improve a few unclear bits of code
      iommufd: Change the order of MSI setup

Joerg Roedel (1):
      Merge tag 'for-joerg' of git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd into core

Kevin Tian (1):
      iommufd: Document overview of iommufd

Lu Baolu (14):
      iommu: Add max_pasids field in struct iommu_device
      iommu: Add max_pasids field in struct dev_iommu
      iommu: Remove SVM_FLAG_SUPERVISOR_MODE support
      PCI: Enable PASID only when ACS RR & UF enabled on upstream path
      iommu: Add attach/detach_dev_pasid iommu interfaces
      iommu: Add IOMMU SVA domain support
      iommu/vt-d: Add SVA domain support
      arm-smmu-v3/sva: Add SVA domain support
      iommu/sva: Refactoring iommu_sva_bind/unbind_device()
      iommu: Remove SVA related callbacks from iommu ops
      iommu: Prepare IOMMU domain for IOPF
      iommu: Per-domain I/O page fault handling
      iommu: Rename iommu-sva-lib.{c,h}
      iommu: Add device-centric DMA ownership interfaces

Matthew Rosato (1):
      vfio/ap: Validate iova during dma_unmap and trigger irq disable

Nicolin Chen (5):
      iommu/amd: Drop unnecessary checks in amd_iommu_attach_device()
      iommu: Add return value rules to attach_dev op and APIs
      iommu: Regulate EINVAL in ->attach_dev callback functions
      iommu: Use EINVAL for incompatible device/domain in ->attach_dev
      iommu: Propagate return value in ->attach_dev callback functions

Yi Liu (9):
      i915/gvt: Move gvt mapping cache initialization to intel_vgpu_init_dev()
      vfio: Create wrappers for group register/unregister
      vfio: Set device->group in helper function
      vfio: Swap order of vfio_device_container_register() and open_device()
      vfio: Make vfio_device_open() truly device specific
      vfio: Refactor vfio_device open and close
      vfio: Wrap vfio group module init/clean code into helpers
      vfio: Refactor dma APIs for emulated devices
      vfio: Move vfio group specific code into group.c

 .clang-format                                      |    3 +
 Documentation/userspace-api/index.rst              |    1 +
 Documentation/userspace-api/ioctl/ioctl-number.rst |    1 +
 Documentation/userspace-api/iommufd.rst            |  223 +++
 MAINTAINERS                                        |   12 +
 drivers/dma/idxd/cdev.c                            |    3 +-
 drivers/dma/idxd/init.c                            |   25 +-
 drivers/gpu/drm/i915/gvt/kvmgt.c                   |   21 +-
 drivers/iommu/Kconfig                              |    1 +
 drivers/iommu/Makefile                             |    4 +-
 drivers/iommu/amd/iommu.c                          |   14 +-
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c    |  104 +-
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c        |   32 +-
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h        |   23 +-
 drivers/iommu/arm/arm-smmu/arm-smmu.c              |    3 -
 drivers/iommu/arm/arm-smmu/qcom_iommu.c            |    7 +-
 drivers/iommu/fsl_pamu.c                           |    2 +-
 drivers/iommu/fsl_pamu_domain.c                    |    4 +-
 drivers/iommu/intel/dmar.c                         |    7 +
 drivers/iommu/intel/iommu.c                        |   56 +-
 drivers/iommu/intel/iommu.h                        |   18 +-
 drivers/iommu/intel/pasid.c                        |    6 +-
 drivers/iommu/intel/svm.c                          |  145 +-
 drivers/iommu/io-pgfault.c                         |   77 +-
 drivers/iommu/iommu-sva-lib.c                      |   71 -
 drivers/iommu/iommu-sva.c                          |  240 +++
 drivers/iommu/{iommu-sva-lib.h => iommu-sva.h}     |   14 +-
 drivers/iommu/iommu.c                              |  416 ++--
 drivers/iommu/iommufd/Kconfig                      |   44 +
 drivers/iommu/iommufd/Makefile                     |   13 +
 drivers/iommu/iommufd/device.c                     |  772 ++++++++
 drivers/iommu/iommufd/double_span.h                |   53 +
 drivers/iommu/iommufd/hw_pagetable.c               |   57 +
 drivers/iommu/iommufd/io_pagetable.c               | 1216 ++++++++++++
 drivers/iommu/iommufd/io_pagetable.h               |  241 +++
 drivers/iommu/iommufd/ioas.c                       |  398 ++++
 drivers/iommu/iommufd/iommufd_private.h            |  307 +++
 drivers/iommu/iommufd/iommufd_test.h               |   93 +
 drivers/iommu/iommufd/main.c                       |  460 +++++
 drivers/iommu/iommufd/pages.c                      | 1984 ++++++++++++++++++++
 drivers/iommu/iommufd/selftest.c                   |  853 +++++++++
 drivers/iommu/iommufd/vfio_compat.c                |  472 +++++
 drivers/iommu/ipmmu-vmsa.c                         |    2 -
 drivers/iommu/mtk_iommu.c                          |    4 +-
 drivers/iommu/omap-iommu.c                         |    6 +-
 drivers/iommu/sprd-iommu.c                         |    4 +-
 drivers/iommu/tegra-gart.c                         |    2 +-
 drivers/iommu/virtio-iommu.c                       |    7 +-
 drivers/misc/uacce/uacce.c                         |    2 +-
 drivers/pci/ats.c                                  |    3 +
 drivers/s390/cio/vfio_ccw_ops.c                    |    3 +
 drivers/s390/crypto/vfio_ap_ops.c                  |   21 +-
 drivers/vfio/Kconfig                               |   36 +-
 drivers/vfio/Makefile                              |    6 +-
 drivers/vfio/container.c                           |  145 +-
 drivers/vfio/fsl-mc/vfio_fsl_mc.c                  |    3 +
 drivers/vfio/group.c                               |  877 +++++++++
 drivers/vfio/iommufd.c                             |  158 ++
 drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c     |    6 +
 drivers/vfio/pci/mlx5/main.c                       |    3 +
 drivers/vfio/pci/vfio_pci.c                        |    3 +
 drivers/vfio/platform/vfio_amba.c                  |    3 +
 drivers/vfio/platform/vfio_platform.c              |    3 +
 drivers/vfio/vfio.h                                |  120 +-
 drivers/vfio/vfio_main.c                           |  983 ++--------
 include/linux/intel-svm.h                          |   13 -
 include/linux/interval_tree.h                      |   58 +
 include/linux/iommu.h                              |  145 +-
 include/linux/iommufd.h                            |   98 +
 include/linux/sched/user.h                         |    2 +-
 include/linux/vfio.h                               |   39 +
 include/uapi/linux/iommufd.h                       |  347 ++++
 kernel/user.c                                      |    1 +
 lib/Kconfig                                        |    4 +
 lib/interval_tree.c                                |  132 ++
 scripts/kernel-doc                                 |   12 +-
 tools/testing/selftests/Makefile                   |    1 +
 tools/testing/selftests/iommu/.gitignore           |    3 +
 tools/testing/selftests/iommu/Makefile             |   12 +
 tools/testing/selftests/iommu/config               |    2 +
 tools/testing/selftests/iommu/iommufd.c            | 1654 ++++++++++++++++
 tools/testing/selftests/iommu/iommufd_fail_nth.c   |  580 ++++++
 tools/testing/selftests/iommu/iommufd_utils.h      |  278 +++
 83 files changed, 12811 insertions(+), 1466 deletions(-)

diff --cc drivers/vfio/Kconfig
index 286c1663bd7564,0b8d53f63c7e5c..a8f54462946742
--- a/drivers/vfio/Kconfig
+++ b/drivers/vfio/Kconfig
@@@ -46,17 -38,6 +46,12 @@@ config VFIO_NOIOMM
  	  this mode since there is no IOMMU to provide DMA translation.
  
  	  If you don't know what to do here, say N.
 +endif
 +
- config VFIO_SPAPR_EEH
- 	tristate
- 	depends on EEH && VFIO_IOMMU_SPAPR_TCE
- 	default VFIO
- 
 +config VFIO_VIRQFD
- 	tristate
++	bool
 +	select EVENTFD
 +	default n
  
  source "drivers/vfio/pci/Kconfig"
  source "drivers/vfio/platform/Kconfig"
diff --cc drivers/vfio/Makefile
index 3783db7e8082c8,0721ed4831c92f..7eae72e2c6bf9f
--- a/drivers/vfio/Makefile
+++ b/drivers/vfio/Makefile
@@@ -2,17 -2,12 +2,14 @@@
  obj-$(CONFIG_VFIO) += vfio.o
  
  vfio-y += vfio_main.o \
 -	  iova_bitmap.o \
 -	  container.o
 +	  group.o \
 +	  iova_bitmap.o
+ vfio-$(CONFIG_VFIO_VIRQFD) += virqfd.o
 +vfio-$(CONFIG_IOMMUFD) += iommufd.o
 +vfio-$(CONFIG_VFIO_CONTAINER) += container.o
  
- obj-$(CONFIG_VFIO_VIRQFD) += vfio_virqfd.o
  obj-$(CONFIG_VFIO_IOMMU_TYPE1) += vfio_iommu_type1.o
  obj-$(CONFIG_VFIO_IOMMU_SPAPR_TCE) += vfio_iommu_spapr_tce.o
- obj-$(CONFIG_VFIO_SPAPR_EEH) += vfio_spapr_eeh.o
  obj-$(CONFIG_VFIO_PCI) += pci/
  obj-$(CONFIG_VFIO_PLATFORM) += platform/
  obj-$(CONFIG_VFIO_MDEV) += mdev/
diff --cc drivers/vfio/vfio.h
index 2e05418fd18df0,7c2cbf8a48ad1b..d5fa896b5a8562
--- a/drivers/vfio/vfio.h
+++ b/drivers/vfio/vfio.h
@@@ -73,27 -60,8 +73,22 @@@ struct vfio_group 
  	struct kvm			*kvm;
  	struct file			*opened_file;
  	struct blocking_notifier_head	notifier;
 +	struct iommufd_ctx		*iommufd;
  };
  
 +int vfio_device_set_group(struct vfio_device *device,
 +			  enum vfio_group_type type);
 +void vfio_device_remove_group(struct vfio_device *device);
 +void vfio_device_group_register(struct vfio_device *device);
 +void vfio_device_group_unregister(struct vfio_device *device);
 +int vfio_device_group_use_iommu(struct vfio_device *device);
 +void vfio_device_group_unuse_iommu(struct vfio_device *device);
 +void vfio_device_group_close(struct vfio_device *device);
 +bool vfio_device_has_container(struct vfio_device *device);
 +int __init vfio_group_init(void);
 +void vfio_group_cleanup(void);
 +
 +#if IS_ENABLED(CONFIG_VFIO_CONTAINER)
- /* events for the backend driver notify callback */
- enum vfio_iommu_notify_type {
- 	VFIO_IOMMU_CONTAINER_CLOSE = 0,
- };
- 
  /**
   * struct vfio_iommu_driver_ops - VFIO IOMMU driver callbacks
   */
diff --cc drivers/vfio/vfio_main.c
index e21ff965141e69,03dbcd3d96f0e5..d4087fe7419996
--- a/drivers/vfio/vfio_main.c
+++ b/drivers/vfio/vfio_main.c
@@@ -1260,27 -1902,59 +1348,34 @@@ static int __init vfio_init(void
  	if (ret)
  		return ret;
  
+ 	ret = vfio_virqfd_init();
+ 	if (ret)
 -		goto err_virqfd;
 -
 -	/* /dev/vfio/$GROUP */
 -	vfio.class = class_create(THIS_MODULE, "vfio");
 -	if (IS_ERR(vfio.class)) {
 -		ret = PTR_ERR(vfio.class);
 -		goto err_group_class;
 -	}
 -
 -	vfio.class->devnode = vfio_devnode;
++		goto err_group;
+ 
  	/* /sys/class/vfio-dev/vfioX */
  	vfio.device_class = class_create(THIS_MODULE, "vfio-dev");
  	if (IS_ERR(vfio.device_class)) {
  		ret = PTR_ERR(vfio.device_class);
--		goto err_dev_class;
++		goto err_virqfd;
  	}
  
 -	ret = alloc_chrdev_region(&vfio.group_devt, 0, MINORMASK + 1, "vfio");
 -	if (ret)
 -		goto err_alloc_chrdev;
 -
  	pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
  	return 0;
  
 -err_alloc_chrdev:
 -	class_destroy(vfio.device_class);
 -	vfio.device_class = NULL;
--err_dev_class:
 -	class_destroy(vfio.class);
 -	vfio.class = NULL;
 -err_group_class:
 -	vfio_virqfd_exit();
+ err_virqfd:
 -	vfio_container_cleanup();
++	vfio_virqfd_exit();
++err_group:
 +	vfio_group_cleanup();
  	return ret;
  }
  
  static void __exit vfio_cleanup(void)
  {
 -	WARN_ON(!list_empty(&vfio.group_list));
 -
  	ida_destroy(&vfio.device_ida);
 -	ida_destroy(&vfio.group_ida);
 -	unregister_chrdev_region(vfio.group_devt, MINORMASK + 1);
  	class_destroy(vfio.device_class);
  	vfio.device_class = NULL;
 -	class_destroy(vfio.class);
+ 	vfio_virqfd_exit();
 -	vfio_container_cleanup();
 -	vfio.class = NULL;
 +	vfio_group_cleanup();
  	xa_destroy(&vfio_device_set_xa);
  }
  

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2022-12-12 18:30 [GIT PULL] Please pull IOMMUFD subsystem changes Jason Gunthorpe
@ 2022-12-14 18:04 ` pr-tracker-bot
  0 siblings, 0 replies; 31+ messages in thread
From: pr-tracker-bot @ 2022-12-14 18:04 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Linus Torvalds, iommu, kvm, linux-kernel, Kevin Tian

The pull request you sent on Mon, 12 Dec 2022 14:30:37 -0400:

> git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/08cdc2157966c07d3f986a097ddaa74cee312751

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2024-04-19 17:29 Jason Gunthorpe
@ 2024-04-19 21:07 ` pr-tracker-bot
  0 siblings, 0 replies; 31+ messages in thread
From: pr-tracker-bot @ 2024-04-19 21:07 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Linus Torvalds, iommu, kvm, linux-kernel, Kevin Tian

The pull request you sent on Fri, 19 Apr 2024 14:29:00 -0300:

> git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/50a1317fd18acc2793edcb1d078909527c273a9e

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [GIT PULL] Please pull IOMMUFD subsystem changes
@ 2024-04-19 17:29 Jason Gunthorpe
  2024-04-19 21:07 ` pr-tracker-bot
  0 siblings, 1 reply; 31+ messages in thread
From: Jason Gunthorpe @ 2024-04-19 17:29 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

[-- Attachment #1: Type: text/plain, Size: 1072 bytes --]

Hi Linus,

Minor selftest fixes.

The following changes since commit fec50db7033ea478773b159e0e2efb135270e3b7:

  Linux 6.9-rc3 (2024-04-07 13:22:46 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

for you to fetch changes up to 2760c51b8040d7cffedc337939e7475a17cc4b19:

  iommufd: Add config needed for iommufd_fail_nth (2024-04-14 13:52:08 -0300)

----------------------------------------------------------------
iommufd for 6.9 first rc

Two fixes for the selftests:

- CONFIG_IOMMUFD_TEST needs CONFIG_IOMMUFD_DRIVER to work

- The kconfig fragment sshould include fault injection so the fault
  injection test can work

----------------------------------------------------------------
Jason Gunthorpe (1):
      iommufd: Add missing IOMMUFD_DRIVER kconfig for the selftest

Muhammad Usama Anjum (1):
      iommufd: Add config needed for iommufd_fail_nth

 drivers/iommu/iommufd/Kconfig        | 1 +
 tools/testing/selftests/iommu/config | 2 ++
 2 files changed, 3 insertions(+)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2024-03-02  0:08 Jason Gunthorpe
@ 2024-03-02  1:31 ` pr-tracker-bot
  0 siblings, 0 replies; 31+ messages in thread
From: pr-tracker-bot @ 2024-03-02  1:31 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Linus Torvalds, iommu, kvm, linux-kernel, Kevin Tian

The pull request you sent on Fri, 1 Mar 2024 20:08:29 -0400:

> git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/e613c90ddabcef5134ec4daa23b319ad7c99b94b

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [GIT PULL] Please pull IOMMUFD subsystem changes
@ 2024-03-02  0:08 Jason Gunthorpe
  2024-03-02  1:31 ` pr-tracker-bot
  0 siblings, 1 reply; 31+ messages in thread
From: Jason Gunthorpe @ 2024-03-02  0:08 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

[-- Attachment #1: Type: text/plain, Size: 1397 bytes --]

Hi Linus,

The fixes for the new syzkaller bugs I mentioned before.

Thanks,
Jason

The following changes since commit d206a76d7d2726f3b096037f2079ce0bd3ba329b:

  Linux 6.8-rc6 (2024-02-25 15:46:06 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

for you to fetch changes up to bb04d13353885f81c87879b2deb296bd2adb6cab:

  iommufd/selftest: Don't check map/unmap pairing with HUGE_PAGES (2024-02-26 16:59:12 -0400)

----------------------------------------------------------------
iommufd for 6.8 rc

Four syzkaller found bugs:

- Corruption during error unwind in iommufd_access_change_ioas()

- Overlapping IDs in the test suite due to out of order destruction

- Missing locking for access->ioas in the test suite

- False failures in the test suite validation logic with huge pages

----------------------------------------------------------------
Jason Gunthorpe (1):
      iommufd/selftest: Don't check map/unmap pairing with HUGE_PAGES

Nicolin Chen (3):
      iommufd: Fix iopt_access_list_id overwrite bug
      iommufd/selftest: Fix mock_dev_num bug
      iommufd: Fix protection fault in iommufd_test_syz_conv_iova

 drivers/iommu/iommufd/io_pagetable.c |  9 +++--
 drivers/iommu/iommufd/selftest.c     | 69 +++++++++++++++++++++++++-----------
 2 files changed, 54 insertions(+), 24 deletions(-)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2024-02-22 13:23 Jason Gunthorpe
@ 2024-02-22 20:03 ` pr-tracker-bot
  0 siblings, 0 replies; 31+ messages in thread
From: pr-tracker-bot @ 2024-02-22 20:03 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Linus Torvalds, iommu, kvm, linux-kernel, Kevin Tian

The pull request you sent on Thu, 22 Feb 2024 09:23:04 -0400:

> git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/4c36fbb46f1326c8a11d81594a710098909eb9bf

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [GIT PULL] Please pull IOMMUFD subsystem changes
@ 2024-02-22 13:23 Jason Gunthorpe
  2024-02-22 20:03 ` pr-tracker-bot
  0 siblings, 1 reply; 31+ messages in thread
From: Jason Gunthorpe @ 2024-02-22 13:23 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

[-- Attachment #1: Type: text/plain, Size: 2281 bytes --]

Hi Linus,

Some small fixes and updates for the selftest. I'm aware of some
syzkaller issues that hopefully will get fixes into another PR before
the merge window.

The following changes since commit 54be6c6c5ae8e0d93a6c4641cb7528eb0b6ba478:

  Linux 6.8-rc3 (2024-02-04 12:20:36 +0000)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

for you to fetch changes up to 510325e5ac5f45c1180189d3bfc108c54bf64544:

  selftests/iommu: fix the config fragment (2024-02-22 09:02:05 -0400)

----------------------------------------------------------------
iommufd for 6.8 rc

- Fix dirty tracking bitmap collection when using reporting bitmaps that
  are not neatly aligned to u64's or match the IO page table radix tree
  layout.

- Add self tests to cover the cases that were found to be broken.

- Add missing enforcement of invalidation type in the uapi.

- Fix selftest config generation

----------------------------------------------------------------
Jason Gunthorpe (1):
      iommufd: Reject non-zero data_type if no data_len is provided

Joao Martins (9):
      iommufd/iova_bitmap: Bounds check mapped::pages access
      iommufd/iova_bitmap: Switch iova_bitmap::bitmap to an u8 array
      iommufd/selftest: Test u64 unaligned bitmaps
      iommufd/iova_bitmap: Handle recording beyond the mapped pages
      iommufd/selftest: Refactor dirty bitmap tests
      iommufd/selftest: Refactor mock_domain_read_and_clear_dirty()
      iommufd/selftest: Hugepage mock domain support
      iommufd/selftest: Add mock IO hugepages tests
      iommufd/iova_bitmap: Consider page offset for the pages to be pinned

Muhammad Usama Anjum (1):
      selftests/iommu: fix the config fragment

 drivers/iommu/iommufd/hw_pagetable.c          |  3 +-
 drivers/iommu/iommufd/iommufd_test.h          |  1 +
 drivers/iommu/iommufd/iova_bitmap.c           | 68 +++++++++++++++++++----
 drivers/iommu/iommufd/selftest.c              | 79 ++++++++++++++++++++-------
 tools/testing/selftests/iommu/config          |  5 +-
 tools/testing/selftests/iommu/iommufd.c       | 78 +++++++++++++++++++++-----
 tools/testing/selftests/iommu/iommufd_utils.h | 39 ++++++++-----
 7 files changed, 210 insertions(+), 63 deletions(-)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2024-01-12 17:49 Jason Gunthorpe
@ 2024-01-18 23:35 ` pr-tracker-bot
  0 siblings, 0 replies; 31+ messages in thread
From: pr-tracker-bot @ 2024-01-18 23:35 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Linus Torvalds, iommu, kvm, linux-kernel, Kevin Tian

The pull request you sent on Fri, 12 Jan 2024 13:49:28 -0400:

> git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/86c4d58a99ab1ccfa03860d4dead157be51eb2b6

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [GIT PULL] Please pull IOMMUFD subsystem changes
@ 2024-01-12 17:49 Jason Gunthorpe
  2024-01-18 23:35 ` pr-tracker-bot
  0 siblings, 1 reply; 31+ messages in thread
From: Jason Gunthorpe @ 2024-01-12 17:49 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

[-- Attachment #1: Type: text/plain, Size: 5174 bytes --]

Hi Linus,

There was a last minute doubt from Intel on their error handling
plan. They decided to remove it since it has uAPI meaning this was
delayed while they made that edit. The prior verions has been in
linux-next for a while now but the update has only had a day.

This PR includes the second part of the nested translation items for
iommufd, details in the tag.

For those following, these series are still progressing:

- User page table invalidation (non-Intel) has a roadmap:
 https://lore.kernel.org/linux-iommu/20231209014726.GA2945299@nvidia.com/

 There will be at least two more invalidation IOCTLs - IOMMU_DEVICE_INVALIDATE
 and IOMMU_VIOMMU_INVALIDATE in future.

- ARM SMMUv3 nested translation:
 https://github.com/jgunthorpe/linux/commits/smmuv3_newapi

- Draft AMD IOMMU nested translation:
 https://lore.kernel.org/linux-iommu/20240112000646.98001-1-suravee.suthikulpanit@amd.com

- ARM SMMUv3 Dirty tracking:
 https://lore.kernel.org/linux-iommu/20231128094940.1344-1-shameerali.kolothum.thodi@huawei.com/

- x86 KVM and IOMMU page table sharing (IOMMU_DOMAIN_KVM):
 https://lore.kernel.org/all/20231202091211.13376-1-yan.y.zhao@intel.com/

There is also a lot of ongoing work to consistently and generically enable
PASID and SVA support in all the IOMMU drivers:
 SMMUv3:
   https://lore.kernel.org/r/0-v3-d794f8d934da+411a-smmuv3_newapi_p1_jgg@nvidia.com
   https://lore.kernel.org/r/0-v3-9083a9368a5c+23fb-smmuv3_newapi_p2_jgg@nvidia.com
 AMD:
   https://lore.kernel.org/linux-iommu/20231212085224.6985-1-vasant.hegde@amd.com/
   https://lore.kernel.org/linux-iommu/20231221111558.64652-1-vasant.hegde@amd.com/
 Intel:
   https://lore.kernel.org/r/20231017032045.114868-1-tina.zhang@intel.com

RFC patches for PASID support in iommufd & vfio:
 https://lore.kernel.org/all/20231127063428.127436-1-yi.l.liu@intel.com/
 https://lore.kernel.org/all/20231127063909.129153-1-yi.l.liu@intel.com/

IO page faults and events delivered to userspace through iommufd:
 https://lore.kernel.org/all/20231220012332.168188-1-baolu.lu@linux.intel.com/
 https://lore.kernel.org/all/20231026024930.382898-1-baolu.lu@linux.intel.com/

RFC patches exploring support for the first Intel Scalable IO Virtualization
(SIOV r1) device are posted:
 https://lore.kernel.org/all/20231009085123.463179-1-yi.l.liu@intel.com/

A lot of the iommufd support has now been merged to qemu, though I think we
are still needing dirty tracking and nesting stuff.
 https://lore.kernel.org/all/20231121084426.1286987-1-zhenzhong.duan@intel.com/
 https://lore.kernel.org/all/20230622214845.3980-1-joao.m.martins@oracle.com/

A video of the iommufd session at LPC has been posted:
 https://youtu.be/IE_A8wSWV7g

Thanks,
Jason

The following changes since commit 861deac3b092f37b2c5e6871732f3e11486f7082:

  Linux 6.7-rc7 (2023-12-23 16:25:56 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

for you to fetch changes up to 47f2bd2ff382e5fe766b1322e354558a8da4a470:

  iommufd/selftest: Check the bus type during probe (2024-01-11 15:53:28 -0400)

----------------------------------------------------------------
iommufd for 6.8

This brings the first of three planned user IO page table invalidation
operations:

 - IOMMU_HWPT_INVALIDATE allows invalidating the IOTLB integrated into the
   iommu itself. The Intel implementation will also generate an ATC
   invalidation to flush the device IOTLB as it unambiguously knows the
   device, but other HW will not.

It goes along with the prior PR to implement userspace IO page tables (aka
nested translation for VMs) to allow Intel to have full functionality for
simple cases. An Intel implementation of the operation is provided.

Fix a small bug in the selftest mock iommu driver probe.

----------------------------------------------------------------
Jason Gunthorpe (1):
      iommufd/selftest: Check the bus type during probe

Lu Baolu (2):
      iommu: Add cache_invalidate_user op
      iommu/vt-d: Add iotlb flush for nested domain

Nicolin Chen (4):
      iommu: Add iommu_copy_struct_from_user_array helper
      iommufd/selftest: Add mock_domain_cache_invalidate_user support
      iommufd/selftest: Add IOMMU_TEST_OP_MD_CHECK_IOTLB test op
      iommufd/selftest: Add coverage for IOMMU_HWPT_INVALIDATE ioctl

Yi Liu (2):
      iommufd: Add IOMMU_HWPT_INVALIDATE
      iommufd: Add data structure for Intel VT-d stage-1 cache invalidation

 drivers/iommu/intel/nested.c                  |  88 +++++++++++++++
 drivers/iommu/iommufd/hw_pagetable.c          |  41 +++++++
 drivers/iommu/iommufd/iommufd_private.h       |  10 ++
 drivers/iommu/iommufd/iommufd_test.h          |  23 ++++
 drivers/iommu/iommufd/main.c                  |   3 +
 drivers/iommu/iommufd/selftest.c              | 104 +++++++++++++++---
 include/linux/iommu.h                         |  77 +++++++++++++
 include/uapi/linux/iommufd.h                  |  79 +++++++++++++
 tools/testing/selftests/iommu/iommufd.c       | 152 ++++++++++++++++++++++++++
 tools/testing/selftests/iommu/iommufd_utils.h |  55 ++++++++++
 10 files changed, 619 insertions(+), 13 deletions(-)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2023-12-04 19:35 Jason Gunthorpe
@ 2023-12-04 21:59 ` pr-tracker-bot
  0 siblings, 0 replies; 31+ messages in thread
From: pr-tracker-bot @ 2023-12-04 21:59 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Linus Torvalds, iommu, kvm, linux-kernel, Kevin Tian

The pull request you sent on Mon, 4 Dec 2023 15:35:34 -0400:

> git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/bee0e7762ad2c6025b9f5245c040fcc36ef2bde8

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [GIT PULL] Please pull IOMMUFD subsystem changes
@ 2023-12-04 19:35 Jason Gunthorpe
  2023-12-04 21:59 ` pr-tracker-bot
  0 siblings, 1 reply; 31+ messages in thread
From: Jason Gunthorpe @ 2023-12-04 19:35 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

[-- Attachment #1: Type: text/plain, Size: 1527 bytes --]

Hi Linus,

Two bug fixes for the rc cycle.

Thanks,
Jason

The following changes since commit 98b1cc82c4affc16f5598d4fa14b1858671b2263:

  Linux 6.7-rc2 (2023-11-19 15:02:14 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

for you to fetch changes up to 6f9c4d8c468c189d6dc470324bd52955f8aa0a10:

  iommufd: Do not UAF during iommufd_put_object() (2023-11-29 20:30:03 -0400)

----------------------------------------------------------------
iommufd 6.7 first rc pull request

A small fix for the dirty tracking self test to fail correctly if the code
is buggy.

Fix a tricky syzkaller race UAF with object reference counting.

----------------------------------------------------------------
Jason Gunthorpe (2):
      iommufd: Add iommufd_ctx to iommufd_put_object()
      iommufd: Do not UAF during iommufd_put_object()

Robin Murphy (1):
      iommufd/selftest: Fix _test_mock_dirty_bitmaps()

 drivers/iommu/iommufd/device.c                |  14 +--
 drivers/iommu/iommufd/hw_pagetable.c          |   8 +-
 drivers/iommu/iommufd/ioas.c                  |  14 +--
 drivers/iommu/iommufd/iommufd_private.h       |  70 +++++++++---
 drivers/iommu/iommufd/main.c                  | 146 ++++++++++++++------------
 drivers/iommu/iommufd/selftest.c              |  14 +--
 drivers/iommu/iommufd/vfio_compat.c           |  18 ++--
 tools/testing/selftests/iommu/iommufd_utils.h |  13 ++-
 8 files changed, 177 insertions(+), 120 deletions(-)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2023-10-31 13:14 Jason Gunthorpe
@ 2023-11-02  2:51 ` pr-tracker-bot
  0 siblings, 0 replies; 31+ messages in thread
From: pr-tracker-bot @ 2023-11-02  2:51 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Linus Torvalds, iommu, kvm, linux-kernel, Kevin Tian

The pull request you sent on Tue, 31 Oct 2023 10:14:17 -0300:

> git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/463f46e114f74465cf8d01b124e7b74ad1ce2afd

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [GIT PULL] Please pull IOMMUFD subsystem changes
@ 2023-10-31 13:14 Jason Gunthorpe
  2023-11-02  2:51 ` pr-tracker-bot
  0 siblings, 1 reply; 31+ messages in thread
From: Jason Gunthorpe @ 2023-10-31 13:14 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

[-- Attachment #1: Type: text/plain, Size: 12638 bytes --]

Hi Linus,

This PR includes the dirty tracking and first part of the nested
translation items for iommufd, details in the tag.

For those following, these series are still progressing:

- User page table invalidation:
 https://lore.kernel.org/r/20231020092426.13907-1-yi.l.liu@intel.com
 https://lore.kernel.org/r/20231020093719.18725-1-yi.l.liu@intel.com

- ARM SMMUv3 nested translation:
 https://lore.kernel.org/all/cover.1683688960.git.nicolinc@nvidia.com/

- Draft AMD IOMMU nested translation:
 https://lore.kernel.org/all/20230621235508.113949-1-suravee.suthikulpanit@amd.com/

- ARM SMMUv3 Dirty tracking:
 https://github.com/jpemartins/linux/commits/smmu-iommufd-v3

There is also a lot of ongoing work to consistently and generically enable
PASID and SVA support in all the IOMMU drivers:

 SMMUv3:
   https://lore.kernel.org/r/0-v1-e289ca9121be+2be-smmuv3_newapi_p1_jgg@nvidia.com
   https://lore.kernel.org/r/0-v1-afbb86647bbd+5-smmuv3_newapi_p2_jgg@nvidia.com
 AMD:
   https://lore.kernel.org/all/20231016104351.5749-1-vasant.hegde@amd.com/
   https://lore.kernel.org/all/20231013151652.6008-1-vasant.hegde@amd.com/
 Intel:
   https://lore.kernel.org/r/20231017032045.114868-1-tina.zhang@intel.com

RFC patches for PASID support in iommufd & vfio:
 https://lore.kernel.org/all/20230926092651.17041-1-yi.l.liu@intel.com/
 https://lore.kernel.org/all/20230926093121.18676-1-yi.l.liu@intel.com/

IO page faults and events delivered to userspace through iommufd:
 https://lore.kernel.org/all/20231026024930.382898-1-baolu.lu@linux.intel.com/

RFC patches exploring support for the first Intel Scalable IO Virtualization
(SIOV r1) device are posted:
 https://lore.kernel.org/all/20231009085123.463179-1-yi.l.liu@intel.com/

Along with qemu patches implementing iommufd:
 https://lore.kernel.org/all/20231016083223.1519410-1-zhenzhong.duan@intel.com/

There are some conflicts with Joerg's main iommu tree, most are of the append
to list type of conflict. A few notes:

drivers/iommu/iommufd/selftest.c needs a non-conflict hunk:

- static struct iommu_domain *mock_domain_alloc(unsigned int iommu_domain_type)
- {
-       if (iommu_domain_type == IOMMU_DOMAIN_BLOCKED)
-               return &mock_blocking_domain;
-       if (iommu_domain_type == IOMMU_DOMAIN_UNMANAGED)
-               return mock_domain_alloc_paging(NULL);
-       return NULL;
- }
-

drivers/iommu/iommufd/selftest.c should be:

@@@ -466,10 -293,8 +450,9 @@@ static const struct iommu_ops mock_ops
        .owner = THIS_MODULE,
        .pgsize_bitmap = MOCK_IO_PAGE_SIZE,
        .hw_info = mock_domain_hw_info,
-       .domain_alloc = mock_domain_alloc,
+       .domain_alloc_paging = mock_domain_alloc_paging,
 +      .domain_alloc_user = mock_domain_alloc_user,
        .capable = mock_domain_capable,
-       .set_platform_dma_ops = mock_domain_set_plaform_dma_ops,

include/linux/iommu.h should be:

 - * @domain_alloc: allocate iommu domain
 + * @domain_alloc: allocate and return an iommu domain if success. Otherwise
 + *                NULL is returned. The domain is not fully initialized until
 + *                the caller iommu_domain_alloc() returns.
 + * @domain_alloc_user: Allocate an iommu domain corresponding to the input
 + *                     parameters as defined in include/uapi/linux/iommufd.h.
 + *                     Unlike @domain_alloc, it is called only by IOMMUFD and
 + *                     must fully initialize the new domain before return.
 + *                     Upon success, if the @user_data is valid and the @parent
 + *                     points to a kernel-managed domain, the new domain must be
 + *                     IOMMU_DOMAIN_NESTED type; otherwise, the @parent must be
 + *                     NULL while the @user_data can be optionally provided, the
 + *                     new domain must support __IOMMU_DOMAIN_PAGING.
 + *                     Upon failure, ERR_PTR must be returned.
+  * @domain_alloc_paging: Allocate an iommu_domain that can be used for
+  *                       UNMANAGED, DMA, and DMA_FQ domain types.

The rest were straightforward.

The tag for-linus-iommufd-merged with my merge resolution to your tree
is also available to pull.

Thanks,
Jason

The following changes since commit ce9ecca0238b140b88f43859b211c9fdfd8e5b70:

  Linux 6.6-rc2 (2023-09-17 14:40:24 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

for you to fetch changes up to b2b67c997bf74453f3469d8b54e4859f190943bd:

  iommufd: Organize the mock domain alloc functions closer to Joerg's tree (2023-10-30 18:01:56 -0300)

----------------------------------------------------------------
iommufd for 6.7

This branch has three new iommufd capabilities:

 - Dirty tracking for DMA. AMD/ARM/Intel CPUs can now record if a DMA
   writes to a page in the IOPTEs within the IO page table. This can be used
   to generate a record of what memory is being dirtied by DMA activities
   during a VM migration process. A VMM like qemu will combine the IOMMU
   dirty bits with the CPU's dirty log to determine what memory to
   transfer.

   VFIO already has a DMA dirty tracking framework that requires PCI
   devices to implement tracking HW internally. The iommufd version
   provides an alternative that the VMM can select, if available. The two
   are designed to have very similar APIs.

 - Userspace controlled attributes for hardware page
   tables (HWPT/iommu_domain). There are currently a few generic attributes
   for HWPTs (support dirty tracking, and parent of a nest). This is an
   entry point for the userspace iommu driver to control the HW in detail.

 - Nested translation support for HWPTs. This is a 2D translation scheme
   similar to the CPU where a DMA goes through a first stage to determine
   an intermediate address which is then translated trough a second stage
   to a physical address.

   Like for CPU translation the first stage table would exist in VM
   controlled memory and the second stage is in the kernel and matches the
   VM's guest to physical map.

   As every IOMMU has a unique set of parameter to describe the S1 IO page
   table and its associated parameters the userspace IOMMU driver has to
   marshal the information into the correct format.

   This is 1/3 of the feature, it allows creating the nested translation
   and binding it to VFIO devices, however the API to support IOTLB and
   ATC invalidation of the stage 1 io page table, and forwarding of IO
   faults are still in progress.

The series includes AMD and Intel support for dirty tracking. Intel
support for nested translation.

Along the way are a number of internal items:

 - New iommu core items: ops->domain_alloc_user(), ops->set_dirty_tracking,
   ops->read_and_clear_dirty(), IOMMU_DOMAIN_NESTED, and iommu_copy_struct_from_user

 - UAF fix in iopt_area_split()

 - Spelling fixes and some test suite improvement

----------------------------------------------------------------
GuokaiXu (1):
      iommufd: Fix spelling errors in comments

Jason Gunthorpe (4):
      iommufd: Rename IOMMUFD_OBJ_HW_PAGETABLE to IOMMUFD_OBJ_HWPT_PAGING
      iommufd/device: Wrap IOMMUFD_OBJ_HWPT_PAGING-only configurations
      iommufd: Add iopt_area_alloc()
      iommufd: Organize the mock domain alloc functions closer to Joerg's tree

Joao Martins (19):
      vfio/iova_bitmap: Export more API symbols
      vfio: Move iova_bitmap into iommufd
      iommufd/iova_bitmap: Move symbols to IOMMUFD namespace
      iommu: Add iommu_domain ops for dirty tracking
      iommufd: Add a flag to enforce dirty tracking on attach
      iommufd: Add IOMMU_HWPT_SET_DIRTY_TRACKING
      iommufd: Add IOMMU_HWPT_GET_DIRTY_BITMAP
      iommufd: Add capabilities to IOMMU_GET_HW_INFO
      iommufd: Add a flag to skip clearing of IOPTE dirty
      iommu/amd: Add domain_alloc_user based domain allocation
      iommu/amd: Access/Dirty bit support in IOPTEs
      iommu/vt-d: Access/Dirty bit support for SS domains
      iommufd/selftest: Expand mock_domain with dev_flags
      iommufd/selftest: Test IOMMU_HWPT_ALLOC_DIRTY_TRACKING
      iommufd/selftest: Test IOMMU_HWPT_SET_DIRTY_TRACKING
      iommufd/selftest: Test IOMMU_HWPT_GET_DIRTY_BITMAP
      iommufd/selftest: Test out_capabilities in IOMMU_GET_HW_INFO
      iommufd/selftest: Test IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CLEAR flag
      iommufd/selftest: Fix page-size check in iommufd_test_dirty()

Koichiro Den (1):
      iommufd: Fix missing update of domains_itree after splitting iopt_area

Lu Baolu (6):
      iommu: Add IOMMU_DOMAIN_NESTED
      iommu/vt-d: Extend dmar_domain to support nested domain
      iommu/vt-d: Add helper for nested domain allocation
      iommu/vt-d: Add helper to setup pasid nested translation
      iommu/vt-d: Add nested domain allocation
      iommu/vt-d: Disallow read-only mappings to nest parent domain

Nicolin Chen (10):
      iommufd/selftest: Iterate idev_ids in mock_domain's alloc_hwpt test
      iommufd/selftest: Rework TEST_LENGTH to test min_size explicitly
      iommufd: Correct IOMMU_HWPT_ALLOC_NEST_PARENT description
      iommufd: Only enforce cache coherency in iommufd_hw_pagetable_alloc
      iommufd: Derive iommufd_hwpt_paging from iommufd_hw_pagetable
      iommufd: Share iommufd_hwpt_alloc with IOMMUFD_OBJ_HWPT_NESTED
      iommufd: Add a nested HW pagetable object
      iommu: Add iommu_copy_struct_from_user helper
      iommufd/selftest: Add nested domain allocation for mock domain
      iommufd/selftest: Add coverage for IOMMU_HWPT_ALLOC with nested HWPTs

Yi Liu (11):
      iommu: Add new iommu op to create domains owned by userspace
      iommufd: Use the domain_alloc_user() op for domain allocation
      iommufd: Flow user flags for domain allocation to domain_alloc_user()
      iommufd: Support allocating nested parent domain
      iommufd/selftest: Add domain_alloc_user() support in iommu mock
      iommu/vt-d: Add domain_alloc_user op
      iommu: Pass in parent domain with user_data to domain_alloc_user op
      iommu/vt-d: Enhance capability check for nested parent domain allocation
      iommufd: Add data structure for Intel VT-d stage-1 domain allocation
      iommu/vt-d: Make domain attach helpers to be extern
      iommu/vt-d: Set the nested domain to a device

 drivers/iommu/Kconfig                            |   4 +
 drivers/iommu/amd/Kconfig                        |   1 +
 drivers/iommu/amd/amd_iommu_types.h              |  12 +
 drivers/iommu/amd/io_pgtable.c                   |  68 ++++
 drivers/iommu/amd/iommu.c                        | 147 ++++++++-
 drivers/iommu/intel/Kconfig                      |   1 +
 drivers/iommu/intel/Makefile                     |   2 +-
 drivers/iommu/intel/iommu.c                      | 156 +++++++++-
 drivers/iommu/intel/iommu.h                      |  64 +++-
 drivers/iommu/intel/nested.c                     | 117 +++++++
 drivers/iommu/intel/pasid.c                      | 221 +++++++++++++
 drivers/iommu/intel/pasid.h                      |   6 +
 drivers/iommu/iommufd/Makefile                   |   1 +
 drivers/iommu/iommufd/device.c                   | 174 +++++++----
 drivers/iommu/iommufd/hw_pagetable.c             | 304 ++++++++++++++----
 drivers/iommu/iommufd/io_pagetable.c             | 200 +++++++++++-
 drivers/iommu/iommufd/iommufd_private.h          |  84 ++++-
 drivers/iommu/iommufd/iommufd_test.h             |  39 +++
 drivers/{vfio => iommu/iommufd}/iova_bitmap.c    |   5 +-
 drivers/iommu/iommufd/main.c                     |  17 +-
 drivers/iommu/iommufd/pages.c                    |   2 +
 drivers/iommu/iommufd/selftest.c                 | 328 ++++++++++++++++++--
 drivers/iommu/iommufd/vfio_compat.c              |   6 +-
 drivers/vfio/Makefile                            |   3 +-
 drivers/vfio/pci/mlx5/Kconfig                    |   1 +
 drivers/vfio/pci/mlx5/main.c                     |   1 +
 drivers/vfio/pci/pds/Kconfig                     |   1 +
 drivers/vfio/pci/pds/pci_drv.c                   |   1 +
 drivers/vfio/vfio_main.c                         |   1 +
 include/linux/io-pgtable.h                       |   4 +
 include/linux/iommu.h                            | 146 ++++++++-
 include/linux/iova_bitmap.h                      |  26 ++
 include/uapi/linux/iommufd.h                     | 180 ++++++++++-
 tools/testing/selftests/iommu/iommufd.c          | 379 ++++++++++++++++++++++-
 tools/testing/selftests/iommu/iommufd_fail_nth.c |   7 +-
 tools/testing/selftests/iommu/iommufd_utils.h    | 233 +++++++++++++-
 36 files changed, 2723 insertions(+), 219 deletions(-)


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2023-08-31  3:59 ` Linus Torvalds
@ 2023-08-31 16:43   ` Jason Gunthorpe
  0 siblings, 0 replies; 31+ messages in thread
From: Jason Gunthorpe @ 2023-08-31 16:43 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

On Wed, Aug 30, 2023 at 08:59:15PM -0700, Linus Torvalds wrote:
> On Wed, 30 Aug 2023 at 16:40, Jason Gunthorpe <jgg@nvidia.com> wrote:
> >
> > This includes a shared branch with VFIO:
> >
> >  - Enhance VFIO_DEVICE_GET_PCI_HOT_RESET_INFO so it can work with iommufd
> >    FDs, not just group FDs. [...]
> 
> So because I had pulled the vfio changes independently with their own
> merge message, I ended up editing out all the commentary you had about
> the vfio side of the changes.
> 
> Which is kind of sad, since you arguably put some more information and
> effort into it than Alex had done in his vfio pull request. But the
> vfio parts just weren't part of the merge any more.
> 
> I did put a link to your pull request in the commit, so people can
> find this info, but I thought I'd mention how I ruthlessly edited down
> the merge commit message to just the parts that were new to the merge.
> 
> I appreciate the extra background, even if I then decided that by the
> time I merged your part, some of it was "old news" and not actually
> about what I merged when I pulled your branch.
> 
> .. and if I had realized when I merged the vfio parts, I probably
> could have added your commentary to that merge. Oh well.

Thanks, I've been trying to make these PR emails sort of a 'state of
the union' for the project as there are a lot of collaborators
involved right now. The vfio parts are logically part of the iommufd
work.

Jason

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2023-08-30 23:40 Jason Gunthorpe
  2023-08-31  3:50 ` pr-tracker-bot
@ 2023-08-31  3:59 ` Linus Torvalds
  2023-08-31 16:43   ` Jason Gunthorpe
  1 sibling, 1 reply; 31+ messages in thread
From: Linus Torvalds @ 2023-08-31  3:59 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: iommu, kvm, linux-kernel, Kevin Tian

On Wed, 30 Aug 2023 at 16:40, Jason Gunthorpe <jgg@nvidia.com> wrote:
>
> This includes a shared branch with VFIO:
>
>  - Enhance VFIO_DEVICE_GET_PCI_HOT_RESET_INFO so it can work with iommufd
>    FDs, not just group FDs. [...]

So because I had pulled the vfio changes independently with their own
merge message, I ended up editing out all the commentary you had about
the vfio side of the changes.

Which is kind of sad, since you arguably put some more information and
effort into it than Alex had done in his vfio pull request. But the
vfio parts just weren't part of the merge any more.

I did put a link to your pull request in the commit, so people can
find this info, but I thought I'd mention how I ruthlessly edited down
the merge commit message to just the parts that were new to the merge.

I appreciate the extra background, even if I then decided that by the
time I merged your part, some of it was "old news" and not actually
about what I merged when I pulled your branch.

.. and if I had realized when I merged the vfio parts, I probably
could have added your commentary to that merge. Oh well.

                  Linus

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2023-08-30 23:40 Jason Gunthorpe
@ 2023-08-31  3:50 ` pr-tracker-bot
  2023-08-31  3:59 ` Linus Torvalds
  1 sibling, 0 replies; 31+ messages in thread
From: pr-tracker-bot @ 2023-08-31  3:50 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Linus Torvalds, iommu, kvm, linux-kernel, Kevin Tian

The pull request you sent on Wed, 30 Aug 2023 20:40:43 -0300:

> git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/4debf77169ee459c46ec70e13dc503bc25efd7d2

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [GIT PULL] Please pull IOMMUFD subsystem changes
@ 2023-08-30 23:40 Jason Gunthorpe
  2023-08-31  3:50 ` pr-tracker-bot
  2023-08-31  3:59 ` Linus Torvalds
  0 siblings, 2 replies; 31+ messages in thread
From: Jason Gunthorpe @ 2023-08-30 23:40 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

[-- Attachment #1: Type: text/plain, Size: 12007 bytes --]

Hi Linus,

This PR includes several of the items that have been in progress for quite
some time now, details in the tag.

For those following, these series are still progressing:

- User page table invalidation:
 https://lore.kernel.org/all/20230724110406.107212-1-yi.l.liu@intel.com/

- Intel VT-d nested translation:
 https://lore.kernel.org/all/20230724111335.107427-1-yi.l.liu@intel.com/

- ARM SMMv3 nested translation:
 https://lore.kernel.org/all/cover.1683688960.git.nicolinc@nvidia.com/

- Draft AMD IOMMU nested translation:
 https://lore.kernel.org/all/20230621235508.113949-1-suravee.suthikulpanit@amd.com/

There is also alot of ongoing work to generically enable PASID support in all
the IOMMU drivers:
 SMMUv3:
   https://lore.kernel.org/linux-iommu/20230621063825.268890-1-mshavit@google.com/
 AMD:
   https://lore.kernel.org/all/20230821104227.706997-1-vasant.hegde@amd.com/
   https://lore.kernel.org/all/20230821104956.707235-1-vasant.hegde@amd.com/
   https://lore.kernel.org/all/20230816174031.634453-1-vasant.hegde@amd.com/

Which will see exposure through the iommufd uAPI soon.

Along with qemu patches implementing iommufd:
 https://lore.kernel.org/all/20230830103754.36461-1-zhenzhong.duan@intel.com/

Draft patches for the qemu side support for nested translation support in
the vIOMMU drivers are linked from the above.

Thanks,
Jason

The following changes since commit 2ccdd1b13c591d306f0401d98dedc4bdcd02b421:

  Linux 6.5-rc6 (2023-08-13 11:29:55 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

for you to fetch changes up to eb501c2d96cfce6b42528e8321ea085ec605e790:

  iommufd/selftest: Don't leak the platform device memory when unloading the module (2023-08-18 12:56:24 -0300)

----------------------------------------------------------------
iommufd for 6.6

This includes a shared branch with VFIO:

 - Enhance VFIO_DEVICE_GET_PCI_HOT_RESET_INFO so it can work with iommufd
   FDs, not just group FDs. This removes the last place in the uAPI that
   required the group fd.

 - Give VFIO a new device node /dev/vfio/devices/vfioX (the so called cdev
   node) which is very similar to the FD from VFIO_GROUP_GET_DEVICE_FD.
   The cdev is associated with the struct device that the VFIO driver is
   bound to and shows up in sysfs in the normal way.

 - Add a cdev IOCTL VFIO_DEVICE_BIND_IOMMUFD which allows a newly opened
   /dev/vfio/devices/vfioX to be associated with an IOMMUFD, this replaces
   the VFIO_GROUP_SET_CONTAINER flow.

 - Add cdev IOCTLs VFIO_DEVICE_[AT|DE]TACH_IOMMUFD_PT to allow the IOMMU
   translation the vfio_device is associated with to be changed. This is a
   significant new feature for VFIO as previously each vfio_device was
   fixed to a single translation.

   The translation is under the control of iommufd, so it can be any of
   the different translation modes that iommufd is learning to create.

At this point VFIO has compilation options to remove the legacy interfaces
and in modern mode it behaves like a normal driver subsystem. The
/dev/vfio/iommu and /dev/vfio/groupX nodes are not present and each
vfio_device only has a /dev/vfio/devices/vfioX cdev node that represents
the device.

On top of this is built some of the new iommufd functionality:

 - IOMMU_HWPT_ALLOC allows userspace to directly create the low level
   IO Page table objects and affiliate them with IOAS objects that hold
   the translation mapping. This is the basic functionality for the
   normal IOMMU_DOMAIN_PAGING domains.

 - VFIO_DEVICE_ATTACH_IOMMUFD_PT can be used to replace the current
   translation. This is wired up to through all the layers down to the
   driver so the driver has the ability to implement a hitless
   replacement. This is necessary to fully support guest behaviors when
   emulating HW (eg guest atomic change of translation)

 - IOMMU_GET_HW_INFO returns information about the IOMMU driver HW that
   owns a VFIO device. This includes support for the Intel iommu, and
   patches have been posted for all the other server IOMMU.

Along the way are a number of internal items:

 - New iommufd kapis iommufd_ctx_has_group(), iommufd_device_to_ictx(),
   iommufd_device_to_id(), iommufd_access_detach(), iommufd_ctx_from_fd(),
   iommufd_device_replace()

 - iommufd now internally tracks iommu_groups as it needs some per-group
   data

 - Reorganize how the internal hwpt allocation flows to have more robust
   locking

 - Improve the access interfaces to support detach and replace of an IOAS
   from an access

 - New selftests and a rework of how the selftests creates a mock iommu
   driver to be more like a real iommu driver

----------------------------------------------------------------
Jason Gunthorpe (21):
      Merge branch 'v6.6/vfio/cdev' of https://github.com/awilliam/linux-vfio into iommufd for-next
      iommufd: Move isolated msi enforcement to iommufd_device_bind()
      iommufd: Add iommufd_group
      iommufd: Replace the hwpt->devices list with iommufd_group
      iommu: Export iommu_get_resv_regions()
      iommufd: Keep track of each device's reserved regions instead of groups
      iommufd: Use the iommufd_group to avoid duplicate MSI setup
      iommufd: Make sw_msi_start a group global
      iommufd: Move putting a hwpt to a helper function
      iommufd: Add enforced_cache_coherency to iommufd_hw_pagetable_alloc()
      iommufd: Allow a hwpt to be aborted after allocation
      iommufd: Fix locking around hwpt allocation
      iommufd: Reorganize iommufd_device_attach into iommufd_device_change_pt
      iommufd: Add iommufd_device_replace()
      iommufd: Make destroy_rwsem use a lock class per object type
      iommufd: Add IOMMU_HWPT_ALLOC
      iommufd/selftest: Return the real idev id from selftest mock_domain
      iommufd/selftest: Add a selftest for IOMMU_HWPT_ALLOC
      iommufd/selftest: Make the mock iommu driver into a real driver
      Merge tag 'v6.5-rc6' into iommufd for-next
      iommufd: Remove iommufd_ref_to_users()

Lu Baolu (1):
      iommu: Add new iommu op to get iommu hardware information

Nicolin Chen (11):
      iommufd/device: Add iommufd_access_detach() API
      iommu: Introduce a new iommu_group_replace_domain() API
      iommufd/selftest: Test iommufd_device_replace()
      vfio: Do not allow !ops->dma_unmap in vfio_pin/unpin_pages()
      iommufd: Allow passing in iopt_access_list_id to iopt_remove_access()
      iommufd: Add iommufd_access_change_ioas(_id) helpers
      iommufd: Use iommufd_access_change_ioas in iommufd_access_destroy_object
      iommufd: Add iommufd_access_replace() API
      iommufd/selftest: Add IOMMU_TEST_OP_ACCESS_REPLACE_IOAS coverage
      vfio: Support IO page table replacement
      iommufd/selftest: Add coverage for IOMMU_GET_HW_INFO ioctl

Yang Yingliang (1):
      iommufd/selftest: Don't leak the platform device memory when unloading the module

Yi Liu (38):
      vfio/pci: Update comment around group_fd get in vfio_pci_ioctl_pci_hot_reset()
      vfio/pci: Move the existing hot reset logic to be a helper
      iommufd: Reserve all negative IDs in the iommufd xarray
      iommufd: Add iommufd_ctx_has_group()
      iommufd: Add helper to retrieve iommufd_ctx and devid
      vfio: Mark cdev usage in vfio_device
      vfio: Add helper to search vfio_device in a dev_set
      vfio/pci: Extend VFIO_DEVICE_GET_PCI_HOT_RESET_INFO for vfio device cdev
      vfio/pci: Copy hot-reset device info to userspace in the devices loop
      vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET
      vfio: Allocate per device file structure
      vfio: Refine vfio file kAPIs for KVM
      vfio: Accept vfio device file in the KVM facing kAPI
      kvm/vfio: Prepare for accepting vfio device fd
      kvm/vfio: Accept vfio device file from userspace
      vfio: Pass struct vfio_device_file * to vfio_device_open/close()
      vfio: Block device access via device fd until device is opened
      vfio: Add cdev_device_open_cnt to vfio_group
      vfio: Make vfio_df_open() single open for device cdev path
      vfio-iommufd: Move noiommu compat validation out of vfio_iommufd_bind()
      vfio-iommufd: Split bind/attach into two steps
      vfio: Record devid in vfio_device_file
      vfio-iommufd: Add detach_ioas support for physical VFIO devices
      vfio-iommufd: Add detach_ioas support for emulated VFIO devices
      vfio: Move vfio_device_group_unregister() to be the first operation in unregister
      vfio: Move device_del() before waiting for the last vfio_device registration refcount
      vfio: Add cdev for vfio_device
      vfio: Test kvm pointer in _vfio_device_get_kvm_safe()
      iommufd: Add iommufd_ctx_from_fd()
      vfio: Avoid repeated user pointer cast in vfio_device_fops_unl_ioctl()
      vfio: Add VFIO_DEVICE_BIND_IOMMUFD
      vfio: Add VFIO_DEVICE_[AT|DE]TACH_IOMMUFD_PT
      vfio: Move the IOMMU_CAP_CACHE_COHERENCY check in __vfio_register_dev()
      vfio: Compile vfio_group infrastructure optionally
      docs: vfio: Add vfio device cdev description
      iommu: Move dev_iommu_ops() to private header
      iommufd: Add IOMMU_GET_HW_INFO
      iommu/vt-d: Implement hw_info for iommu capability query

 Documentation/driver-api/vfio.rst                | 147 ++++-
 Documentation/virt/kvm/devices/vfio.rst          |  47 +-
 drivers/gpu/drm/i915/gvt/kvmgt.c                 |   1 +
 drivers/iommu/intel/iommu.c                      |  19 +
 drivers/iommu/iommu-priv.h                       |  30 +
 drivers/iommu/iommu.c                            |  81 ++-
 drivers/iommu/iommufd/Kconfig                    |   4 +-
 drivers/iommu/iommufd/device.c                   | 801 ++++++++++++++++++-----
 drivers/iommu/iommufd/hw_pagetable.c             | 112 +++-
 drivers/iommu/iommufd/io_pagetable.c             |  36 +-
 drivers/iommu/iommufd/iommufd_private.h          |  86 +--
 drivers/iommu/iommufd/iommufd_test.h             |  19 +
 drivers/iommu/iommufd/main.c                     |  61 +-
 drivers/iommu/iommufd/selftest.c                 | 213 ++++--
 drivers/s390/cio/vfio_ccw_ops.c                  |   1 +
 drivers/s390/crypto/vfio_ap_ops.c                |   1 +
 drivers/vfio/Kconfig                             |  27 +
 drivers/vfio/Makefile                            |   3 +-
 drivers/vfio/device_cdev.c                       | 228 +++++++
 drivers/vfio/fsl-mc/vfio_fsl_mc.c                |   1 +
 drivers/vfio/group.c                             | 173 +++--
 drivers/vfio/iommufd.c                           | 145 +++-
 drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c   |   2 +
 drivers/vfio/pci/mlx5/main.c                     |   1 +
 drivers/vfio/pci/vfio_pci.c                      |   1 +
 drivers/vfio/pci/vfio_pci_core.c                 | 250 ++++---
 drivers/vfio/platform/vfio_amba.c                |   1 +
 drivers/vfio/platform/vfio_platform.c            |   1 +
 drivers/vfio/vfio.h                              | 218 +++++-
 drivers/vfio/vfio_main.c                         | 258 +++++++-
 include/linux/iommu.h                            |  16 +-
 include/linux/iommufd.h                          |   9 +
 include/linux/vfio.h                             |  66 +-
 include/uapi/linux/iommufd.h                     |  97 +++
 include/uapi/linux/kvm.h                         |  13 +-
 include/uapi/linux/vfio.h                        | 148 ++++-
 samples/vfio-mdev/mbochs.c                       |   1 +
 samples/vfio-mdev/mdpy.c                         |   1 +
 samples/vfio-mdev/mtty.c                         |   1 +
 tools/testing/selftests/iommu/iommufd.c          | 130 +++-
 tools/testing/selftests/iommu/iommufd_fail_nth.c |  71 +-
 tools/testing/selftests/iommu/iommufd_utils.h    | 144 +++-
 virt/kvm/vfio.c                                  | 137 ++--
 43 files changed, 3130 insertions(+), 672 deletions(-)
 create mode 100644 drivers/iommu/iommu-priv.h
 create mode 100644 drivers/vfio/device_cdev.c

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2023-07-28 13:48 Jason Gunthorpe
@ 2023-07-28 18:39 ` pr-tracker-bot
  0 siblings, 0 replies; 31+ messages in thread
From: pr-tracker-bot @ 2023-07-28 18:39 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Linus Torvalds, iommu, kvm, linux-kernel, Kevin Tian

The pull request you sent on Fri, 28 Jul 2023 10:48:08 -0300:

> git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/0299a13af0be43f2679047c7236e3a58e587f3f8

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [GIT PULL] Please pull IOMMUFD subsystem changes
@ 2023-07-28 13:48 Jason Gunthorpe
  2023-07-28 18:39 ` pr-tracker-bot
  0 siblings, 1 reply; 31+ messages in thread
From: Jason Gunthorpe @ 2023-07-28 13:48 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

[-- Attachment #1: Type: text/plain, Size: 1369 bytes --]

Hi Linus,

Small rc update for some recently found bugs

Thanks,
Jason

The following changes since commit 6eaae198076080886b9e7d57f4ae06fa782f90ef:

  Linux 6.5-rc3 (2023-07-23 15:24:10 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

for you to fetch changes up to b7c822fa6b7701b17e139f1c562fc24135880ed4:

  iommufd: Set end correctly when doing batch carry (2023-07-27 11:27:20 -0300)

----------------------------------------------------------------
iommufd for 6.5 rc

Two user triggerable problems:

- Syzkaller found a way to trigger a WARN_ON and leak memory by racing
  destroy with other actions

- There is still a bug in the "batch carry" stuff that gets invoked for
  complex cases with accesses and unmapping of huge pages. The test suite
  found this (triggers rarely)

----------------------------------------------------------------
Jason Gunthorpe (2):
      iommufd: IOMMUFD_DESTROY should not increase the refcount
      iommufd: Set end correctly when doing batch carry

 drivers/iommu/iommufd/device.c          | 12 ++---
 drivers/iommu/iommufd/iommufd_private.h | 15 ++++++-
 drivers/iommu/iommufd/main.c            | 78 +++++++++++++++++++++++++--------
 drivers/iommu/iommufd/pages.c           |  2 +-
 4 files changed, 76 insertions(+), 31 deletions(-)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2023-06-28 14:04 Jason Gunthorpe
@ 2023-06-30  4:16 ` pr-tracker-bot
  0 siblings, 0 replies; 31+ messages in thread
From: pr-tracker-bot @ 2023-06-30  4:16 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Linus Torvalds, iommu, kvm, linux-kernel, Kevin Tian

The pull request you sent on Wed, 28 Jun 2023 11:04:20 -0300:

> git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/31929ae00890d921618b0b449722dcdf4a4416cc

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [GIT PULL] Please pull IOMMUFD subsystem changes
@ 2023-06-28 14:04 Jason Gunthorpe
  2023-06-30  4:16 ` pr-tracker-bot
  0 siblings, 1 reply; 31+ messages in thread
From: Jason Gunthorpe @ 2023-06-28 14:04 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

[-- Attachment #1: Type: text/plain, Size: 1168 bytes --]

Hi Linus,

Just two rc syzkaller fixes for this merge window. It looks like the
vfio changes are now done so we should see progress next cycle.

Thanks,
Jason

The following changes since commit 6995e2de6891c724bfeb2db33d7b87775f913ad1:

  Linux 6.4 (2023-06-25 16:29:58 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

for you to fetch changes up to dbe245cdf5189e88d680379ed13901356628b650:

  iommufd: Call iopt_area_contig_done() under the lock (2023-06-26 09:00:23 -0300)

----------------------------------------------------------------
iommufd for 6.5

Just two RC syzkaller fixes, both for the same basic issue, using the area
pointer during an access forced unmap while the locks protecting it were
let go.

----------------------------------------------------------------
Jason Gunthorpe (2):
      iommufd: Do not access the area pointer after unlocking
      iommufd: Call iopt_area_contig_done() under the lock

 drivers/iommu/iommufd/device.c       |  2 +-
 drivers/iommu/iommufd/io_pagetable.c | 14 +++++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2023-04-25 14:46 Jason Gunthorpe
@ 2023-04-27 17:15 ` pr-tracker-bot
  0 siblings, 0 replies; 31+ messages in thread
From: pr-tracker-bot @ 2023-04-27 17:15 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Linus Torvalds, iommu, kvm, linux-kernel, Kevin Tian

The pull request you sent on Tue, 25 Apr 2023 11:46:17 -0300:

> git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/6df969b77ecc2ba21dcd0e57f416e58bec2a5ca1

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [GIT PULL] Please pull IOMMUFD subsystem changes
@ 2023-04-25 14:46 Jason Gunthorpe
  2023-04-27 17:15 ` pr-tracker-bot
  0 siblings, 1 reply; 31+ messages in thread
From: Jason Gunthorpe @ 2023-04-25 14:46 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

[-- Attachment #1: Type: text/plain, Size: 5534 bytes --]

Hi Linus,

We did not manage to get the VFIO parts ready for this cycle, but it
looks really close now. Here is the stuff still in progress:

- VFIO PCI hot reset support for iommufd:
  https://lore.kernel.org/kvm/20230401144429.88673-1-yi.l.liu@intel.com/

- VFIO device cdev support to allow exposing all the iommufd features:
  https://lore.kernel.org/kvm/20230401151833.124749-1-yi.l.liu@intel.com/

- iommufd page table replace operation:
  https://lore.kernel.org/kvm/0-v6-fdb604df649a+369-iommufd_alloc_jgg@nvidia.com/

- IOMMU driver information query:
  https://lore.kernel.org/kvm/20230309075358.571567-1-yi.l.liu@intel.com/

- Intel VT-d nested translation:
  https://lore.kernel.org/kvm/20230309082207.612346-1-yi.l.liu@intel.com/

- ARM SMMUv3 nested translation:
  https://lore.kernel.org/linux-iommu/cover.1678348754.git.nicolinc@nvidia.com/

Along with qemu patches implementing iommufd:
https://lore.kernel.org/qemu-devel/20230131205305.2726330-1-eric.auger@redhat.com/

And draft patches for the qemu side support for nested translation.

This PR is some small fixes and two preperatory reworks for the above
series.

Thanks,
Jason

The following changes since commit 13a0d1ae7ee6b438f5537711a8c60cba00554943:

  iommufd: Do not corrupt the pfn list when doing batch carry (2023-04-04 09:10:55 -0300)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

for you to fetch changes up to 62e37c86bf0718e1ec0156c7a88a43ced6cdf201:

  iommufd/selftest: Cover domain unmap with huge pages and access (2023-04-04 13:11:24 -0300)

----------------------------------------------------------------
iommufd for 6.4

Two series:

 - Reorganize how the hardware page table objects are managed,
   particularly their destruction flow. Increase the selftest
   test coverage in this area by creating a more complete mock
   iommu driver.

   This is preparation to add a replace operation for HWPT binding,
   which is done but waiting for the VFIO parts to complete so there
   is a user.

 - Split the iommufd support for "access" to make it two step - allocate
   an access then link it to an IOAS. Update VFIO and have VFIO always
   create an access even for the VFIO mdevs that never do DMA.

   This is also preperation for the replace VFIO series that will allow
   replace to work on access types as well.

Three minor fixes:

 - Sykzaller found the selftest code didn't check for overflow when
   processing user VAs

 - smatch noted a .data item should have been static

 - Add a selftest that reproduces a syzkaller bug for batch carry already
   fixed in rc

----------------------------------------------------------------
Jason Gunthorpe (16):
      iommufd: Assert devices_lock for iommufd_hw_pagetable_has_group()
      iommufd: Add iommufd_lock_obj() around the auto-domains hwpts
      iommufd: Consistently manage hwpt_item
      iommufd: Move ioas related HWPT destruction into iommufd_hw_pagetable_destroy()
      iommufd: Move iommufd_device to iommufd_private.h
      iommufd: Make iommufd_hw_pagetable_alloc() do iopt_table_add_domain()
      iommufd/selftest: Rename the sefltest 'device_id' to 'stdev_id'
      iommufd/selftest: Rename domain_id to stdev_id for FIXTURE iommufd_ioas
      iommufd/selftest: Rename domain_id to hwpt_id for FIXTURE iommufd_mock_domain
      iommufd/selftest: Rename the remaining mock device_id's to stdev_id
      iommufd/selftest: Make selftest create a more complete mock device
      iommufd/selftest: Add a selftest for iommufd_device_attach() with a hwpt argument
      iommufd/selftest: Catch overflow of uptr and length
      Merge branch 'vfio_mdev_ops' into iommufd.git for-next
      Merge branch 'iommufd/for-rc' into for-next
      iommufd/selftest: Cover domain unmap with huge pages and access

Nicolin Chen (1):
      iommufd: Create access in vfio_iommufd_emulated_bind()

Tom Rix (1):
      iommufd/selftest: Set varaiable mock_iommu_device storage-class-specifier to static

Yi Liu (5):
      iommu/iommufd: Pass iommufd_ctx pointer in iommufd_get_ioas()
      vfio-iommufd: No need to record iommufd_ctx in vfio_device
      vfio-iommufd: Make vfio_iommufd_emulated_bind() return iommufd_access ID
      vfio/mdev: Uses the vfio emulated iommufd ops set in the mdev sample drivers
      vfio: Check the presence for iommufd callbacks in __vfio_register_dev()

 drivers/iommu/iommufd/device.c                   | 205 +++++++++------------
 drivers/iommu/iommufd/hw_pagetable.c             |  70 ++++++--
 drivers/iommu/iommufd/ioas.c                     |  14 +-
 drivers/iommu/iommufd/iommufd_private.h          |  39 +++-
 drivers/iommu/iommufd/iommufd_test.h             |   2 +-
 drivers/iommu/iommufd/selftest.c                 | 219 +++++++++++++++++++----
 drivers/iommu/iommufd/vfio_compat.c              |   2 +-
 drivers/vfio/iommufd.c                           |  37 ++--
 drivers/vfio/vfio_main.c                         |   5 +-
 include/linux/iommufd.h                          |   5 +-
 include/linux/vfio.h                             |   1 -
 samples/vfio-mdev/mbochs.c                       |   3 +
 samples/vfio-mdev/mdpy.c                         |   3 +
 samples/vfio-mdev/mtty.c                         |   3 +
 tools/testing/selftests/iommu/iommufd.c          | 104 +++++++----
 tools/testing/selftests/iommu/iommufd_fail_nth.c |  38 ++--
 tools/testing/selftests/iommu/iommufd_utils.h    |  16 +-
 17 files changed, 494 insertions(+), 272 deletions(-)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2023-04-06 13:34 Jason Gunthorpe
@ 2023-04-06 18:46 ` pr-tracker-bot
  0 siblings, 0 replies; 31+ messages in thread
From: pr-tracker-bot @ 2023-04-06 18:46 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Linus Torvalds, iommu, kvm, linux-kernel, Kevin Tian

The pull request you sent on Thu, 6 Apr 2023 10:34:39 -0300:

> git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/105b64c83872c39d86c1e3dea9ee4185c62114dc

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [GIT PULL] Please pull IOMMUFD subsystem changes
@ 2023-04-06 13:34 Jason Gunthorpe
  2023-04-06 18:46 ` pr-tracker-bot
  0 siblings, 1 reply; 31+ messages in thread
From: Jason Gunthorpe @ 2023-04-06 13:34 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

[-- Attachment #1: Type: text/plain, Size: 1667 bytes --]

Hi Linus,

Three bug fixes that a syzkaller instance found in iommufd. We added
some selftest coverage for this, but it will come in the merge window
as it depends on some other selftest changes.

I'm pretty happy with this as it shows the selftest setup is allowing
syzkaller into code paths that would normally be only reached by
in-kernel VFIO mdev drivers. These are bugs that the normal vGVT and
S390 vfio-mdev test suites didn't find.

Thanks,
Jason

The following changes since commit 7e364e56293bb98cae1b55fd835f5991c4e96e7d:

  Linux 6.3-rc5 (2023-04-02 14:29:29 -0700)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

for you to fetch changes up to 13a0d1ae7ee6b438f5537711a8c60cba00554943:

  iommufd: Do not corrupt the pfn list when doing batch carry (2023-04-04 09:10:55 -0300)

----------------------------------------------------------------
iommufd for 6.3 rc

Three bugs found by syzkaller:

 - An invalid VA range can be be put in a pages and eventually trigger
   WARN_ON, reject it early

 - Use of the wrong start index value when doing the complex batch carry
   scheme

 - Wrong store ordering resulting in corrupting data used in a later
   calculation that corrupted the batch structure during carry

----------------------------------------------------------------
Jason Gunthorpe (3):
      iommufd: Check for uptr overflow
      iommufd: Fix unpinning of pages when an access is present
      iommufd: Do not corrupt the pfn list when doing batch carry

 drivers/iommu/iommufd/pages.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2023-02-25  0:02   ` Jason Gunthorpe
@ 2023-02-25  0:50     ` Linus Torvalds
  0 siblings, 0 replies; 31+ messages in thread
From: Linus Torvalds @ 2023-02-25  0:50 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: iommu, kvm, linux-kernel, Kevin Tian

On Fri, Feb 24, 2023 at 4:02 PM Jason Gunthorpe <jgg@nvidia.com> wrote:
>
> Do you like this sort of explanation in the email or the tag?

Either works, I really don't have a strong preference. Some people do
one, others do the other. And some people (like Rafael) do both - with
the summary list in the tag (and thus also as part of the pull
request), but an overview at the top of the email.

> Honestly, after 5 years (wow time flies) of sending PRs for rdma I'm
> still a bit unclear on the best way to write the tag message.

Heh. Probably because there isn't any "one correct" way. Whatever
works best for you.

The thing I personally care about is just that there _is_ an
explanation, and that it makes sense in the context of a human reader
who looks at the merge later.

So no automatically generated stuff that you could just get with some
git command anyway, but an actual overview.

And I'll edit things to make sense in a commit message anyway, so I'll
remove language like "This pull request contains.." because that
doesn't make sense once it's just a merge commit and no longer is a
pull request.

So I'll generally edit that kind of laniage down to "This contains.."
instead or something like that.

I also try to *generally* make the merge commit messages look roughly
the same, so that when people use wildly different whitespace (tabs vs
spaces) or use different bullet points - "-" vs "o" vs "*" etc) I
generally try to make those kinds of things also be at least
*somewhat* consistent.

And for that, it can certainly make my life easier if you look at what
merge messages look like, and don't try to make your pull request
message wildly different. But it's really not a big deal - I do that
kind of reformatting as part of simply reading the message, so it's
all fine.

Finally - remember that the merge message is for humans reading it
later, and not everybody necessarily knows the TLA's that may be
obvious to you as a maintainer of that subsystem. So try to make it
somewhat legible to a general (kernel developer) public.

And then if I feel like the message doesn't cover all of the changes,
I'll prod you, like I did in this case.

               Linus

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2023-02-24 22:50 ` Linus Torvalds
@ 2023-02-25  0:02   ` Jason Gunthorpe
  2023-02-25  0:50     ` Linus Torvalds
  0 siblings, 1 reply; 31+ messages in thread
From: Jason Gunthorpe @ 2023-02-25  0:02 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

On Fri, Feb 24, 2023 at 02:50:45PM -0800, Linus Torvalds wrote:
> On Tue, Feb 21, 2023 at 7:39 AM Jason Gunthorpe <jgg@nvidia.com> wrote:
> >
> > iommufd for 6.3
> >
> > Some polishing and small fixes for iommufd:
> 
> Hmm. About half the patches seem to not be about iommufd, but about
> 'isolated_msi', which isn't even mentioned in the pull request at all
> (well, it's there in the shortlog, but not in the actual "this is what
> happened")

Ah, it is perhaps somewhat cryptically mentioned in the tag:

"Remove IOMMU_CAP_INTR_REMAP, instead rely on the interrupt subsystem"

In retrospect I can see that is pretty obtuse, but from my POV that
was the goal of that series :)

> I already merged it, and am not sure what I would add to the commit
> message, but I really would have liked to see that mentioned,
> considering that it wasn't some small part of it all.

I think the missing paragraph is something like:

 This PR includes some rework of MSI isolation/security capability
 detection that touches irq, iommu, vfio and iommufd. It consolidates
 two partially overlapping approaches into a single one.

Do you like this sort of explanation in the email or the tag?

Honestly, after 5 years (wow time flies) of sending PRs for rdma I'm
still a bit unclear on the best way to write the tag message.

I suppose you noticed, but I've followed John Corbet's suggestion to
capture the cover letters in internal merge commits. Eg isolated-msi
has a lot of words in commit fc3873095a

Thanks,
Jason

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2023-02-21 15:39 Jason Gunthorpe
  2023-02-24 22:50 ` Linus Torvalds
@ 2023-02-24 23:27 ` pr-tracker-bot
  1 sibling, 0 replies; 31+ messages in thread
From: pr-tracker-bot @ 2023-02-24 23:27 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Linus Torvalds, iommu, kvm, linux-kernel, Kevin Tian

The pull request you sent on Tue, 21 Feb 2023 11:39:51 -0400:

> git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/143c7bc6496c886ce5db2a2f9cec580494690170

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [GIT PULL] Please pull IOMMUFD subsystem changes
  2023-02-21 15:39 Jason Gunthorpe
@ 2023-02-24 22:50 ` Linus Torvalds
  2023-02-25  0:02   ` Jason Gunthorpe
  2023-02-24 23:27 ` pr-tracker-bot
  1 sibling, 1 reply; 31+ messages in thread
From: Linus Torvalds @ 2023-02-24 22:50 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: iommu, kvm, linux-kernel, Kevin Tian

On Tue, Feb 21, 2023 at 7:39 AM Jason Gunthorpe <jgg@nvidia.com> wrote:
>
> iommufd for 6.3
>
> Some polishing and small fixes for iommufd:

Hmm. About half the patches seem to not be about iommufd, but about
'isolated_msi', which isn't even mentioned in the pull request at all
(well, it's there in the shortlog, but not in the actual "this is what
happened")

I already merged it, and am not sure what I would add to the commit
message, but I really would have liked to see that mentioned,
considering that it wasn't some small part of it all.

              Linus

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [GIT PULL] Please pull IOMMUFD subsystem changes
@ 2023-02-21 15:39 Jason Gunthorpe
  2023-02-24 22:50 ` Linus Torvalds
  2023-02-24 23:27 ` pr-tracker-bot
  0 siblings, 2 replies; 31+ messages in thread
From: Jason Gunthorpe @ 2023-02-21 15:39 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: iommu, kvm, linux-kernel, Kevin Tian

[-- Attachment #1: Type: text/plain, Size: 7203 bytes --]

Hi Linus,

This PR has a few smaller updates related to iommufd. Several big topics are
currently still on the mailing list in review:

- VFIO device cdev support to allow exposing all the iommufd features:
  https://lore.kernel.org/kvm/20230221034812.138051-1-yi.l.liu@intel.com/

- iommufd page table replace operation:
  https://lore.kernel.org/kvm/cover.1675802050.git.nicolinc@nvidia.com/

- IOMMU driver information query:
  https://lore.kernel.org/r/20230209041642.9346-1-yi.l.liu@intel.com

- Intel VT-d nested translation:
  https://lore.kernel.org/r/20230209043153.14964-1-yi.l.liu@intel.com

- Draft patches for ARM SMMUv3 nested translation:
  https://github.com/nicolinc/iommufd/commits/wip/iommufd-v6.2-rc5-nesting

Along with qemu patches implementing iommufd:
https://lore.kernel.org/qemu-devel/20230131205305.2726330-1-eric.auger@redhat.com/

And draft patches for the qemu side support for nested translation.

This PR has a shared branch with Joerg's tree changing the signature of
iommu_map() to add a gfp_t. There were some conflicts with v6.2 which I've
resolved in this PR and there will be a conflict against the rpmsg tree:

 https://lore.kernel.org/r/20230127180226.783baf07@canb.auug.org.au

--- a/drivers/remoteproc/qcom_q6v5_adsp.c
+++ b/drivers/remoteproc/qcom_q6v5_adsp.c
@@ -367,7 +367,8 @@ static int adsp_map_carveout(struct rproc *rproc)
        iova =  adsp->mem_phys | (sid << 32);

        ret = iommu_map(rproc->domain, iova, adsp->mem_phys,
-                       adsp->mem_size, IOMMU_READ | IOMMU_WRITE);
+                       adsp->mem_size, IOMMU_READ | IOMMU_WRITE,
+                       GFP_KERNEL);
        if (ret) {
                dev_err(adsp->dev, "Unable to map ADSP Physical Memory\n");
                return ret;

Thanks,
Jason

The following changes since commit c9c3395d5e3dcc6daee66c6908354d47bf98cb0c:

  Linux 6.2 (2023-02-19 14:24:22 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd

for you to fetch changes up to 939204e4df962982cbc84acc26b29b421dd530a8:

  Merge tag 'v6.2' into iommufd.git for-next (2023-02-21 11:11:03 -0400)

----------------------------------------------------------------
iommufd for 6.3

Some polishing and small fixes for iommufd:

- Remove IOMMU_CAP_INTR_REMAP, instead rely on the interrupt subsystem

- Use GFP_KERNEL_ACCOUNT inside the iommu_domains

- Support VFIO_NOIOMMU mode with iommufd

- Various typos

- A list corruption bug if HWPTs are used for attach

----------------------------------------------------------------
Jason Gunthorpe (26):
      genirq/msi: Add msi_device_has_isolated_msi()
      iommu: Add iommu_group_has_isolated_msi()
      vfio/type1: Convert to iommu_group_has_isolated_msi()
      iommufd: Convert to msi_device_has_isolated_msi()
      genirq/irqdomain: Remove unused irq_domain_check_msi_remap() code
      genirq/msi: Rename IRQ_DOMAIN_MSI_REMAP to IRQ_DOMAIN_ISOLATED_MSI
      iommu/x86: Replace IOMMU_CAP_INTR_REMAP with IRQ_DOMAIN_FLAG_ISOLATED_MSI
      irq/s390: Add arch_is_isolated_msi() for s390
      iommu: Remove IOMMU_CAP_INTR_REMAP
      Merge branch 'isolated_msi' into iommufd.git for-next
      iommu: Add a gfp parameter to iommu_map()
      iommu: Remove iommu_map_atomic()
      iommu: Add a gfp parameter to iommu_map_sg()
      iommu/dma: Use the gfp parameter in __iommu_dma_alloc_noncontiguous()
      iommufd: Use GFP_KERNEL_ACCOUNT for iommu_map()
      iommu/intel: Add a gfp parameter to alloc_pgtable_page()
      iommu/intel: Support the gfp argument to the map_pages op
      iommu/intel: Use GFP_KERNEL in sleepable contexts
      iommu/s390: Push the gfp parameter to the kmem_cache_alloc()'s
      iommu/s390: Use GFP_KERNEL in sleepable contexts
      Merge branch 'iommu-memory-accounting' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/joro/iommu intoiommufd/for-next
      vfio: Support VFIO_NOIOMMU with iommufd
      Merge branch 'vfio-no-iommu' into iommufd.git for-next
      iommufd: Make sure to zero vfio_iommu_type1_info before copying to user
      iommufd: Do not add the same hwpt to the ioas->hwpt_list twice
      Merge tag 'v6.2' into iommufd.git for-next

Nicolin Chen (1):
      selftests: iommu: Fix test_cmd_destroy_access() call in user_copy

Yi Liu (1):
      iommufd: Add three missing structures in ucmd_buffer

 arch/arm/mm/dma-mapping.c                          |  11 ++-
 arch/s390/include/asm/msi.h                        |  17 ++++
 arch/s390/include/asm/pci_dma.h                    |   5 +-
 arch/s390/pci/pci_dma.c                            |  31 +++---
 .../gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c    |   3 +-
 drivers/gpu/drm/tegra/drm.c                        |   2 +-
 drivers/gpu/host1x/cdma.c                          |   2 +-
 drivers/infiniband/hw/usnic/usnic_uiom.c           |   8 +-
 drivers/iommu/amd/iommu.c                          |   5 +-
 drivers/iommu/dma-iommu.c                          |  18 +++-
 drivers/iommu/intel/iommu.c                        |  38 ++++----
 drivers/iommu/intel/iommu.h                        |   2 +-
 drivers/iommu/intel/irq_remapping.c                |   3 +-
 drivers/iommu/intel/pasid.c                        |   2 +-
 drivers/iommu/iommu.c                              |  77 ++++++++-------
 drivers/iommu/iommufd/Kconfig                      |   2 +-
 drivers/iommu/iommufd/device.c                     |   8 +-
 drivers/iommu/iommufd/iommufd_private.h            |   2 +
 drivers/iommu/iommufd/main.c                       |   3 +
 drivers/iommu/iommufd/pages.c                      |   6 +-
 drivers/iommu/iommufd/vfio_compat.c                | 107 +++++++++++++++++----
 drivers/iommu/s390-iommu.c                         |  17 ++--
 drivers/irqchip/irq-gic-v3-its.c                   |   4 +-
 drivers/media/platform/qcom/venus/firmware.c       |   2 +-
 drivers/net/ipa/ipa_mem.c                          |   6 +-
 drivers/net/wireless/ath/ath10k/snoc.c             |   2 +-
 drivers/net/wireless/ath/ath11k/ahb.c              |   4 +-
 drivers/remoteproc/remoteproc_core.c               |   5 +-
 drivers/vfio/Kconfig                               |   2 +-
 drivers/vfio/container.c                           |   7 --
 drivers/vfio/group.c                               |   7 +-
 drivers/vfio/iommufd.c                             |  19 +++-
 drivers/vfio/vfio.h                                |   8 +-
 drivers/vfio/vfio_iommu_type1.c                    |  25 ++---
 drivers/vfio/vfio_main.c                           |   7 ++
 drivers/vhost/vdpa.c                               |   2 +-
 include/linux/iommu.h                              |  33 ++-----
 include/linux/iommufd.h                            |  12 ++-
 include/linux/irqdomain.h                          |  29 +-----
 include/linux/msi.h                                |  17 ++++
 kernel/irq/irqdomain.c                             |  39 --------
 kernel/irq/msi.c                                   |  27 ++++++
 tools/testing/selftests/iommu/iommufd.c            |   2 +-
 43 files changed, 369 insertions(+), 259 deletions(-)
 create mode 100644 arch/s390/include/asm/msi.h

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2024-04-19 21:07 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-12 18:30 [GIT PULL] Please pull IOMMUFD subsystem changes Jason Gunthorpe
2022-12-14 18:04 ` pr-tracker-bot
2023-02-21 15:39 Jason Gunthorpe
2023-02-24 22:50 ` Linus Torvalds
2023-02-25  0:02   ` Jason Gunthorpe
2023-02-25  0:50     ` Linus Torvalds
2023-02-24 23:27 ` pr-tracker-bot
2023-04-06 13:34 Jason Gunthorpe
2023-04-06 18:46 ` pr-tracker-bot
2023-04-25 14:46 Jason Gunthorpe
2023-04-27 17:15 ` pr-tracker-bot
2023-06-28 14:04 Jason Gunthorpe
2023-06-30  4:16 ` pr-tracker-bot
2023-07-28 13:48 Jason Gunthorpe
2023-07-28 18:39 ` pr-tracker-bot
2023-08-30 23:40 Jason Gunthorpe
2023-08-31  3:50 ` pr-tracker-bot
2023-08-31  3:59 ` Linus Torvalds
2023-08-31 16:43   ` Jason Gunthorpe
2023-10-31 13:14 Jason Gunthorpe
2023-11-02  2:51 ` pr-tracker-bot
2023-12-04 19:35 Jason Gunthorpe
2023-12-04 21:59 ` pr-tracker-bot
2024-01-12 17:49 Jason Gunthorpe
2024-01-18 23:35 ` pr-tracker-bot
2024-02-22 13:23 Jason Gunthorpe
2024-02-22 20:03 ` pr-tracker-bot
2024-03-02  0:08 Jason Gunthorpe
2024-03-02  1:31 ` pr-tracker-bot
2024-04-19 17:29 Jason Gunthorpe
2024-04-19 21:07 ` pr-tracker-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).