On Thu, Dec 23, 2021 at 11:50:33AM -0700, Philip Guenther wrote:
> CVSROOT:      /cvs
> Module name:  src
> Changes by:   guent...@cvs.openbsd.org        2021/12/23 11:50:33
> 
> Modified files:
>       sys/kern       : syscalls.master vfs_syscalls.c kern_ktrace.c 
>                        kern_pledge.c 
>       sys/arch/sh/sh : trap.c 
>       sys/arch/hppa/hppa: trap.c 
>       sys/uvm        : uvm_mmap.c 
>       lib/libc/sys   : Makefile.inc 
>       libexec/ld.so  : Makefile loader.c 
>       libexec/ld.so/m88k: rtld_machine.c 
>       usr.bin/kdump  : kdump.c 
> Added files:
>       libexec/ld.so  : syscall.h 
> Removed files:
>       lib/libc/sys   : ftruncate.c lseek.c mmap.c mquery.c pread.c 
>                        preadv.c pwrite.c pwritev.c truncate.c 
>       libexec/ld.so/m88k: syscall.h 
>       libexec/ld.so/aarch64: syscall.h 
>       libexec/ld.so/alpha: syscall.h 
>       libexec/ld.so/amd64: syscall.h 
>       libexec/ld.so/arm: syscall.h 
>       libexec/ld.so/hppa: syscall.h 
>       libexec/ld.so/i386: syscall.h 
>       libexec/ld.so/mips64: syscall.h 
>       libexec/ld.so/powerpc: syscall.h 
>       libexec/ld.so/powerpc64: syscall.h 
>       libexec/ld.so/riscv64: syscall.h 
>       libexec/ld.so/sh: syscall.h 
>       libexec/ld.so/sparc64: syscall.h 
> 
> Log message:
> Roll the syscalls that have an off_t argument to remove the explicit padding.
> Switch libc and ld.so to the generic stubs for these calls.
> WARNING: reboot to updated kernel before installing libc or ld.so!
> 
> Time for a story...
> 
> When gcc (back in 1.x days) first implemented long long, it didn't (always)
> pass 64bit arguments in 'aligned' registers/stack slots, with the result that
> argument offsets didn't match structure offsets.  This affected the nine 
> system
> calls that pass off_t arguments:
> ftruncate lseek mmap mquery pread preadv pwrite pwritev truncate
> 
> To avoid having to do custom ASM wrappers for those, BSD put an explicit pad
> argument in so that the off_t argument would always start on a even slot and
> thus be naturally aligned.  Thus those odd wrappers in lib/libc/sys/ that use
> __syscall() and pass an extra '0' argument.
> 
> The ABIs for different CPUs eventually settled how things should be passed on
> each and gcc 2.x followed them.  The only arch now where it helps is landisk,
> which needs to skip the last argument register if it would be the first half 
> of
> a 64bit argument.  So: add new syscalls without the pad argument and on 
> landisk
> do that skipping directly in the syscall handler in the kernel.  Keep compat
> support for the existing syscalls long enough for the transition.
> 
> ok deraadt@

The sys/kern/__syscall tests can probably be removed at this point:

> sys/kern/__syscall:
Exit: 1
Duration: 00:00:00
Log: 65-sys-kern-__syscall.log

+ . /usr/local/libexec/robsd/util.sh
+ . /usr/local/libexec/robsd/util-ports.sh
+ . /usr/local/libexec/robsd/util-regress.sh
+ regress_root sys/kern/__syscall
+ unpriv anton exec make -C /home/src/regress/sys/kern/__syscall
cc -O2 -pipe   -MD -MP  -c /home/src/regress/sys/kern/__syscall/__syscall.c
cc   -o __syscall __syscall.o 
==== run-regress-__syscall ====
./__syscall
__syscall: lseek: wrong position 0
*** Error 1 in . (<bsd.regress.mk>:36 'run-regress-__syscall')
FAILED

Reply via email to