glibc/sysdeps
H.J. Lu df76ff3a44 x32: Properly pass long to syscall [BZ #25810]
X32 has 32-bit long and pointer with 64-bit off_t.  Since x32 psABI
requires that pointers passed in registers must be zero-extended to
64bit, x32 can share many syscall interfaces with LP64.  When a LP64
syscall with long and unsigned long arguments is used for x32, these
arguments must be properly extended to 64-bit.  Otherwise if the upper
32 bits of the register have undefined value, such a syscall will be
rejected by kernel.

Enforce zero-extension for pointers and array system call arguments.
For integer types, extend to int64_t (the full register) using a
regular cast, resulting in zero or sign extension based on the
signedness of the original type.

For

       void *mmap(void *addr, size_t length, int prot, int flags,
                  int fd, off_t offset);

we now generate

   0:	41 f7 c1 ff 0f 00 00 	test   $0xfff,%r9d
   7:	75 1f                	jne    28 <__mmap64+0x28>
   9:	48 63 d2             	movslq %edx,%rdx
   c:	89 f6                	mov    %esi,%esi
   e:	4d 63 c0             	movslq %r8d,%r8
  11:	4c 63 d1             	movslq %ecx,%r10
  14:	b8 09 00 00 40       	mov    $0x40000009,%eax
  19:	0f 05                	syscall

That is

1. addr is unchanged.
2. length is zero-extend to 64 bits.
3. prot is sign-extend to 64 bits.
4. flags is sign-extend to 64 bits.
5. fd is sign-extend to 64 bits.
6. offset is unchanged.

For int arguments, since kernel uses only the lower 32 bits and ignores
the upper 32 bits in 64-bit registers, these work correctly.

Tested on x86-64 and x32.  There are no code changes on x86-64.
2020-04-13 10:31:26 -07:00
..
aarch64 Update aarch64 libm-test-ulps 2020-04-08 13:52:44 -03:00
alpha Update alpha libm-test-ulps 2020-04-08 13:52:45 -03:00
arm Update arm libm-test-ulps 2020-04-08 13:52:44 -03:00
csky math: Remove inline math tests 2020-03-19 11:45:44 -03:00
generic ldbl-128ibm-compat: Provide ieee128 symbols to narrow functions 2020-02-20 17:12:14 -06:00
gnu Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
hppa Update hppa libm-test-ulps 2020-04-06 22:19:03 +00:00
htl pthread: Move robust mutex tests from nptl to sysdeps/pthread 2020-02-16 14:43:54 +00:00
hurd C11 threads: Move implementation to sysdeps/pthread 2020-02-09 13:56:48 +01:00
i386 i386: Remove build support for GCC older than GCC 6 2020-04-07 06:44:37 -07:00
ia64 Update ia64 libm-test-ulps 2020-04-08 13:52:45 -03:00
ieee754 ldbl-128ibm: simplify iscanonical.h 2020-04-06 10:23:58 -05:00
m68k math: Remove inline math tests 2020-03-19 11:45:44 -03:00
mach posix: Remove posix waitid 2020-02-27 16:16:17 -03:00
microblaze math: Remove inline math tests 2020-03-19 11:45:44 -03:00
mips Update mips libm-test-ulps 2020-04-08 13:53:08 -03:00
nios2 math: Remove inline math tests 2020-03-19 11:45:44 -03:00
nptl Linux: set_robust_list syscall number is always available 2020-03-03 12:49:44 +01:00
posix posix: Fix system error return value [BZ #25715] 2020-03-23 18:00:38 -03:00
powerpc powerpc: Update ULPs and xfail more ibm128 outputs 2020-04-07 11:41:29 -03:00
pthread pthread: Fix building tst-robust8 with nptl 2020-02-16 23:53:45 +01:00
riscv math: Remove inline math tests 2020-03-19 11:45:44 -03:00
s390 S390: Regenerate ULPs. 2020-04-03 09:38:02 +02:00
sh math: Remove inline math tests 2020-03-19 11:45:44 -03:00
sparc Update sparc libm-test-ulps 2020-04-08 13:52:44 -03:00
unix x32: Properly pass long to syscall [BZ #25810] 2020-04-13 10:31:26 -07:00
wordsize-32 Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
wordsize-64 Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
x86 x86: Remove feraiseexcept optimization 2020-03-30 10:52:32 -03:00
x86_64 nptl: Remove x86_64 cancellation assembly implementations [BZ #25765] 2020-04-03 10:47:59 -03:00