File tree Expand file tree Collapse file tree 9 files changed +60
-8
lines changed
tools/testing/selftests/mm Expand file tree Collapse file tree 9 files changed +60
-8
lines changed Original file line number Diff line number Diff line change 15
15
#define _GNU_SOURCE
16
16
#include <stdlib.h>
17
17
#include <stdio.h>
18
- #include <asm-generic/ unistd.h>
18
+ #include <unistd.h>
19
19
#include <sys/mman.h>
20
20
#include <errno.h>
21
21
#include <fcntl.h> /* Definition of O_* constants */
Original file line number Diff line number Diff line change 11
11
#include <string.h>
12
12
#include <stdbool.h>
13
13
#include <stdint.h>
14
- #include <asm-generic/ unistd.h>
14
+ #include <unistd.h>
15
15
#include <errno.h>
16
16
#include <fcntl.h>
17
17
#include <sys/mman.h>
@@ -369,6 +369,7 @@ static void test_unmerge_discarded(void)
369
369
munmap (map , size );
370
370
}
371
371
372
+ #ifdef __NR_userfaultfd
372
373
static void test_unmerge_uffd_wp (void )
373
374
{
374
375
struct uffdio_writeprotect uffd_writeprotect ;
@@ -429,6 +430,7 @@ static void test_unmerge_uffd_wp(void)
429
430
unmap :
430
431
munmap (map , size );
431
432
}
433
+ #endif
432
434
433
435
/* Verify that KSM can be enabled / queried with prctl. */
434
436
static void test_prctl (void )
@@ -684,7 +686,9 @@ int main(int argc, char **argv)
684
686
exit (test_child_ksm ());
685
687
}
686
688
689
+ #ifdef __NR_userfaultfd
687
690
tests ++ ;
691
+ #endif
688
692
689
693
ksft_print_header ();
690
694
ksft_set_plan (tests );
@@ -696,7 +700,9 @@ int main(int argc, char **argv)
696
700
test_unmerge ();
697
701
test_unmerge_zero_pages ();
698
702
test_unmerge_discarded ();
703
+ #ifdef __NR_userfaultfd
699
704
test_unmerge_uffd_wp ();
705
+ #endif
700
706
701
707
test_prot_none ();
702
708
Original file line number Diff line number Diff line change 17
17
18
18
#include <stdlib.h>
19
19
#include <string.h>
20
- #include <asm-generic/ unistd.h>
20
+ #include <unistd.h>
21
21
#include <errno.h>
22
22
#include <stdio.h>
23
23
#include <fcntl.h>
28
28
#define pass (fmt , ...) ksft_test_result_pass(fmt, ##__VA_ARGS__)
29
29
#define skip (fmt , ...) ksft_test_result_skip(fmt, ##__VA_ARGS__)
30
30
31
+ #ifdef __NR_memfd_secret
32
+
31
33
#define PATTERN 0x55
32
34
33
35
static const int prot = PROT_READ | PROT_WRITE ;
@@ -332,3 +334,13 @@ int main(int argc, char *argv[])
332
334
333
335
ksft_finished ();
334
336
}
337
+
338
+ #else /* __NR_memfd_secret */
339
+
340
+ int main (int argc , char * argv [])
341
+ {
342
+ printf ("skip: skipping memfd_secret test (missing __NR_memfd_secret)\n" );
343
+ return KSFT_SKIP ;
344
+ }
345
+
346
+ #endif /* __NR_memfd_secret */
Original file line number Diff line number Diff line change 9
9
*/
10
10
#include <fcntl.h>
11
11
#include <signal.h>
12
- #include <asm-generic/ unistd.h>
12
+ #include <unistd.h>
13
13
#include <string.h>
14
14
#include <errno.h>
15
15
#include <stdlib.h>
@@ -265,6 +265,7 @@ static void test_pte_mapped_thp(void)
265
265
munmap (mmap_mem , mmap_size );
266
266
}
267
267
268
+ #ifdef __NR_userfaultfd
268
269
static void test_uffdio_copy (void )
269
270
{
270
271
struct uffdio_register uffdio_register ;
@@ -322,6 +323,7 @@ static void test_uffdio_copy(void)
322
323
munmap (dst , pagesize );
323
324
free (src );
324
325
}
326
+ #endif /* __NR_userfaultfd */
325
327
326
328
int main (void )
327
329
{
@@ -334,7 +336,9 @@ int main(void)
334
336
thpsize / 1024 );
335
337
tests += 3 ;
336
338
}
339
+ #ifdef __NR_userfaultfd
337
340
tests += 1 ;
341
+ #endif /* __NR_userfaultfd */
338
342
339
343
ksft_print_header ();
340
344
ksft_set_plan (tests );
@@ -364,7 +368,9 @@ int main(void)
364
368
if (thpsize )
365
369
test_pte_mapped_thp ();
366
370
/* Placing a fresh page via userfaultfd may set the PTE dirty. */
371
+ #ifdef __NR_userfaultfd
367
372
test_uffdio_copy ();
373
+ #endif /* __NR_userfaultfd */
368
374
369
375
err = ksft_get_fail_cnt ();
370
376
if (err )
Original file line number Diff line number Diff line change 3
3
#include <errno.h>
4
4
#include <stdio.h>
5
5
#include <stdlib.h>
6
- #include <asm-generic/unistd.h>
7
6
8
7
static int mlock2_ (void * start , size_t len , int flags )
9
8
{
Original file line number Diff line number Diff line change 42
42
#include <sys/wait.h>
43
43
#include <sys/stat.h>
44
44
#include <fcntl.h>
45
- #include <asm-generic/ unistd.h>
45
+ #include <unistd.h>
46
46
#include <sys/ptrace.h>
47
47
#include <setjmp.h>
48
48
Original file line number Diff line number Diff line change @@ -673,7 +673,11 @@ int uffd_open_dev(unsigned int flags)
673
673
674
674
int uffd_open_sys (unsigned int flags )
675
675
{
676
+ #ifdef __NR_userfaultfd
676
677
return syscall (__NR_userfaultfd , flags );
678
+ #else
679
+ return -1 ;
680
+ #endif
677
681
}
678
682
679
683
int uffd_open (unsigned int flags )
Original file line number Diff line number Diff line change 33
33
* pthread_mutex_lock will also verify the atomicity of the memory
34
34
* transfer (UFFDIO_COPY).
35
35
*/
36
- #include <asm-generic/unistd.h>
36
+
37
37
#include "uffd-common.h"
38
38
39
39
uint64_t features ;
40
+ #ifdef __NR_userfaultfd
40
41
41
42
#define BOUNCE_RANDOM (1<<0)
42
43
#define BOUNCE_RACINGFAULTS (1<<1)
@@ -471,3 +472,15 @@ int main(int argc, char **argv)
471
472
nr_pages , nr_pages_per_cpu );
472
473
return userfaultfd_stress ();
473
474
}
475
+
476
+ #else /* __NR_userfaultfd */
477
+
478
+ #warning "missing __NR_userfaultfd definition"
479
+
480
+ int main (void )
481
+ {
482
+ printf ("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n" );
483
+ return KSFT_SKIP ;
484
+ }
485
+
486
+ #endif /* __NR_userfaultfd */
Original file line number Diff line number Diff line change 5
5
* Copyright (C) 2015-2023 Red Hat, Inc.
6
6
*/
7
7
8
- #include <asm-generic/unistd.h>
9
8
#include "uffd-common.h"
10
9
11
10
#include "../../../../mm/gup_test.h"
12
11
12
+ #ifdef __NR_userfaultfd
13
+
13
14
/* The unit test doesn't need a large or random size, make it 32MB for now */
14
15
#define UFFD_TEST_MEM_SIZE (32UL << 20)
15
16
@@ -1558,3 +1559,14 @@ int main(int argc, char *argv[])
1558
1559
return ksft_get_fail_cnt () ? KSFT_FAIL : KSFT_PASS ;
1559
1560
}
1560
1561
1562
+ #else /* __NR_userfaultfd */
1563
+
1564
+ #warning "missing __NR_userfaultfd definition"
1565
+
1566
+ int main (void )
1567
+ {
1568
+ printf ("Skipping %s (missing __NR_userfaultfd)\n" , __file__ );
1569
+ return KSFT_SKIP ;
1570
+ }
1571
+
1572
+ #endif /* __NR_userfaultfd */
You can’t perform that action at this time.
0 commit comments