On Fri, Feb 23, 2024, Paolo Bonzini wrote: > On 2/21/24 08:25, David Stevens wrote: > > + } else if (!kfp->refcounted_page && > > + !kfp->guarded_by_mmu_notifier && > > + !allow_unsafe_mappings) { > > + r = -EFAULT; > > Why is allow_unsafe_mappings desirable at all? It's for use cases where memory is hidden from the kernel and managed by userspace, e.g. where AWS uses /dev/mem (I think) to map guest memory. From a kernel perspective, that is unsafe because KVM won't do the right thing if userspace unmaps memory while it is exposed to L2 via a pfn in vmcs02. I suggested allow_unsafe_mappings as a way to make upstream KVM safe by default, without completely breaking support for AWS and friends.