Skip to content

Test MADV_COLLAPSE on guest_memfd

Ackerley Tng kvm linux-kselftest linux-mm lkml stable 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 2 repliesIn review
  2. v11 patch 2 repliesSuperseded

Changes in v2 from the cover letter

+ Found get_trans_hugepagesz(), which I should have used instead of adding getpmdsize()
+ Extended tools/testing/selftests/kvm/include/kvm_syscalls.h to add kvm_madvise()
+ Removed the magic constant address and explained alignment requirements in comments
+ Refactored gmem_test() macro to expose __gmem_test(), which allows custom sized guest_memfds for tests. Sean, I didn't add the gmem_test_huge_pmd() since I'm guessing a test requiring a pmd_sized guest_memfd would probably be once-off.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2KVM: selftests: Wrap madvise() to assert successtools/testing/selftests/kvm/include/kvm_syscalls.h+1 -01 reply
2/2KVM: selftests: Test MADV_COLLAPSE on guest_memfdtools/testing/selftests/kvm/guest_memfd_test.c+67 -30 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchDavid Hildenbrand (Arm)
1/2R-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] Test MADV_COLLAPSE on guest_memfd

syzkaller identified that khugepaged, operating on guest_memfd memory, could cause guest_memfd folios to get collapsed, leading to a WARNing during fault [1].

Add selftest to guard against similar regressions.

Changes in v2:

+ Found get_trans_hugepagesz(), which I should have used instead of adding getpmdsize()
+ Extended tools/testing/selftests/kvm/include/kvm_syscalls.h to add kvm_madvise()
+ Removed the magic constant address and explained alignment requirements in comments
+ Refactored gmem_test() macro to expose __gmem_test(), which allows custom sized guest_memfds for tests. Sean, I didn't add the gmem_test_huge_pmd() since I'm guessing a test requiring a pmd_sized guest_memfd would probably be once-off.

PATCH v1 [3] was sent in reply to the fix [2].

[1] https://syzkaller.appspot.com/bug?extid=33a04338019ac7e43a44
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/

Ackerley Tng (2):
KVM: selftests: Wrap madvise() to assert success
KVM: selftests: Test MADV_COLLAPSE on guest_memfd

 .../testing/selftests/kvm/guest_memfd_test.c  | 70 ++++++++++++++++++-
 .../selftests/kvm/include/kvm_syscalls.h      |  1 +
 2 files changed, 68 insertions(+), 3 deletions(-)

base-commit: a95f71ad3e2e224277508e006580c333d0a5fe36
prerequisite-patch-id: e001eecc9215dc0ed28546936f86a5a09e57141e --
2.53.0.345.g96ddfc5eaa-goog