Hi Fuad, On 3/18/2025 9:48 PM, Fuad Tabba wrote: > Add support for mmap() and fault() for guest_memfd backed memory > in the host for VMs that support in-place conversion between > shared and private. To that end, this patch adds the ability to > check whether the VM type supports in-place conversion, and only > allows mapping its memory if that's the case. > > Also add the KVM capability KVM_CAP_GMEM_SHARED_MEM, which > indicates that the VM supports shared memory in guest_memfd, or > that the host can create VMs that support shared memory. > Supporting shared memory implies that memory can be mapped when > shared with the host. > > This is controlled by the KVM_GMEM_SHARED_MEM configuration > option. > > Signed-off-by: Fuad Tabba <tabba@xxxxxxxxxx> ... ... > + > +static int kvm_gmem_mmap(struct file *file, struct vm_area_struct *vma) > +{ > + struct kvm_gmem *gmem = file->private_data; > + > + if (!kvm_arch_gmem_supports_shared_mem(gmem->kvm)) > + return -ENODEV; > + > + if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) != > + (VM_SHARED | VM_MAYSHARE)) { > + return -EINVAL; > + } > + > + file_accessed(file); As it is not directly visible to userspace, do we need to update the file's access time via file_accessed()? > + vm_flags_set(vma, VM_DONTDUMP); > + vma->vm_ops = &kvm_gmem_vm_ops; > + > + return 0; > +} > +#else > +#define kvm_gmem_mmap NULL > +#endif /* CONFIG_KVM_GMEM_SHARED_MEM */ > + > static struct file_operations kvm_gmem_fops = { > + .mmap = kvm_gmem_mmap, > .open = generic_file_open, > .release = kvm_gmem_release, > .fallocate = kvm_gmem_fallocate, Thanks, Shivank