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: <20241031131637.GK10193@nvidia.com>
Date: Thu, 31 Oct 2024 10:16:37 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Nicolin Chen <nicolinc@...dia.com>
Cc: kevin.tian@...el.com, corbet@....net, joro@...tes.org,
	suravee.suthikulpanit@....com, will@...nel.org,
	robin.murphy@....com, dwmw2@...radead.org, shuah@...nel.org,
	iommu@...ts.linux.dev, linux-doc@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
	baolu.lu@...ux.intel.com, eric.auger@...hat.com,
	jean-philippe@...aro.org, mdf@...nel.org, mshavit@...gle.com,
	shameerali.kolothum.thodi@...wei.com, smostafa@...gle.com,
	yi.l.liu@...el.com, aik@....com, zhangfei.gao@...aro.org,
	patches@...ts.linux.dev
Subject: Re: [PATCH v6 12/13] iommufd/selftest: Add IOMMU_VIOMMU_ALLOC test
 coverage

On Wed, Oct 30, 2024 at 02:34:38PM -0700, Nicolin Chen wrote:
> +FIXTURE_SETUP(iommufd_viommu)
> +{
> +	self->fd = open("/dev/iommu", O_RDWR);
> +	ASSERT_NE(-1, self->fd);
> +	test_ioctl_ioas_alloc(&self->ioas_id);
> +	test_ioctl_set_default_memory_limit();
> +
> +	if (variant->viommu) {
> +		struct iommu_hwpt_selftest data = {
> +			.iotlb = IOMMU_TEST_IOTLB_DEFAULT,
> +		};
> +
> +		test_cmd_mock_domain(self->ioas_id, &self->stdev_id, NULL,
> +				     &self->device_id);
> +
> +		/* Negative test -- invalid hwpt */
> +		test_err_viommu_alloc(ENOENT, self->device_id, self->hwpt_id,
> +				      IOMMU_VIOMMU_TYPE_SELFTEST, NULL);
> +
> +		/* Negative test -- not a nesting parent hwpt */
> +		test_cmd_hwpt_alloc(self->device_id, self->ioas_id, 0,
> +				    &self->hwpt_id);
> +		test_err_viommu_alloc(EINVAL, self->device_id, self->hwpt_id,
> +				      IOMMU_VIOMMU_TYPE_SELFTEST, NULL);
> +		test_ioctl_destroy(self->hwpt_id);
> +
> +		/* Allocate a nesting parent hwpt */
> +		test_cmd_hwpt_alloc(self->device_id, self->ioas_id,
> +				    IOMMU_HWPT_ALLOC_NEST_PARENT,
> +				    &self->hwpt_id);
> +		/* Negative test -- unsupported viommu type */
> +		test_err_viommu_alloc(EOPNOTSUPP, self->device_id,
> +				      self->hwpt_id, 0xdead, NULL);
> +
> +		/* Allocate a vIOMMU taking refcount of the parent hwpt */
> +		test_cmd_viommu_alloc(self->device_id, self->hwpt_id,
> +				      IOMMU_VIOMMU_TYPE_SELFTEST,
> +				      &self->viommu_id);
> +		EXPECT_ERRNO(EBUSY,
> +			     _test_ioctl_destroy(self->fd, self->hwpt_id));

There shouldn't be testing in the FIXTURE_SETUP, it should just do
enough to setup the fixture. negative tests/etc should be in their own
function

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ