mirror of https://github.com/torvalds/linux.git
iommufd 6.18 first rc pull
Three fixes: - Syzkaller found a case where maths overflows can cause divide by 0 - Typo in a compiler bug warning fix in the selftests broke the selftests - type1 compatability had a mismatch when unmapping an already unmaped range, it should succeed -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRRRCHOFoQz/8F5bUaFwuHvBreFYQUCaQ473AAKCRCFwuHvBreF Ya8gAP9Qifu4AYobrhgD9rKKXLniGRejXUHBQ0G8y8y9sBHJdgEApwxzCUcI1jLZ GTaPEABblBBWxUmN+Psya2Hm3Oa53AA= =TJHp -----END PGP SIGNATURE----- Merge tag 'for-linus-iommufd' of git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd Pull iommufd fixes from Jason Gunthorpe: - Syzkaller found a case where maths overflows can cause divide by 0 - Typo in a compiler bug warning fix in the selftests broke the selftests - type1 compatability had a mismatch when unmapping an already unmapped range, it should succeed * tag 'for-linus-iommufd' of git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd: iommufd: Make vfio_compat's unmap succeed if the range is already empty iommufd/selftest: Fix ioctl return value in _test_cmd_trigger_vevents() iommufd: Don't overflow during division for dirty tracking
This commit is contained in:
commit
a2e33fb926
|
|
@ -707,7 +707,8 @@ static int iopt_unmap_iova_range(struct io_pagetable *iopt, unsigned long start,
|
|||
struct iopt_area *area;
|
||||
unsigned long unmapped_bytes = 0;
|
||||
unsigned int tries = 0;
|
||||
int rc = -ENOENT;
|
||||
/* If there are no mapped entries then success */
|
||||
int rc = 0;
|
||||
|
||||
/*
|
||||
* The domains_rwsem must be held in read mode any time any area->pages
|
||||
|
|
@ -777,8 +778,6 @@ static int iopt_unmap_iova_range(struct io_pagetable *iopt, unsigned long start,
|
|||
|
||||
down_write(&iopt->iova_rwsem);
|
||||
}
|
||||
if (unmapped_bytes)
|
||||
rc = 0;
|
||||
|
||||
out_unlock_iova:
|
||||
up_write(&iopt->iova_rwsem);
|
||||
|
|
@ -815,13 +814,8 @@ int iopt_unmap_iova(struct io_pagetable *iopt, unsigned long iova,
|
|||
|
||||
int iopt_unmap_all(struct io_pagetable *iopt, unsigned long *unmapped)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = iopt_unmap_iova_range(iopt, 0, ULONG_MAX, unmapped);
|
||||
/* If the IOVAs are empty then unmap all succeeds */
|
||||
if (rc == -ENOENT)
|
||||
return 0;
|
||||
return rc;
|
||||
return iopt_unmap_iova_range(iopt, 0, ULONG_MAX, unmapped);
|
||||
}
|
||||
|
||||
/* The caller must always free all the nodes in the allowed_iova rb_root. */
|
||||
|
|
|
|||
|
|
@ -367,6 +367,10 @@ int iommufd_ioas_unmap(struct iommufd_ucmd *ucmd)
|
|||
&unmapped);
|
||||
if (rc)
|
||||
goto out_put;
|
||||
if (!unmapped) {
|
||||
rc = -ENOENT;
|
||||
goto out_put;
|
||||
}
|
||||
}
|
||||
|
||||
cmd->length = unmapped;
|
||||
|
|
|
|||
|
|
@ -130,9 +130,8 @@ struct iova_bitmap {
|
|||
static unsigned long iova_bitmap_offset_to_index(struct iova_bitmap *bitmap,
|
||||
unsigned long iova)
|
||||
{
|
||||
unsigned long pgsize = 1UL << bitmap->mapped.pgshift;
|
||||
|
||||
return iova / (BITS_PER_TYPE(*bitmap->bitmap) * pgsize);
|
||||
return (iova >> bitmap->mapped.pgshift) /
|
||||
BITS_PER_TYPE(*bitmap->bitmap);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -2638,6 +2638,8 @@ TEST_F(vfio_compat_mock_domain, map)
|
|||
ASSERT_EQ(0, ioctl(self->fd, VFIO_IOMMU_MAP_DMA, &map_cmd));
|
||||
ASSERT_EQ(0, ioctl(self->fd, VFIO_IOMMU_UNMAP_DMA, &unmap_cmd));
|
||||
ASSERT_EQ(BUFFER_SIZE, unmap_cmd.size);
|
||||
/* Unmap of empty is success */
|
||||
ASSERT_EQ(0, ioctl(self->fd, VFIO_IOMMU_UNMAP_DMA, &unmap_cmd));
|
||||
|
||||
/* UNMAP_FLAG_ALL requires 0 iova/size */
|
||||
ASSERT_EQ(0, ioctl(self->fd, VFIO_IOMMU_MAP_DMA, &map_cmd));
|
||||
|
|
|
|||
|
|
@ -1044,7 +1044,7 @@ static int _test_cmd_trigger_vevents(int fd, __u32 dev_id, __u32 nvevents)
|
|||
};
|
||||
|
||||
while (nvevents--) {
|
||||
if (!ioctl(fd, _IOMMU_TEST_CMD(IOMMU_TEST_OP_TRIGGER_VEVENT),
|
||||
if (ioctl(fd, _IOMMU_TEST_CMD(IOMMU_TEST_OP_TRIGGER_VEVENT),
|
||||
&trigger_vevent_cmd))
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue