13 fprintf(stderr, "%s: %s\n", op, strerror(errno));
18 main(int argc, char **argv)
23 * gcc -O2 will optimize foo's storage, prevent reproducing
25 * foo is never actually used after fault in value stored.
27 volatile char foo __attribute__((__unused__));
28 int pagesize = getpagesize();
31 printf("Usage: %s <file> <pmem file>\n", basename(argv[0]));
35 /* O_DIRECT is necessary for reproduce this bug. */
36 fd = open(argv[1], O_RDONLY|O_DIRECT);
40 pfd = open(argv[2], O_RDONLY);
42 err_exit("pmem open");
44 buf = mmap(NULL, pagesize, PROT_READ, MAP_SHARED, pfd, 0);
45 if (buf == MAP_FAILED)
49 * Read from the DAX mmap to populate the first page in the
50 * address_space with a read-only mapping.
55 * Now write to the DAX mmap. This *should* fail, but if the bug is
56 * present in __get_user_pages_fast(), it will succeed.
58 ret = read(fd, buf, pagesize);
62 ret = msync(buf, pagesize, MS_SYNC);
66 ret = munmap(buf, pagesize);
76 err_exit("close pfd");