Lines Matching refs:mem
41 static void do_test_write_sigsegv(char *mem) in do_test_write_sigsegv() argument
43 char orig = *mem; in do_test_write_sigsegv()
53 *mem = orig + 1; in do_test_write_sigsegv()
58 ksft_test_result(ret == 1 && *mem == orig, in do_test_write_sigsegv()
65 char *mem, *mmap_mem; in mmap_thp_range() local
73 mem = (char *)(((uintptr_t)mmap_mem + thpsize) & ~(thpsize - 1)); in mmap_thp_range()
75 if (madvise(mem, thpsize, MADV_HUGEPAGE)) { in mmap_thp_range()
83 return mem; in mmap_thp_range()
89 char *mem; in test_ptrace_write() local
94 mem = mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE|MAP_ANON, -1, 0); in test_ptrace_write()
95 if (mem == MAP_FAILED) { in test_ptrace_write()
101 if (*mem != 0) { in test_ptrace_write()
110 lseek(mem_fd, (uintptr_t) mem, SEEK_SET); in test_ptrace_write()
112 if (ret != 1 || *mem != data) { in test_ptrace_write()
117 do_test_write_sigsegv(mem); in test_ptrace_write()
119 munmap(mem, pagesize); in test_ptrace_write()
124 char *mem, *mmap_mem; in test_ptrace_write_thp() local
131 mem = mmap_thp_range(PROT_READ, &mmap_mem, &mmap_size); in test_ptrace_write_thp()
132 if (mem == MAP_FAILED) in test_ptrace_write_thp()
140 lseek(mem_fd, (uintptr_t) mem, SEEK_SET); in test_ptrace_write_thp()
142 if (ret != 1 || *mem != data) { in test_ptrace_write_thp()
148 if (!pagemap_is_populated(pagemap_fd, mem + thpsize - pagesize)) { in test_ptrace_write_thp()
153 do_test_write_sigsegv(mem); in test_ptrace_write_thp()
160 char *mem; in test_page_migration() local
164 mem = mmap(NULL, pagesize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, in test_page_migration()
166 if (mem == MAP_FAILED) { in test_page_migration()
172 memset(mem, 1, pagesize); in test_page_migration()
173 if (mprotect(mem, pagesize, PROT_READ)) { in test_page_migration()
179 if (syscall(__NR_mbind, mem, pagesize, MPOL_LOCAL, NULL, 0x7fful, in test_page_migration()
185 do_test_write_sigsegv(mem); in test_page_migration()
187 munmap(mem, pagesize); in test_page_migration()
192 char *mem, *mmap_mem; in test_page_migration_thp() local
197 mem = mmap_thp_range(PROT_READ|PROT_WRITE, &mmap_mem, &mmap_size); in test_page_migration_thp()
198 if (mem == MAP_FAILED) in test_page_migration_thp()
205 memset(mem, 1, pagesize); in test_page_migration_thp()
206 if (mprotect(mem, thpsize, PROT_READ)) { in test_page_migration_thp()
212 if (!pagemap_is_populated(pagemap_fd, mem + thpsize - pagesize)) { in test_page_migration_thp()
218 if (syscall(__NR_mbind, mem, thpsize, MPOL_LOCAL, NULL, 0x7fful, in test_page_migration_thp()
224 do_test_write_sigsegv(mem); in test_page_migration_thp()
231 char *mem, *mmap_mem; in test_pte_mapped_thp() local
236 mem = mmap_thp_range(PROT_READ|PROT_WRITE, &mmap_mem, &mmap_size); in test_pte_mapped_thp()
237 if (mem == MAP_FAILED) in test_pte_mapped_thp()
244 memset(mem, 1, pagesize); in test_pte_mapped_thp()
245 if (mprotect(mem, thpsize, PROT_READ)) { in test_pte_mapped_thp()
251 if (!pagemap_is_populated(pagemap_fd, mem + thpsize - pagesize)) { in test_pte_mapped_thp()
257 if (mprotect(mem + thpsize - pagesize, pagesize, in test_pte_mapped_thp()
263 do_test_write_sigsegv(mem); in test_pte_mapped_thp()