|
Packit Service |
82fcde |
/* Copyright (C) 2001-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifndef _LINUX_X86_64_SYSDEP_H
|
|
Packit Service |
82fcde |
#define _LINUX_X86_64_SYSDEP_H 1
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* There is some commonality. */
|
|
Packit Service |
82fcde |
#include <sysdeps/unix/sysv/linux/sysdep.h>
|
|
Packit Service |
82fcde |
#include <sysdeps/unix/x86_64/sysdep.h>
|
|
Packit Service |
82fcde |
#include <tls.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Defines RTLD_PRIVATE_ERRNO. */
|
|
Packit Service |
82fcde |
#include <dl-sysdep.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* For Linux we can use the system call table in the header file
|
|
Packit Service |
82fcde |
/usr/include/asm/unistd.h
|
|
Packit Service |
82fcde |
of the kernel. But these symbols do not follow the SYS_* syntax
|
|
Packit Service |
82fcde |
so we have to redefine the `SYS_ify' macro here. */
|
|
Packit Service |
82fcde |
#undef SYS_ify
|
|
Packit Service |
82fcde |
#define SYS_ify(syscall_name) __NR_##syscall_name
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* This is a kludge to make syscalls.list find these under the names
|
|
Packit Service |
82fcde |
pread and pwrite, since some kernel headers define those names
|
|
Packit Service |
82fcde |
and some define the *64 names for the same system calls. */
|
|
Packit Service |
82fcde |
#if !defined __NR_pread && defined __NR_pread64
|
|
Packit Service |
82fcde |
# define __NR_pread __NR_pread64
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
#if !defined __NR_pwrite && defined __NR_pwrite64
|
|
Packit Service |
82fcde |
# define __NR_pwrite __NR_pwrite64
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* This is to help the old kernel headers where __NR_semtimedop is not
|
|
Packit Service |
82fcde |
available. */
|
|
Packit Service |
82fcde |
#ifndef __NR_semtimedop
|
|
Packit Service |
82fcde |
# define __NR_semtimedop 220
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifdef __ASSEMBLER__
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Linux uses a negative return value to indicate syscall errors,
|
|
Packit Service |
82fcde |
unlike most Unices, which use the condition codes' carry flag.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
Since version 2.1 the return value of a system call might be
|
|
Packit Service |
82fcde |
negative even if the call succeeded. E.g., the `lseek' system call
|
|
Packit Service |
82fcde |
might return a large offset. Therefore we must not anymore test
|
|
Packit Service |
82fcde |
for < 0, but test for a real error by making sure the value in %eax
|
|
Packit Service |
82fcde |
is a real error number. Linus said he will make sure the no syscall
|
|
Packit Service |
82fcde |
returns a value in -1 .. -4095 as a valid result so we can savely
|
|
Packit Service |
82fcde |
test with -4095. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* We don't want the label for the error handle to be global when we define
|
|
Packit Service |
82fcde |
it here. */
|
|
Packit Service |
82fcde |
# ifdef PIC
|
|
Packit Service |
82fcde |
# define SYSCALL_ERROR_LABEL 0f
|
|
Packit Service |
82fcde |
# else
|
|
Packit Service |
82fcde |
# define SYSCALL_ERROR_LABEL syscall_error
|
|
Packit Service |
82fcde |
# endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# undef PSEUDO
|
|
Packit Service |
82fcde |
# define PSEUDO(name, syscall_name, args) \
|
|
Packit Service |
82fcde |
.text; \
|
|
Packit Service |
82fcde |
ENTRY (name) \
|
|
Packit Service |
82fcde |
DO_CALL (syscall_name, args); \
|
|
Packit Service |
82fcde |
cmpq $-4095, %rax; \
|
|
Packit Service |
82fcde |
jae SYSCALL_ERROR_LABEL
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# undef PSEUDO_END
|
|
Packit Service |
82fcde |
# define PSEUDO_END(name) \
|
|
Packit Service |
82fcde |
SYSCALL_ERROR_HANDLER \
|
|
Packit Service |
82fcde |
END (name)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# undef PSEUDO_NOERRNO
|
|
Packit Service |
82fcde |
# define PSEUDO_NOERRNO(name, syscall_name, args) \
|
|
Packit Service |
82fcde |
.text; \
|
|
Packit Service |
82fcde |
ENTRY (name) \
|
|
Packit Service |
82fcde |
DO_CALL (syscall_name, args)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# undef PSEUDO_END_NOERRNO
|
|
Packit Service |
82fcde |
# define PSEUDO_END_NOERRNO(name) \
|
|
Packit Service |
82fcde |
END (name)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# define ret_NOERRNO ret
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# undef PSEUDO_ERRVAL
|
|
Packit Service |
82fcde |
# define PSEUDO_ERRVAL(name, syscall_name, args) \
|
|
Packit Service |
82fcde |
.text; \
|
|
Packit Service |
82fcde |
ENTRY (name) \
|
|
Packit Service |
82fcde |
DO_CALL (syscall_name, args); \
|
|
Packit Service |
82fcde |
negq %rax
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# undef PSEUDO_END_ERRVAL
|
|
Packit Service |
82fcde |
# define PSEUDO_END_ERRVAL(name) \
|
|
Packit Service |
82fcde |
END (name)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# define ret_ERRVAL ret
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# if defined PIC && RTLD_PRIVATE_ERRNO
|
|
Packit Service |
82fcde |
# define SYSCALL_SET_ERRNO \
|
|
Packit Service |
82fcde |
lea rtld_errno(%rip), %RCX_LP; \
|
|
Packit Service |
82fcde |
neg %eax; \
|
|
Packit Service |
82fcde |
movl %eax, (%rcx)
|
|
Packit Service |
82fcde |
# else
|
|
Packit Service |
82fcde |
# if IS_IN (libc)
|
|
Packit Service |
82fcde |
# define SYSCALL_ERROR_ERRNO __libc_errno
|
|
Packit Service |
82fcde |
# else
|
|
Packit Service |
82fcde |
# define SYSCALL_ERROR_ERRNO errno
|
|
Packit Service |
82fcde |
# endif
|
|
Packit Service |
82fcde |
# define SYSCALL_SET_ERRNO \
|
|
Packit Service |
82fcde |
movq SYSCALL_ERROR_ERRNO@GOTTPOFF(%rip), %rcx;\
|
|
Packit Service |
82fcde |
neg %eax; \
|
|
Packit Service |
82fcde |
movl %eax, %fs:(%rcx);
|
|
Packit Service |
82fcde |
# endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# ifndef PIC
|
|
Packit Service |
82fcde |
# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
|
|
Packit Service |
82fcde |
# else
|
|
Packit Service |
82fcde |
# define SYSCALL_ERROR_HANDLER \
|
|
Packit Service |
82fcde |
0: \
|
|
Packit Service |
82fcde |
SYSCALL_SET_ERRNO; \
|
|
Packit Service |
82fcde |
or $-1, %RAX_LP; \
|
|
Packit Service |
82fcde |
ret;
|
|
Packit Service |
82fcde |
# endif /* PIC */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* The Linux/x86-64 kernel expects the system call parameters in
|
|
Packit Service |
82fcde |
registers according to the following table:
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
syscall number rax
|
|
Packit Service |
82fcde |
arg 1 rdi
|
|
Packit Service |
82fcde |
arg 2 rsi
|
|
Packit Service |
82fcde |
arg 3 rdx
|
|
Packit Service |
82fcde |
arg 4 r10
|
|
Packit Service |
82fcde |
arg 5 r8
|
|
Packit Service |
82fcde |
arg 6 r9
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The Linux kernel uses and destroys internally these registers:
|
|
Packit Service |
82fcde |
return address from
|
|
Packit Service |
82fcde |
syscall rcx
|
|
Packit Service |
82fcde |
eflags from syscall r11
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
Normal function call, including calls to the system call stub
|
|
Packit Service |
82fcde |
functions in the libc, get the first six parameters passed in
|
|
Packit Service |
82fcde |
registers and the seventh parameter and later on the stack. The
|
|
Packit Service |
82fcde |
register use is as follows:
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
system call number in the DO_CALL macro
|
|
Packit Service |
82fcde |
arg 1 rdi
|
|
Packit Service |
82fcde |
arg 2 rsi
|
|
Packit Service |
82fcde |
arg 3 rdx
|
|
Packit Service |
82fcde |
arg 4 rcx
|
|
Packit Service |
82fcde |
arg 5 r8
|
|
Packit Service |
82fcde |
arg 6 r9
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
We have to take care that the stack is aligned to 16 bytes. When
|
|
Packit Service |
82fcde |
called the stack is not aligned since the return address has just
|
|
Packit Service |
82fcde |
been pushed.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
Syscalls of more than 6 arguments are not supported. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# undef DO_CALL
|
|
Packit Service |
82fcde |
# define DO_CALL(syscall_name, args) \
|
|
Packit Service |
82fcde |
DOARGS_##args \
|
|
Packit Service |
82fcde |
movl $SYS_ify (syscall_name), %eax; \
|
|
Packit Service |
82fcde |
syscall;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# define DOARGS_0 /* nothing */
|
|
Packit Service |
82fcde |
# define DOARGS_1 /* nothing */
|
|
Packit Service |
82fcde |
# define DOARGS_2 /* nothing */
|
|
Packit Service |
82fcde |
# define DOARGS_3 /* nothing */
|
|
Packit Service |
82fcde |
# define DOARGS_4 movq %rcx, %r10;
|
|
Packit Service |
82fcde |
# define DOARGS_5 DOARGS_4
|
|
Packit Service |
82fcde |
# define DOARGS_6 DOARGS_5
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#else /* !__ASSEMBLER__ */
|
|
Packit Service |
82fcde |
/* Define a macro which expands inline into the wrapper code for a system
|
|
Packit Service |
82fcde |
call. */
|
|
Packit Service |
82fcde |
# undef INLINE_SYSCALL
|
|
Packit Service |
82fcde |
# define INLINE_SYSCALL(name, nr, args...) \
|
|
Packit Service |
82fcde |
({ \
|
|
Packit Service |
82fcde |
unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
|
|
Packit Service |
82fcde |
if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
|
|
Packit Service |
82fcde |
{ \
|
|
Packit Service |
82fcde |
__set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
|
|
Packit Service |
82fcde |
resultvar = (unsigned long int) -1; \
|
|
Packit Service |
82fcde |
} \
|
|
Packit Service |
82fcde |
(long int) resultvar; })
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Define a macro with explicit types for arguments, which expands inline
|
|
Packit Service |
82fcde |
into the wrapper code for a system call. It should be used when size
|
|
Packit Service |
82fcde |
of any argument > size of long int. */
|
|
Packit Service |
82fcde |
# undef INLINE_SYSCALL_TYPES
|
|
Packit Service |
82fcde |
# define INLINE_SYSCALL_TYPES(name, nr, args...) \
|
|
Packit Service |
82fcde |
({ \
|
|
Packit Service |
82fcde |
unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , nr, args); \
|
|
Packit Service |
82fcde |
if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
|
|
Packit Service |
82fcde |
{ \
|
|
Packit Service |
82fcde |
__set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
|
|
Packit Service |
82fcde |
resultvar = (unsigned long int) -1; \
|
|
Packit Service |
82fcde |
} \
|
|
Packit Service |
82fcde |
(long int) resultvar; })
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# undef INTERNAL_SYSCALL_DECL
|
|
Packit Service |
82fcde |
# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Registers clobbered by syscall. */
|
|
Packit Service |
82fcde |
# define REGISTERS_CLOBBERED_BY_SYSCALL "cc", "r11", "cx"
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Create a variable 'name' based on type 'X' to avoid explicit types.
|
|
Packit Service |
82fcde |
This is mainly used set use 64-bits arguments in x32. */
|
|
Packit Service |
82fcde |
#define TYPEFY(X, name) __typeof__ ((X) - (X)) name
|
|
Packit Service |
82fcde |
/* Explicit cast the argument to avoid integer from pointer warning on
|
|
Packit Service |
82fcde |
x32. */
|
|
Packit Service |
82fcde |
#define ARGIFY(X) ((__typeof__ ((X) - (X))) (X))
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#undef INTERNAL_SYSCALL
|
|
Packit Service |
82fcde |
#define INTERNAL_SYSCALL(name, err, nr, args...) \
|
|
Packit Service |
82fcde |
internal_syscall##nr (SYS_ify (name), err, args)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#undef INTERNAL_SYSCALL_NCS
|
|
Packit Service |
82fcde |
#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
|
|
Packit Service |
82fcde |
internal_syscall##nr (number, err, args)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#undef internal_syscall0
|
|
Packit Service |
82fcde |
#define internal_syscall0(number, err, dummy...) \
|
|
Packit Service |
82fcde |
({ \
|
|
Packit Service |
82fcde |
unsigned long int resultvar; \
|
|
Packit Service |
82fcde |
asm volatile ( \
|
|
Packit Service |
82fcde |
"syscall\n\t" \
|
|
Packit Service |
82fcde |
: "=a" (resultvar) \
|
|
Packit Service |
82fcde |
: "0" (number) \
|
|
Packit Service |
82fcde |
: "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
|
|
Packit Service |
82fcde |
(long int) resultvar; \
|
|
Packit Service |
82fcde |
})
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#undef internal_syscall1
|
|
Packit Service |
82fcde |
#define internal_syscall1(number, err, arg1) \
|
|
Packit Service |
82fcde |
({ \
|
|
Packit Service |
82fcde |
unsigned long int resultvar; \
|
|
Packit Service |
82fcde |
TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
|
|
Packit Service |
82fcde |
register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
|
|
Packit Service |
82fcde |
asm volatile ( \
|
|
Packit Service |
82fcde |
"syscall\n\t" \
|
|
Packit Service |
82fcde |
: "=a" (resultvar) \
|
|
Packit Service |
82fcde |
: "0" (number), "r" (_a1) \
|
|
Packit Service |
82fcde |
: "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
|
|
Packit Service |
82fcde |
(long int) resultvar; \
|
|
Packit Service |
82fcde |
})
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#undef internal_syscall2
|
|
Packit Service |
82fcde |
#define internal_syscall2(number, err, arg1, arg2) \
|
|
Packit Service |
82fcde |
({ \
|
|
Packit Service |
82fcde |
unsigned long int resultvar; \
|
|
Packit Service |
82fcde |
TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
|
|
Packit Service |
82fcde |
TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
|
|
Packit Service |
82fcde |
register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
|
|
Packit Service |
82fcde |
asm volatile ( \
|
|
Packit Service |
82fcde |
"syscall\n\t" \
|
|
Packit Service |
82fcde |
: "=a" (resultvar) \
|
|
Packit Service |
82fcde |
: "0" (number), "r" (_a1), "r" (_a2) \
|
|
Packit Service |
82fcde |
: "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
|
|
Packit Service |
82fcde |
(long int) resultvar; \
|
|
Packit Service |
82fcde |
})
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#undef internal_syscall3
|
|
Packit Service |
82fcde |
#define internal_syscall3(number, err, arg1, arg2, arg3) \
|
|
Packit Service |
82fcde |
({ \
|
|
Packit Service |
82fcde |
unsigned long int resultvar; \
|
|
Packit Service |
82fcde |
TYPEFY (arg3, __arg3) = ARGIFY (arg3); \
|
|
Packit Service |
82fcde |
TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
|
|
Packit Service |
82fcde |
TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
|
|
Packit Service |
82fcde |
register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
|
|
Packit Service |
82fcde |
asm volatile ( \
|
|
Packit Service |
82fcde |
"syscall\n\t" \
|
|
Packit Service |
82fcde |
: "=a" (resultvar) \
|
|
Packit Service |
82fcde |
: "0" (number), "r" (_a1), "r" (_a2), "r" (_a3) \
|
|
Packit Service |
82fcde |
: "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
|
|
Packit Service |
82fcde |
(long int) resultvar; \
|
|
Packit Service |
82fcde |
})
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#undef internal_syscall4
|
|
Packit Service |
82fcde |
#define internal_syscall4(number, err, arg1, arg2, arg3, arg4) \
|
|
Packit Service |
82fcde |
({ \
|
|
Packit Service |
82fcde |
unsigned long int resultvar; \
|
|
Packit Service |
82fcde |
TYPEFY (arg4, __arg4) = ARGIFY (arg4); \
|
|
Packit Service |
82fcde |
TYPEFY (arg3, __arg3) = ARGIFY (arg3); \
|
|
Packit Service |
82fcde |
TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
|
|
Packit Service |
82fcde |
TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
|
|
Packit Service |
82fcde |
register TYPEFY (arg4, _a4) asm ("r10") = __arg4; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
|
|
Packit Service |
82fcde |
asm volatile ( \
|
|
Packit Service |
82fcde |
"syscall\n\t" \
|
|
Packit Service |
82fcde |
: "=a" (resultvar) \
|
|
Packit Service |
82fcde |
: "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4) \
|
|
Packit Service |
82fcde |
: "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
|
|
Packit Service |
82fcde |
(long int) resultvar; \
|
|
Packit Service |
82fcde |
})
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#undef internal_syscall5
|
|
Packit Service |
82fcde |
#define internal_syscall5(number, err, arg1, arg2, arg3, arg4, arg5) \
|
|
Packit Service |
82fcde |
({ \
|
|
Packit Service |
82fcde |
unsigned long int resultvar; \
|
|
Packit Service |
82fcde |
TYPEFY (arg5, __arg5) = ARGIFY (arg5); \
|
|
Packit Service |
82fcde |
TYPEFY (arg4, __arg4) = ARGIFY (arg4); \
|
|
Packit Service |
82fcde |
TYPEFY (arg3, __arg3) = ARGIFY (arg3); \
|
|
Packit Service |
82fcde |
TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
|
|
Packit Service |
82fcde |
TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
|
|
Packit Service |
82fcde |
register TYPEFY (arg5, _a5) asm ("r8") = __arg5; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg4, _a4) asm ("r10") = __arg4; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
|
|
Packit Service |
82fcde |
asm volatile ( \
|
|
Packit Service |
82fcde |
"syscall\n\t" \
|
|
Packit Service |
82fcde |
: "=a" (resultvar) \
|
|
Packit Service |
82fcde |
: "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4), \
|
|
Packit Service |
82fcde |
"r" (_a5) \
|
|
Packit Service |
82fcde |
: "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
|
|
Packit Service |
82fcde |
(long int) resultvar; \
|
|
Packit Service |
82fcde |
})
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#undef internal_syscall6
|
|
Packit Service |
82fcde |
#define internal_syscall6(number, err, arg1, arg2, arg3, arg4, arg5, arg6) \
|
|
Packit Service |
82fcde |
({ \
|
|
Packit Service |
82fcde |
unsigned long int resultvar; \
|
|
Packit Service |
82fcde |
TYPEFY (arg6, __arg6) = ARGIFY (arg6); \
|
|
Packit Service |
82fcde |
TYPEFY (arg5, __arg5) = ARGIFY (arg5); \
|
|
Packit Service |
82fcde |
TYPEFY (arg4, __arg4) = ARGIFY (arg4); \
|
|
Packit Service |
82fcde |
TYPEFY (arg3, __arg3) = ARGIFY (arg3); \
|
|
Packit Service |
82fcde |
TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
|
|
Packit Service |
82fcde |
TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
|
|
Packit Service |
82fcde |
register TYPEFY (arg6, _a6) asm ("r9") = __arg6; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg5, _a5) asm ("r8") = __arg5; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg4, _a4) asm ("r10") = __arg4; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
|
|
Packit Service |
82fcde |
register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
|
|
Packit Service |
82fcde |
asm volatile ( \
|
|
Packit Service |
82fcde |
"syscall\n\t" \
|
|
Packit Service |
82fcde |
: "=a" (resultvar) \
|
|
Packit Service |
82fcde |
: "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4), \
|
|
Packit Service |
82fcde |
"r" (_a5), "r" (_a6) \
|
|
Packit Service |
82fcde |
: "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
|
|
Packit Service |
82fcde |
(long int) resultvar; \
|
|
Packit Service |
82fcde |
})
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# undef INTERNAL_SYSCALL_ERROR_P
|
|
Packit Service |
82fcde |
# define INTERNAL_SYSCALL_ERROR_P(val, err) \
|
|
Packit Service |
82fcde |
((unsigned long int) (long int) (val) >= -4095L)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# undef INTERNAL_SYSCALL_ERRNO
|
|
Packit Service |
82fcde |
# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* List of system calls which are supported as vsyscalls. */
|
|
Packit Service |
82fcde |
# define HAVE_CLOCK_GETTIME_VSYSCALL 1
|
|
Packit Service |
82fcde |
# define HAVE_GETTIMEOFDAY_VSYSCALL 1
|
|
Packit Service |
82fcde |
# define HAVE_GETCPU_VSYSCALL 1
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# define SINGLE_THREAD_BY_GLOBAL 1
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#endif /* __ASSEMBLER__ */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Pointer mangling support. */
|
|
Packit Service |
82fcde |
#if IS_IN (rtld)
|
|
Packit Service |
82fcde |
/* We cannot use the thread descriptor because in ld.so we use setjmp
|
|
Packit Service |
82fcde |
earlier than the descriptor is initialized. */
|
|
Packit Service |
82fcde |
# ifdef __ASSEMBLER__
|
|
Packit Service |
82fcde |
# define PTR_MANGLE(reg) xor __pointer_chk_guard_local(%rip), reg; \
|
|
Packit Service |
82fcde |
rol $2*LP_SIZE+1, reg
|
|
Packit Service |
82fcde |
# define PTR_DEMANGLE(reg) ror $2*LP_SIZE+1, reg; \
|
|
Packit Service |
82fcde |
xor __pointer_chk_guard_local(%rip), reg
|
|
Packit Service |
82fcde |
# else
|
|
Packit Service |
82fcde |
# define PTR_MANGLE(reg) asm ("xor __pointer_chk_guard_local(%%rip), %0\n" \
|
|
Packit Service |
82fcde |
"rol $2*" LP_SIZE "+1, %0" \
|
|
Packit Service |
82fcde |
: "=r" (reg) : "0" (reg))
|
|
Packit Service |
82fcde |
# define PTR_DEMANGLE(reg) asm ("ror $2*" LP_SIZE "+1, %0\n" \
|
|
Packit Service |
82fcde |
"xor __pointer_chk_guard_local(%%rip), %0" \
|
|
Packit Service |
82fcde |
: "=r" (reg) : "0" (reg))
|
|
Packit Service |
82fcde |
# endif
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
# ifdef __ASSEMBLER__
|
|
Packit Service |
82fcde |
# define PTR_MANGLE(reg) xor %fs:POINTER_GUARD, reg; \
|
|
Packit Service |
82fcde |
rol $2*LP_SIZE+1, reg
|
|
Packit Service |
82fcde |
# define PTR_DEMANGLE(reg) ror $2*LP_SIZE+1, reg; \
|
|
Packit Service |
82fcde |
xor %fs:POINTER_GUARD, reg
|
|
Packit Service |
82fcde |
# else
|
|
Packit Service |
82fcde |
# define PTR_MANGLE(var) asm ("xor %%fs:%c2, %0\n" \
|
|
Packit Service |
82fcde |
"rol $2*" LP_SIZE "+1, %0" \
|
|
Packit Service |
82fcde |
: "=r" (var) \
|
|
Packit Service |
82fcde |
: "0" (var), \
|
|
Packit Service |
82fcde |
"i" (offsetof (tcbhead_t, \
|
|
Packit Service |
82fcde |
pointer_guard)))
|
|
Packit Service |
82fcde |
# define PTR_DEMANGLE(var) asm ("ror $2*" LP_SIZE "+1, %0\n" \
|
|
Packit Service |
82fcde |
"xor %%fs:%c2, %0" \
|
|
Packit Service |
82fcde |
: "=r" (var) \
|
|
Packit Service |
82fcde |
: "0" (var), \
|
|
Packit Service |
82fcde |
"i" (offsetof (tcbhead_t, \
|
|
Packit Service |
82fcde |
pointer_guard)))
|
|
Packit Service |
82fcde |
# endif
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* How to pass the off{64}_t argument on p{readv,writev}{64}. */
|
|
Packit Service |
82fcde |
#undef LO_HI_LONG
|
|
Packit Service |
82fcde |
#define LO_HI_LONG(val) (val), 0
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Each shadow stack slot takes 8 bytes. Assuming that each stack
|
|
Packit Service |
82fcde |
frame takes 256 bytes, this is used to compute shadow stack size
|
|
Packit Service |
82fcde |
from stack size. */
|
|
Packit Service |
82fcde |
#define STACK_SIZE_TO_SHADOW_STACK_SIZE_SHIFT 5
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#endif /* linux/x86_64/sysdep.h */
|