Move from the deprecated mmap hook to the new mmap_prepare hook for the
xenfs xsd_kva file and the xenbus_backend device, both of which remap the
xenstore interface page.

Use the PFN remap mmap action to do so, retaining the -EAGAIN error on
failure via the action error override.

Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]>
---
 drivers/xen/xenbus/xenbus_dev_backend.c | 14 ++++++--------
 drivers/xen/xenfs/xenstored.c           | 14 ++++++--------
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/xen/xenbus/xenbus_dev_backend.c 
b/drivers/xen/xenbus/xenbus_dev_backend.c
index edba5fecde4d..3e4cb267f411 100644
--- a/drivers/xen/xenbus/xenbus_dev_backend.c
+++ b/drivers/xen/xenbus/xenbus_dev_backend.c
@@ -89,27 +89,25 @@ static long xenbus_backend_ioctl(struct file *file, 
unsigned int cmd,
        }
 }
 
-static int xenbus_backend_mmap(struct file *file, struct vm_area_struct *vma)
+static int xenbus_backend_mmap_prepare(struct vm_area_desc *desc)
 {
-       size_t size = vma->vm_end - vma->vm_start;
+       size_t size = vma_desc_size(desc);
 
        if (!capable(CAP_SYS_ADMIN))
                return -EPERM;
 
-       if ((size > PAGE_SIZE) || (vma->vm_pgoff != 0))
+       if ((size > PAGE_SIZE) || (desc->pgoff != 0))
                return -EINVAL;
 
-       if (remap_pfn_range(vma, vma->vm_start,
-                           virt_to_pfn(xen_store_interface),
-                           size, vma->vm_page_prot))
-               return -EAGAIN;
+       mmap_action_remap_full(desc, virt_to_pfn(xen_store_interface));
+       desc->action.error_override = -EAGAIN;
 
        return 0;
 }
 
 static const struct file_operations xenbus_backend_fops = {
        .open = xenbus_backend_open,
-       .mmap = xenbus_backend_mmap,
+       .mmap_prepare = xenbus_backend_mmap_prepare,
        .unlocked_ioctl = xenbus_backend_ioctl,
 };
 
diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
index f59235f9f8a2..0cf57c286adb 100644
--- a/drivers/xen/xenfs/xenstored.c
+++ b/drivers/xen/xenfs/xenstored.c
@@ -31,24 +31,22 @@ static int xsd_kva_open(struct inode *inode, struct file 
*file)
        return 0;
 }
 
-static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma)
+static int xsd_kva_mmap_prepare(struct vm_area_desc *desc)
 {
-       size_t size = vma->vm_end - vma->vm_start;
+       size_t size = vma_desc_size(desc);
 
-       if ((size > PAGE_SIZE) || (vma->vm_pgoff != 0))
+       if ((size > PAGE_SIZE) || (desc->pgoff != 0))
                return -EINVAL;
 
-       if (remap_pfn_range(vma, vma->vm_start,
-                           virt_to_pfn(xen_store_interface),
-                           size, vma->vm_page_prot))
-               return -EAGAIN;
+       mmap_action_remap_full(desc, virt_to_pfn(xen_store_interface));
+       desc->action.error_override = -EAGAIN;
 
        return 0;
 }
 
 const struct file_operations xsd_kva_file_ops = {
        .open = xsd_kva_open,
-       .mmap = xsd_kva_mmap,
+       .mmap_prepare = xsd_kva_mmap_prepare,
        .read = xsd_read,
        .release = xsd_release,
 };

-- 
2.56.0


Reply via email to