Lines Matching +full:lsb +full:- +full:first
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * syscall_numbering.c - test calling the x86-64 kernel with various
33 /* x64-only system call numbers */
37 /* x32-only system call numbers (without X32_BIT) */
44 static int nullfd = -1; /* File descriptor for /dev/null */
64 [PTP_INTNUM] = "sign-extending the syscall number",
80 unsigned int level = sh ? sh->indent : 0; in offset()
85 #define msg(lvl, fmt, ...) printf("%-*s" fmt, offset(), "[" #lvl "]", \
95 sh->nerr++; \
100 sh->indent = 0; \
106 /* Sentinel for ptrace-modified return value */
107 #define MODIFIED_BY_PTRACE -9999
110 * Directly invokes the given syscall with nullfd as the first argument
115 static long long probe_syscall(int msb, int lsb) in probe_syscall() argument
123 long long nr = ((long long)msb << 32) | (unsigned int)lsb; in probe_syscall()
133 sh->probing_syscall = true; in probe_syscall()
140 sh->probing_syscall = false; in probe_syscall()
149 int lsb = start; in syscall_str() local
153 * toward zero so we don't display -1 as -1073741825. in syscall_str()
155 if (lsb < 0) in syscall_str()
156 lsb |= X32_BIT; in syscall_str()
158 lsb &= ~X32_BIT; in syscall_str()
162 type, msb, lsb); in syscall_str()
165 type, msb, lsb, lsb + (end-start)); in syscall_str()
175 sh->indent++; in _check_for()
177 sh->indent++; in _check_for()
191 sh->indent--; in _check_for()
203 sh->indent--; in _check_for()
218 return check_for(msb, nr, nr, -ENOSYS); in check_enosys()
234 sh->indent++; in test_x32()
238 } else if (ret == -ENOSYS) { in test_x32()
242 …fail("x32 getpid() returned %lld, but it should have returned either %lld or -ENOSYS\n", ret, (lon… in test_x32()
245 sh->indent--; in test_x32()
251 enum ptrace_pass pass = sh->ptrace_pass; in test_syscalls_common()
257 run("Checking some 64-bit only syscalls as 64 bit\n"); in test_syscalls_common()
262 check_for(msb, -64, -2, -ENOSYS); in test_syscalls_common()
264 check_for(msb, -1, -1, MODIFIED_BY_PTRACE); in test_syscalls_common()
266 check_for(msb, -1, -1, -ENOSYS); in test_syscalls_common()
267 check_for(msb, X32_BIT-64, X32_BIT-1, -ENOSYS); in test_syscalls_common()
268 check_for(msb, -64-X32_BIT, -1-X32_BIT, -ENOSYS); in test_syscalls_common()
269 check_for(msb, INT_MAX-64, INT_MAX-1, -ENOSYS); in test_syscalls_common()
275 * Syscalls 512-547 are "x32" syscalls. They are in test_syscalls_with_x32()
281 check_for(msb, 512, 547, -ENOSYS); in test_syscalls_with_x32()
291 run("Checking some 64-bit syscalls as x32\n"); in test_syscalls_with_x32()
300 check_for(msb, 0 | X32_BIT, 999 | X32_BIT, -ENOSYS); in test_syscalls_without_x32()
306 0, 1, -1, X32_BIT-1, X32_BIT, X32_BIT-1, -X32_BIT, INT_MAX, in test_syscall_numbering()
310 sh->indent++; in test_syscall_numbering()
321 sh->indent++; in test_syscall_numbering()
329 sh->indent--; in test_syscall_numbering()
332 sh->indent--; in test_syscall_numbering()
345 for (sh->ptrace_pass = pass = PTP_NOTHING; pass < PTP_DONE; in syscall_numbering_tracee()
346 sh->ptrace_pass = ++pass) { in syscall_numbering_tracee()
356 sh->probing_syscall = false; /* Do this on entry only */ in mess_with_syscall()
409 if (sh->probing_syscall && WSTOPSIG(wstatus) == SIGTRAP) in syscall_numbering_tracer()
410 mess_with_syscall(testpid, sh->ptrace_pass); in syscall_numbering_tracer()
411 } while (sh->ptrace_pass != PTP_DONE && in syscall_numbering_tracer()
473 nerr = sh->nerr; in main()