@@ -4,6 +4,9 @@
#include <linux/kvm_host.h>
#include <linux/pagemap.h>
#include <linux/anon_inodes.h>
+#ifdef CONFIG_KVM_PRIVATE_MEM
+#include <linux/userfaultfd_k.h>
+#endif /* CONFIG_KVM_PRIVATE_MEM */
#include "kvm_mm.h"
@@ -380,6 +383,13 @@ static vm_fault_t kvm_gmem_fault(struct vm_fault *vmf)
kvm_gmem_mark_prepared(folio);
}
+ if (userfaultfd_minor(vmf->vma) &&
+ !(vmf->flags & FAULT_FLAG_NO_USERFAULT_MINOR)) {
+ folio_unlock(folio);
+ filemap_invalidate_unlock_shared(inode->i_mapping);
+ return handle_userfault(vmf, VM_UFFD_MINOR);
+ }
+
vmf->page = folio_file_page(folio, vmf->pgoff);
out_folio:
Add support for sending a pagefault event if userfaultfd is registered. Only page minor event is currently supported. Signed-off-by: Nikita Kalyazin <kalyazin@amazon.com> --- virt/kvm/guest_memfd.c | 10 ++++++++++ 1 file changed, 10 insertions(+)