]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: guest_memfd: Use guest mem inodes instead of anonymous inodes
authorAckerley Tng <ackerleytng@google.com>
Thu, 16 Oct 2025 17:28:44 +0000 (10:28 -0700)
committerSean Christopherson <seanjc@google.com>
Mon, 20 Oct 2025 13:30:40 +0000 (06:30 -0700)
commita63ca4236e6799cf4343f9aec9d92afdfa582446
treeec964e86b5dc2b1901ab0b64904819bf29a3f8e2
parent392dd9d9488a8a81c2d58f9f4eee99c5b7b8e1c7
KVM: guest_memfd: Use guest mem inodes instead of anonymous inodes

guest_memfd's inode represents memory the guest_memfd is
providing. guest_memfd's file represents a struct kvm's view of that
memory.

Using a custom inode allows customization of the inode teardown
process via callbacks. For example, ->evict_inode() allows
customization of the truncation process on file close, and
->destroy_inode() and ->free_inode() allow customization of the inode
freeing process.

Customizing the truncation process allows flexibility in management of
guest_memfd memory and customization of the inode freeing process
allows proper cleanup of memory metadata stored on the inode.

Memory metadata is more appropriately stored on the inode (as opposed
to the file), since the metadata is for the memory and is not unique
to a specific binding and struct kvm.

Acked-by: David Hildenbrand <david@redhat.com>
Co-developed-by: Fuad Tabba <tabba@google.com>
Signed-off-by: Fuad Tabba <tabba@google.com>
Signed-off-by: Ackerley Tng <ackerleytng@google.com>
Signed-off-by: Shivank Garg <shivankg@amd.com>
Tested-by: Ashish Kalra <ashish.kalra@amd.com>
[sean: drop helpers, open code logic in __kvm_gmem_create()]
Link: https://lore.kernel.org/r/20251016172853.52451-4-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
include/uapi/linux/magic.h
virt/kvm/guest_memfd.c
virt/kvm/kvm_main.c
virt/kvm/kvm_mm.h