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

Jason Gunthorpe
2025-06-17T15:42:02Z

On Tue, Jun 17, 2025 at 11:39:07AM -0400, Peter Xu wrote:
>
> +#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
> };

IMHO this also seems like something the core code should be dealing
with and not putting weird ifdefs in drivers.

Jason