Add detach() to the guest_memfd provider operations. Providers must disable new bindings and private requests and stop and drain callbacks that access the VM before returning. This separates quiescing VM access from release(), which may run after the guest_memfd file and its VM reference have been released. Cc: Paolo Bonzini Cc: Sean Christopherson Cc: David Hildenbrand Cc: kvm@vger.kernel.org Cc: patches@lists.linux.dev Signed-off-by: Aneesh Kumar K.V (Arm) --- include/linux/guest_memfd.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/guest_memfd.h b/include/linux/guest_memfd.h index f0c62889f823..cfc26294d7ea 100644 --- a/include/linux/guest_memfd.h +++ b/include/linux/guest_memfd.h @@ -47,6 +47,8 @@ struct guest_memfd { * @get_pfn: Resolve a shared resource offset without taking a folio reference. * @prepare_conversion: Prepare protected PFN conversion; NULL request shares. * @finish_conversion: Finish conversion after attribute publication. + * @detach: Disable new bindings and private requests before final cleanup. + * Stop and drain callbacks that access the VM before returning. * * Provider operations supply exactly one of alloc_folio() and get_pfn(). * PFN providers start shared and require the bind and conversion callbacks @@ -65,6 +67,7 @@ struct guest_memfd_provider_operations { const struct guest_memfd_device_request *req); void (*finish_conversion)(void *provider, const struct guest_memfd_device_request *req); + void (*detach)(void *provider); }; #endif /* _LINUX_GUEST_MEMFD_H */ -- 2.43.0