]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: selftests: Add guest_memfd tests for mmap and NUMA policy support
authorShivank Garg <shivankg@amd.com>
Thu, 16 Oct 2025 17:28:52 +0000 (10:28 -0700)
committerSean Christopherson <seanjc@google.com>
Mon, 20 Oct 2025 13:30:45 +0000 (06:30 -0700)
commit38ccc50ac037ab79609c33556b696064ef52521c
tree801d5e60767c26887b47124010fcd66ba3faccb8
parente698e89b3ed1772e543a5ab4c072b9bbdb730948
KVM: selftests: Add guest_memfd tests for mmap and NUMA policy support

Add tests for NUMA memory policy binding and NUMA aware allocation in
guest_memfd. This extends the existing selftests by adding proper
validation for:
  - KVM GMEM set_policy and get_policy() vm_ops functionality using
    mbind() and get_mempolicy()
  - NUMA policy application before and after memory allocation

Run the NUMA mbind() test with and without INIT_SHARED, as KVM should allow
doing mbind(), madvise(), etc. on guest-private memory, e.g. so that
userspace can set NUMA policy for CoCo VMs.

Run the NUMA allocation test only for INIT_SHARED, i.e. if the host can't
fault-in memory (via direct access, madvise(), etc.) as move_pages()
returns -ENOENT if the page hasn't been faulted in (walks the host page
tables to find the associated folio)

[sean: don't skip entire test when running on non-NUMA system, test mbind()
       with private memory, provide more info in assert messages]

Signed-off-by: Shivank Garg <shivankg@amd.com>
Tested-by: Ashish Kalra <ashish.kalra@amd.com>
Link: https://lore.kernel.org/r/20251016172853.52451-12-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/guest_memfd_test.c