glibc/sysdeps/unix/sysv/linux/x86_64
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
..
64 Update syscall lists for Linux 5.6. 2020-04-03 18:07:55 +00:00
x32 x32: Properly pass long to syscall [BZ #25810] 2020-04-13 10:31:26 -07:00
Implies
Makefile
Versions
____longjmp_chk.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
__start_context.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
brk.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
clone.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
compat-timer.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
configure
configure.ac
dl-cache.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
dl-procinfo.c
dl-procinfo.h
getcontext.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
kernel-features.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
kernel_stat.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
ldconfig.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
ldd-rewrite.sed
libmvec.abilist
makecontext.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
pthread_setaffinity.c
readelflib.c
register-dump.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
sched_setaffinity.c
setcontext.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
sigaction.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
sigaltstack-offsets.sym
sigcontextinfo.h Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
swapcontext.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
syscall.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
syscalls.list
sysdep.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
sysdep.h x32: Properly pass long to syscall [BZ #25810] 2020-04-13 10:31:26 -07:00
timer_create.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
timer_delete.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
timer_getoverr.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
timer_gettime.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
timer_settime.c Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00
ucontext_i.sym
vfork.S Update copyright dates with scripts/update-copyrights. 2020-01-01 00:14:33 +00:00