public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: selftests: Include linux version of mman.h
@ 2026-04-27 20:43 Rick Edgecombe
  2026-04-27 23:39 ` Sean Christopherson
  2026-04-28 23:55 ` Ackerley Tng
  0 siblings, 2 replies; 6+ messages in thread
From: Rick Edgecombe @ 2026-04-27 20:43 UTC (permalink / raw)
  To: pbonzini, ackerleytng, seanjc
  Cc: kvm, linux-kselftest, linux-kernel, rick.p.edgecombe

Fix a selftest build error by switching a mman.h header include from the
"sys" version to the "linux" one.

Recently a reference to MADV_COLLAPSE was added to guest_memfd_test.c.
This works fine if the system libc has this definition, but against older
libcs, it leads to build errors like:
  In file included from include/kvm_util.h:8,
                   from guest_memfd_test.c:21:
  guest_memfd_test.c: In function ‘test_collapse’:
  guest_memfd_test.c:219:47: error: ‘MADV_COLLAPSE’ undeclared (first use in this function); did you mean ‘MADV_COLD’?
      219 |         TEST_ASSERT_EQ(madvise(mem, pmd_size, MADV_COLLAPSE), -1);
          |                                               ^~~~~~~~~~~~~
    include/test_util.h:62:16: note: in definition of macro ‘TEST_ASSERT_EQ’
       62 |         typeof(a) __a = (a);                                            \
          |                ^
    guest_memfd_test.c:219:47: note: each undeclared identifier is reported only once for each function it appears in
      219 |         TEST_ASSERT_EQ(madvise(mem, pmd_size, MADV_COLLAPSE), -1);
          |                                               ^~~~~~~~~~~~~
    include/test_util.h:62:16: note: in definition of macro ‘TEST_ASSERT_EQ’
       62 |         typeof(a) __a = (a);                                            \
          |                ^

The problem is the test is pulling in the libc version of mman.h instead of
the Linux one. Switch it to the Linux one so MADV_COLLAPSE will be
guaranteed to be present (if the user installs the headers).

Fixes: 9830209b4ae8 ("KVM: selftests: Test MADV_COLLAPSE on guest_memfd")
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
---

Hi,

I'm not sure if there is standard official version of the header to include
for the selftests, but the KVM selftests no longer build for me. This fixes
it.

 tools/testing/selftests/kvm/guest_memfd_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/guest_memfd_test.c b/tools/testing/selftests/kvm/guest_memfd_test.c
index ec7644aae999..7c113b8c4f75 100644
--- a/tools/testing/selftests/kvm/guest_memfd_test.c
+++ b/tools/testing/selftests/kvm/guest_memfd_test.c
@@ -14,7 +14,7 @@
 #include <linux/bitmap.h>
 #include <linux/falloc.h>
 #include <linux/sizes.h>
-#include <sys/mman.h>
+#include <linux/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-04-28 23:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 20:43 [PATCH] KVM: selftests: Include linux version of mman.h Rick Edgecombe
2026-04-27 23:39 ` Sean Christopherson
2026-04-27 23:49   ` Edgecombe, Rick P
2026-04-27 23:57     ` Sean Christopherson
2026-04-27 23:59       ` Edgecombe, Rick P
2026-04-28 23:55 ` Ackerley Tng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox