Binbin Wu <[email protected]> writes: > On 6/19/2026 8:31 AM, Ackerley Tng via B4 Relay wrote: > > [...] > >> diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c >> index bca912db5be6e..e0e544ef47d69 100644 >> --- a/virt/kvm/guest_memfd.c >> +++ b/virt/kvm/guest_memfd.c >> @@ -926,6 +926,24 @@ int kvm_gmem_get_pfn(struct kvm *kvm, struct >> kvm_memory_slot *slot, >> EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_gmem_get_pfn); >> >> #ifdef CONFIG_HAVE_KVM_ARCH_GMEM_POPULATE >> +static bool kvm_gmem_range_is_private(struct file *file, pgoff_t index, >> + size_t nr_pages, struct kvm *kvm, gfn_t >> gfn) >> +{ >> + struct maple_tree *mt = &GMEM_I(file_inode(file))->attributes; >> + pgoff_t end = index + nr_pages - 1; >> + void *entry; >> + >> + if (!gmem_in_place_conversion) >> + return kvm_range_has_vm_memory_attributes(kvm, gfn, gfn + >> nr_pages, >> + >> KVM_MEMORY_ATTRIBUTE_PRIVATE, >> + >> KVM_MEMORY_ATTRIBUTE_PRIVATE); >> + >> + mt_for_each(mt, entry, index, end) { >> + if (xa_to_value(entry) != KVM_MEMORY_ATTRIBUTE_PRIVATE) >> + return false; >> + } > > Patch 1 noted that "Ensuring every index is represented in the maple tree at > all times". > So I think the queried range should not be a hole in the maple tree. > However, there is a inconsistency: in patch 1 kvm_gmem_get_attributes() > explicitly > checks for holes, but this patch does not. > >> + return true; >> +} >>
With Sean's suggestion for patch 1, I'll update this one to default to the "init" state if xa_to_value(entry) is NULL. Thanks!
