[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BN9PR11MB5276F362FA971F6A5861BA418CB82@BN9PR11MB5276.namprd11.prod.outlook.com>
Date: Mon, 21 Apr 2025 08:05:40 +0000
From: "Tian, Kevin" <kevin.tian@...el.com>
To: Nicolin Chen <nicolinc@...dia.com>, "jgg@...dia.com" <jgg@...dia.com>,
"corbet@....net" <corbet@....net>, "will@...nel.org" <will@...nel.org>
CC: "robin.murphy@....com" <robin.murphy@....com>, "joro@...tes.org"
<joro@...tes.org>, "thierry.reding@...il.com" <thierry.reding@...il.com>,
"vdumpa@...dia.com" <vdumpa@...dia.com>, "jonathanh@...dia.com"
<jonathanh@...dia.com>, "shuah@...nel.org" <shuah@...nel.org>,
"praan@...gle.com" <praan@...gle.com>, "nathan@...nel.org"
<nathan@...nel.org>, "peterz@...radead.org" <peterz@...radead.org>, "Liu, Yi
L" <yi.l.liu@...el.com>, "jsnitsel@...hat.com" <jsnitsel@...hat.com>,
"mshavit@...gle.com" <mshavit@...gle.com>, "zhangzekun11@...wei.com"
<zhangzekun11@...wei.com>, "iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>, "linux-tegra@...r.kernel.org"
<linux-tegra@...r.kernel.org>, "linux-kselftest@...r.kernel.org"
<linux-kselftest@...r.kernel.org>, "patches@...ts.linux.dev"
<patches@...ts.linux.dev>
Subject: RE: [PATCH v1 09/16] iommufd/viommmu: Add IOMMUFD_CMD_VCMDQ_ALLOC
ioctl
> From: Nicolin Chen <nicolinc@...dia.com>
> Sent: Friday, April 11, 2025 2:38 PM
>
> +
> +/**
> + * enum iommu_vcmdq_type - Virtual Queue Type
"Virtual Command Queue Type"
> + * @IOMMU_VCMDQ_TYPE_DEFAULT: Reserved for future use
> + */
> +enum iommu_vcmdq_data_type {
> + IOMMU_VCMDQ_TYPE_DEFAULT = 0,
> +};
> +
> +/**
> + * struct iommu_vcmdq_alloc - ioctl(IOMMU_VCMDQ_ALLOC)
> + * @size: sizeof(struct iommu_vcmdq_alloc)
> + * @flags: Must be 0
> + * @viommu_id: viommu ID to associate the virtual queue with
> + * @type: One of enum iommu_vcmdq_type
s/ iommu_vcmdq_type/ iommu_vcmdq_data_type/
> +int iommufd_vcmdq_alloc_ioctl(struct iommufd_ucmd *ucmd)
> +{
> + struct iommu_vcmdq_alloc *cmd = ucmd->cmd;
> + const struct iommu_user_data user_data = {
> + .type = cmd->type,
> + .uptr = u64_to_user_ptr(cmd->data_uptr),
> + .len = cmd->data_len,
> + };
> + struct iommufd_vcmdq *vcmdq;
> + struct iommufd_viommu *viommu;
> + int rc;
> +
> + if (cmd->flags || cmd->type == IOMMU_VCMDQ_TYPE_DEFAULT)
> + return -EOPNOTSUPP;
> + if (!cmd->data_len)
> + return -EINVAL;
> +
> + viommu = iommufd_get_viommu(ucmd, cmd->viommu_id);
> + if (IS_ERR(viommu))
> + return PTR_ERR(viommu);
> +
> + if (!viommu->ops || !viommu->ops->vcmdq_alloc) {
> + rc = -EOPNOTSUPP;
> + goto out_put_viommu;
> + }
> +
> + vcmdq = viommu->ops->vcmdq_alloc(viommu,
> + user_data.len ? &user_data : NULL);
the length cannot be zero at this point due to earlier check.
Powered by blists - more mailing lists