Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+34 -13
-2
drivers/iommu/iommufd/fault.c
··· 420 420 put_unused_fd(fdno); 421 421 out_fput: 422 422 fput(filep); 423 - refcount_dec(&fault->obj.users); 424 - iommufd_ctx_put(fault->ictx); 425 423 out_abort: 426 424 iommufd_object_abort_and_destroy(ucmd->ictx, &fault->obj); 427 425
+20 -11
include/uapi/linux/iommufd.h
··· 297 297 * ioctl(IOMMU_OPTION_HUGE_PAGES) 298 298 * @IOMMU_OPTION_RLIMIT_MODE: 299 299 * 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 301 301 * based accounting. Global option, object_id must be 0 302 302 * @IOMMU_OPTION_HUGE_PAGES: 303 303 * Value 1 (default) allows contiguous pages to be combined when generating ··· 390 390 * @IOMMU_HWPT_ALLOC_PASID: Requests a domain that can be used with PASID. The 391 391 * domain can be attached to any PASID on the device. 392 392 * 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 394 394 * PASID will blocked. 395 395 * If IOMMU does not support PASID it will return 396 396 * error (-EOPNOTSUPP). ··· 558 558 * For the details of @idr, @iidr and @aidr, please refer to the chapters 559 559 * from 6.3.1 to 6.3.6 in the SMMUv3 Spec. 560 560 * 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: 563 563 * 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 569 568 * 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. 571 580 */ 572 581 struct iommu_hw_info_arm_smmuv3 { 573 582 __u32 flags; ··· 775 766 }; 776 767 777 768 /** 778 - * struct iommu_viommu_arm_smmuv3_invalidate - ARM SMMUv3 cahce invalidation 769 + * struct iommu_viommu_arm_smmuv3_invalidate - ARM SMMUv3 cache invalidation 779 770 * (IOMMU_VIOMMU_INVALIDATE_DATA_ARM_SMMUV3) 780 771 * @cmd: 128-bit cache invalidation command that runs in SMMU CMDQ. 781 772 * Must be little-endian.
+14
tools/testing/selftests/iommu/iommufd_fail_nth.c
··· 615 615 /* device.c */ 616 616 TEST_FAIL_NTH(basic_fail_nth, device) 617 617 { 618 + struct iommu_hwpt_selftest data = { 619 + .iotlb = IOMMU_TEST_IOTLB_DEFAULT, 620 + }; 618 621 struct iommu_test_hw_info info; 622 + uint32_t fault_id, fault_fd; 623 + uint32_t fault_hwpt_id; 619 624 uint32_t ioas_id; 620 625 uint32_t ioas_id2; 621 626 uint32_t stdev_id; ··· 681 676 return -1; 682 677 683 678 if (_test_cmd_vdevice_alloc(self->fd, viommu_id, idev_id, 0, &vdev_id)) 679 + return -1; 680 + 681 + if (_test_ioctl_fault_alloc(self->fd, &fault_id, &fault_fd)) 682 + return -1; 683 + close(fault_fd); 684 + 685 + if (_test_cmd_hwpt_alloc(self->fd, idev_id, hwpt_id, fault_id, 686 + IOMMU_HWPT_FAULT_ID_VALID, &fault_hwpt_id, 687 + IOMMU_HWPT_DATA_SELFTEST, &data, sizeof(data))) 684 688 return -1; 685 689 686 690 return 0;