#include <linux/syscalls.h>
 #include <linux/fcntl.h>
 #include <uapi/linux/memfd.h>
+#include <linux/userfaultfd_k.h>
 #include <linux/rmap.h>
 
 #include <linux/uaccess.h>
                                struct shmem_inode_info *info, pgoff_t index);
 static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
                struct page **pagep, enum sgp_type sgp,
-               gfp_t gfp, struct mm_struct *fault_mm, int *fault_type);
+               gfp_t gfp, struct vm_area_struct *vma,
+               struct vm_fault *vmf, int *fault_type);
 
 int shmem_getpage(struct inode *inode, pgoff_t index,
                struct page **pagep, enum sgp_type sgp)
 {
        return shmem_getpage_gfp(inode, index, pagep, sgp,
-               mapping_gfp_mask(inode->i_mapping), NULL, NULL);
+               mapping_gfp_mask(inode->i_mapping), NULL, NULL, NULL);
 }
 
 static inline struct shmem_sb_info *SHMEM_SB(struct super_block *sb)
  */
 static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
        struct page **pagep, enum sgp_type sgp, gfp_t gfp,
-       struct mm_struct *fault_mm, int *fault_type)
+       struct vm_area_struct *vma, struct vm_fault *vmf, int *fault_type)
 {
        struct address_space *mapping = inode->i_mapping;
        struct shmem_inode_info *info = SHMEM_I(inode);
         * bring it back from swap or allocate.
         */
        sbinfo = SHMEM_SB(inode->i_sb);
-       charge_mm = fault_mm ? : current->mm;
+       charge_mm = vma ? vma->vm_mm : current->mm;
 
        if (swap.val) {
                /* Look it up and read it in.. */
                        if (fault_type) {
                                *fault_type |= VM_FAULT_MAJOR;
                                count_vm_event(PGMAJFAULT);
-                               mem_cgroup_count_vm_event(fault_mm, PGMAJFAULT);
+                               mem_cgroup_count_vm_event(charge_mm,
+                                                         PGMAJFAULT);
                        }
                        /* Here we actually start the io */
                        page = shmem_swapin(swap, gfp, info, index);
                swap_free(swap);
 
        } else {
+               if (vma && userfaultfd_missing(vma)) {
+                       *fault_type = handle_userfault(vmf, VM_UFFD_MISSING);
+                       return 0;
+               }
+
                /* shmem_symlink() */
                if (mapping->a_ops != &shmem_aops)
                        goto alloc_nohuge;
                sgp = SGP_NOHUGE;
 
        error = shmem_getpage_gfp(inode, vmf->pgoff, &vmf->page, sgp,
-                                 gfp, vma->vm_mm, &ret);
+                                 gfp, vma, vmf, &ret);
        if (error)
                return ((error == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS);
        return ret;
 
        BUG_ON(mapping->a_ops != &shmem_aops);
        error = shmem_getpage_gfp(inode, index, &page, SGP_CACHE,
-                                 gfp, NULL, NULL);
+                                 gfp, NULL, NULL, NULL);
        if (error)
                page = ERR_PTR(error);
        else