8d99b6d78f89a839943f94d8ef5f22e8c777a785
[linux-2.6-microblaze.git] / tools / testing / selftests / kvm / demand_paging_test.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * KVM demand paging test
4  * Adapted from dirty_log_test.c
5  *
6  * Copyright (C) 2018, Red Hat, Inc.
7  * Copyright (C) 2019, Google, Inc.
8  */
9
10 #define _GNU_SOURCE /* for program_invocation_name */
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <sys/syscall.h>
15 #include <unistd.h>
16 #include <asm/unistd.h>
17 #include <time.h>
18 #include <poll.h>
19 #include <pthread.h>
20 #include <linux/bitmap.h>
21 #include <linux/bitops.h>
22 #include <linux/userfaultfd.h>
23
24 #include "test_util.h"
25 #include "kvm_util.h"
26 #include "processor.h"
27
28 #ifdef __NR_userfaultfd
29
30 /* The memory slot index demand page */
31 #define TEST_MEM_SLOT_INDEX             1
32
33 /* Default guest test virtual memory offset */
34 #define DEFAULT_GUEST_TEST_MEM          0xc0000000
35
36 #define DEFAULT_GUEST_TEST_MEM_SIZE (1 << 30) /* 1G */
37
38 #ifdef PRINT_PER_PAGE_UPDATES
39 #define PER_PAGE_DEBUG(...) printf(__VA_ARGS__)
40 #else
41 #define PER_PAGE_DEBUG(...) _no_printf(__VA_ARGS__)
42 #endif
43
44 #ifdef PRINT_PER_VCPU_UPDATES
45 #define PER_VCPU_DEBUG(...) printf(__VA_ARGS__)
46 #else
47 #define PER_VCPU_DEBUG(...) _no_printf(__VA_ARGS__)
48 #endif
49
50 #define MAX_VCPUS 512
51
52 /*
53  * Guest/Host shared variables. Ensure addr_gva2hva() and/or
54  * sync_global_to/from_guest() are used when accessing from
55  * the host. READ/WRITE_ONCE() should also be used with anything
56  * that may change.
57  */
58 static uint64_t host_page_size;
59 static uint64_t guest_page_size;
60
61 static char *guest_data_prototype;
62
63 /*
64  * Guest physical memory offset of the testing memory slot.
65  * This will be set to the topmost valid physical address minus
66  * the test memory size.
67  */
68 static uint64_t guest_test_phys_mem;
69
70 /*
71  * Guest virtual memory offset of the testing memory slot.
72  * Must not conflict with identity mapped test code.
73  */
74 static uint64_t guest_test_virt_mem = DEFAULT_GUEST_TEST_MEM;
75
76 struct vcpu_args {
77         uint64_t gva;
78         uint64_t pages;
79
80         /* Only used by the host userspace part of the vCPU thread */
81         int vcpu_id;
82         struct kvm_vm *vm;
83 };
84
85 static struct vcpu_args vcpu_args[MAX_VCPUS];
86
87 /*
88  * Continuously write to the first 8 bytes of each page in the demand paging
89  * memory region.
90  */
91 static void guest_code(uint32_t vcpu_id)
92 {
93         uint64_t gva;
94         uint64_t pages;
95         int i;
96
97         /* Make sure vCPU args data structure is not corrupt. */
98         GUEST_ASSERT(vcpu_args[vcpu_id].vcpu_id == vcpu_id);
99
100         gva = vcpu_args[vcpu_id].gva;
101         pages = vcpu_args[vcpu_id].pages;
102
103         for (i = 0; i < pages; i++) {
104                 uint64_t addr = gva + (i * guest_page_size);
105
106                 addr &= ~(host_page_size - 1);
107                 *(uint64_t *)addr = 0x0123456789ABCDEF;
108         }
109
110         GUEST_SYNC(1);
111 }
112
113 static void *vcpu_worker(void *data)
114 {
115         int ret;
116         struct vcpu_args *args = (struct vcpu_args *)data;
117         struct kvm_vm *vm = args->vm;
118         int vcpu_id = args->vcpu_id;
119         struct kvm_run *run;
120         struct timespec start;
121         struct timespec end;
122
123         vcpu_args_set(vm, vcpu_id, 1, vcpu_id);
124         run = vcpu_state(vm, vcpu_id);
125
126         clock_gettime(CLOCK_MONOTONIC, &start);
127
128         /* Let the guest access its memory */
129         ret = _vcpu_run(vm, vcpu_id);
130         TEST_ASSERT(ret == 0, "vcpu_run failed: %d\n", ret);
131         if (get_ucall(vm, vcpu_id, NULL) != UCALL_SYNC) {
132                 TEST_ASSERT(false,
133                             "Invalid guest sync status: exit_reason=%s\n",
134                             exit_reason_str(run->exit_reason));
135         }
136
137         clock_gettime(CLOCK_MONOTONIC, &end);
138         PER_VCPU_DEBUG("vCPU %d execution time: %lld.%.9lds\n", vcpu_id,
139                        (long long)(timespec_diff(start, end).tv_sec),
140                        timespec_diff(start, end).tv_nsec);
141
142         return NULL;
143 }
144
145 #define PAGE_SHIFT_4K  12
146 #define PTES_PER_4K_PT 512
147
148 static struct kvm_vm *create_vm(enum vm_guest_mode mode, int vcpus,
149                                 uint64_t vcpu_memory_bytes)
150 {
151         struct kvm_vm *vm;
152         uint64_t pages = DEFAULT_GUEST_PHY_PAGES;
153
154         /* Account for a few pages per-vCPU for stacks */
155         pages += DEFAULT_STACK_PGS * vcpus;
156
157         /*
158          * Reserve twice the ammount of memory needed to map the test region and
159          * the page table / stacks region, at 4k, for page tables. Do the
160          * calculation with 4K page size: the smallest of all archs. (e.g., 64K
161          * page size guest will need even less memory for page tables).
162          */
163         pages += (2 * pages) / PTES_PER_4K_PT;
164         pages += ((2 * vcpus * vcpu_memory_bytes) >> PAGE_SHIFT_4K) /
165                  PTES_PER_4K_PT;
166         pages = vm_adjust_num_guest_pages(mode, pages);
167
168         pr_info("Testing guest mode: %s\n", vm_guest_mode_string(mode));
169
170         vm = _vm_create(mode, pages, O_RDWR);
171         kvm_vm_elf_load(vm, program_invocation_name, 0, 0);
172 #ifdef __x86_64__
173         vm_create_irqchip(vm);
174 #endif
175         return vm;
176 }
177
178 static int handle_uffd_page_request(int uffd, uint64_t addr)
179 {
180         pid_t tid;
181         struct timespec start;
182         struct timespec end;
183         struct uffdio_copy copy;
184         int r;
185
186         tid = syscall(__NR_gettid);
187
188         copy.src = (uint64_t)guest_data_prototype;
189         copy.dst = addr;
190         copy.len = host_page_size;
191         copy.mode = 0;
192
193         clock_gettime(CLOCK_MONOTONIC, &start);
194
195         r = ioctl(uffd, UFFDIO_COPY, &copy);
196         if (r == -1) {
197                 pr_info("Failed Paged in 0x%lx from thread %d with errno: %d\n",
198                         addr, tid, errno);
199                 return r;
200         }
201
202         clock_gettime(CLOCK_MONOTONIC, &end);
203
204         PER_PAGE_DEBUG("UFFDIO_COPY %d \t%lld ns\n", tid,
205                        (long long)timespec_to_ns(timespec_diff(start, end)));
206         PER_PAGE_DEBUG("Paged in %ld bytes at 0x%lx from thread %d\n",
207                        host_page_size, addr, tid);
208
209         return 0;
210 }
211
212 bool quit_uffd_thread;
213
214 struct uffd_handler_args {
215         int uffd;
216         int pipefd;
217         useconds_t delay;
218 };
219
220 static void *uffd_handler_thread_fn(void *arg)
221 {
222         struct uffd_handler_args *uffd_args = (struct uffd_handler_args *)arg;
223         int uffd = uffd_args->uffd;
224         int pipefd = uffd_args->pipefd;
225         useconds_t delay = uffd_args->delay;
226         int64_t pages = 0;
227         struct timespec start;
228         struct timespec end;
229
230         clock_gettime(CLOCK_MONOTONIC, &start);
231         while (!quit_uffd_thread) {
232                 struct uffd_msg msg;
233                 struct pollfd pollfd[2];
234                 char tmp_chr;
235                 int r;
236                 uint64_t addr;
237
238                 pollfd[0].fd = uffd;
239                 pollfd[0].events = POLLIN;
240                 pollfd[1].fd = pipefd;
241                 pollfd[1].events = POLLIN;
242
243                 r = poll(pollfd, 2, -1);
244                 switch (r) {
245                 case -1:
246                         pr_info("poll err");
247                         continue;
248                 case 0:
249                         continue;
250                 case 1:
251                         break;
252                 default:
253                         pr_info("Polling uffd returned %d", r);
254                         return NULL;
255                 }
256
257                 if (pollfd[0].revents & POLLERR) {
258                         pr_info("uffd revents has POLLERR");
259                         return NULL;
260                 }
261
262                 if (pollfd[1].revents & POLLIN) {
263                         r = read(pollfd[1].fd, &tmp_chr, 1);
264                         TEST_ASSERT(r == 1,
265                                     "Error reading pipefd in UFFD thread\n");
266                         return NULL;
267                 }
268
269                 if (!pollfd[0].revents & POLLIN)
270                         continue;
271
272                 r = read(uffd, &msg, sizeof(msg));
273                 if (r == -1) {
274                         if (errno == EAGAIN)
275                                 continue;
276                         pr_info("Read of uffd gor errno %d", errno);
277                         return NULL;
278                 }
279
280                 if (r != sizeof(msg)) {
281                         pr_info("Read on uffd returned unexpected size: %d bytes", r);
282                         return NULL;
283                 }
284
285                 if (!(msg.event & UFFD_EVENT_PAGEFAULT))
286                         continue;
287
288                 if (delay)
289                         usleep(delay);
290                 addr =  msg.arg.pagefault.address;
291                 r = handle_uffd_page_request(uffd, addr);
292                 if (r < 0)
293                         return NULL;
294                 pages++;
295         }
296
297         clock_gettime(CLOCK_MONOTONIC, &end);
298         PER_VCPU_DEBUG("userfaulted %ld pages over %lld.%.9lds. (%f/sec)\n",
299                        pages, (long long)(timespec_diff(start, end).tv_sec),
300                        timespec_diff(start, end).tv_nsec, pages /
301                        ((double)timespec_diff(start, end).tv_sec +
302                         (double)timespec_diff(start, end).tv_nsec / 100000000.0));
303
304         return NULL;
305 }
306
307 static int setup_demand_paging(struct kvm_vm *vm,
308                                pthread_t *uffd_handler_thread, int pipefd,
309                                useconds_t uffd_delay,
310                                struct uffd_handler_args *uffd_args,
311                                void *hva, uint64_t len)
312 {
313         int uffd;
314         struct uffdio_api uffdio_api;
315         struct uffdio_register uffdio_register;
316
317         uffd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);
318         if (uffd == -1) {
319                 pr_info("uffd creation failed\n");
320                 return -1;
321         }
322
323         uffdio_api.api = UFFD_API;
324         uffdio_api.features = 0;
325         if (ioctl(uffd, UFFDIO_API, &uffdio_api) == -1) {
326                 pr_info("ioctl uffdio_api failed\n");
327                 return -1;
328         }
329
330         uffdio_register.range.start = (uint64_t)hva;
331         uffdio_register.range.len = len;
332         uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;
333         if (ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) == -1) {
334                 pr_info("ioctl uffdio_register failed\n");
335                 return -1;
336         }
337
338         if ((uffdio_register.ioctls & UFFD_API_RANGE_IOCTLS) !=
339                         UFFD_API_RANGE_IOCTLS) {
340                 pr_info("unexpected userfaultfd ioctl set\n");
341                 return -1;
342         }
343
344         uffd_args->uffd = uffd;
345         uffd_args->pipefd = pipefd;
346         uffd_args->delay = uffd_delay;
347         pthread_create(uffd_handler_thread, NULL, uffd_handler_thread_fn,
348                        uffd_args);
349
350         PER_VCPU_DEBUG("Created uffd thread for HVA range [%p, %p)\n",
351                        hva, hva + len);
352
353         return 0;
354 }
355
356 static void run_test(enum vm_guest_mode mode, bool use_uffd,
357                      useconds_t uffd_delay, int vcpus,
358                      uint64_t vcpu_memory_bytes)
359 {
360         pthread_t *vcpu_threads;
361         pthread_t *uffd_handler_threads = NULL;
362         struct uffd_handler_args *uffd_args = NULL;
363         int *pipefds = NULL;
364         struct kvm_vm *vm;
365         uint64_t guest_num_pages;
366         int vcpu_id;
367         int r;
368         struct timespec start;
369         struct timespec end;
370
371         vm = create_vm(mode, vcpus, vcpu_memory_bytes);
372
373         guest_page_size = vm_get_page_size(vm);
374
375         TEST_ASSERT(vcpu_memory_bytes % guest_page_size == 0,
376                     "Guest memory size is not guest page size aligned.");
377
378         guest_num_pages = (vcpus * vcpu_memory_bytes) / guest_page_size;
379         guest_num_pages = vm_adjust_num_guest_pages(mode, guest_num_pages);
380
381         /*
382          * If there should be more memory in the guest test region than there
383          * can be pages in the guest, it will definitely cause problems.
384          */
385         TEST_ASSERT(guest_num_pages < vm_get_max_gfn(vm),
386                     "Requested more guest memory than address space allows.\n"
387                     "    guest pages: %lx max gfn: %x vcpus: %d wss: %lx]\n",
388                     guest_num_pages, vm_get_max_gfn(vm), vcpus,
389                     vcpu_memory_bytes);
390
391         host_page_size = getpagesize();
392         TEST_ASSERT(vcpu_memory_bytes % host_page_size == 0,
393                     "Guest memory size is not host page size aligned.");
394
395         guest_test_phys_mem = (vm_get_max_gfn(vm) - guest_num_pages) *
396                               guest_page_size;
397         guest_test_phys_mem &= ~(host_page_size - 1);
398
399 #ifdef __s390x__
400         /* Align to 1M (segment size) */
401         guest_test_phys_mem &= ~((1 << 20) - 1);
402 #endif
403
404         pr_info("guest physical test memory offset: 0x%lx\n", guest_test_phys_mem);
405
406         /* Add an extra memory slot for testing demand paging */
407         vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS,
408                                     guest_test_phys_mem,
409                                     TEST_MEM_SLOT_INDEX,
410                                     guest_num_pages, 0);
411
412         /* Do mapping for the demand paging memory slot */
413         virt_map(vm, guest_test_virt_mem, guest_test_phys_mem,
414                  guest_num_pages * guest_page_size, 0);
415
416         ucall_init(vm, NULL);
417
418         guest_data_prototype = malloc(host_page_size);
419         TEST_ASSERT(guest_data_prototype,
420                     "Failed to allocate buffer for guest data pattern");
421         memset(guest_data_prototype, 0xAB, host_page_size);
422
423         vcpu_threads = malloc(vcpus * sizeof(*vcpu_threads));
424         TEST_ASSERT(vcpu_threads, "Memory allocation failed");
425
426         if (use_uffd) {
427                 uffd_handler_threads =
428                         malloc(vcpus * sizeof(*uffd_handler_threads));
429                 TEST_ASSERT(uffd_handler_threads, "Memory allocation failed");
430
431                 uffd_args = malloc(vcpus * sizeof(*uffd_args));
432                 TEST_ASSERT(uffd_args, "Memory allocation failed");
433
434                 pipefds = malloc(sizeof(int) * vcpus * 2);
435                 TEST_ASSERT(pipefds, "Unable to allocate memory for pipefd");
436         }
437
438         for (vcpu_id = 0; vcpu_id < vcpus; vcpu_id++) {
439                 vm_paddr_t vcpu_gpa;
440                 void *vcpu_hva;
441
442                 vm_vcpu_add_default(vm, vcpu_id, guest_code);
443
444                 vcpu_gpa = guest_test_phys_mem + (vcpu_id * vcpu_memory_bytes);
445                 PER_VCPU_DEBUG("Added VCPU %d with test mem gpa [%lx, %lx)\n",
446                                vcpu_id, vcpu_gpa, vcpu_gpa + vcpu_memory_bytes);
447
448                 /* Cache the HVA pointer of the region */
449                 vcpu_hva = addr_gpa2hva(vm, vcpu_gpa);
450
451                 if (use_uffd) {
452                         /*
453                          * Set up user fault fd to handle demand paging
454                          * requests.
455                          */
456                         r = pipe2(&pipefds[vcpu_id * 2],
457                                   O_CLOEXEC | O_NONBLOCK);
458                         TEST_ASSERT(!r, "Failed to set up pipefd");
459
460                         r = setup_demand_paging(vm,
461                                                 &uffd_handler_threads[vcpu_id],
462                                                 pipefds[vcpu_id * 2],
463                                                 uffd_delay, &uffd_args[vcpu_id],
464                                                 vcpu_hva, vcpu_memory_bytes);
465                         if (r < 0)
466                                 exit(-r);
467                 }
468
469 #ifdef __x86_64__
470                 vcpu_set_cpuid(vm, vcpu_id, kvm_get_supported_cpuid());
471 #endif
472
473                 vcpu_args[vcpu_id].vm = vm;
474                 vcpu_args[vcpu_id].vcpu_id = vcpu_id;
475                 vcpu_args[vcpu_id].gva = guest_test_virt_mem +
476                                          (vcpu_id * vcpu_memory_bytes);
477                 vcpu_args[vcpu_id].pages = vcpu_memory_bytes / guest_page_size;
478         }
479
480         /* Export the shared variables to the guest */
481         sync_global_to_guest(vm, host_page_size);
482         sync_global_to_guest(vm, guest_page_size);
483         sync_global_to_guest(vm, vcpu_args);
484
485         pr_info("Finished creating vCPUs and starting uffd threads\n");
486
487         clock_gettime(CLOCK_MONOTONIC, &start);
488
489         for (vcpu_id = 0; vcpu_id < vcpus; vcpu_id++) {
490                 pthread_create(&vcpu_threads[vcpu_id], NULL, vcpu_worker,
491                                &vcpu_args[vcpu_id]);
492         }
493
494         pr_info("Started all vCPUs\n");
495
496         /* Wait for the vcpu threads to quit */
497         for (vcpu_id = 0; vcpu_id < vcpus; vcpu_id++) {
498                 pthread_join(vcpu_threads[vcpu_id], NULL);
499                 PER_VCPU_DEBUG("Joined thread for vCPU %d\n", vcpu_id);
500         }
501
502         pr_info("All vCPU threads joined\n");
503
504         clock_gettime(CLOCK_MONOTONIC, &end);
505
506         if (use_uffd) {
507                 char c;
508
509                 /* Tell the user fault fd handler threads to quit */
510                 for (vcpu_id = 0; vcpu_id < vcpus; vcpu_id++) {
511                         r = write(pipefds[vcpu_id * 2 + 1], &c, 1);
512                         TEST_ASSERT(r == 1, "Unable to write to pipefd");
513
514                         pthread_join(uffd_handler_threads[vcpu_id], NULL);
515                 }
516         }
517
518         pr_info("Total guest execution time: %lld.%.9lds\n",
519                 (long long)(timespec_diff(start, end).tv_sec),
520                 timespec_diff(start, end).tv_nsec);
521         pr_info("Overall demand paging rate: %f pgs/sec\n",
522                 guest_num_pages / ((double)timespec_diff(start, end).tv_sec +
523                 (double)timespec_diff(start, end).tv_nsec / 100000000.0));
524
525         ucall_uninit(vm);
526         kvm_vm_free(vm);
527
528         free(guest_data_prototype);
529         free(vcpu_threads);
530         if (use_uffd) {
531                 free(uffd_handler_threads);
532                 free(uffd_args);
533                 free(pipefds);
534         }
535 }
536
537 struct guest_mode {
538         bool supported;
539         bool enabled;
540 };
541 static struct guest_mode guest_modes[NUM_VM_MODES];
542
543 #define guest_mode_init(mode, supported, enabled) ({ \
544         guest_modes[mode] = (struct guest_mode){ supported, enabled }; \
545 })
546
547 static void help(char *name)
548 {
549         int i;
550
551         puts("");
552         printf("usage: %s [-h] [-m mode] [-u] [-d uffd_delay_usec]\n"
553                "          [-b memory] [-v vcpus]\n", name);
554         printf(" -m: specify the guest mode ID to test\n"
555                "     (default: test all supported modes)\n"
556                "     This option may be used multiple times.\n"
557                "     Guest mode IDs:\n");
558         for (i = 0; i < NUM_VM_MODES; ++i) {
559                 printf("         %d:    %s%s\n", i, vm_guest_mode_string(i),
560                        guest_modes[i].supported ? " (supported)" : "");
561         }
562         printf(" -u: use User Fault FD to handle vCPU page\n"
563                "     faults.\n");
564         printf(" -d: add a delay in usec to the User Fault\n"
565                "     FD handler to simulate demand paging\n"
566                "     overheads. Ignored without -u.\n");
567         printf(" -b: specify the size of the memory region which should be\n"
568                "     demand paged by each vCPU. e.g. 10M or 3G.\n"
569                "     Default: 1G\n");
570         printf(" -v: specify the number of vCPUs to run.\n");
571         puts("");
572         exit(0);
573 }
574
575 int main(int argc, char *argv[])
576 {
577         bool mode_selected = false;
578         uint64_t vcpu_memory_bytes = DEFAULT_GUEST_TEST_MEM_SIZE;
579         int vcpus = 1;
580         unsigned int mode;
581         int opt, i;
582         bool use_uffd = false;
583         useconds_t uffd_delay = 0;
584
585 #ifdef __x86_64__
586         guest_mode_init(VM_MODE_PXXV48_4K, true, true);
587 #endif
588 #ifdef __aarch64__
589         guest_mode_init(VM_MODE_P40V48_4K, true, true);
590         guest_mode_init(VM_MODE_P40V48_64K, true, true);
591         {
592                 unsigned int limit = kvm_check_cap(KVM_CAP_ARM_VM_IPA_SIZE);
593
594                 if (limit >= 52)
595                         guest_mode_init(VM_MODE_P52V48_64K, true, true);
596                 if (limit >= 48) {
597                         guest_mode_init(VM_MODE_P48V48_4K, true, true);
598                         guest_mode_init(VM_MODE_P48V48_64K, true, true);
599                 }
600         }
601 #endif
602 #ifdef __s390x__
603         guest_mode_init(VM_MODE_P40V48_4K, true, true);
604 #endif
605
606         while ((opt = getopt(argc, argv, "hm:ud:b:v:")) != -1) {
607                 switch (opt) {
608                 case 'm':
609                         if (!mode_selected) {
610                                 for (i = 0; i < NUM_VM_MODES; ++i)
611                                         guest_modes[i].enabled = false;
612                                 mode_selected = true;
613                         }
614                         mode = strtoul(optarg, NULL, 10);
615                         TEST_ASSERT(mode < NUM_VM_MODES,
616                                     "Guest mode ID %d too big", mode);
617                         guest_modes[mode].enabled = true;
618                         break;
619                 case 'u':
620                         use_uffd = true;
621                         break;
622                 case 'd':
623                         uffd_delay = strtoul(optarg, NULL, 0);
624                         TEST_ASSERT(uffd_delay >= 0,
625                                     "A negative UFFD delay is not supported.");
626                         break;
627                 case 'b':
628                         vcpu_memory_bytes = parse_size(optarg);
629                         break;
630                 case 'v':
631                         vcpus = atoi(optarg);
632                         TEST_ASSERT(vcpus > 0,
633                                     "Must have a positive number of vCPUs");
634                         TEST_ASSERT(vcpus <= MAX_VCPUS,
635                                     "This test does not currently support\n"
636                                     "more than %d vCPUs.", MAX_VCPUS);
637                         break;
638                 case 'h':
639                 default:
640                         help(argv[0]);
641                         break;
642                 }
643         }
644
645         for (i = 0; i < NUM_VM_MODES; ++i) {
646                 if (!guest_modes[i].enabled)
647                         continue;
648                 TEST_ASSERT(guest_modes[i].supported,
649                             "Guest mode ID %d (%s) not supported.",
650                             i, vm_guest_mode_string(i));
651                 run_test(i, use_uffd, uffd_delay, vcpus, vcpu_memory_bytes);
652         }
653
654         return 0;
655 }
656
657 #else /* __NR_userfaultfd */
658
659 #warning "missing __NR_userfaultfd definition"
660
661 int main(void)
662 {
663         printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n");
664         return KSFT_SKIP;
665 }
666
667 #endif /* __NR_userfaultfd */