On Thu, Jan 09, 2025, James Houghton wrote: > James Houghton (13): > KVM: Add KVM_MEM_USERFAULT memslot flag and bitmap > KVM: Add KVM_MEMORY_EXIT_FLAG_USERFAULT > KVM: Allow late setting of KVM_MEM_USERFAULT on guest_memfd memslot > KVM: Advertise KVM_CAP_USERFAULT in KVM_CHECK_EXTENSION Starting with some series-wide feedback, the granularity of these first few patches is too fine. I normally like to split things up, but honestly, this is such a small feature that I don't see much point in separating the uAPI from the infrastructure. To avoid cyclical dependencies between common KVM and arch code, we can do all the prep, but not fully enable+advertise support on any architecture until all targeted architectures are fully ready. In other words, I think we should squish these into one patch, minus this bit at the very end of the series (spoiler alert): diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index ce7bf5de6d72..0106d6d461a3 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1545,6 +1545,9 @@ static int check_memory_region_flags(struct kvm *kvm, !(mem->flags & KVM_MEM_GUEST_MEMFD)) valid_flags |= KVM_MEM_READONLY; + if (IS_ENABLED(CONFIG_KVM_GENERIC_PAGE_FAULT)) + valid_flags |= KVM_MEM_USERFAULT; + if (mem->flags & ~valid_flags) return -EINVAL; @@ -4824,6 +4827,9 @@ static int kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) case KVM_CAP_CHECK_EXTENSION_VM: case KVM_CAP_ENABLE_CAP_VM: case KVM_CAP_HALT_POLL: +#ifdef CONFIG_KVM_GENERIC_PAGE_FAULT + case KVM_CAP_USERFAULT: +#endif return 1; #ifdef CONFIG_KVM_MMIO case KVM_CAP_COALESCED_MMIO: