NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-amd64/53316: syscalls with more than 6 args may not work



The following reply was made to PR port-amd64/53316; it has been noted by GNATS.

From: Valery Ushakov <uwe%stderr.spb.ru@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: martin%NetBSD.org@localhost
Subject: Re: port-amd64/53316: syscalls with more than 6 args may not work
Date: Mon, 28 May 2018 04:34:16 +0300

 On Sat, May 26, 2018 at 12:00:00 +0000, martin%NetBSD.org@localhost wrote:
 
 > The new test /usr/tests/lib/libc/sys/t_syscall fails on amd64. It tries
 > to call mmap(2) via __syscall(2) with this code:
 > 
 >   p = (const char *)__SYSCALL_TO_UINTPTR_T(__syscall(SYS_mmap,
 >           0, sizeof(secrect_data), PROT_READ, MAP_PRIVATE, fd, 0, 0, 0));
 
 The last but one zero you pass is an int, but the arguments passed on
 the stack are passed in 8-byte chunks, so compiler emits movl that
 stores zero to the LSW, but the MSW contains garbage.  Syscall code in
 the kernel will pick that half-garbage value as the 8-byte off_t
 argument.
 
 I guess you are passing two zeroes to manually create 64-bit off_t,
 but as you can see that doesn't work as expected.
 
 The test should do
 
    ... fd, /* pad */ 0, (off_t)0)
 
 I think, which should also DTRT in the 32-bit case.
 
 The code works on sparc64 b/c its ABI defines that stack args are
 sign-extended to 8-bytes.
 
 -uwe 
 


Home | Main Index | Thread Index | Old Index