diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2023-12-10 16:45:53 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2023-12-10 16:45:53 +0000 |
commit | 554b5050f9716b60f4c464fa47c45e44d2ec17f4 (patch) | |
tree | 8344cc9c3c2f56166365c306bad742ae31323505 /lib/libc | |
parent | b280d04449932c61248bf5a44e27a1e8ec1c2dd9 (diff) |
Populate the non-LOAD openbsd.syscalls section (and PT_OPENBSD_SYSCALL)
with {uint offset, uint syscall#} entries in libc & ld.so.
In libc a few syscall# entries (break, sigprocmask, _tfork, _threxit)
are duplicated because additional or inline uses occur (that situation
is handled elsewhere)
ok kettenis
Diffstat (limited to 'lib/libc')
73 files changed, 392 insertions, 201 deletions
diff --git a/lib/libc/arch/DEFS.h b/lib/libc/arch/DEFS.h index 97832c3ead9..d9852ecb17f 100644 --- a/lib/libc/arch/DEFS.h +++ b/lib/libc/arch/DEFS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: DEFS.h,v 1.1 2022/01/01 23:47:14 guenther Exp $ */ +/* $OpenBSD: DEFS.h,v 1.2 2023/12/10 16:45:50 deraadt Exp $ */ /* * Copyright (c) 2015,2018,2021 Philip Guenther <guenther@openbsd.org> * @@ -67,3 +67,9 @@ #endif #define _END(x) .size x, . - x + +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; diff --git a/lib/libc/arch/aarch64/SYS.h b/lib/libc/arch/aarch64/SYS.h index 8eb2463d45a..8f85a31eadc 100644 --- a/lib/libc/arch/aarch64/SYS.h +++ b/lib/libc/arch/aarch64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.6 2022/12/08 01:25:43 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.7 2023/12/10 16:45:50 deraadt Exp $ */ /* $NetBSD: SYS.h,v 1.8 2003/08/07 16:42:02 agc Exp $ */ /*- @@ -53,7 +53,8 @@ #define SYSTRAP(x) \ ldr x8, =SYS_ ## x; \ - svc 0; \ +97: svc 0; \ + PINSYSCALL(SYS_ ## x, 97b); \ dsb nsh; \ isb diff --git a/lib/libc/arch/alpha/SYS.h b/lib/libc/arch/alpha/SYS.h index 688864beff0..62adccb89b5 100644 --- a/lib/libc/arch/alpha/SYS.h +++ b/lib/libc/arch/alpha/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.16 2023/12/06 06:15:33 miod Exp $ */ +/* $OpenBSD: SYS.h,v 1.17 2023/12/10 16:45:50 deraadt Exp $ */ /* $NetBSD: SYS.h,v 1.4 1996/10/17 03:03:53 cgd Exp $ */ /* @@ -56,6 +56,12 @@ */ #define _END(x) .size x, . - x +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; + /* * For functions implemented in ASM that aren't syscalls. * END_STRONG(x) Like DEF_STRONG() in C; for standard/reserved C names @@ -67,7 +73,8 @@ #define CALLSYS_NOERROR(name) \ ldiq v0, ___CONCAT(SYS_,name); \ - call_pal PAL_OSF1_callsys +97: call_pal PAL_OSF1_callsys; \ + PINSYSCALL(___CONCAT(SYS_,name), 97b) #define CALLSYS_ERROR(name) \ CALLSYS_NOERROR(name); \ diff --git a/lib/libc/arch/amd64/SYS.h b/lib/libc/arch/amd64/SYS.h index ce67ad0325c..95cee3b60a2 100644 --- a/lib/libc/arch/amd64/SYS.h +++ b/lib/libc/arch/amd64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.21 2023/01/11 01:55:17 mortimer Exp $ */ +/* $OpenBSD: SYS.h,v 1.22 2023/12/10 16:45:50 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -41,7 +41,11 @@ /* offsetof(struct tib, tib_errno) - offsetof(struct tib, __tib_tcb) */ #define TCB_OFFSET_ERRNO 32 -#define SYSTRAP(x) movl $(SYS_ ## x),%eax; movq %rcx, %r10; syscall +#define SYSTRAP(x) \ + movl $(SYS_ ## x),%eax; \ + movq %rcx, %r10; \ +97: syscall; \ + PINSYSCALL(SYS_ ## x, 97b) #define SYSENTRY(x) \ SYSENTRY_HIDDEN(x); \ diff --git a/lib/libc/arch/amd64/gen/setjmp.S b/lib/libc/arch/amd64/gen/setjmp.S index dff42508a9e..ded7c9ec4c1 100644 --- a/lib/libc/arch/amd64/gen/setjmp.S +++ b/lib/libc/arch/amd64/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.9 2020/10/21 17:22:59 kettenis Exp $ */ +/* $OpenBSD: setjmp.S,v 1.10 2023/12/10 16:45:51 deraadt Exp $ */ /* $NetBSD: __setjmp14.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $ */ /* @@ -64,7 +64,8 @@ ENTRY(setjmp) movl $1,%edi /* how = SIG_BLOCK */ xorl %esi,%esi /* set = empty */ movl $SYS_sigprocmask,%eax - syscall +99: syscall + PINSYSCALL(SYS_sigprocmask, 99b) movq %r8,%rdi /* restore jmpbuf addr */ movq %rax,(_JB_SIGMASK * 8)(%rdi) @@ -100,7 +101,8 @@ ENTRY(longjmp) movq (_JB_SIGMASK * 8)(%rdi),%rsi /* get set from sc_mask */ movl $3,%edi /* how = SIG_SETMASK */ movl $SYS_sigprocmask,%eax - syscall +98: syscall + PINSYSCALL(SYS_sigprocmask, 98b) movl %r8d,%eax leaq __jmpxor(%rip),%rcx diff --git a/lib/libc/arch/amd64/gen/sigsetjmp.S b/lib/libc/arch/amd64/gen/sigsetjmp.S index 55a10c03d62..d26ed4a2789 100644 --- a/lib/libc/arch/amd64/gen/sigsetjmp.S +++ b/lib/libc/arch/amd64/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsetjmp.S,v 1.9 2020/10/21 17:22:59 kettenis Exp $ */ +/* $OpenBSD: sigsetjmp.S,v 1.10 2023/12/10 16:45:51 deraadt Exp $ */ /* $NetBSD: __setjmp14.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $ */ /* @@ -62,7 +62,8 @@ ENTRY(sigsetjmp) movl $1,%edi /* how = SIG_BLOCK */ xorl %esi,%esi /* set = empty */ movl $SYS_sigprocmask,%eax - syscall +99: syscall + PINSYSCALL(SYS_sigprocmask, 99b) movq %r8,%rdi /* restore jmpbuf addr */ movq %rax,(_JB_SIGMASK * 8)(%rdi) @@ -100,7 +101,8 @@ ENTRY(siglongjmp) movq (_JB_SIGMASK * 8)(%rdi),%rsi /* get set from sc_mask */ movl $3,%edi /* how = SIG_SETMASK */ movl $SYS_sigprocmask,%eax - syscall +98: syscall + PINSYSCALL(SYS_sigprocmask, 98b) 2: movl %r8d,%eax leaq __jmpxor(%rip),%rcx diff --git a/lib/libc/arch/amd64/sys/tfork_thread.S b/lib/libc/arch/amd64/sys/tfork_thread.S index 8de236b7d21..7889e5b1466 100644 --- a/lib/libc/arch/amd64/sys/tfork_thread.S +++ b/lib/libc/arch/amd64/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.11 2023/01/11 01:55:17 mortimer Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.12 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org> * Copyright (c) 2003 Alan L. Cox <alc@cs.rice.edu> @@ -56,7 +56,8 @@ ENTRY(__tfork_thread) */ movl $SYS___tfork, %eax .cfi_endproc - syscall +99: syscall + PINSYSCALL(SYS___tfork, 99b) jb 2f /* @@ -90,7 +91,8 @@ ENTRY(__tfork_thread) */ movl $SYS___threxit, %eax xorl %edi, %edi - syscall +98: syscall + PINSYSCALL(SYS___threxit, 98b) int3 /* diff --git a/lib/libc/arch/arm/SYS.h b/lib/libc/arch/arm/SYS.h index 037ded4050a..b6d4407ce57 100644 --- a/lib/libc/arch/arm/SYS.h +++ b/lib/libc/arch/arm/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.19 2022/12/08 01:25:43 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.20 2023/12/10 16:45:51 deraadt Exp $ */ /* $NetBSD: SYS.h,v 1.8 2003/08/07 16:42:02 agc Exp $ */ /*- @@ -54,7 +54,8 @@ #define SYSTRAP(x) \ ldr r12, =SYS_ ## x; \ - swi 0; \ +97: swi 0; \ + PINSYSCALL(SYS_ ## x, 97b); \ dsb nsh; \ isb diff --git a/lib/libc/arch/hppa/SYS.h b/lib/libc/arch/hppa/SYS.h index 896bf6fb372..6c0f547474c 100644 --- a/lib/libc/arch/hppa/SYS.h +++ b/lib/libc/arch/hppa/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.23 2023/02/11 06:10:39 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.24 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1998-2002 Michael Shalayeff @@ -67,6 +67,11 @@ #define EXIT_WEAK(x) EXIT_STRONG(x) !\ .weak x +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits !\ + .long label !\ + .long sysno !\ + .popsection #define SYSENTRY(x) !\ LEAF_ENTRY(__CONCAT(_thread_sys_,x)) !\ @@ -84,8 +89,9 @@ LEAF_ENTRY(__CONCAT(_thread_sys_,x)) #define SYSCALL(x) !\ stw rp, HPPA_FRAME_ERP(sr0,sp) !\ ldil L%SYSCALLGATE, r1 !\ - ble 4(sr7, r1) !\ - ldi __CONCAT(SYS_,x), t1 !\ +97: ble 4(sr7, r1) !\ + PINSYSCALL(__CONCAT(SYS_,x), 97b) !\ + ldi __CONCAT(SYS_,x), t1 !\ comb,= 0, t1, 1f !\ ldw HPPA_FRAME_ERP(sr0,sp), rp !\ /* set errno */ \ @@ -113,8 +119,9 @@ SYSEXIT_HIDDEN(x) SYSENTRY(x) !\ stw rp, HPPA_FRAME_ERP(sr0,sp) !\ ldil L%SYSCALLGATE, r1 !\ - ble 4(sr7, r1) !\ - ldi __CONCAT(SYS_,y), t1 !\ +97: ble 4(sr7, r1) !\ + PINSYSCALL(__CONCAT(SYS_,x), 97b) !\ + ldi __CONCAT(SYS_,x), t1 !\ ldw HPPA_FRAME_ERP(sr0,sp), rp !\ bv r0(rp) !\ nop !\ diff --git a/lib/libc/arch/hppa/gen/setjmp.S b/lib/libc/arch/hppa/gen/setjmp.S index f8c48db2658..e5adf7e8cd2 100644 --- a/lib/libc/arch/hppa/gen/setjmp.S +++ b/lib/libc/arch/hppa/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.11 2016/05/29 07:59:36 guenther Exp $ */ +/* $OpenBSD: setjmp.S,v 1.12 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -63,7 +63,8 @@ ALTENTRY(setjmp) copy %r0, %arg1 ; set = empty stw %rp, HPPA_FRAME_ERP(%sr0,%sp) ldil L%SYSCALLGATE, %r1 - ble 4(%sr7, %r1) +99: ble 4(%sr7, %r1) + PINSYSCALL(SYS_sigprocmask, 99b) ldi SYS_sigprocmask, %t1 ldw HPPA_FRAME_ERP(%sr0,%sp), %rp @@ -129,7 +130,8 @@ ALTENTRY(longjmp) ldi 3, %arg0 ; how = SIG_SETMASK stw %rp, HPPA_FRAME_ERP(%sr0,%sp) ldil L%SYSCALLGATE, %r1 - ble 4(%sr7, %r1) +98: ble 4(%sr7, %r1) + PINSYSCALL(SYS_sigprocmask, 98b) ldi SYS_sigprocmask, %t1 ldw HPPA_FRAME_ERP(%sr0,%sp), %rp diff --git a/lib/libc/arch/hppa/sys/Ovfork.S b/lib/libc/arch/hppa/sys/Ovfork.S index 8be9141b338..fc8057313ba 100644 --- a/lib/libc/arch/hppa/sys/Ovfork.S +++ b/lib/libc/arch/hppa/sys/Ovfork.S @@ -1,4 +1,4 @@ -/* $OpenBSD: Ovfork.S,v 1.15 2016/05/07 19:05:21 guenther Exp $ */ +/* $OpenBSD: Ovfork.S,v 1.16 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1999,2002 Michael Shalayeff @@ -32,8 +32,9 @@ SYSENTRY_HIDDEN(vfork) .import errno, data copy rp, t4 ldil L%SYSCALLGATE, r1 - ble 4(sr7, r1) - ldi __CONCAT(SYS_,vfork), t1 +99: ble 4(sr7, r1) + PINSYSCALL(__CONCAT(SYS_,vfork), 99b) + ldi __CONCAT(SYS_,vfork), t1 comb,= r0, t1, 1f copy t4, rp /* set errno */ diff --git a/lib/libc/arch/i386/DEFS.h b/lib/libc/arch/i386/DEFS.h index db2d9696d1d..c8ae4a29beb 100644 --- a/lib/libc/arch/i386/DEFS.h +++ b/lib/libc/arch/i386/DEFS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: DEFS.h,v 1.3 2017/11/29 05:13:57 guenther Exp $ */ +/* $OpenBSD: DEFS.h,v 1.4 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 2017 Philip Guenther <guenther@openbsd.org> * @@ -47,3 +47,9 @@ #else #define END_BUILTIN(x) END_STRONG(x) #endif + +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; diff --git a/lib/libc/arch/i386/SYS.h b/lib/libc/arch/i386/SYS.h index 993ad31715d..699744b9425 100644 --- a/lib/libc/arch/i386/SYS.h +++ b/lib/libc/arch/i386/SYS.h @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: SYS.h,v 1.27 2017/11/29 05:13:57 guenther Exp $ + * $OpenBSD: SYS.h,v 1.28 2023/12/10 16:45:51 deraadt Exp $ */ #include "DEFS.h" @@ -59,7 +59,9 @@ #define __DO_SYSCALL(x) \ movl $(SYS_ ## x),%eax; \ - int $0x80 + 97: int $0x80; \ + PINSYSCALL(SYS_ ## x, 97b) + #define SET_ERRNO() \ movl %eax,%gs:(TCB_OFFSET_ERRNO); \ diff --git a/lib/libc/arch/i386/gen/setjmp.S b/lib/libc/arch/i386/gen/setjmp.S index 9dbb4ffafc1..3d62109bf72 100644 --- a/lib/libc/arch/i386/gen/setjmp.S +++ b/lib/libc/arch/i386/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.14 2020/12/13 21:21:32 bluhm Exp $ */ +/* $OpenBSD: setjmp.S,v 1.15 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -59,7 +59,8 @@ ENTRY(setjmp) pushl $1 /* how = SIG_BLOCK */ call 1f 1: movl $(SYS_sigprocmask),%eax - int $0x80 /* leave oset in %eax */ +99: int $0x80 /* leave oset in %eax */ + PINSYSCALL(SYS_sigprocmask, 99b) popl %edx addl $8,%esp addl $__jmpxor-1b,%edx # load cookie address @@ -89,7 +90,8 @@ ENTRY(longjmp) pushl $3 /* how = SIG_SETMASK */ call 1f /* get our eip */ 1: movl $(SYS_sigprocmask),%eax - int $0x80 +98: int $0x80 + PINSYSCALL(SYS_sigprocmask, 98b) popl %ecx addl $8,%esp addl $__jmpxor-1b,%ecx # load cookie address diff --git a/lib/libc/arch/i386/gen/sigsetjmp.S b/lib/libc/arch/i386/gen/sigsetjmp.S index 2c2013257bf..c34b28dbf10 100644 --- a/lib/libc/arch/i386/gen/sigsetjmp.S +++ b/lib/libc/arch/i386/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsetjmp.S,v 1.13 2020/12/13 21:21:32 bluhm Exp $ */ +/* $OpenBSD: sigsetjmp.S,v 1.14 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -47,7 +47,8 @@ ENTRY(sigsetjmp) pushl $1 /* how = SIG_BLOCK */ subl $4,%esp movl $(SYS_sigprocmask),%eax - int $0x80 /* leave oset in %eax */ +99: int $0x80 /* leave oset in %eax */ + PINSYSCALL(SYS_sigprocmask, 99b) addl $12,%esp movl %eax,(_JB_SIGMASK * 4)(%ecx) @@ -81,7 +82,8 @@ ENTRY(siglongjmp) pushl $3 /* how = SIG_SETMASK */ subl $4,%esp movl $(SYS_sigprocmask),%eax - int $0x80 +98: int $0x80 + PINSYSCALL(SYS_sigprocmask, 98b) addl $12,%esp 1: call 2f diff --git a/lib/libc/arch/i386/sys/Ovfork.S b/lib/libc/arch/i386/sys/Ovfork.S index 2c276186606..b827f89fe35 100644 --- a/lib/libc/arch/i386/sys/Ovfork.S +++ b/lib/libc/arch/i386/sys/Ovfork.S @@ -1,4 +1,4 @@ -/* $OpenBSD: Ovfork.S,v 1.10 2016/05/07 19:05:21 guenther Exp $ */ +/* $OpenBSD: Ovfork.S,v 1.11 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -36,7 +36,8 @@ SYSENTRY_HIDDEN(vfork) popl %ecx /* my rta into ecx */ movl $(SYS_vfork),%eax - int $0x80 +99: int $0x80 + PINSYSCALL(SYS_vfork, 99b) HANDLE_ERRNO() jmp *%ecx SYSCALL_END_HIDDEN(vfork) diff --git a/lib/libc/arch/i386/sys/brk.S b/lib/libc/arch/i386/sys/brk.S index a360f96b1ee..5d485961c0f 100644 --- a/lib/libc/arch/i386/sys/brk.S +++ b/lib/libc/arch/i386/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.15 2022/12/04 08:22:13 tb Exp $ */ +/* $OpenBSD: brk.S,v 1.16 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -54,7 +54,8 @@ ENTRY_NB(brk) movl %ecx,4(%esp) 1: movl $(SYS_break),%eax - int $0x80 +99: int $0x80 + PINSYSCALL(SYS_break, 99b) jc 2f PIC_PROLOGUE movl PIC_GOT(__curbrk),%edx # set up GOT addressing @@ -71,7 +72,8 @@ ENTRY_NB(brk) movl %ecx,4(%esp) 1: movl $(SYS_break),%eax - int $0x80 +98: int $0x80 + PINSYSCALL(SYS_break, 98b) jc 2f xorl %eax,%eax movl %ecx,__curbrk diff --git a/lib/libc/arch/i386/sys/sbrk.S b/lib/libc/arch/i386/sys/sbrk.S index 4d2ac8baa46..675f8d2785e 100644 --- a/lib/libc/arch/i386/sys/sbrk.S +++ b/lib/libc/arch/i386/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.15 2022/12/04 08:22:13 tb Exp $ */ +/* $OpenBSD: sbrk.S,v 1.16 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -51,7 +51,8 @@ ENTRY_NB(sbrk) movl (%edx),%eax addl %eax,4(%esp) movl $(SYS_break),%eax - int $0x80 +99: int $0x80 + PINSYSCALL(SYS_break, 99b) jc 2f PIC_PROLOGUE movl PIC_GOT(__curbrk),%edx @@ -65,7 +66,8 @@ ENTRY_NB(sbrk) movl __curbrk,%eax addl %eax,4(%esp) movl $(SYS_break),%eax - int $0x80 +98: int $0x80 + PINSYSCALL(SYS_break, 98b) jc 2f movl __curbrk,%eax addl %ecx,__curbrk diff --git a/lib/libc/arch/i386/sys/sigprocmask.S b/lib/libc/arch/i386/sys/sigprocmask.S index 489eabcbf11..262744ba470 100644 --- a/lib/libc/arch/i386/sys/sigprocmask.S +++ b/lib/libc/arch/i386/sys/sigprocmask.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigprocmask.S,v 1.12 2016/05/07 19:05:21 guenther Exp $ */ +/* $OpenBSD: sigprocmask.S,v 1.13 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -43,7 +43,8 @@ SYSENTRY_HIDDEN(sigprocmask) 1: movl (%ecx),%ecx # fetch indirect ... movl %ecx,8(%esp) # to new mask arg 2: movl $(SYS_sigprocmask),%eax - int $0x80 +99: int $0x80 + PINSYSCALL(SYS_sigprocmask, 99b) jc 1f movl 12(%esp),%ecx # fetch old mask requested testl %ecx,%ecx # test if old mask requested diff --git a/lib/libc/arch/i386/sys/sigsuspend.S b/lib/libc/arch/i386/sys/sigsuspend.S index 88a08c7a1c4..e93dffb4162 100644 --- a/lib/libc/arch/i386/sys/sigsuspend.S +++ b/lib/libc/arch/i386/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.10 2016/05/07 19:05:21 guenther Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.11 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -38,7 +38,8 @@ SYSENTRY_HIDDEN(sigsuspend) movl (%eax),%eax # indirect to mask arg movl %eax,4(%esp) movl $(SYS_sigsuspend),%eax - int $0x80 +99: int $0x80 + PINSYSCALL(SYS_sigsuspend, 99b) SET_ERRNO() ret SYSCALL_END_HIDDEN(sigsuspend) diff --git a/lib/libc/arch/i386/sys/tfork_thread.S b/lib/libc/arch/i386/sys/tfork_thread.S index dfafb9139b6..85e912963cb 100644 --- a/lib/libc/arch/i386/sys/tfork_thread.S +++ b/lib/libc/arch/i386/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.10 2020/10/18 14:28:17 deraadt Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.11 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org> * All rights reserved. @@ -62,7 +62,8 @@ ENTRY(__tfork_thread) pushl 8(%ebp) # push param pushl $0 # slot for return address, ignored by kernel movl $SYS___tfork, %eax - int $0x80 +99: int $0x80 + PINSYSCALL(SYS___tfork, 99b) jb 2f /* @@ -98,7 +99,8 @@ ENTRY(__tfork_thread) pushl $0 # NULL pointer argument to __threxit pushl $0 # slot for return address, ignored by kernel movl $SYS___threxit, %eax - int $0x80 +98: int $0x80 + PINSYSCALL(SYS___threxit, 98b) int3 /* diff --git a/lib/libc/arch/m88k/DEFS.h b/lib/libc/arch/m88k/DEFS.h index 3db1a435fc1..804636ee852 100644 --- a/lib/libc/arch/m88k/DEFS.h +++ b/lib/libc/arch/m88k/DEFS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: DEFS.h,v 1.3 2016/09/22 18:19:59 guenther Exp $ */ +/* $OpenBSD: DEFS.h,v 1.4 2023/12/10 16:45:51 deraadt Exp $ */ #include <machine/asm.h> @@ -23,3 +23,9 @@ */ #define END_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); END(_HIDDEN(x)) #define END_WEAK(x) END_STRONG(x); .weak x + +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; diff --git a/lib/libc/arch/m88k/SYS.h b/lib/libc/arch/m88k/SYS.h index feb08d91253..60e54c6b3ea 100644 --- a/lib/libc/arch/m88k/SYS.h +++ b/lib/libc/arch/m88k/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.25 2018/06/16 16:06:03 guenther Exp $*/ +/* $OpenBSD: SYS.h,v 1.26 2023/12/10 16:45:51 deraadt Exp $*/ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -80,7 +80,8 @@ #define __DO_SYSCALL(x) \ or %r13, %r0, __SYSCALLNAME(SYS_,x); \ - tb0 0, %r0, 450 +97: tb0 0, %r0, 450; \ + PINSYSCALL(__SYSCALLNAME(SYS_,x), 97b) #define __SYSCALL__NOERROR(p,x,y) \ __ENTRY(p,x); \ diff --git a/lib/libc/arch/m88k/sys/brk.S b/lib/libc/arch/m88k/sys/brk.S index f1aecbf6804..12270b72436 100644 --- a/lib/libc/arch/m88k/sys/brk.S +++ b/lib/libc/arch/m88k/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.14 2015/09/10 13:29:09 guenther Exp $ */ +/* $OpenBSD: brk.S,v 1.15 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -65,7 +65,8 @@ ENTRY(brk) 1: or %r4,%r2,0 or %r13,%r0,__SYSCALLNAME(SYS_,break) - tb0 0,%r0,450 +99: tb0 0,%r0,450 + PINSYSCALL(SYS_break, 99b) #ifdef __PIC__ br 9f #else diff --git a/lib/libc/arch/m88k/sys/sbrk.S b/lib/libc/arch/m88k/sys/sbrk.S index a35804a9e85..8c8262500f4 100644 --- a/lib/libc/arch/m88k/sys/sbrk.S +++ b/lib/libc/arch/m88k/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.14 2015/09/10 13:29:09 guenther Exp $ */ +/* $OpenBSD: sbrk.S,v 1.15 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -64,7 +64,8 @@ ENTRY(sbrk) add %r2,%r2,%r5 or %r4,%r2,0 or %r13,%r0,SYS_break - tb0 0,%r0,450 +99: tb0 0,%r0,450 + PINSYSCALL(SYS_break, 99b) #ifdef __PIC__ br 9f #else diff --git a/lib/libc/arch/m88k/sys/sigpending.S b/lib/libc/arch/m88k/sys/sigpending.S index d3f41f116a3..15d11c00b70 100644 --- a/lib/libc/arch/m88k/sys/sigpending.S +++ b/lib/libc/arch/m88k/sys/sigpending.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigpending.S,v 1.10 2015/09/10 13:29:09 guenther Exp $ */ +/* $OpenBSD: sigpending.S,v 1.11 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -38,7 +38,8 @@ SYSENTRY(sigpending) or %r4,%r2,0 /* save r2 */ or %r13,%r0,SYS_sigpending - tb0 0,%r0,450 +99: tb0 0,%r0,450 + PINSYSCALL(SYS_sigpending, 99b) br CERROR st %r2,%r4,0 jmp.n %r1 diff --git a/lib/libc/arch/m88k/sys/sigprocmask.S b/lib/libc/arch/m88k/sys/sigprocmask.S index 5ce01f22762..ed376360299 100644 --- a/lib/libc/arch/m88k/sys/sigprocmask.S +++ b/lib/libc/arch/m88k/sys/sigprocmask.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigprocmask.S,v 1.12 2015/10/23 04:39:24 guenther Exp $ */ +/* $OpenBSD: sigprocmask.S,v 1.13 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -43,7 +43,8 @@ SYSENTRY_HIDDEN(sigprocmask) ld %r3,%r3,0 /* else load set from *set and do it */ 2: or %r13,%r0,SYS_sigprocmask - tb0 0,%r0,450 +99: tb0 0,%r0,450 + PINSYSCALL(SYS_sigprocmask, 99b) br CERROR bcnd eq0,%r4,3f /* if old mask not requested, done */ st %r2,%r4,0 /* otherwise, set it */ diff --git a/lib/libc/arch/m88k/sys/sigsuspend.S b/lib/libc/arch/m88k/sys/sigsuspend.S index 847179c0845..5ead0ac77de 100644 --- a/lib/libc/arch/m88k/sys/sigsuspend.S +++ b/lib/libc/arch/m88k/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.13 2016/05/07 19:05:21 guenther Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.14 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -45,7 +45,8 @@ SYSENTRY_HIDDEN(sigsuspend) ld %r2,%r2,0 /* dereference the pointer mask */ or %r13,%r0,SYS_sigsuspend - tb0 0,%r0,450 +99: tb0 0,%r0,450 + PINSYSCALL(SYS_sigsuspend, 99b) br CERROR jmp.n %r1 or %r2,%r0,0 diff --git a/lib/libc/arch/m88k/sys/tfork_thread.S b/lib/libc/arch/m88k/sys/tfork_thread.S index e8ba8289291..151319e802f 100644 --- a/lib/libc/arch/m88k/sys/tfork_thread.S +++ b/lib/libc/arch/m88k/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.7 2020/11/07 02:52:08 aoyama Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.8 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat @@ -34,7 +34,8 @@ */ ENTRY(__tfork_thread) or %r13, %r0, __SYSCALLNAME(SYS_,__tfork) - tb0 0, %r0, 450 /* corrupts r2 and r3 in the child */ +99: tb0 0, %r0, 450 /* corrupts r2 and r3 in the child */ + PINSYSCALL(SYS___tfork, 99b) br CERROR bcnd eq0, %r2, 1f @@ -52,7 +53,8 @@ ENTRY(__tfork_thread) or %r2, %r5, %r0 /* arg */ or %r13, %r0, __SYSCALLNAME(SYS_,__threxit) - tb0 0, %r0, 450 +98: tb0 0, %r0, 450 + PINSYSCALL(SYS___threxit, 98b) NOP tb0 0, %r0, 130 /* breakpoint */ END(__tfork_thread) diff --git a/lib/libc/arch/mips64/SYS.h b/lib/libc/arch/mips64/SYS.h index 0eae2a001cc..c9ac6b24cf3 100644 --- a/lib/libc/arch/mips64/SYS.h +++ b/lib/libc/arch/mips64/SYS.h @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: SYS.h,v 1.12 2016/05/07 19:05:22 guenther Exp $ + * $OpenBSD: SYS.h,v 1.13 2023/12/10 16:45:51 deraadt Exp $ */ #include <sys/syscall.h> @@ -59,15 +59,16 @@ .size _HIDDEN(x), . - _HIDDEN(x) #define END_WEAK(x) END_STRONG(x); .weak x - #define CERROR __cerror .hidden CERROR # define __ENTRY(p,x) ENTRY(p ## x) -# define __DO_SYSCALL(x) \ - li v0,SYS_ ## x; \ - syscall +# define __DO_SYSCALL(x) \ + li v0,SYS_ ## x; \ + 97: syscall; \ + PINSYSCALL(SYS_ ## x, 97b) \ + # define __LEAF2(p,x,sz) LEAF(p ## x, sz) \ WEAK_ALIAS(x, p ## x); @@ -124,3 +125,8 @@ #define SYSCALL_END(x) __END2(_thread_sys_,x) #define SYSCALL_END_HIDDEN(x) __END2_HIDDEN(_thread_sys_,x) +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; diff --git a/lib/libc/arch/mips64/gen/setjmp.S b/lib/libc/arch/mips64/gen/setjmp.S index 95748045bef..bd6ea86eae6 100644 --- a/lib/libc/arch/mips64/gen/setjmp.S +++ b/lib/libc/arch/mips64/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.12 2018/01/08 16:44:32 visa Exp $ */ +/* $OpenBSD: setjmp.S,v 1.13 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -60,7 +60,8 @@ LEAF(setjmp, FRAMESZ) li a0, 1 # how = SIG_BLOCK move a1, zero # get current signal mask li v0, SYS_sigprocmask - syscall # mask in v0 +99: syscall # mask in v0 + PINSYSCALL(SYS_sigprocmask, 99b) bne a3, zero, botch REG_S v0, _JB_MASK(a2) # save sc_mask @@ -132,7 +133,8 @@ LEAF(longjmp, FRAMESZ) REG_L a1, _JB_MASK(a2) # load sc_mask li a0, 3 # how = SIG_SETMASK li v0, SYS_sigprocmask - syscall +98: syscall + PINSYSCALL(SYS_sigprocmask, 98b) bne a3, zero, botch REG_L v0, _JB_REGS+ZERO*REGSZ(a2) diff --git a/lib/libc/arch/mips64/sys/brk.S b/lib/libc/arch/mips64/sys/brk.S index f1996672af8..a75be841fa5 100644 --- a/lib/libc/arch/mips64/sys/brk.S +++ b/lib/libc/arch/mips64/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.10 2022/12/08 01:25:43 guenther Exp $ */ +/* $OpenBSD: brk.S,v 1.11 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -55,7 +55,8 @@ LEAF(brk, FRAMESZ) move a0, v0 # dont allow break < minbrk 1: li v0, SYS_break - syscall +99: syscall + PINSYSCALL(SYS_break, 99b) bne a3, zero, 2f PTR_S a0, __curbrk move v0, zero diff --git a/lib/libc/arch/mips64/sys/sbrk.S b/lib/libc/arch/mips64/sys/sbrk.S index 1647b613608..d5a9197a573 100644 --- a/lib/libc/arch/mips64/sys/sbrk.S +++ b/lib/libc/arch/mips64/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.10 2022/12/08 01:25:43 guenther Exp $ */ +/* $OpenBSD: sbrk.S,v 1.11 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -52,7 +52,8 @@ LEAF(sbrk, FRAMESZ) PTR_L v1, __curbrk li v0, SYS_break PTR_ADDU a0, a0, v1 # compute current break - syscall +99: syscall + PINSYSCALL(SYS_break, 99b) bne a3, zero, 1f move v0, v1 # return old val of curbrk from above diff --git a/lib/libc/arch/mips64/sys/sigpending.S b/lib/libc/arch/mips64/sys/sigpending.S index f1217070fdd..fc1be104f57 100644 --- a/lib/libc/arch/mips64/sys/sigpending.S +++ b/lib/libc/arch/mips64/sys/sigpending.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigpending.S,v 1.7 2015/10/23 04:39:24 guenther Exp $ */ +/* $OpenBSD: sigpending.S,v 1.8 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -41,7 +41,8 @@ SYSLEAF(sigpending, FRAMESZ) SETUP_GP64(GPOFF, _HIDDEN(sigpending)) .set reorder li v0, SYS_sigpending - syscall +99: syscall + PINSYSCALL(SYS_sigpending, 99b) bne a3, zero, 1f sw v0, 0(a0) move v0, zero diff --git a/lib/libc/arch/mips64/sys/sigprocmask.S b/lib/libc/arch/mips64/sys/sigprocmask.S index 5b079a8a8ea..2f6d5957276 100644 --- a/lib/libc/arch/mips64/sys/sigprocmask.S +++ b/lib/libc/arch/mips64/sys/sigprocmask.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigprocmask.S,v 1.7 2015/10/23 04:39:24 guenther Exp $ */ +/* $OpenBSD: sigprocmask.S,v 1.8 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -47,7 +47,8 @@ SYSLEAF_HIDDEN(sigprocmask, FRAMESZ) lw a1, 0(a1) # indirect to new mask arg .Ldoit: li v0, SYS_sigprocmask - syscall +99: syscall + PINSYSCALL(SYS_sigprocmask, 99b) bne a3, zero, .Lerr beq a2, zero, .Lout # test if old mask requested sw v0, 0(a2) # store old mask diff --git a/lib/libc/arch/mips64/sys/sigsuspend.S b/lib/libc/arch/mips64/sys/sigsuspend.S index 6c445f61037..e704364d571 100644 --- a/lib/libc/arch/mips64/sys/sigsuspend.S +++ b/lib/libc/arch/mips64/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.7 2016/05/07 19:05:22 guenther Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.8 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -42,7 +42,8 @@ SYSLEAF_HIDDEN(sigsuspend, FRAMESZ) .set reorder lw a0, 0(a0) # indirect to mask arg li v0, SYS_sigsuspend - syscall +99: syscall + PINSYSCALL(SYS_sigsuspend, 99b) bne a3, zero, 1f move v0, zero # should not happen RESTORE_GP64 diff --git a/lib/libc/arch/powerpc/SYS.h b/lib/libc/arch/powerpc/SYS.h index 5ae77643568..32677feb59f 100644 --- a/lib/libc/arch/powerpc/SYS.h +++ b/lib/libc/arch/powerpc/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.27 2023/02/11 06:10:39 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.28 2023/12/10 16:45:51 deraadt Exp $ */ /*- * Copyright (c) 1994 * Andrew Cagney. All rights reserved. @@ -64,7 +64,8 @@ #define PSEUDO_NOERROR(x,y) SYSENTRY(x) \ RETGUARD_SETUP(x, %r11, %r12); \ li %r0, SYS_ ## y ; \ - sc; \ + 97: sc; \ + PINSYSCALL(SYS_ ## y, 97b); \ RETGUARD_CHECK(x, %r11, %r12); \ blr; \ __END(x) @@ -72,7 +73,8 @@ #define PSEUDO_HIDDEN(x,y) SYSENTRY_HIDDEN(x) \ RETGUARD_SETUP(x, %r11, %r12); \ li %r0, SYS_ ## y; \ - sc; \ + 97: sc; \ + PINSYSCALL(SYS_ ## y, 97b); \ cmpwi %r0, 0; \ beq+ .L_ret; \ stw %r0, R2_OFFSET_ERRNO(2); \ diff --git a/lib/libc/arch/powerpc/gen/setjmp.S b/lib/libc/arch/powerpc/gen/setjmp.S index e62121eec92..879876c8cee 100644 --- a/lib/libc/arch/powerpc/gen/setjmp.S +++ b/lib/libc/arch/powerpc/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.14 2022/06/10 01:56:02 guenther Exp $ */ +/* $OpenBSD: setjmp.S,v 1.15 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn. All rights reserved. * @@ -68,7 +68,9 @@ ENTRY(setjmp) li 3, 1 /* how = SIG_BLOCK */ li 4, 0 /* oset = empty */ li 0, SYS_sigprocmask - sc +99: sc + PINSYSCALL(SYS_sigprocmask, 99b) + stw 3, JMP_sig(5) mr 3, 5 ENTRY(_setjmp) @@ -125,7 +127,8 @@ ENTRY(longjmp) li 3, 3 /* how = SIG_SETMASK */ lwz 4, JMP_sig(5) /* oset from the jmpbuf */ li 0, SYS_sigprocmask - sc +98: sc + PINSYSCALL(SYS_sigprocmask, 98b) mr 3, 5 /* restore jmpbuf and val to r3,r4 */ mr 4, 6 diff --git a/lib/libc/arch/powerpc/gen/sigsetjmp.S b/lib/libc/arch/powerpc/gen/sigsetjmp.S index db10a1a8330..1b1a5115ca8 100644 --- a/lib/libc/arch/powerpc/gen/sigsetjmp.S +++ b/lib/libc/arch/powerpc/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsetjmp.S,v 1.8 2022/06/10 01:56:02 guenther Exp $ */ +/* $OpenBSD: sigsetjmp.S,v 1.9 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn. All rights reserved. * @@ -63,7 +63,8 @@ ENTRY(sigsetjmp) li 3, 1 /* how = SIG_BLOCK */ li 4, 0 /* oset = empty */ li 0, SYS_sigprocmask - sc +99: sc + PINSYSCALL(SYS_sigprocmask, 99b) stw 3, JMP_sigmask(5) 1: mflr 6 bcl 20, 31, 2f @@ -122,7 +123,8 @@ ENTRY(siglongjmp) li 3, 3 /* how = SIG_SETMASK */ lwz 4, JMP_sigmask(5) /* oset from the jmpbuf */ li 0, SYS_sigprocmask - sc +98: sc + PINSYSCALL(SYS_sigprocmask, 98b) 1: bcl 20, 31, 2f 2: mflr 9 diff --git a/lib/libc/arch/powerpc/sys/brk.S b/lib/libc/arch/powerpc/sys/brk.S index 9e117ffda67..07f3ab42a14 100644 --- a/lib/libc/arch/powerpc/sys/brk.S +++ b/lib/libc/arch/powerpc/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.18 2022/12/08 01:25:43 guenther Exp $ */ +/* $OpenBSD: brk.S,v 1.19 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -60,7 +60,8 @@ ENTRY_NB(brk) #endif li 0, SYS_break - sc +99: sc + PINSYSCALL(SYS_break, 99b) /* check for error */ cmpwi 0, 0 diff --git a/lib/libc/arch/powerpc/sys/sbrk.S b/lib/libc/arch/powerpc/sys/sbrk.S index b554245d037..4fb145f4510 100644 --- a/lib/libc/arch/powerpc/sys/sbrk.S +++ b/lib/libc/arch/powerpc/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.17 2022/12/08 01:25:43 guenther Exp $ */ +/* $OpenBSD: sbrk.S,v 1.18 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -57,7 +57,8 @@ ENTRY_NB(sbrk) mr 7, 3 li 0, SYS_break - sc +99: sc + PINSYSCALL(SYS_break, 99b) /* check for error */ cmpwi 0, 0 diff --git a/lib/libc/arch/powerpc/sys/sigpending.S b/lib/libc/arch/powerpc/sys/sigpending.S index fa41751497e..e61b8c7ecb8 100644 --- a/lib/libc/arch/powerpc/sys/sigpending.S +++ b/lib/libc/arch/powerpc/sys/sigpending.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigpending.S,v 1.8 2020/11/28 19:49:30 gkoehler Exp $ */ +/* $OpenBSD: sigpending.S,v 1.9 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 2012 Mark Kettenis * @@ -24,7 +24,8 @@ SYSENTRY(sigpending) RETGUARD_SETUP(sigpending, %r11, %r12) mr %r5, %r3 li %r0, SYS_sigpending - sc +99: sc + PINSYSCALL(SYS_sigpending, 99b) stw %r3, 0(%r5) li %r3, 0 RETGUARD_CHECK(sigpending, %r11, %r12) diff --git a/lib/libc/arch/powerpc/sys/sigprocmask.S b/lib/libc/arch/powerpc/sys/sigprocmask.S index bb21c0ca741..980e98af628 100644 --- a/lib/libc/arch/powerpc/sys/sigprocmask.S +++ b/lib/libc/arch/powerpc/sys/sigprocmask.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigprocmask.S,v 1.14 2020/11/28 19:49:30 gkoehler Exp $ */ +/* $OpenBSD: sigprocmask.S,v 1.15 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -46,8 +46,9 @@ SYSENTRY_HIDDEN(sigprocmask) .L_do_call: li 0, SYS_sigprocmask - sc - +99: sc + PINSYSCALL(SYS_sigprocmask, 99b) + /* didnt work? */ cmpwi 0, 0 beq+ .L_sigprocmask_ok diff --git a/lib/libc/arch/powerpc/sys/sigsuspend.S b/lib/libc/arch/powerpc/sys/sigsuspend.S index 1c0f2372fff..0f2cdfd3684 100644 --- a/lib/libc/arch/powerpc/sys/sigsuspend.S +++ b/lib/libc/arch/powerpc/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.7 2020/11/28 19:49:30 gkoehler Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.8 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -35,7 +35,8 @@ SYSENTRY_HIDDEN(sigsuspend) li %r0, SYS_sigsuspend lwz %r3, 0(%r3) /* load the mask */ - sc +99: sc + PINSYSCALL(SYS_sigsuspend, 99b) cmpwi %r0, 0 beq+ .L_ret diff --git a/lib/libc/arch/powerpc/sys/tfork_thread.S b/lib/libc/arch/powerpc/sys/tfork_thread.S index a90bd4ec390..b04bf5beb14 100644 --- a/lib/libc/arch/powerpc/sys/tfork_thread.S +++ b/lib/libc/arch/powerpc/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.10 2020/11/28 19:49:30 gkoehler Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.11 2023/12/10 16:45:51 deraadt Exp $ */ /* * Copyright (c) 2005 Tim Wiess <tim@nop.cx> @@ -22,7 +22,8 @@ ENTRY(__tfork_thread) RETGUARD_SETUP(__tfork_thread, %r11, %r12) /* call __tfork */ li %r0, SYS___tfork - sc +99: sc + PINSYSCALL(SYS___tfork, 99b) cmpwi %r0, 0 bne 1f @@ -38,7 +39,8 @@ ENTRY(__tfork_thread) /* child returned, call __threxit */ li %r0, SYS___threxit - sc +98: sc + PINSYSCALL(SYS___threxit, 98b) .long 0 /* illegal */ 1: diff --git a/lib/libc/arch/powerpc64/DEFS.h b/lib/libc/arch/powerpc64/DEFS.h index f6f20da0936..3b8c9332061 100644 --- a/lib/libc/arch/powerpc64/DEFS.h +++ b/lib/libc/arch/powerpc64/DEFS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: DEFS.h,v 1.1 2020/06/25 01:59:27 drahn Exp $ */ +/* $OpenBSD: DEFS.h,v 1.2 2023/12/10 16:45:52 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -67,3 +67,9 @@ #else #define END_BUILTIN(x) END_STRONG(x) #endif + +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; diff --git a/lib/libc/arch/powerpc64/SYS.h b/lib/libc/arch/powerpc64/SYS.h index 9964c48093d..ea96ed19e92 100644 --- a/lib/libc/arch/powerpc64/SYS.h +++ b/lib/libc/arch/powerpc64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.5 2022/12/07 23:25:59 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.6 2023/12/10 16:45:52 deraadt Exp $ */ /*- * Copyright (c) 1994 * Andrew Cagney. All rights reserved. @@ -69,7 +69,8 @@ ENTRY(_thread_sys_ ## x) \ RETGUARD_SETUP(_thread_sys_ ## x, %r11); \ li %r0, SYS_ ## y ; \ - sc ; \ + 97: sc ; \ + PINSYSCALL(SYS_ ## y, 97b); \ RETGUARD_CHECK(_thread_sys_ ## x, %r11); \ blr; \ __END(_thread_sys_,x) @@ -77,7 +78,8 @@ #define PSEUDO_HIDDEN(x,y) ENTRY(_thread_sys_ ## x) \ RETGUARD_SETUP(_thread_sys_ ## x, %r11); \ li %r0, SYS_ ## y ; \ - sc ; \ + 97: sc ; \ + PINSYSCALL(SYS_ ## y, 97b); \ cmpwi %r0, 0 ; \ beq .L_ret ; \ stw %r0, R13_OFFSET_ERRNO(%r13); \ diff --git a/lib/libc/arch/powerpc64/gen/setjmp.S b/lib/libc/arch/powerpc64/gen/setjmp.S index 0d099f506d3..ea425199474 100644 --- a/lib/libc/arch/powerpc64/gen/setjmp.S +++ b/lib/libc/arch/powerpc64/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.4 2020/10/18 17:51:39 mortimer Exp $ */ +/* $OpenBSD: setjmp.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 2020 Dale Rahn. All rights reserved. * @@ -70,7 +70,8 @@ ENTRY(setjmp) li %r3, 1 /* how = SIG_BLOCK */ li %r4, 0 /* oset = empty */ li %r0, SYS_sigprocmask - sc +99: sc + PINSYSCALL(SYS_sigprocmask, 99b) std %r3, JMP_sig(%r5) b 1f nop @@ -130,7 +131,8 @@ ENTRY(longjmp) li %r3, 3 /* how = SIG_SETMASK */ ld %r4, JMP_sig(%r5) /* oset from the jmpbuf */ li %r0, SYS_sigprocmask - sc +98: sc + PINSYSCALL(SYS_sigprocmask, 98b) nop b 1f nop diff --git a/lib/libc/arch/powerpc64/gen/sigsetjmp.S b/lib/libc/arch/powerpc64/gen/sigsetjmp.S index fe5de2ebaa5..7dfcd5ee9bf 100644 --- a/lib/libc/arch/powerpc64/gen/sigsetjmp.S +++ b/lib/libc/arch/powerpc64/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsetjmp.S,v 1.3 2020/10/19 23:24:17 mortimer Exp $ */ +/* $OpenBSD: sigsetjmp.S,v 1.4 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 2020 Dale Rahn. All rights reserved. * @@ -67,7 +67,8 @@ ENTRY(sigsetjmp) li %r3, 1 /* how = SIG_BLOCK */ li %r4, 0 /* oset = empty */ li %r0, SYS_sigprocmask - sc +99: sc + PINSYSCALL(SYS_sigprocmask, 99b) nop std %r3, JMP_sigmask(5) 1: @@ -126,7 +127,8 @@ ENTRY(siglongjmp) li %r3, 3 /* how = SIG_SETMASK */ ld %r4, JMP_sigmask(%r5) /* oset from the jmpbuf */ li %r0, SYS_sigprocmask - sc +98: sc + PINSYSCALL(SYS_sigprocmask, 98b) 1: addis %r9, %r2, __jmpxor@toc@ha addi %r9, %r9, __jmpxor@toc@l diff --git a/lib/libc/arch/powerpc64/sys/brk.S b/lib/libc/arch/powerpc64/sys/brk.S index a101010b340..9aa27fa4131 100644 --- a/lib/libc/arch/powerpc64/sys/brk.S +++ b/lib/libc/arch/powerpc64/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.5 2022/12/07 23:25:59 guenther Exp $ */ +/* $OpenBSD: brk.S,v 1.6 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -50,7 +50,8 @@ SYSENTRY(brk) addi %r6, %r6, __curbrk@toc@l /* # %r6 = &__curbrk */ li %r0, SYS_break - sc +99: sc + PINSYSCALL(SYS_break, 99b) /* check for error */ cmpwi %r0, 0 diff --git a/lib/libc/arch/powerpc64/sys/sbrk.S b/lib/libc/arch/powerpc64/sys/sbrk.S index 28f04efa5d8..3f17a280181 100644 --- a/lib/libc/arch/powerpc64/sys/sbrk.S +++ b/lib/libc/arch/powerpc64/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.4 2020/10/16 23:42:16 deraadt Exp $ */ +/* $OpenBSD: sbrk.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -51,7 +51,8 @@ SYSENTRY(sbrk) mr %r7, %r3 li %r0, SYS_break - sc +99: sc + PINSYSCALL(SYS_break, 99b) /* check for error */ cmpwi %r0, 0 diff --git a/lib/libc/arch/powerpc64/sys/sigpending.S b/lib/libc/arch/powerpc64/sys/sigpending.S index 0af6670dd32..488596e86eb 100644 --- a/lib/libc/arch/powerpc64/sys/sigpending.S +++ b/lib/libc/arch/powerpc64/sys/sigpending.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigpending.S,v 1.2 2020/10/16 23:42:16 deraadt Exp $ */ +/* $OpenBSD: sigpending.S,v 1.3 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 2012 Mark Kettenis * @@ -25,7 +25,8 @@ SYSENTRY(sigpending) li %r0, SYS_sigpending mr %r5, %r3 - sc +99: sc + PINSYSCALL(SYS_sigpending, 99b) stw %r3, 0(%r5) li %r3, 0 RETGUARD_CHECK(sigpending, %r11) diff --git a/lib/libc/arch/powerpc64/sys/sigprocmask.S b/lib/libc/arch/powerpc64/sys/sigprocmask.S index 29342cac89e..a58331048bb 100644 --- a/lib/libc/arch/powerpc64/sys/sigprocmask.S +++ b/lib/libc/arch/powerpc64/sys/sigprocmask.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigprocmask.S,v 1.4 2020/10/16 23:42:16 deraadt Exp $ */ +/* $OpenBSD: sigprocmask.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn @@ -47,7 +47,8 @@ SYSENTRY_HIDDEN(sigprocmask) lwz %r4, 0(%r4) /* get new mask */ .L_do_call: - sc +99: sc + PINSYSCALL(SYS_sigprocmask, 99b) /* didnt work? */ cmpwi %r0, 0 diff --git a/lib/libc/arch/powerpc64/sys/sigsuspend.S b/lib/libc/arch/powerpc64/sys/sigsuspend.S index 74b5f0f5153..e6f4c5eaa14 100644 --- a/lib/libc/arch/powerpc64/sys/sigsuspend.S +++ b/lib/libc/arch/powerpc64/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.3 2020/10/16 23:42:16 deraadt Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.4 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 1996 Dale Rahn <drahn@openbsd.org> @@ -35,7 +35,8 @@ SYSENTRY(sigsuspend) li %r0, SYS_sigsuspend lwz %r3, 0(%r3) /* load the mask */ - sc +99: sc + PINSYSCALL(SYS_sigsuspend, 99b) cmpwi %r0, 0 beq .L_ret diff --git a/lib/libc/arch/powerpc64/sys/tfork_thread.S b/lib/libc/arch/powerpc64/sys/tfork_thread.S index 5a466af7431..b2403d7c218 100644 --- a/lib/libc/arch/powerpc64/sys/tfork_thread.S +++ b/lib/libc/arch/powerpc64/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.4 2020/10/19 14:15:29 deraadt Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 2005 Tim Wiess <tim@nop.cx> @@ -22,7 +22,8 @@ ENTRY(__tfork_thread) RETGUARD_SETUP(__tfork_thread, %r11) li %r0, SYS___tfork - sc +99: sc + PINSYSCALL(SYS___tfork, 99b) cmpwi %r0, 0 bne 1f @@ -39,7 +40,8 @@ ENTRY(__tfork_thread) /* child returned, call __threxit */ li %r0, SYS___threxit - sc +98: sc + PINSYSCALL(SYS___threxit, 98b) .long 0 /* illegal */ 1: stw %r0, R13_OFFSET_ERRNO(%r13) diff --git a/lib/libc/arch/riscv64/DEFS.h b/lib/libc/arch/riscv64/DEFS.h index 90e5eec2a4d..a2c61dda980 100644 --- a/lib/libc/arch/riscv64/DEFS.h +++ b/lib/libc/arch/riscv64/DEFS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: DEFS.h,v 1.1 2021/04/29 18:39:53 drahn Exp $ */ +/* $OpenBSD: DEFS.h,v 1.2 2023/12/10 16:45:52 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -58,3 +58,8 @@ #define END_STRONG(x) END(x); _HIDDEN_FALIAS(x,x); END(_HIDDEN(x)) #define END_WEAK(x) END_STRONG(x); .weak x +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; diff --git a/lib/libc/arch/riscv64/SYS.h b/lib/libc/arch/riscv64/SYS.h index ad2fdf3f59d..9857cfbc9c8 100644 --- a/lib/libc/arch/riscv64/SYS.h +++ b/lib/libc/arch/riscv64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.4 2022/12/02 12:27:08 jca Exp $ */ +/* $OpenBSD: SYS.h,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /*- * Copyright (c) 2020 Brian Bamsch <bbamsch@google.com> * Copyright (c) 1990 The Regents of the University of California. @@ -56,9 +56,10 @@ #define __END(x) \ __END_HIDDEN(x); END(x) -#define SYSTRAP(x) \ - li t0, SYS_ ## x; \ - ecall +#define SYSTRAP(x) \ + li t0, SYS_ ## x; \ +97: ecall; \ + PINSYSCALL(SYS_ ## x, 97b) #define HANDLE_ERROR() \ beqz t0, 200f; \ diff --git a/lib/libc/arch/riscv64/sys/brk.S b/lib/libc/arch/riscv64/sys/brk.S index 287f28a7ff1..6a777d143e9 100644 --- a/lib/libc/arch/riscv64/sys/brk.S +++ b/lib/libc/arch/riscv64/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.4 2022/12/03 15:02:30 jca Exp $ */ +/* $OpenBSD: brk.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 2021 Dale Rahn <drahn@openbsd.org> * @@ -38,7 +38,8 @@ ENTRY_NB(brk) lla t1, __curbrk li t0, SYS_break - ecall +99: ecall + PINSYSCALL(SYS_break, 99b) /* check for error */ beqz t0, .L_brk_ok diff --git a/lib/libc/arch/sh/SYS.h b/lib/libc/arch/sh/SYS.h index 6c14b919449..cd5dbeaaf51 100644 --- a/lib/libc/arch/sh/SYS.h +++ b/lib/libc/arch/sh/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.13 2023/02/11 06:10:39 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.14 2023/12/10 16:45:52 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -85,6 +85,12 @@ #define __END(x) \ __END_HIDDEN(x); SET_ENTRY_SIZE(x) +#define PINSYSCALL(sysno, label) \ + .pushsection .openbsd.syscalls,"",@progbits; \ + .long label; \ + .long sysno; \ + .popsection; + #ifdef __ASSEMBLER__ /* * If the system call number fits in a 8-bit signed value (i.e. fits in 7 bits), @@ -94,10 +100,12 @@ .macro systrap num .iflt \num - 128 mov # \num, r0 - trapa #0x80 +97: trapa #0x80 + PINSYSCALL(\num, 97b) .else mov.l 903f, r0 - trapa #0x80 +97: trapa #0x80 + PINSYSCALL(\num, 97b) bra 904f nop .align 2 diff --git a/lib/libc/arch/sh/sys/brk.S b/lib/libc/arch/sh/sys/brk.S index 0ecee462ce5..5a98da3597d 100644 --- a/lib/libc/arch/sh/sys/brk.S +++ b/lib/libc/arch/sh/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.8 2022/12/08 02:11:27 guenther Exp $ */ +/* $OpenBSD: brk.S,v 1.9 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: brk.S,v 1.10 2006/01/06 03:58:31 uwe Exp $ */ /*- @@ -69,7 +69,8 @@ ENTRY(brk) #else mov #SYS_break, r0 #endif - trapa #0x80 +99: trapa #0x80 + PINSYSCALL(SYS_break, 99b) bf 2f #ifdef __PIC__ mov.l Lcurbrk, r0 diff --git a/lib/libc/arch/sh/sys/sbrk.S b/lib/libc/arch/sh/sys/sbrk.S index 0f11b4c3d8f..b86d0eb7573 100644 --- a/lib/libc/arch/sh/sys/sbrk.S +++ b/lib/libc/arch/sh/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.8 2022/12/08 02:11:27 guenther Exp $ */ +/* $OpenBSD: sbrk.S,v 1.9 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: sbrk.S,v 1.9 2006/01/06 03:58:31 uwe Exp $ */ /*- @@ -69,7 +69,8 @@ ENTRY(sbrk) #else mov #SYS_break, r0 #endif - trapa #0x80 +99: trapa #0x80 + PINSYSCALL(SYS_break, 99b) bf 1f #ifdef __PIC__ mov.l Lcurbrk, r0 diff --git a/lib/libc/arch/sh/sys/sigprocmask.S b/lib/libc/arch/sh/sys/sigprocmask.S index 74bacc8ae85..28841e6003d 100644 --- a/lib/libc/arch/sh/sys/sigprocmask.S +++ b/lib/libc/arch/sh/sys/sigprocmask.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigprocmask.S,v 1.6 2022/09/02 06:19:04 miod Exp $ */ +/* $OpenBSD: sigprocmask.S,v 1.7 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: sigprocmask.S,v 1.6 2003/08/07 16:42:21 agc Exp $ */ /*- @@ -52,7 +52,8 @@ SYSENTRY_HIDDEN(sigprocmask) #else mov #SYS_sigprocmask, r0 #endif - trapa #0x80 +99: trapa #0x80 + PINSYSCALL(SYS_sigprocmask, 99b) bf 4f mov r6, r2 /* fetch old mask requested */ tst r2, r2 /* test if old mask requested */ diff --git a/lib/libc/arch/sh/sys/sigsuspend.S b/lib/libc/arch/sh/sys/sigsuspend.S index 4e2dffbb7b0..b2e2b25fca1 100644 --- a/lib/libc/arch/sh/sys/sigsuspend.S +++ b/lib/libc/arch/sh/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.5 2022/09/02 06:19:04 miod Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.6 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: sigsuspend.S,v 1.5 2003/08/07 16:42:21 agc Exp $ */ /*- @@ -46,7 +46,8 @@ SYSENTRY_HIDDEN(sigsuspend) #else mov #SYS_sigsuspend, r0 #endif - trapa #0x80 +99: trapa #0x80 + PINSYSCALL(SYS_sigsuspend, 99b) SET_ERRNO_AND_RETURN .align 2 diff --git a/lib/libc/arch/sh/sys/tfork_thread.S b/lib/libc/arch/sh/sys/tfork_thread.S index 6a322fe2b3b..b17f2cffc8a 100644 --- a/lib/libc/arch/sh/sys/tfork_thread.S +++ b/lib/libc/arch/sh/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.4 2022/09/02 06:19:04 miod Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 2007 Miodrag Vallat. @@ -29,7 +29,8 @@ ENTRY(__tfork_thread) #else mov #SYS___tfork, r0 #endif - trapa #0x80 +99: trapa #0x80 + PINSYSCALL(SYS___tfork, 99b) bf 9f tst r0, r0 @@ -53,7 +54,8 @@ ENTRY(__tfork_thread) #else mov #SYS___threxit, r0 #endif - trapa #0x80 +98: trapa #0x80 + PINSYSCALL(SYS___threxit, 98b) 9: /* diff --git a/lib/libc/arch/sparc64/SYS.h b/lib/libc/arch/sparc64/SYS.h index b0fd99d1ed8..b8b10c80942 100644 --- a/lib/libc/arch/sparc64/SYS.h +++ b/lib/libc/arch/sparc64/SYS.h @@ -1,4 +1,4 @@ -/* $OpenBSD: SYS.h,v 1.17 2022/01/01 23:47:14 guenther Exp $ */ +/* $OpenBSD: SYS.h,v 1.18 2023/12/10 16:45:52 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -49,8 +49,8 @@ #define __ENTRY(p,x) ENTRY(_CAT(p,x)) ; .weak x; x = _CAT(p,x) #define __ENTRY_HIDDEN(p,x) ENTRY(_CAT(p,x)) -#define __END_HIDDEN(p,x) END(_CAT(p,x)); \ - _HIDDEN_FALIAS(x, _CAT(p,x)); \ +#define __END_HIDDEN(p,x) END(_CAT(p,x)); \ + _HIDDEN_FALIAS(x, _CAT(p,x)); \ END(_HIDDEN(x)) #define __END(p,x) __END_HIDDEN(p,x); END(x) @@ -67,15 +67,30 @@ * Note that it adds a `nop' over what we could do, if we only knew what * came at label 1.... */ -#define _SYSCALL(p,x,y) \ - __ENTRY(p,x); mov _CAT(SYS_,y),%g1; t ST_SYSCALL; bcc 1f; nop; ERROR(); 1: -#define _SYSCALL_HIDDEN(p,x,y) \ - __ENTRY_HIDDEN(p,x); mov _CAT(SYS_,y),%g1; t ST_SYSCALL; bcc 1f; nop; ERROR(); 1: +#define _SYSCALL(p,x,y) \ + __ENTRY(p,x); \ + mov _CAT(SYS_,y),%g1; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,y), 97b); \ + bcc 1f; \ + nop; \ + ERROR(); \ +1: -#define __SYSCALL(p,x) \ +#define _SYSCALL_HIDDEN(p,x,y) \ + __ENTRY_HIDDEN(p,x); \ + mov _CAT(SYS_,y),%g1; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,y), 97b); \ + bcc 1f; \ + nop; \ + ERROR(); \ +1: + +#define __SYSCALL(p,x) \ _SYSCALL(p,x,x) -#define __SYSCALL_HIDDEN(p,x) \ +#define __SYSCALL_HIDDEN(p,x) \ _SYSCALL_HIDDEN(p,x,x) /* @@ -83,19 +98,34 @@ * we use the SYSCALL_G2RFLAG to put the `success' return address in %g2 * and avoid a branch. */ -#define __RSYSCALL(p,x) \ - __ENTRY(p,x); mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; \ - add %o7,8,%g2; t ST_SYSCALL; ERROR(); __END(p,x) -#define __RSYSCALL_HIDDEN(p,x) \ - __ENTRY_HIDDEN(p,x); mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; \ - add %o7,8,%g2; t ST_SYSCALL; ERROR(); __END_HIDDEN(p,x) +#define __RSYSCALL(p,x) \ + __ENTRY(p,x); \ + mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; \ + add %o7,8,%g2; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,x), 97b); \ + ERROR(); \ + __END(p,x) +#define __RSYSCALL_HIDDEN(p,x) \ + __ENTRY_HIDDEN(p,x); \ + mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; \ + add %o7,8,%g2; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,x), 97b); \ + ERROR(); \ + __END_HIDDEN(p,x) /* * PSEUDO(x,y) is like RSYSCALL(y) except that the name is x. */ -#define __PSEUDO(p,x,y) \ - __ENTRY(p,x); mov (_CAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \ - t ST_SYSCALL; ERROR(); __END(p,x) +#define __PSEUDO(p,x,y) \ + __ENTRY(p,x); \ + mov (_CAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; \ + add %o7,8,%g2; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,y), 97b); \ + ERROR(); \ + __END(p,x) /* * SYSCALL_NOERROR is like SYSCALL, except it's used for syscalls @@ -103,8 +133,11 @@ * * XXX - This should be optimized. */ -#define __SYSCALL_NOERROR(p,x) \ - __ENTRY(p,x); mov _CAT(SYS_,x),%g1; t ST_SYSCALL +#define __SYSCALL_NOERROR(p,x) \ + __ENTRY(p,x); \ + mov _CAT(SYS_,x),%g1; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,x), 97b) /* * RSYSCALL_NOERROR is like RSYSCALL, except it's used for syscalls @@ -112,16 +145,24 @@ * * XXX - This should be optimized. */ -#define __RSYSCALL_NOERROR(p,x) \ - __ENTRY(p,x); mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \ - t ST_SYSCALL; __END(p,x) +#define __RSYSCALL_NOERROR(p,x) \ + __ENTRY(p,x); \ + mov (_CAT(SYS_,x))|SYSCALL_G2RFLAG,%g1; \ + add %o7,8,%g2; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,x), 97b); \ + __END(p,x) /* * PSEUDO_NOERROR(x,y) is like RSYSCALL_NOERROR(y) except that the name is x. */ -#define __PSEUDO_NOERROR(p,x,y) \ - __ENTRY(p,x); mov (_CAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \ - t ST_SYSCALL; __END(p,x) +#define __PSEUDO_NOERROR(p,x,y) \ + __ENTRY(p,x); \ + mov (_CAT(SYS_,y))|SYSCALL_G2RFLAG,%g1; \ + add %o7,8,%g2; \ +97: t ST_SYSCALL; \ + PINSYSCALL(_CAT(SYS_,y), 97b); \ + __END(p,x) /* * SYSENTRY is for functions that pretend to be syscalls. diff --git a/lib/libc/arch/sparc64/gen/setjmp.S b/lib/libc/arch/sparc64/gen/setjmp.S index 66e4c665dcf..07f05903c37 100644 --- a/lib/libc/arch/sparc64/gen/setjmp.S +++ b/lib/libc/arch/sparc64/gen/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.6 2016/04/28 12:53:47 kettenis Exp $ */ +/* $OpenBSD: setjmp.S,v 1.7 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: setjmp.S,v 1.4 2000/08/28 00:45:59 eeh Exp $ */ /* @@ -53,7 +53,8 @@ ENTRY(setjmp) mov 1, %o0 /* SIG_BLOCK */ mov SYS_sigprocmask, %g1 clr %o1 /* sigprocmask(SIG_BLOCK, 0) */ - t ST_SYSCALL +99: t ST_SYSCALL + PINSYSCALL(SYS_sigprocmask, 99b) stx %o0, [%o3 + 0x10] stx %sp, [%o3 + 0x00] /* store caller's stack pointer */ @@ -68,7 +69,8 @@ ENTRY(longjmp) mov 3, %o0 /* SIG_SETMASK */ ldx [%i0 + 0x10], %o1 mov SYS_sigprocmask, %g1 - t ST_SYSCALL +98: t ST_SYSCALL + PINSYSCALL(SYS_sigprocmask, 98b) ldx [%i0 + 0x00], %fp ldx [%i0 + 0x08], %i7 diff --git a/lib/libc/arch/sparc64/gen/sigsetjmp.S b/lib/libc/arch/sparc64/gen/sigsetjmp.S index feb27097975..b7d68fe7f61 100644 --- a/lib/libc/arch/sparc64/gen/sigsetjmp.S +++ b/lib/libc/arch/sparc64/gen/sigsetjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsetjmp.S,v 1.4 2016/05/08 18:29:34 guenther Exp $ */ +/* $OpenBSD: sigsetjmp.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: sigsetjmp.S,v 1.5 2000/08/28 00:45:59 eeh Exp $ */ /* * Copyright (c) 1992, 1993 @@ -43,7 +43,8 @@ ENTRY(sigsetjmp) mov 1, %o0 /* SIG_BLOCK */ mov SYS_sigprocmask, %g1 clr %o1 /* sigprocmask(SIG_BLOCK, 0) */ - t ST_SYSCALL +99: t ST_SYSCALL + PINSYSCALL(SYS_sigprocmask, 99b) stx %o0, [%o3 + 0x10] 1: stx %sp, [%o3 + 0x00] /* store caller's stack pointer */ @@ -62,7 +63,8 @@ ENTRY(siglongjmp) mov 3, %o0 /* SIG_SETMASK */ ldx [%i0 + 0x10], %o1 mov SYS_sigprocmask, %g1 - t ST_SYSCALL +98: t ST_SYSCALL + PINSYSCALL(SYS_sigprocmask, 98b) 1: ldx [%i0 + 0x00], %fp ldx [%i0 + 0x08], %i7 diff --git a/lib/libc/arch/sparc64/sys/brk.S b/lib/libc/arch/sparc64/sys/brk.S index a8636e2e326..bfe6f9f8cce 100644 --- a/lib/libc/arch/sparc64/sys/brk.S +++ b/lib/libc/arch/sparc64/sys/brk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: brk.S,v 1.11 2023/01/13 17:52:08 miod Exp $ */ +/* $OpenBSD: brk.S,v 1.12 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: brk.S,v 1.9 2000/07/25 20:15:40 mycroft Exp $ */ /* @@ -59,7 +59,8 @@ ENTRY_NB(brk) movgu %xcc, %o1, %o0 /* %o0 = minbrk */ mov %o0, %o2 /* save argument to syscall */ mov SYS_break, %g1 - t ST_SYSCALL +99: t ST_SYSCALL + PINSYSCALL(SYS_break, 99b) set __curbrk, %o3 bcc,a,pt %icc, 1f ldx [%o5 + %o3], %o4 @@ -74,7 +75,8 @@ ENTRY_NB(brk) movgu %xcc, %o1, %o0 /* %o0 = minbrk */ mov %o0, %o2 /* save argument to syscall */ mov SYS_break, %g1 - t ST_SYSCALL +98: t ST_SYSCALL + PINSYSCALL(SYS_break, 98b) bcc,a,pt %icc,1f sethi %hi(__curbrk), %g1 ERROR() diff --git a/lib/libc/arch/sparc64/sys/sbrk.S b/lib/libc/arch/sparc64/sys/sbrk.S index 09d2a4f093f..0bf04e928b8 100644 --- a/lib/libc/arch/sparc64/sys/sbrk.S +++ b/lib/libc/arch/sparc64/sys/sbrk.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sbrk.S,v 1.9 2023/01/13 17:52:08 miod Exp $ */ +/* $OpenBSD: sbrk.S,v 1.10 2023/12/10 16:45:52 deraadt Exp $ */ /* $NetBSD: sbrk.S,v 1.7 2000/07/25 15:14:46 mycroft Exp $ */ /* @@ -59,7 +59,8 @@ ENTRY_NB(sbrk) add %o3, %o0, %o4 /* %o4 = new break */ mov %o4, %o0 /* copy for syscall */ mov SYS_break, %g1 - t ST_SYSCALL /* break(new_break) */ +99: t ST_SYSCALL /* break(new_break) */ + PINSYSCALL(SYS_break, 99b) bcc,a 1f /* if success, */ mov %o3, %o0 /* set return value */ ERROR() @@ -72,7 +73,8 @@ ENTRY_NB(sbrk) add %o3, %o0, %o4 /* %o4 = new break */ mov %o4, %o0 /* copy for syscall */ mov SYS_break, %g1 - t ST_SYSCALL /* break(new_break) */ +98: t ST_SYSCALL /* break(new_break) */ + PINSYSCALL(SYS_break, 98b) bcc,a 1f /* if success, */ mov %o3, %o0 /* set return value */ ERROR() diff --git a/lib/libc/arch/sparc64/sys/sigpending.S b/lib/libc/arch/sparc64/sys/sigpending.S index 0099c267991..cf52219b63b 100644 --- a/lib/libc/arch/sparc64/sys/sigpending.S +++ b/lib/libc/arch/sparc64/sys/sigpending.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigpending.S,v 1.3 2015/09/05 06:22:47 guenther Exp $ */ +/* $OpenBSD: sigpending.S,v 1.4 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -38,7 +38,8 @@ SYSENTRY(sigpending) mov %o0, %o2 /* save pointer */ mov SYS_sigpending, %g1 - t ST_SYSCALL /* sigpending() */ +99: t ST_SYSCALL /* sigpending() */ + PINSYSCALL(SYS_sigpending, 99b) bcc,a 1f /* if success, */ st %o0, [%o2] /* store return value */ ERROR() diff --git a/lib/libc/arch/sparc64/sys/sigprocmask.S b/lib/libc/arch/sparc64/sys/sigprocmask.S index 3d3fa865c0f..c8266131cc7 100644 --- a/lib/libc/arch/sparc64/sys/sigprocmask.S +++ b/lib/libc/arch/sparc64/sys/sigprocmask.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigprocmask.S,v 1.4 2015/10/23 04:39:25 guenther Exp $ */ +/* $OpenBSD: sigprocmask.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -46,7 +46,8 @@ SYSENTRY_HIDDEN(sigprocmask) mov 1, %o0 /* ... using sigprocmask(SIG_BLOCK) */ 1: mov SYS_sigprocmask, %g1 - t ST_SYSCALL +99: t ST_SYSCALL + PINSYSCALL(SYS_sigprocmask, 99b) bcc 2f /* if success, */ tst %o2 /* check to see if oset requested */ ERROR() diff --git a/lib/libc/arch/sparc64/sys/sigsuspend.S b/lib/libc/arch/sparc64/sys/sigsuspend.S index 0bede84ef73..0ea01074122 100644 --- a/lib/libc/arch/sparc64/sys/sigsuspend.S +++ b/lib/libc/arch/sparc64/sys/sigsuspend.S @@ -1,4 +1,4 @@ -/* $OpenBSD: sigsuspend.S,v 1.4 2016/05/07 19:05:22 guenther Exp $ */ +/* $OpenBSD: sigsuspend.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -39,6 +39,7 @@ SYSENTRY_HIDDEN(sigsuspend) ld [%o0], %o0 /* indirect to mask argument */ mov SYS_sigsuspend, %g1 - t ST_SYSCALL +99: t ST_SYSCALL + PINSYSCALL(SYS_sigsuspend, 99b) ERROR() /* always terminates with EINTR */ SYSCALL_END_HIDDEN(sigsuspend) diff --git a/lib/libc/arch/sparc64/sys/tfork_thread.S b/lib/libc/arch/sparc64/sys/tfork_thread.S index c879c3e7146..4304498b66f 100644 --- a/lib/libc/arch/sparc64/sys/tfork_thread.S +++ b/lib/libc/arch/sparc64/sys/tfork_thread.S @@ -1,4 +1,4 @@ -/* $OpenBSD: tfork_thread.S,v 1.4 2020/10/18 14:28:18 deraadt Exp $ */ +/* $OpenBSD: tfork_thread.S,v 1.5 2023/12/10 16:45:52 deraadt Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat @@ -36,7 +36,8 @@ ENTRY(__tfork_thread) * different return paths. */ mov SYS___tfork, %g1 - t ST_SYSCALL +99: t ST_SYSCALL + PINSYSCALL(SYS___tfork, 99b) bcs 9f nop @@ -59,7 +60,8 @@ ENTRY(__tfork_thread) mov SYS___threxit, %g1 clr %o0 - t ST_SYSCALL /* will not return */ +98: t ST_SYSCALL /* will not return */ + PINSYSCALL(SYS___threxit, 98b) unimp 9: |