lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231024171312.GN3952@nvidia.com>
Date:   Tue, 24 Oct 2023 14:13:12 -0300
From:   Jason Gunthorpe <jgg@...dia.com>
To:     Yi Liu <yi.l.liu@...el.com>
Cc:     joro@...tes.org, alex.williamson@...hat.com, kevin.tian@...el.com,
        robin.murphy@....com, baolu.lu@...ux.intel.com, cohuck@...hat.com,
        eric.auger@...hat.com, nicolinc@...dia.com, kvm@...r.kernel.org,
        mjrosato@...ux.ibm.com, chao.p.peng@...ux.intel.com,
        yi.y.sun@...ux.intel.com, peterx@...hat.com, jasowang@...hat.com,
        shameerali.kolothum.thodi@...wei.com, lulu@...hat.com,
        suravee.suthikulpanit@....com, iommu@...ts.linux.dev,
        linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
        zhenzhong.duan@...el.com, joao.m.martins@...cle.com
Subject: Re: [PATCH v6 07/10] iommufd: Add a nested HW pagetable object

On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote:
> +static struct iommufd_hwpt_nested *
> +iommufd_hwpt_nested_alloc(struct iommufd_ctx *ictx,
> +			  struct iommufd_hwpt_paging *parent,
> +			  struct iommufd_device *idev, u32 flags,
> +			  const struct iommu_user_data *user_data)
> +{
> +	const struct iommu_ops *ops = dev_iommu_ops(idev->dev);
> +	struct iommufd_hwpt_nested *hwpt_nested;
> +	struct iommufd_hw_pagetable *hwpt;
> +	int rc;
> +
> +	if (flags != 0)
> +		return ERR_PTR(-EOPNOTSUPP);
> +	if (!user_data)
> +		return ERR_PTR(-EINVAL);

user_data is never NULL now, I removed this

> +	if (user_data->type == IOMMU_HWPT_DATA_NONE)
> +		return ERR_PTR(-EINVAL);
> +	if (parent->auto_domain)
> +		return ERR_PTR(-EINVAL);
> +	if (!parent->nest_parent)
> +		return ERR_PTR(-EINVAL);

And put these all together

	if (flags || user_data->type == IOMMU_HWPT_DATA_NONE ||
	    !ops->domain_alloc_user)
		return ERR_PTR(-EOPNOTSUPP);
	if (parent->auto_domain || !parent->nest_parent)
		return ERR_PTR(-EINVAL);


> +
> +	if (!ops->domain_alloc_user)
> +		return ERR_PTR(-EOPNOTSUPP);
> +
> +	hwpt_nested = __iommufd_object_alloc(ictx, hwpt_nested,
> +					     IOMMUFD_OBJ_HWPT_NESTED,
> +					     common.obj);
> +	if (IS_ERR(hwpt_nested))
> +		return ERR_CAST(hwpt_nested);
> +	hwpt = &hwpt_nested->common;
> +
> +	refcount_inc(&parent->common.obj.users);
> +	hwpt_nested->parent = parent;
> +
> +	hwpt->domain = ops->domain_alloc_user(idev->dev, 0,

And we may as well pass flags here even though we know it is 0 today.

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ