Re: [PATCH v5 16/18] iommufd/selftest: Test IOMMU_HWPT_GET_DIRTY_BITMAP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 20, 2023 at 11:28:02PM +0100, Joao Martins wrote:
 
> +static int iommufd_test_dirty(struct iommufd_ucmd *ucmd,
> +                             unsigned int mockpt_id, unsigned long iova,
> +                             size_t length, unsigned long page_size,
> +                             void __user *uptr, u32 flags)
> +{
> +       unsigned long i, max = length / page_size;
> +       struct iommu_test_cmd *cmd = ucmd->cmd;
> +       struct iommufd_hw_pagetable *hwpt;
> +       struct mock_iommu_domain *mock;
> +       int rc, count = 0;
> +
> +       if (iova % page_size || length % page_size ||
> +           (uintptr_t)uptr % page_size)
> +               return -EINVAL;
> +
> +       hwpt = get_md_pagetable(ucmd, mockpt_id, &mock);
> +       if (IS_ERR(hwpt))
> +               return PTR_ERR(hwpt);
> +
> +       if (!(mock->flags & MOCK_DIRTY_TRACK)) {
> +               rc = -EINVAL;
> +               goto out_put;
> +       }
> +
> +       for (i = 0; i < max; i++) {
> +               unsigned long cur = iova + i * page_size;
> +               void *ent, *old;
> +
> +               if (!test_bit(i, (unsigned long *) uptr))
> +                       continue;

Is it okay to test_bit on a user pointer/page? Should we call
get_user_pages or so?

Thanks
Nicolin



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux