]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommufd: Return EOPNOTSUPP for failures due to driver bugs
authorNicolin Chen <nicolinc@nvidia.com>
Sat, 14 Jun 2025 06:35:17 +0000 (23:35 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 19 Jun 2025 18:43:28 +0000 (15:43 -0300)
It's more accurate to report EOPNOTSUPP when an ioctl failed due to driver
bug, since there is nothing wrong with the user space side.

Link: https://patch.msgid.link/r/623bb6f0e8fdd7b9c5745a2f99f280163f9f1f5a.1749882255.git.nicolinc@nvidia.com
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/device.c
drivers/iommu/iommufd/hw_pagetable.c

index ed0dc539d490de1e4e8f5a748598e523362e347a..e9b6ca47095c8116e0f864daf8f91d51dd75ab14 100644 (file)
@@ -1483,7 +1483,7 @@ int iommufd_get_hw_info(struct iommufd_ucmd *ucmd)
                 */
                if (WARN_ON_ONCE(cmd->out_data_type ==
                                 IOMMU_HW_INFO_TYPE_NONE)) {
-                       rc = -ENODEV;
+                       rc = -EOPNOTSUPP;
                        goto out_free;
                }
        } else {
index 8565a6f596b23811412c18a0cd885ae73ce0f5d6..fe789c2dc0c97289dacf28d25d9eea6b48d563fc 100644 (file)
@@ -264,7 +264,7 @@ iommufd_hwpt_nested_alloc(struct iommufd_ctx *ictx,
        hwpt->domain->cookie_type = IOMMU_COOKIE_IOMMUFD;
 
        if (WARN_ON_ONCE(hwpt->domain->type != IOMMU_DOMAIN_NESTED)) {
-               rc = -EINVAL;
+               rc = -EOPNOTSUPP;
                goto out_abort;
        }
        return hwpt_nested;
@@ -321,7 +321,7 @@ iommufd_viommu_alloc_hwpt_nested(struct iommufd_viommu *viommu, u32 flags,
        hwpt->domain->cookie_type = IOMMU_COOKIE_IOMMUFD;
 
        if (WARN_ON_ONCE(hwpt->domain->type != IOMMU_DOMAIN_NESTED)) {
-               rc = -EINVAL;
+               rc = -EOPNOTSUPP;
                goto out_abort;
        }
        return hwpt_nested;