Re: [PATCH v4 07/18] iommufd: Add IOMMU_HWPT_GET_DIRTY_IOVA

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

 



On 19/10/2023 13:01, Jason Gunthorpe wrote:
> On Thu, Oct 19, 2023 at 12:43:19AM +0100, Joao Martins wrote:
>> On 18/10/2023 23:39, Jason Gunthorpe wrote:
>>> On Wed, Oct 18, 2023 at 09:27:04PM +0100, Joao Martins wrote:
>>>
>>>> +int iommufd_check_iova_range(struct iommufd_ioas *ioas,
>>>> +			     struct iommu_hwpt_get_dirty_iova *bitmap)
>>>> +{
>>>> +	unsigned long pgshift, npages;
>>>> +	size_t iommu_pgsize;
>>>> +	int rc = -EINVAL;
>>>> +
>>>> +	pgshift = __ffs(bitmap->page_size);
>>>> +	npages = bitmap->length >> pgshift;
>>>
>>> npages = bitmap->length / bitmap->page_size;
>>>
>>> ? (if page_size is a bitmask it is badly named)
>>>
>>
>> It was a way to avoid the divide by zero, but
>> I can switch to the above, and check for bitmap->page_size
>> being non-zero. should be less obscure
> 
> Why would we ge so far along with a 0 page size? Reject that when
> bitmap is created??
> 
Yeah, right now I have an extra

	if (!bitmap->page_size)
		return rc;

	npages = bitmap->length / bitmap->page_size;

It is non-sensical to consider the whole thing valid is page size is 0.



[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