Re: [PATCH 4/5] vfio: Introduce vfio_device_ops.get_unmapped_area hook

Peter Xu
2025-06-17T15:39:18Z

On Sat, Jun 14, 2025 at 10:46:45PM +0800, kernel test robot wrote:
> Hi Peter,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on akpm-mm/mm-everything]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Peter-Xu/mm-Deduplicate-mm_get_unmapped_area/20250613-214307
> base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> patch link: https://lore.kernel.org/r/20250613134111.469884-5-peterx%40redhat.com
> patch subject: [PATCH 4/5] vfio: Introduce vfio_device_ops.get_unmapped_area hook
> config: sh-randconfig-002-20250614 (https://download.01.org/0day-ci/archive/20250614/202506142215.koMEU2rT-lkp@intel.com/config)
> compiler: sh4-linux-gcc (GCC) 12.4.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250614/202506142215.koMEU2rT-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202506142215.koMEU2rT-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
> drivers/vfio/vfio_main.c: In function 'vfio_device_get_unmapped_area':
> >> drivers/vfio/vfio_main.c:1367:24: error: implicit declaration of function 'mm_get_unmapped_area'; did you mean 'get_unmapped_area'? [-Werror=implicit-function-declaration]
> 1367 | return mm_get_unmapped_area(current->mm, file, addr,
> | ^~~~~~~~~~~~~~~~~~~~
> | get_unmapped_area
> cc1: some warnings being treated as errors
>
>
> vim +1367 drivers/vfio/vfio_main.c
>
> 1356
> 1357 static unsigned long vfio_device_get_unmapped_area(struct file *file,
> 1358 unsigned long addr,
> 1359 unsigned long len,
> 1360 unsigned long pgoff,
> 1361 unsigned long flags)
> 1362 {
> 1363 struct vfio_device_file *df = file->private_data;
> 1364 struct vfio_device *device = df->device;
> 1365
> 1366 if (!device->ops->get_unmapped_area)
> > 1367 return mm_get_unmapped_area(current->mm, file, addr,
> 1368 len, pgoff, flags);
> 1369
> 1370 return device->ops->get_unmapped_area(device, file, addr, len,
> 1371 pgoff, flags);
> 1372 }
> 1373

This is "ARCH_SH + VFIO + !MMU".. I'll make sure to cover this config when
repost. I'll squash below into the patch:

diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c
index 19db8e58d223..cc14884d282f 100644
--- a/drivers/vfio/vfio_main.c
+++ b/drivers/vfio/vfio_main.c
@@ -1354,6 +1354,7 @@ static int vfio_device_fops_mmap(struct file *filep, struct vm_area_struct *vma)
return device->ops->mmap(device, vma);
}

+#ifdef CONFIG_ARCH_SUPPORTS_HUGE_PFNMAP
static unsigned long vfio_device_get_unmapped_area(struct file *file,
unsigned long addr,
unsigned long len,
@@ -1370,6 +1371,7 @@ static unsigned long vfio_device_get_unmapped_area(struct file *file,
return device->ops->get_unmapped_area(device, file, addr, len,
pgoff, flags);
}
+#endif

const struct file_operations vfio_device_fops = {
.owner = THIS_MODULE,
@@ -1380,7 +1382,9 @@ const struct file_operations vfio_device_fops = {
.unlocked_ioctl = vfio_device_fops_unl_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.mmap = vfio_device_fops_mmap,
+#ifdef CONFIG_ARCH_SUPPORTS_HUGE_PFNMAP
.get_unmapped_area = vfio_device_get_unmapped_area,
+#endif
};

static struct vfio_device *vfio_device_from_file(struct file *file)

--
Peter Xu