Skip to content

Commit 6987ff5

Browse files
committed
vfio/type1: Use consistent types for page counts
jira LE-3557 Rebuild_History Non-Buildable kernel-5.14.0-570.26.1.el9_6 commit-author Alex Williamson <[email protected]> commit 0635559 Page count should more consistently be an unsigned long when passed as an argument while functions returning a number of pages should use a signed long to allow for -errno. vaddr_get_pfns() can therefore be upgraded to return long, though in practice it's currently limited by the batch capacity. In fact, the batch indexes are noted to never hold negative values, so while it doesn't make sense to bloat the structure with unsigned longs in this case, it does make sense to specify these as unsigned. No change in behavior expected. Reviewed-by: Peter Xu <[email protected]> Reviewed-by: Mitchell Augustin <[email protected]> Tested-by: Mitchell Augustin <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]> (cherry picked from commit 0635559) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 258edb7 commit 6987ff5

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/vfio/vfio_iommu_type1.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ struct vfio_dma {
105105
struct vfio_batch {
106106
struct page **pages; /* for pin_user_pages_remote */
107107
struct page *fallback_page; /* if pages alloc fails */
108-
int capacity; /* length of pages array */
109-
int size; /* of batch currently */
110-
int offset; /* of next entry in pages */
108+
unsigned int capacity; /* length of pages array */
109+
unsigned int size; /* of batch currently */
110+
unsigned int offset; /* of next entry in pages */
111111
};
112112

113113
struct vfio_iommu_group {
@@ -567,14 +567,14 @@ static int follow_fault_pfn(struct vm_area_struct *vma, struct mm_struct *mm,
567567
* initial offset. For VM_PFNMAP pfns, only the returned number of pfns and
568568
* returned initial pfn are provided; subsequent pfns are contiguous.
569569
*/
570-
static int vaddr_get_pfns(struct mm_struct *mm, unsigned long vaddr,
571-
long npages, int prot, unsigned long *pfn,
572-
struct vfio_batch *batch)
570+
static long vaddr_get_pfns(struct mm_struct *mm, unsigned long vaddr,
571+
unsigned long npages, int prot, unsigned long *pfn,
572+
struct vfio_batch *batch)
573573
{
574-
long pin_pages = min_t(long, npages, batch->capacity);
574+
unsigned long pin_pages = min_t(unsigned long, npages, batch->capacity);
575575
struct vm_area_struct *vma;
576576
unsigned int flags = 0;
577-
int ret;
577+
long ret;
578578

579579
if (prot & IOMMU_WRITE)
580580
flags |= FOLL_WRITE;
@@ -619,7 +619,7 @@ static int vaddr_get_pfns(struct mm_struct *mm, unsigned long vaddr,
619619
* first page and all consecutive pages with the same locking.
620620
*/
621621
static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
622-
long npage, unsigned long *pfn_base,
622+
unsigned long npage, unsigned long *pfn_base,
623623
unsigned long limit, struct vfio_batch *batch)
624624
{
625625
unsigned long pfn;
@@ -731,7 +731,7 @@ static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
731731
}
732732

733733
static long vfio_unpin_pages_remote(struct vfio_dma *dma, dma_addr_t iova,
734-
unsigned long pfn, long npage,
734+
unsigned long pfn, unsigned long npage,
735735
bool do_accounting)
736736
{
737737
long unlocked = 0, locked = 0;

0 commit comments

Comments
 (0)