diff options
author | Joseph Myers <joseph@codesourcery.com> | 2015-03-25 15:17:54 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2015-03-25 15:17:54 +0000 |
commit | a9fe4c5aa8e53ee30f7d0a1c878391d5d6324e6e (patch) | |
tree | b57c4c83b9a6758d50264de82f0e4a09c9bde4b1 /sysdeps/unix/sysv/linux/i386/libc-do-syscall.S | |
parent | afcd9480feca651eef436d8438b783dde5c3bbb2 (diff) | |
download | glibc-a9fe4c5aa8e53ee30f7d0a1c878391d5d6324e6e.tar glibc-a9fe4c5aa8e53ee30f7d0a1c878391d5d6324e6e.tar.gz glibc-a9fe4c5aa8e53ee30f7d0a1c878391d5d6324e6e.tar.bz2 glibc-a9fe4c5aa8e53ee30f7d0a1c878391d5d6324e6e.zip |
Support six-argument syscalls from C for 32-bit x86, use generic lowlevellock-futex.h (bug 18138).
This patch follows the approach outlined in
<https://sourceware.org/ml/libc-alpha/2015-03/msg00656.html> to
support six-argument syscalls from INTERNAL_SYSCALL for 32-bit x86,
making them call a function __libc_do_syscall that takes the syscall
number and three syscall arguments in the registers in which the
kernel expects them, along with a pointer to a structure containing
the other three arguments.
In turn, this allows the generic lowlevellock-futex.h to be used on
32-bit x86, so supporting lll_futex_timed_wait_bitset (and so allowing
FUTEX_CLOCK_REALTIME to be used in various cases, so fixing bug 18138
for 32-bit x86 and leaving hppa as the only architecture missing
lll_futex_timed_wait_bitset). The change to lowlevellock.h's
definition of SYS_futex is because the generic lowlevelloc-futex.h
ends up bringing in bits/syscall.h which defines SYS_futex to
__NR_futex, so resulting in redefinition errors. The revised
definition in lowlevellock.h is in line with what the x86_64 version
does.
__libc_do_syscall is only needed in libpthread at present (meaning
nothing special needs to be done to make it shared-only in most
libraries containing it, static in libc only, as on ARM).
Tested for 32-bit x86, with the glibc testsuite and with the test in
bug 18138. The failures seen
FAIL: nptl/tst-cleanupx4
FAIL: rt/tst-cpuclock2
are pre-existing.
[BZ #18138]
* sysdeps/unix/sysv/linux/i386/sysdep.h (struct
libc_do_syscall_args): New structure.
(INTERNAL_SYSCALL_MAIN_0): New macro.
(INTERNAL_SYSCALL_MAIN_1): Likewise.
(INTERNAL_SYSCALL_MAIN_2): Likewise.
(INTERNAL_SYSCALL_MAIN_3): Likewise.
(INTERNAL_SYSCALL_MAIN_4): Likewise.
(INTERNAL_SYSCALL_MAIN_5): Likewise.
(INTERNAL_SYSCALL_MAIN_6): Likewise. Call __libc_do_syscall.
(INTERNAL_SYSCALL): Define to use INTERNAL_SYSCALL_MAIN_##nr.
Replace conditional definitions by conditional definitions of ....
(INTERNAL_SYSCALL_MAIN_INLINE): ... this. New macro.
* sysdeps/unix/sysv/linux/i386/libc-do-syscall.S: New file.
* sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) = nptl]
(libpthread-sysdep_routines): Add libc-do-syscall.
* sysdeps/unix/sysv/linux/i386/lowlevellock-futex.h: Remove file.
* sysdeps/unix/sysv/linux/i386/lowlevellock.h (SYS_futex): Define
to __NR_futex not 240.
Diffstat (limited to 'sysdeps/unix/sysv/linux/i386/libc-do-syscall.S')
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/libc-do-syscall.S | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S b/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S new file mode 100644 index 0000000000..af5c6f05a6 --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/libc-do-syscall.S @@ -0,0 +1,50 @@ +/* Out-of-line syscall stub for six-argument syscalls from C. + Copyright (C) 2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdep.h> + +/* %eax, %ecx, %edx and %esi contain the values expected by the kernel. + %edi points to a structure with the values of %ebx, %edi and %ebp. */ + + .hidden __libc_do_syscall + +ENTRY (__libc_do_syscall) + pushl %ebx + cfi_adjust_cfa_offset (4) + cfi_rel_offset (ebx, 0) + pushl %edi + cfi_adjust_cfa_offset (4) + cfi_rel_offset (edi, 0) + pushl %ebp + cfi_adjust_cfa_offset (4) + cfi_rel_offset (ebp, 0) + movl 0(%edi), %ebx + movl 8(%edi), %ebp + movl 4(%edi), %edi + ENTER_KERNEL + popl %ebp + cfi_adjust_cfa_offset (-4) + cfi_restore (ebp) + popl %edi + cfi_adjust_cfa_offset (-4) + cfi_restore (edi) + popl %ebx + cfi_adjust_cfa_offset (-4) + cfi_restore (ebx) + ret +END (__libc_do_syscall) |