Skip to content

Commit 6a10386

Browse files
committed
Merge tag 'for-linus-iommufd' of git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd
Pull iommufd fixes from Jason Gunthorpe: "One bug fix and some documentation updates: - Correct typos in comments - Elaborate a comment about how the uAPI works for IOMMU_HW_INFO_TYPE_ARM_SMMUV3 - Fix a double free on error path and add test coverage for the bug" * tag 'for-linus-iommufd' of git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd: iommu/arm-smmu-v3: Improve uAPI comment for IOMMU_HW_INFO_TYPE_ARM_SMMUV3 iommufd/selftest: Cover IOMMU_FAULT_QUEUE_ALLOC in iommufd_fail_nth iommufd: Fix out_fput in iommufd_fault_alloc() iommufd: Fix typos in kernel-doc comments
2 parents f65289a + 2ca704f commit 6a10386

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

drivers/iommu/iommufd/fault.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,6 @@ int iommufd_fault_alloc(struct iommufd_ucmd *ucmd)
420420
put_unused_fd(fdno);
421421
out_fput:
422422
fput(filep);
423-
refcount_dec(&fault->obj.users);
424-
iommufd_ctx_put(fault->ictx);
425423
out_abort:
426424
iommufd_object_abort_and_destroy(ucmd->ictx, &fault->obj);
427425

include/uapi/linux/iommufd.h

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ struct iommu_ioas_unmap {
297297
* ioctl(IOMMU_OPTION_HUGE_PAGES)
298298
* @IOMMU_OPTION_RLIMIT_MODE:
299299
* Change how RLIMIT_MEMLOCK accounting works. The caller must have privilege
300-
* to invoke this. Value 0 (default) is user based accouting, 1 uses process
300+
* to invoke this. Value 0 (default) is user based accounting, 1 uses process
301301
* based accounting. Global option, object_id must be 0
302302
* @IOMMU_OPTION_HUGE_PAGES:
303303
* Value 1 (default) allows contiguous pages to be combined when generating
@@ -390,7 +390,7 @@ struct iommu_vfio_ioas {
390390
* @IOMMU_HWPT_ALLOC_PASID: Requests a domain that can be used with PASID. The
391391
* domain can be attached to any PASID on the device.
392392
* Any domain attached to the non-PASID part of the
393-
* device must also be flaged, otherwise attaching a
393+
* device must also be flagged, otherwise attaching a
394394
* PASID will blocked.
395395
* If IOMMU does not support PASID it will return
396396
* error (-EOPNOTSUPP).
@@ -558,16 +558,25 @@ struct iommu_hw_info_vtd {
558558
* For the details of @idr, @iidr and @aidr, please refer to the chapters
559559
* from 6.3.1 to 6.3.6 in the SMMUv3 Spec.
560560
*
561-
* User space should read the underlying ARM SMMUv3 hardware information for
562-
* the list of supported features.
561+
* This reports the raw HW capability, and not all bits are meaningful to be
562+
* read by userspace. Only the following fields should be used:
563563
*
564-
* Note that these values reflect the raw HW capability, without any insight if
565-
* any required kernel driver support is present. Bits may be set indicating the
566-
* HW has functionality that is lacking kernel software support, such as BTM. If
567-
* a VMM is using this information to construct emulated copies of these
568-
* registers it should only forward bits that it knows it can support.
564+
* idr[0]: ST_LEVEL, TERM_MODEL, STALL_MODEL, TTENDIAN , CD2L, ASID16, TTF
565+
* idr[1]: SIDSIZE, SSIDSIZE
566+
* idr[3]: BBML, RIL
567+
* idr[5]: VAX, GRAN64K, GRAN16K, GRAN4K
569568
*
570-
* In future, presence of required kernel support will be indicated in flags.
569+
* - S1P should be assumed to be true if a NESTED HWPT can be created
570+
* - VFIO/iommufd only support platforms with COHACC, it should be assumed to be
571+
* true.
572+
* - ATS is a per-device property. If the VMM describes any devices as ATS
573+
* capable in ACPI/DT it should set the corresponding idr.
574+
*
575+
* This list may expand in future (eg E0PD, AIE, PBHA, D128, DS etc). It is
576+
* important that VMMs do not read bits outside the list to allow for
577+
* compatibility with future kernels. Several features in the SMMUv3
578+
* architecture are not currently supported by the kernel for nesting: HTTU,
579+
* BTM, MPAM and others.
571580
*/
572581
struct iommu_hw_info_arm_smmuv3 {
573582
__u32 flags;
@@ -766,7 +775,7 @@ struct iommu_hwpt_vtd_s1_invalidate {
766775
};
767776

768777
/**
769-
* struct iommu_viommu_arm_smmuv3_invalidate - ARM SMMUv3 cahce invalidation
778+
* struct iommu_viommu_arm_smmuv3_invalidate - ARM SMMUv3 cache invalidation
770779
* (IOMMU_VIOMMU_INVALIDATE_DATA_ARM_SMMUV3)
771780
* @cmd: 128-bit cache invalidation command that runs in SMMU CMDQ.
772781
* Must be little-endian.

tools/testing/selftests/iommu/iommufd_fail_nth.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,12 @@ TEST_FAIL_NTH(basic_fail_nth, access_pin_domain)
615615
/* device.c */
616616
TEST_FAIL_NTH(basic_fail_nth, device)
617617
{
618+
struct iommu_hwpt_selftest data = {
619+
.iotlb = IOMMU_TEST_IOTLB_DEFAULT,
620+
};
618621
struct iommu_test_hw_info info;
622+
uint32_t fault_id, fault_fd;
623+
uint32_t fault_hwpt_id;
619624
uint32_t ioas_id;
620625
uint32_t ioas_id2;
621626
uint32_t stdev_id;
@@ -678,6 +683,15 @@ TEST_FAIL_NTH(basic_fail_nth, device)
678683
if (_test_cmd_vdevice_alloc(self->fd, viommu_id, idev_id, 0, &vdev_id))
679684
return -1;
680685

686+
if (_test_ioctl_fault_alloc(self->fd, &fault_id, &fault_fd))
687+
return -1;
688+
close(fault_fd);
689+
690+
if (_test_cmd_hwpt_alloc(self->fd, idev_id, hwpt_id, fault_id,
691+
IOMMU_HWPT_FAULT_ID_VALID, &fault_hwpt_id,
692+
IOMMU_HWPT_DATA_SELFTEST, &data, sizeof(data)))
693+
return -1;
694+
681695
return 0;
682696
}
683697

0 commit comments

Comments
 (0)