Re: [PATCH v6 07/13] iommufd: Allow pt_id to carry viommu_id for IOMMU_HWPT_ALLOC

2024-10-31 Thread Nicolin Chen
On Thu, Oct 31, 2024 at 10:14:59AM -0300, Jason Gunthorpe wrote: > On Wed, Oct 30, 2024 at 02:34:33PM -0700, Nicolin Chen wrote: > > +static struct iommufd_hwpt_nested * > > +iommufd_viommu_alloc_hwpt_nested(struct iommufd_viommu *viommu, u32 flags, > > +

[PATCH v6 05/13] iommufd/viommu: Add IOMMU_VIOMMU_ALLOC ioctl

2024-10-30 Thread Nicolin Chen
Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/Makefile | 3 +- drivers/iommu/iommufd/iommufd_private.h | 3 + include/uapi/linux/iommufd.h| 40 drivers/iommu/iommufd/main.c| 6 ++ drivers/iommu/iommufd/viommu.c

[PATCH v6 07/13] iommufd: Allow pt_id to carry viommu_id for IOMMU_HWPT_ALLOC

2024-10-30 Thread Nicolin Chen
. Since a vIOMMU object holds the parent hwpt's refcount already, increase the refcount of the vIOMMU only. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 1 + include/uapi/linux/iommufd.h| 14 ++--- drivers/iommu/io

[PATCH v6 13/13] Documentation: userspace-api: iommufd: Update vIOMMU

2024-10-30 Thread Nicolin Chen
With the introduction of the new object and its infrastructure, update the doc to reflect that and add a new graph. Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- Documentation/userspace-api/iommufd.rst | 69 - 1 file changed, 68

[PATCH v6 11/13] iommufd/selftest: Add IOMMU_VIOMMU_TYPE_SELFTEST

2024-10-30 Thread Nicolin Chen
Implement the viommu alloc/free functions to increase/reduce refcount of its dependent mock iommu device. User space can verify this loop via the IOMMU_VIOMMU_TYPE_SELFTEST. Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd

[PATCH v6 10/13] iommufd/selftest: Add refcount to mock_iommu_device

2024-10-30 Thread Nicolin Chen
refcount is unbalanced. The refcount inc/dec will be added in the following patch. Suggested-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/selftest.c | 39 +--- 1 file changed, 31 inse

[PATCH v6 08/10] iommufd/selftest: Add IOMMU_TEST_OP_DEV_CHECK_CACHE test command

2024-10-30 Thread Nicolin Chen
Similar to IOMMU_TEST_OP_MD_CHECK_IOTLB verifying a mock_domain's iotlb, IOMMU_TEST_OP_DEV_CHECK_CACHE will be used to verify a mock_dev's cache. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_test.h | 5 tools/testing/selft

[PATCH v6 06/10] iommufd/viommu: Add iommufd_viommu_find_dev helper

2024-10-30 Thread Nicolin Chen
This avoids a bigger trouble of exposing struct iommufd_device and struct iommufd_vdevice in the public header. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- include/linux/iommufd.h| 8 drivers/iommu/iommufd/driver.c | 13 + 2 files changed, 21

[PATCH v6 09/10] iommufd/selftest: Add vIOMMU coverage for IOMMU_HWPT_INVALIDATE ioctl

2024-10-30 Thread Nicolin Chen
Add a viommu_cache test function to cover vIOMMU invalidations using the updated IOMMU_HWPT_INVALIDATE ioctl, which now allows passing in a vIOMMU via its hwpt_id field. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- tools/testing/selftests/iommu/iommufd_utils.h | 32 tools

[PATCH v6 06/13] iommufd: Add alloc_domain_nested op to iommufd_viommu_ops

2024-10-30 Thread Nicolin Chen
Allow IOMMU driver to use a vIOMMU object that holds a nesting parent hwpt/domain to allocate a nested domain. Suggested-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- include/linux/iommufd.h | 9 + 1 file changed, 9

[PATCH v6 01/10] iommufd/viommu: Add IOMMUFD_OBJ_VDEVICE and IOMMU_VDEVICE_ALLOC ioctl

2024-10-30 Thread Nicolin Chen
tl handler. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 18 ++ include/linux/iommufd.h | 4 ++ include/uapi/linux/iommufd.h| 22 +++ drivers/iommu/iommufd/main.c| 6 ++ drivers/iommu/iommufd/viommu.c

[PATCH v6 12/13] iommufd/selftest: Add IOMMU_VIOMMU_ALLOC test coverage

2024-10-30 Thread Nicolin Chen
Add a new iommufd_viommu FIXTURE and setup it up with a vIOMMU object. Any new vIOMMU feature will be added as a TEST_F under that. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- tools/testing/selftests/iommu/iommufd_utils.h | 28 tools/testing/selftests/iommu/iommufd.c

[PATCH v6 08/13] iommufd/selftest: Add container_of helpers

2024-10-30 Thread Nicolin Chen
Use these inline helpers to shorten those container_of lines. Note that one of them goes back and forth between iommu_domain and mock_iommu_domain, which isn't necessary. So drop its container_of. Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- dr

[PATCH v6 09/13] iommufd/selftest: Prepare for mock_viommu_alloc_domain_nested()

2024-10-30 Thread Nicolin Chen
A nested domain now can be allocated for a parent domain or for a vIOMMU object. Rework the existing allocators to prepare for the latter case. Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/selftest.c | 89

[PATCH v6 05/10] iommu: Add iommu_copy_struct_from_full_user_array helper

2024-10-30 Thread Nicolin Chen
iommu_copy_struct_from_user_array kdoc accordingly. Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- include/linux/iommu.h | 48 ++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/include/linux/iommu.h b/include/linux

[PATCH v6 10/10] Documentation: userspace-api: iommufd: Update vDEVICE

2024-10-30 Thread Nicolin Chen
With the introduction of the new object and its infrastructure, update the doc and the vIOMMU graph to reflect that. Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- Documentation/userspace-api/iommufd.rst | 41 +++-- 1 file changed, 32

[PATCH v6 00/13] iommufd: Add vIOMMU infrastructure (Part-1)

2024-10-30 Thread Nicolin Chen
MUFD_DRIVER config * Dropped useless iommu_dev point from the viommu structure * Added missing index numnbers to new types in the uAPI header * Dropped IOMMU_VIOMMU_INVALIDATE uAPI; Instead, reuse the HWPT one * Reworked mock_viommu_cache_invalidate() using the new iommu helper * Reordered details of s

[PATCH v6 04/13] iommufd: Verify object in iommufd_object_finalize/abort()

2024-10-30 Thread Nicolin Chen
more robust to verify if the xarray slot indexed by the input obj->id is having an XA_ZERO_ENTRY, which is the reserved value stored by xa_alloc via iommufd_object_alloc. Suggested-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/main.c | 16 +++- 1 file

[PATCH v6 02/13] iommufd: Move _iommufd_object_alloc helper to a sharable file

2024-10-30 Thread Nicolin Chen
remaining to be selectable for drivers to build the existing iova_bitmap.c file. Suggested-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/Kconfig | 5 drivers/iommu/iommufd/Makefile | 5 +++- drivers/iommu/iommufd/iommufd_private.h | 4 --- include

[PATCH v6 01/13] iommufd: Move struct iommufd_object to public iommufd header

2024-10-30 Thread Nicolin Chen
; }; It has to expose struct iommufd_object and enum iommufd_object_type from the core-level private header to the public iommufd header. Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 25

[PATCH v6 03/10] iommu/viommu: Add cache_invalidate to iommufd_viommu_ops

2024-10-30 Thread Nicolin Chen
This per-vIOMMU cache_invalidate op is like the cache_invalidate_user op in struct iommu_domain_ops, but wider, supporting device cache (e.g. PCI ATC invaldiations). Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- include/linux/iommufd.h | 10 ++ 1

[PATCH v6 04/10] iommufd: Allow hwpt_id to carry viommu_id for IOMMU_HWPT_INVALIDATE

2024-10-30 Thread Nicolin Chen
. Update the uAPI, kdoc, and selftest case accordingly. Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- include/uapi/linux/iommufd.h| 9 -- drivers/iommu/iommufd/hw_pagetable.c| 40 +++-- tools/testing/selftests/iommu

[PATCH v6 07/10] iommufd/selftest: Add mock_viommu_cache_invalidate

2024-10-30 Thread Nicolin Chen
Similar to the coverage of cache_invalidate_user for iotlb invalidation, add a device cache and a viommu_cache_invalidate function to test it out. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_test.h | 25 + drivers/iommu/iommufd/selftest.c

[PATCH v6 00/10] iommufd: Add vIOMMU infrastructure (Part-2: vDEVICE)

2024-10-30 Thread Nicolin Chen
unthorpe (1): iommu: Add iommu_copy_struct_from_full_user_array helper Nicolin Chen (9): iommufd/viommu: Add IOMMUFD_OBJ_VDEVICE and IOMMU_VDEVICE_ALLOC ioctl iommufd/selftest: Add IOMMU_VDEVICE_ALLOC test coverage iommu/viommu: Add cache_invalidate to iommufd_viommu_ops iommufd: Allow hwpt

[PATCH v6 02/10] iommufd/selftest: Add IOMMU_VDEVICE_ALLOC test coverage

2024-10-30 Thread Nicolin Chen
Add a vdevice_alloc op to the viommu mock_viommu_ops for the coverage of IOMMU_VIOMMU_TYPE_SELFTEST allocations. Then, add a vdevice_alloc TEST_F to cover the IOMMU_VDEVICE_ALLOC ioctl. Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- tools/testing

[PATCH v6 03/13] iommufd: Introduce IOMMUFD_OBJ_VIOMMU and its related struct

2024-10-30 Thread Nicolin Chen
iommu_domain_ops my_driver_domain_ops = { .viommu_alloc = my_driver_viommu_alloc, }; Suggested-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Jason Gunthorpe Signed-off-by: Nicolin Chen --- include/linux/iommu.h | 14 ++ include/lin

Re: [PATCH v6 12/13] iommufd/selftest: Add IOMMU_VIOMMU_ALLOC test coverage

2024-10-31 Thread Nicolin Chen
On Thu, Oct 31, 2024 at 10:16:37AM -0300, Jason Gunthorpe wrote: > On Wed, Oct 30, 2024 at 02:34:38PM -0700, Nicolin Chen wrote: > > +FIXTURE_SETUP(iommufd_viommu) > > +{ > > + self->fd = open("/dev/iommu", O_RDWR); > > + ASSERT_NE(-1, self->fd); &

Re: [PATCH v6 00/10] iommufd: Add vIOMMU infrastructure (Part-2: vDEVICE)

2024-10-31 Thread Nicolin Chen
On Thu, Oct 31, 2024 at 02:28:12PM +0800, Zhangfei Gao wrote: > On Thu, 31 Oct 2024 at 05:36, Nicolin Chen wrote: > > > > Following the previous vIOMMU series, this adds another vDEVICE structure, > > representing the association from an iommufd_device to an iommufd_viomm

Re: [PATCH v6 00/10] iommufd: Add vIOMMU infrastructure (Part-2: vDEVICE)

2024-10-31 Thread Nicolin Chen
On Thu, Oct 31, 2024 at 08:59:37AM -0300, Jason Gunthorpe wrote: > On Thu, Oct 31, 2024 at 02:28:12PM +0800, Zhangfei Gao wrote: > > > > As for the implementation of the series, add driver support in ARM SMMUv3 > > > for a real world use case. > > > > > > This series is on Github: > > > https://gi

Re: [PATCH v6 01/10] iommufd/viommu: Add IOMMUFD_OBJ_VDEVICE and IOMMU_VDEVICE_ALLOC ioctl

2024-10-31 Thread Nicolin Chen
On Thu, Oct 31, 2024 at 10:29:41AM -0300, Jason Gunthorpe wrote: > On Wed, Oct 30, 2024 at 02:35:27PM -0700, Nicolin Chen wrote: > > +void iommufd_vdevice_destroy(struct iommufd_object *obj) > > +{ > > + struct iommufd_vdevice *vdev = > > + container_of(obj,

Re: [PATCH v6 01/10] iommufd/viommu: Add IOMMUFD_OBJ_VDEVICE and IOMMU_VDEVICE_ALLOC ioctl

2024-10-31 Thread Nicolin Chen
On Thu, Oct 31, 2024 at 02:04:46PM -0300, Jason Gunthorpe wrote: > On Thu, Oct 31, 2024 at 09:56:37AM -0700, Nicolin Chen wrote: > > On Thu, Oct 31, 2024 at 10:29:41AM -0300, Jason Gunthorpe wrote: > > > On Wed, Oct 30, 2024 at 02:35:27PM -0700, Nicolin Chen wr

Re: [PATCH v6 01/10] iommufd/viommu: Add IOMMUFD_OBJ_VDEVICE and IOMMU_VDEVICE_ALLOC ioctl

2024-11-07 Thread Nicolin Chen
On Thu, Nov 07, 2024 at 09:11:27PM +1100, Alexey Kardashevskiy wrote: > On 31/10/24 08:35, Nicolin Chen wrote: > > Introduce a new IOMMUFD_OBJ_VDEVICE to represent a physical device (struct > > device) against a vIOMMU (struct iommufd_viommu) object in a VM. > > > > T

Re: [PATCH v7 13/13] Documentation: userspace-api: iommufd: Update vIOMMU

2024-11-06 Thread Nicolin Chen
On Thu, Nov 07, 2024 at 10:20:49AM +0700, Bagas Sanjaya wrote: > On Wed, Nov 06, 2024 at 05:35:45PM -0800, Nicolin Chen wrote: > > On Thu, Nov 07, 2024 at 07:56:31AM +0700, Bagas Sanjaya wrote: > > > On Tue, Nov 05, 2024 at 12:04:29PM -0800, Nicolin Chen wrote: > > > >

Re: [PATCH v6 05/13] iommufd/viommu: Add IOMMU_VIOMMU_ALLOC ioctl

2024-11-06 Thread Nicolin Chen
On Thu, Nov 07, 2024 at 12:37:59PM +1100, Alexey Kardashevskiy wrote: > On 31/10/24 08:34, Nicolin Chen wrote: > > +int iommufd_viommu_alloc_ioctl(struct iommufd_ucmd *ucmd) > > +{ > > + struct iommu_viommu_alloc *cmd = ucmd->cmd; > > + struct io

Re: [PATCH v7 13/13] Documentation: userspace-api: iommufd: Update vIOMMU

2024-11-06 Thread Nicolin Chen
On Thu, Nov 07, 2024 at 07:56:31AM +0700, Bagas Sanjaya wrote: > On Tue, Nov 05, 2024 at 12:04:29PM -0800, Nicolin Chen wrote: > > With the introduction of the new object and its infrastructure, update the > > doc to reflect that and add a new graph. > > > > R

Re: [PATCH v7 13/13] Documentation: userspace-api: iommufd: Update vIOMMU

2024-11-15 Thread Nicolin Chen
On Thu, Nov 14, 2024 at 12:20:10PM -0400, Jason Gunthorpe wrote: > On Wed, Nov 13, 2024 at 07:18:42PM -0800, Nicolin Chen wrote: > > > so the user would try to create vDevices with a given viommu_obj until > > > failure, then it would allocate another viommu_obj for the faile

Re: [PATCH v7 13/13] Documentation: userspace-api: iommufd: Update vIOMMU

2024-11-13 Thread Nicolin Chen
On Thu, Nov 14, 2024 at 11:13:00AM +0800, Yi Liu wrote: > On 2024/11/14 08:18, Nicolin Chen wrote: > > On Tue, Nov 12, 2024 at 09:15:02PM +0800, Yi Liu wrote: > > > On 2024/11/6 04:04, Nicolin Chen wrote: > > > > +5. IOMMUFD_OBJ_VIOMMU can be

Re: [PATCH v7 13/13] Documentation: userspace-api: iommufd: Update vIOMMU

2024-11-13 Thread Nicolin Chen
On Tue, Nov 12, 2024 at 09:15:02PM +0800, Yi Liu wrote: > On 2024/11/6 04:04, Nicolin Chen wrote: > > +5. IOMMUFD_OBJ_VIOMMU can be only manually created via the > > IOMMU_VIOMMU_ALLOC > > + uAPI, provided a dev_id (for the device's physical IOMMU to back the > >

[PATCH v2 07/13] iommufd/viommu: Add iommufd_viommu_report_irq helper

2024-12-03 Thread Nicolin Chen
Similar to iommu_report_device_fault, this allows IOMMU drivers to report, from threaded IRQ handlers to user space hypervisors, IRQs or events that belong to a vIOMMU. Signed-off-by: Nicolin Chen --- include/linux/iommufd.h| 9 drivers/iommu/iommufd/driver.c | 41

[PATCH v2 09/13] iommufd/selftest: Add IOMMU_TEST_OP_TRIGGER_VIRQ for vIRQ coverage

2024-12-03 Thread Nicolin Chen
The handler will get vDEVICE object from the given mdev and convert it to its per-vIOMMU virtual ID to mimic a real IOMMU driver. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_test.h | 10 ++ drivers/iommu/iommufd/selftest.c | 30 2 files

[PATCH v2 12/13] iommu/arm-smmu-v3: Introduce struct arm_smmu_vmaster

2024-12-03 Thread Nicolin Chen
ops don't call arm_smmu_attach_prepare/commit(), thus simply call the new helpers at the top. Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 23 + .../arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 49 +++ drivers/iommu/arm/arm-smmu-v

[PATCH v2 02/13] iommufd/fault: Move iommufd_fault_iopf_handler() to header

2024-12-03 Thread Nicolin Chen
iommufd_fault_iopf_handler() in the header too, since it's quite simple after all. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 20 +++- drivers/iommu/iommufd/fault.c | 17 - 2 files changed, 19 insertions(+), 18 deletions(-) diff --

[PATCH v2 04/13] iommufd: Rename fault.c to eventq.c

2024-12-03 Thread Nicolin Chen
Rename the file, aligning with the new eventq object. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/Makefile | 2 +- drivers/iommu/iommufd/{fault.c => eventq.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename drivers/iommu/iommufd/{fault.c => eventq.c

[PATCH v2 03/13] iommufd: Rename IOMMUFD_OBJ_FAULT to IOMMUFD_OBJ_EVENTQ_IOPF

2024-12-03 Thread Nicolin Chen
out a minimal level of renamings to all the related functions. Add a common iommufd_eventq_ops and iommufd_eventq_init to prepare for an IOMMUFD_OBJ_EVENTQ_VIRQ. Also, add missing xa_destroy and mutex_destroy in iommufd_fault_destroy(). Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iom

[PATCH v2 13/13] iommu/arm-smmu-v3: Report IRQs that belong to devices attached to vIOMMU

2024-12-03 Thread Nicolin Chen
Aside from the IOPF framework, iommufd provides an additional pathway to report a hardware event or IRQ, via the vIRQ of vIOMMU infrastructure. Define an iommu_virq_arm_smmuv3 uAPI structure, and report stage-1 faults in the threaded IRQ handler. Signed-off-by: Nicolin Chen --- drivers/iommu

[PATCH v2 05/13] iommufd: Add IOMMUFD_OBJ_EVENTQ_VIRQ and IOMMUFD_CMD_VIRQ_ALLOC

2024-12-03 Thread Nicolin Chen
Allow a vIOMMU object to allocate vIRQ Event Queues, with a condition that each vIOMMU can only have one single vIRQ event queue per type. Add iommufd_eventq_virq_alloc with an iommufd_eventq_virq_ops for this new ioctl. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h

[PATCH v2 06/13] iommufd/viommu: Add iommufd_viommu_get_vdev_id helper

2024-12-03 Thread Nicolin Chen
-off-by: Nicolin Chen --- include/linux/iommufd.h| 8 drivers/iommu/iommufd/driver.c | 18 ++ 2 files changed, 26 insertions(+) diff --git a/include/linux/iommufd.h b/include/linux/iommufd.h index 40cc9bbb1d24..1f5376476cfa 100644 --- a/include/linux/iommufd.h +++ b

[PATCH v2 08/13] iommufd/selftest: Require vdev_id when attaching to a nested domain

2024-12-03 Thread Nicolin Chen
: Nicolin Chen --- drivers/iommu/iommufd/selftest.c| 23 +++ tools/testing/selftests/iommu/iommufd.c | 5 + 2 files changed, 28 insertions(+) diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c index a0de6d6d4e68..d1438d81e664 100644

[PATCH v2 10/13] iommufd/selftest: Add EVENT_VIRQ test coverage

2024-12-03 Thread Nicolin Chen
Trigger an IRQ giving an idev ID, to test the loopback whether receiving or not the vdev_id that was set to the idev by the line above. Signed-off-by: Nicolin Chen --- tools/testing/selftests/iommu/iommufd_utils.h | 63 +++ tools/testing/selftests/iommu/iommufd.c | 22

[PATCH v2 11/13] Documentation: userspace-api: iommufd: Update EVENTQ_IOPF and EVENTQ_VIRQ

2024-12-03 Thread Nicolin Chen
With the introduction of the new objects, update the doc to reflect that. Signed-off-by: Nicolin Chen --- Documentation/userspace-api/iommufd.rst | 19 +++ 1 file changed, 19 insertions(+) diff --git a/Documentation/userspace-api/iommufd.rst b/Documentation/userspace-api

Re: [PATCH v4 14/14] iommu/arm-smmu-v3: Report events that belong to devices attached to vIOMMU

2025-01-06 Thread Nicolin Chen
On Mon, Jan 06, 2025 at 11:01:32AM +0800, Baolu Lu wrote: > On 1/4/25 03:43, Nicolin Chen wrote: > > diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h > > index 0a08aa82e7cc..55e3d5a14cca 100644 > > --- a/include/uapi/linux/iommufd.h > > +++ b/i

Re: [PATCH v4 14/14] iommu/arm-smmu-v3: Report events that belong to devices attached to vIOMMU

2025-01-06 Thread Nicolin Chen
On Mon, Jan 06, 2025 at 10:46:21AM -0800, Nicolin Chen wrote: > On Mon, Jan 06, 2025 at 11:01:32AM +0800, Baolu Lu wrote: > > Nit: I think it would be more readable to add a check in the vevent > > reporting helper. > > > > diff --git a/drivers/iommu/iommufd/drive

[PATCH v4 06/14] iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOC

2025-01-03 Thread Nicolin Chen
iommufd_veventq_ops for the new ioctl. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 58 +++ include/linux/iommufd.h | 3 + include/uapi/linux/iommufd.h| 31 ++ drivers/iommu/iommufd/eventq.c | 129

[PATCH v4 00/14] iommufd: Add vIOMMU infrastructure (Part-3: vEVENTQ)

2025-01-03 Thread Nicolin Chen
attaching to a nested domain, calling a newly added iommufd_viommu_get_vdev_id helper * Adde an arm_vmaster_report_event helper in arm-smmu-v3-iommufd file to simplify the routine in arm_smmu_handle_evt() of the main driver v1 https://lore.kernel.org/all/cover.1724777091.git

[PATCH v4 03/14] iommufd/fault: Move iommufd_fault_iopf_handler() to header

2025-01-03 Thread Nicolin Chen
iommufd_fault_iopf_handler() in the header too, since it's quite simple after all. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 20 +++- drivers/iommu/iommufd/fault.c | 17 - 2 files changed, 19 insertions(+

[PATCH v4 02/14] iommufd/fault: Add an iommufd_fault_init() helper

2025-01-03 Thread Nicolin Chen
x27;t need "response", leave the xa_init_flags in its original location. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/fault.c | 48 --- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/drivers/iommu/iommufd/fa

[PATCH v4 01/14] iommufd: Keep IOCTL list in an alphabetical order

2025-01-03 Thread Nicolin Chen
Move VDEVICE upward to keep the order. Also run clang-format for the same coding style at line wrappings. No functional change. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/main.c | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/iommufd

[PATCH v4 07/14] iommufd/viommu: Add iommufd_viommu_get_vdev_id helper

2025-01-03 Thread Nicolin Chen
-off-by: Nicolin Chen --- include/linux/iommufd.h| 8 drivers/iommu/iommufd/driver.c | 20 2 files changed, 28 insertions(+) diff --git a/include/linux/iommufd.h b/include/linux/iommufd.h index 8948b1836940..9c6ba7df3994 100644 --- a/include/linux/iommufd.h

[PATCH v4 11/14] iommufd/selftest: Add IOMMU_VEVENTQ_ALLOC test coverage

2025-01-03 Thread Nicolin Chen
Trigger a vEVENT by feeding an idev ID and validating the returned output virt_id whether it equals to the value that was set to the vDEVICE. Signed-off-by: Nicolin Chen --- tools/testing/selftests/iommu/iommufd_utils.h | 65 +++ tools/testing/selftests/iommu/iommufd.c

[PATCH v4 05/14] iommufd: Rename fault.c to eventq.c

2025-01-03 Thread Nicolin Chen
Rename the file, aligning with the new eventq object. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/Makefile | 2 +- drivers/iommu/iommufd/{fault.c => eventq.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename drivers/iommu/iomm

[PATCH v4 09/14] iommufd/selftest: Require vdev_id when attaching to a nested domain

2025-01-03 Thread Nicolin Chen
. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/selftest.c| 23 +++ tools/testing/selftests/iommu/iommufd.c | 5 + 2 files changed, 28 insertions(+) diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c index a0de6d6d4e68

[PATCH v4 04/14] iommufd: Abstract an iommufd_eventq from iommufd_fault

2025-01-03 Thread Nicolin Chen
t Queue). Also, add missing xa_destroy and mutex_destroy in iommufd_fault_destroy(). Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 52 ++--- drivers/iommu/iommufd/fault.c | 142 +++- drivers/iommu/iommufd/hw_pagetable.c| 6 +-

[PATCH v4 12/14] Documentation: userspace-api: iommufd: Update FAULT and VEVENTQ

2025-01-03 Thread Nicolin Chen
With the introduction of the new objects, update the doc to reflect that. Signed-off-by: Nicolin Chen --- Documentation/userspace-api/iommufd.rst | 16 1 file changed, 16 insertions(+) diff --git a/Documentation/userspace-api/iommufd.rst b/Documentation/userspace-api

[PATCH v4 10/14] iommufd/selftest: Add IOMMU_TEST_OP_TRIGGER_VEVENT for vEVENTQ coverage

2025-01-03 Thread Nicolin Chen
The handler will get vDEVICE object from the given mdev and convert it to its per-vIOMMU virtual ID to mimic a real IOMMU driver. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_test.h | 10 ++ drivers/iommu/iommufd/selftest.c | 30 2 files

[PATCH v4 08/14] iommufd/viommu: Add iommufd_viommu_report_event helper

2025-01-03 Thread Nicolin Chen
Similar to iommu_report_device_fault, this allows IOMMU drivers to report vIOMMU events from threaded IRQ handlers to user space hypervisors. Signed-off-by: Nicolin Chen --- include/linux/iommufd.h| 11 ++ drivers/iommu/iommufd/driver.c | 40 ++ 2

[PATCH v4 13/14] iommu/arm-smmu-v3: Introduce struct arm_smmu_vmaster

2025-01-03 Thread Nicolin Chen
gned-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 23 + .../arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 49 +++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 32 +++- 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/drivers/io

Re: [PATCH v3 06/14] iommufd: Add IOMMUFD_OBJ_VIRQ and IOMMUFD_CMD_VIRQ_ALLOC

2025-01-02 Thread Nicolin Chen
On Thu, Jan 02, 2025 at 04:45:07PM -0400, Jason Gunthorpe wrote: > On Tue, Dec 17, 2024 at 09:00:19PM -0800, Nicolin Chen wrote: > > Allow a vIOMMU object to allocate vIRQ Event Queues, with a condition that > > each vIOMMU can only have one single vIRQ event queue per type. >

[PATCH v4 14/14] iommu/arm-smmu-v3: Report events that belong to devices attached to vIOMMU

2025-01-03 Thread Nicolin Chen
Aside from the IOPF framework, iommufd provides an additional pathway to report hardware events, via the vEVENTQ of vIOMMU infrastructure. Define an iommu_vevent_arm_smmuv3 uAPI structure, and report stage-1 events in the threaded IRQ handler. Signed-off-by: Nicolin Chen --- drivers/iommu/arm

[PATCH v5 00/14] iommufd: Add vIOMMU infrastructure (Part-3: vEVENTQ)

2025-01-07 Thread Nicolin Chen
iommufd_viommu_get_vdev_id helper * Adde an arm_vmaster_report_event helper in arm-smmu-v3-iommufd file to simplify the routine in arm_smmu_handle_evt() of the main driver v1 https://lore.kernel.org/all/cover.1724777091.git.nicol...@nvidia.com/ Thanks! Nicolin Nicolin Chen (1

[PATCH v5 06/14] iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOC

2025-01-07 Thread Nicolin Chen
iommufd_veventq_ops for the new ioctl. And add a supports_veventq viommu op for drivers to help the core code validate the input vEVENTQ type. Reviewed-by: Lu Baolu Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 58 ++ include/linux/iommufd.h | 5

[PATCH v5 07/14] iommufd/viommu: Add iommufd_viommu_get_vdev_id helper

2025-01-07 Thread Nicolin Chen
-by: Lu Baolu Signed-off-by: Nicolin Chen --- include/linux/iommufd.h| 8 drivers/iommu/iommufd/driver.c | 20 2 files changed, 28 insertions(+) diff --git a/include/linux/iommufd.h b/include/linux/iommufd.h index 941f2ed29914..a6dd9f8edcf3 100644 --- a

[PATCH v5 05/14] iommufd: Rename fault.c to eventq.c

2025-01-07 Thread Nicolin Chen
Rename the file, aligning with the new eventq object. Reviewed-by: Kevin Tian Reviewed-by: Lu Baolu Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/Makefile | 2 +- drivers/iommu/iommufd/{fault.c => eventq.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) ren

[PATCH v5 08/14] iommufd/viommu: Add iommufd_viommu_report_event helper

2025-01-07 Thread Nicolin Chen
Similar to iommu_report_device_fault, this allows IOMMU drivers to report vIOMMU events from threaded IRQ handlers to user space hypervisors. Reviewed-by: Lu Baolu Signed-off-by: Nicolin Chen --- include/linux/iommufd.h| 11 + drivers/iommu/iommufd/driver.c | 43

[PATCH v5 13/14] iommu/arm-smmu-v3: Introduce struct arm_smmu_vmaster

2025-01-07 Thread Nicolin Chen
gned-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 23 + .../arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 49 +++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 32 +++- 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/drivers/io

[PATCH v5 04/14] iommufd: Abstract an iommufd_eventq from iommufd_fault

2025-01-07 Thread Nicolin Chen
t Queue). Also, add missing xa_destroy and mutex_destroy in iommufd_fault_destroy(). Reviewed-by: Lu Baolu Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 52 ++--- drivers/iommu/iommufd/fault.c | 142 +++- drivers/iommu/iommufd/hw_

[PATCH v5 02/14] iommufd/fault: Add an iommufd_fault_init() helper

2025-01-07 Thread Nicolin Chen
x27;t need "response", leave the xa_init_flags in its original location. Reviewed-by: Kevin Tian Reviewed-by: Lu Baolu Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/fault.c | 48 --- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git

[PATCH v5 03/14] iommufd/fault: Move iommufd_fault_iopf_handler() to header

2025-01-07 Thread Nicolin Chen
iommufd_fault_iopf_handler() in the header too, since it's quite simple after all. Reviewed-by: Kevin Tian Reviewed-by: Lu Baolu Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 20 +++- drivers/iommu/iommufd/fault.c | 17 - 2 files change

[PATCH v5 01/14] iommufd: Keep OBJ/IOCTL lists in an alphabetical order

2025-01-07 Thread Nicolin Chen
Reorder the existing OBJ/IOCTL lists. Also run clang-format for the same coding style at line wrappings. No functional change. Reviewed-by: Lu Baolu Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/main.c | 30 ++ 1 file changed, 14 insertions(+), 16

[PATCH v5 09/14] iommufd/selftest: Require vdev_id when attaching to a nested domain

2025-01-07 Thread Nicolin Chen
. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/selftest.c| 23 +++ tools/testing/selftests/iommu/iommufd.c | 5 + 2 files changed, 28 insertions(+) diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c index a0de6d6d4e68

[PATCH v5 11/14] iommufd/selftest: Add IOMMU_VEVENTQ_ALLOC test coverage

2025-01-07 Thread Nicolin Chen
Trigger a vEVENT by feeding an idev ID and validating the returned output virt_id whether it equals to the value that was set to the vDEVICE. Signed-off-by: Nicolin Chen --- tools/testing/selftests/iommu/iommufd_utils.h | 65 +++ tools/testing/selftests/iommu/iommufd.c

[PATCH v5 12/14] Documentation: userspace-api: iommufd: Update FAULT and VEVENTQ

2025-01-07 Thread Nicolin Chen
With the introduction of the new objects, update the doc to reflect that. Reviewed-by: Lu Baolu Signed-off-by: Nicolin Chen --- Documentation/userspace-api/iommufd.rst | 16 1 file changed, 16 insertions(+) diff --git a/Documentation/userspace-api/iommufd.rst b/Documentation

[PATCH v5 10/14] iommufd/selftest: Add IOMMU_TEST_OP_TRIGGER_VEVENT for vEVENTQ coverage

2025-01-07 Thread Nicolin Chen
The handler will get vDEVICE object from the given mdev and convert it to its per-vIOMMU virtual ID to mimic a real IOMMU driver. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_test.h | 10 ++ drivers/iommu/iommufd/selftest.c | 30 2 files

[PATCH v5 14/14] iommu/arm-smmu-v3: Report events that belong to devices attached to vIOMMU

2025-01-07 Thread Nicolin Chen
Aside from the IOPF framework, iommufd provides an additional pathway to report hardware events, via the vEVENTQ of vIOMMU infrastructure. Define an iommu_vevent_arm_smmuv3 uAPI structure, and report stage-1 events in the threaded IRQ handler. Signed-off-by: Nicolin Chen --- drivers/iommu/arm

Re: [PATCH v4 14/14] iommu/arm-smmu-v3: Report events that belong to devices attached to vIOMMU

2025-01-06 Thread Nicolin Chen
On Mon, Jan 06, 2025 at 08:37:04PM -0800, Nicolin Chen wrote: > I added something like this. Will send a v5. > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c > b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c > index 0c7a5894ba07..348179f3cf2a 100644

Re: [PATCH v4 14/14] iommu/arm-smmu-v3: Report events that belong to devices attached to vIOMMU

2025-01-06 Thread Nicolin Chen
On Tue, Jan 07, 2025 at 01:54:00PM +0800, Baolu Lu wrote: > On 1/7/25 12:36, Nicolin Chen wrote: > > +static bool arm_vsmmu_supports_veventq(unsigned int type) > > +{ > > + return type == IOMMU_VIOMMU_TYPE_ARM_SMMUV3; > > Do you need to check the hardware capabiliti

[PATCH v3 00/14] iommufd: Add vIOMMU infrastructure (Part-3: vIRQ)

2024-12-17 Thread Nicolin Chen
iommu_get_vdev_id helper * Adde an arm_vmaster_report_event helper in arm-smmu-v3-iommufd file to simplify the routine in arm_smmu_handle_evt() of the main driver v1 https://lore.kernel.org/all/cover.1724777091.git.nicol...@nvidia.com/ Thanks! Nicolin Nicolin Chen (14): iommufd:

[PATCH v3 01/14] iommufd: Keep IOCTL list in an alphabetical order

2024-12-17 Thread Nicolin Chen
Move VDEVICE upward to keep the order. Also run clang-format keep the same coding style at line wrappings. No functional change. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/main.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/iommufd

[PATCH v3 03/14] iommufd/fault: Move iommufd_fault_iopf_handler() to header

2024-12-17 Thread Nicolin Chen
iommufd_fault_iopf_handler() in the header too, since it's quite simple after all. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 20 +++- drivers/iommu/iommufd/fault.c | 17 - 2 files changed, 19 insertions(+

[PATCH v3 04/14] iommufd: Abstract an iommufd_eventq from iommufd_fault

2024-12-17 Thread Nicolin Chen
ssing xa_destroy and mutex_destroy in iommufd_fault_destroy(). Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h | 52 ++--- drivers/iommu/iommufd/fault.c | 142 +++- drivers/iommu/iommufd/hw_pagetable.c| 6 +- 3 files changed, 1

[PATCH v3 05/14] iommufd: Rename fault.c to eventq.c

2024-12-17 Thread Nicolin Chen
Rename the file, aligning with the new eventq object. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/Makefile | 2 +- drivers/iommu/iommufd/{fault.c => eventq.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename drivers/iommu/iomm

[PATCH v3 06/14] iommufd: Add IOMMUFD_OBJ_VIRQ and IOMMUFD_CMD_VIRQ_ALLOC

2024-12-17 Thread Nicolin Chen
Allow a vIOMMU object to allocate vIRQ Event Queues, with a condition that each vIOMMU can only have one single vIRQ event queue per type. Add iommufd_eventq_virq_alloc with an iommufd_eventq_virq_ops for this new ioctl. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_private.h

[PATCH v3 02/14] iommufd/fault: Add an iommufd_fault_init() helper

2024-12-17 Thread Nicolin Chen
need "response", leave the xa_init_flags in its original location. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/fault.c | 48 --- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/drivers/iommu/iommufd/fa

[PATCH v3 13/14] iommu/arm-smmu-v3: Introduce struct arm_smmu_vmaster

2024-12-17 Thread Nicolin Chen
gned-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 23 + .../arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 49 +++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 32 +++- 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/drivers/io

[PATCH v3 14/14] iommu/arm-smmu-v3: Report IRQs that belong to devices attached to vIOMMU

2024-12-17 Thread Nicolin Chen
Aside from the IOPF framework, iommufd provides an additional pathway to report a hardware event or IRQ, via the vIRQ of vIOMMU infrastructure. Define an iommu_virq_arm_smmuv3 uAPI structure, and report stage-1 faults in the threaded IRQ handler. Signed-off-by: Nicolin Chen --- drivers/iommu

[PATCH v3 10/14] iommufd/selftest: Add IOMMU_TEST_OP_TRIGGER_VIRQ for vIRQ coverage

2024-12-17 Thread Nicolin Chen
The handler will get vDEVICE object from the given mdev and convert it to its per-vIOMMU virtual ID to mimic a real IOMMU driver. Signed-off-by: Nicolin Chen --- drivers/iommu/iommufd/iommufd_test.h | 10 ++ drivers/iommu/iommufd/selftest.c | 30 2 files

[PATCH v3 11/14] iommufd/selftest: Add IOMMU_VIRQ_ALLOC test coverage

2024-12-17 Thread Nicolin Chen
Trigger a vIRQ giving an idev ID, to test the loopback whether receiving or not the vdev_id that was set to the idev by the line above. Signed-off-by: Nicolin Chen --- tools/testing/selftests/iommu/iommufd_utils.h | 63 +++ tools/testing/selftests/iommu/iommufd.c | 22

[PATCH v3 07/14] iommufd/viommu: Add iommufd_viommu_get_vdev_id helper

2024-12-17 Thread Nicolin Chen
-off-by: Nicolin Chen --- include/linux/iommufd.h| 8 drivers/iommu/iommufd/driver.c | 20 2 files changed, 28 insertions(+) diff --git a/include/linux/iommufd.h b/include/linux/iommufd.h index b082676c9e43..ac1f1897d290 100644 --- a/include/linux/iommufd.h

[PATCH v3 12/14] Documentation: userspace-api: iommufd: Update FAULT and VIRQ

2024-12-17 Thread Nicolin Chen
With the introduction of the new objects, update the doc to reflect that. Signed-off-by: Nicolin Chen --- Documentation/userspace-api/iommufd.rst | 16 1 file changed, 16 insertions(+) diff --git a/Documentation/userspace-api/iommufd.rst b/Documentation/userspace-api

[PATCH v3 09/14] iommufd/selftest: Require vdev_id when attaching to a nested domain

2024-12-17 Thread Nicolin Chen
: Nicolin Chen --- drivers/iommu/iommufd/selftest.c| 23 +++ tools/testing/selftests/iommu/iommufd.c | 5 + 2 files changed, 28 insertions(+) diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c index a0de6d6d4e68..d1438d81e664 100644

[PATCH v3 08/14] iommufd/viommu: Add iommufd_viommu_report_irq helper

2024-12-17 Thread Nicolin Chen
Similar to iommu_report_device_fault, this allows IOMMU drivers to report, from threaded IRQ handlers to user space hypervisors, IRQs or events that belong to a vIOMMU. Signed-off-by: Nicolin Chen --- include/linux/iommufd.h| 9 + drivers/iommu/iommufd/driver.c | 37

<    1   2   3   4   5   6   7   8   >