Lines Matching +full:segment +full:- +full:1 +full:a
1 // SPDX-License-Identifier: GPL-2.0-only
6 * This test case simulates a tracer redirecting tracee execution to
7 * a function and then restoring tracee state using PTRACE_GETREGS and
10 * modify a segment register. This makes sure that ptrace correctly
11 * restores segment state when using PTRACE_SETREGS.
13 * This is not part of fsgsbase.c, because that test is 64-bit only.
53 MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0); in init_seg()
55 err(1, "mmap"); in init_seg()
64 .limit = sizeof(unsigned int) - 1, in init_seg()
65 .seg_32bit = 1, in init_seg()
66 .contents = 0, /* Data, grow-up */ in init_seg()
72 if (syscall(SYS_modify_ldt, 1, &desc, sizeof(desc)) == 0) { in init_seg()
81 MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0); in init_seg()
84 low_desc->entry_number = -1; in init_seg()
86 /* 32-bit set_thread_area */ in init_seg()
89 : "=a" (ret), "+m" (*low_desc) in init_seg()
90 : "a" (243), "b" (low_desc) in init_seg()
99 printf("[NOTE]\tcould not create a segment -- can't test anything\n"); in init_seg()
114 * we modify a segment register in order to make sure that ptrace in tracee_zap_segment()
115 * can correctly restore segment registers. in tracee_zap_segment()
120 * Write a nonzero selector with base zero to the segment register. in tracee_zap_segment()
121 * Using a null selector would defeat the test on AMD pre-Zen2 in tracee_zap_segment()
122 * CPUs, as such CPUs don't clear the base when loading a null in tracee_zap_segment()
144 printf("\tSetting up a segment\n"); in main()
150 return 1; in main()
152 printf("[OK]\tThe segment points to the right place.\n"); in main()
156 err(1, "fork"); in main()
162 err(1, "PTRACE_TRACEME"); in main()
166 printf("\tTracee will take a nap until signaled\n"); in main()
169 printf("\tTracee was resumed. Will re-check segment.\n"); in main()
174 exit(1); in main()
177 printf("[OK]\tThe segment points to the right place.\n"); in main()
185 err(1, "waitpid"); in main()
190 err(1, "PTRACE_GETREGS"); in main()
201 regs2.rsp -= 128; /* Don't clobber the redzone. */ in main()
208 err(1, "PTRACE_GETREGS"); in main()
210 err(1, "PTRACE_GETREGS"); in main()
214 err(1, "waitpid"); in main()
218 err(1, "PTRACE_GETREGS"); in main()
220 err(1, "PTRACE_GETREGS"); in main()
224 err(1, "waitpid"); in main()
228 return 1; in main()
233 return 1; in main()
239 return 1; in main()