-/* $OpenBSD: unistd.h,v 1.107 2023/01/07 05:24:58 guenther Exp $ */
+/* $OpenBSD: unistd.h,v 1.108 2023/12/12 15:30:55 deraadt Exp $ */
/* $NetBSD: unistd.h,v 1.26.4.1 1996/05/28 02:31:51 mrg Exp $ */
/*-
void setusershell(void);
int strtofflags(char **, u_int32_t *, u_int32_t *);
int swapctl(int cmd, const void *arg, int misc);
-int syscall(int, ...);
int getentropy(void *, size_t);
int pledge(const char *, const char *);
int unveil(const char *, const char *);
symlinkat
sync
sysarch
-syscall
timer_create
timer_delete
timer_getoverrun
-/* $OpenBSD: unistd.h,v 1.12 2023/05/18 16:11:09 guenther Exp $ */
+/* $OpenBSD: unistd.h,v 1.13 2023/12/12 15:30:55 deraadt Exp $ */
/*
* Copyright (c) 2015 Philip Guenther <guenther@openbsd.org>
*
PROTO_NORMAL(symlink);
PROTO_NORMAL(symlinkat);
PROTO_NORMAL(sync);
-PROTO_NORMAL(syscall);
PROTO_NORMAL(sysconf);
PROTO_DEPRECATED(tcgetpgrp);
PROTO_DEPRECATED(tcsetpgrp);
-# $OpenBSD: Makefile.inc,v 1.175 2023/12/11 00:34:24 deraadt Exp $
+# $OpenBSD: Makefile.inc,v 1.176 2023/12/12 15:30:55 deraadt Exp $
# $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $
# @(#)Makefile.inc 8.1 (Berkeley) 6/17/93
# modules with non-default implementations on at least one architecture:
SRCS+= Ovfork.S brk.S ${CERROR} \
sbrk.S sigpending.S sigprocmask.S \
- sigsuspend.S syscall.S tfork_thread.S
+ sigsuspend.S tfork_thread.S
# glue to offer userland wrappers for some syscalls
SRCS+= posix_madvise.c pthread_sigmask.c \
shmctl.2 shmget.2 shutdown.2 sigaction.2 sigaltstack.2 sigpending.2 \
sigprocmask.2 sigreturn.2 sigsuspend.2 socket.2 \
socketpair.2 stat.2 statfs.2 swapctl.2 symlink.2 \
- sync.2 sysarch.2 syscall.2 sysctl.2 thrkill.2 truncate.2 \
+ sync.2 sysarch.2 sysctl.2 thrkill.2 truncate.2 \
umask.2 unlink.2 unveil.2 utimes.2 utrace.2 vfork.2 \
wait.2 waitid.2 write.2 \
ypconnect.2
-.\" $OpenBSD: syscall.2,v 1.16 2023/02/22 07:04:50 jmc Exp $
-.\" $NetBSD: syscall.2,v 1.4 1995/02/27 12:38:53 cgd Exp $
-.\"
-.\" Copyright (c) 1980, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)syscall.2 8.1 (Berkeley) 6/16/93
-.\"
-.Dd $Mdocdate: February 22 2023 $
-.Dt SYSCALL 2
-.Os
-.Sh NAME
-.Nm syscall
-.Nd indirect system call
-.Sh SYNOPSIS
-.In sys/syscall.h
-.In unistd.h
-.Ft int
-.Fn syscall "int number" "..."
-.Sh DESCRIPTION
-.Fn syscall
-performs the system call whose assembly language
-interface has the specified
-.Fa number
-with the specified arguments.
-Symbolic constants for system calls can be found in the header file
-.In sys/syscall.h .
-.Sh RETURN VALUES
-The return values are defined by the system call being invoked.
-In general, for system calls returning
-.Va int ,
-a 0 return value indicates success.
-A \-1 return value indicates an error,
-and an error code is stored in
-.Va errno .
-.Sh HISTORY
-The predecessor of these functions, the former
-.Fn indir
-system call, first appeared in
-.At v4 .
-The
-.Fn syscall
-function first appeared in
-.Bx 3 .
-/* $OpenBSD: trap.c,v 1.108 2023/03/08 04:43:07 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.109 2023/12/12 15:30:55 deraadt Exp $ */
/* $NetBSD: trap.c,v 1.52 2000/05/24 16:48:33 thorpej Exp $ */
/*-
* a3, and v0 from the frame before returning to the user process.
*/
void
-syscall(code, framep)
- u_int64_t code;
- struct trapframe *framep;
+syscall(u_int64_t code, struct trapframe *framep)
{
- const struct sysent *callp;
+ const struct sysent *callp = sysent;
struct proc *p;
- int error, indirect = -1;
+ int error;
u_int64_t opc;
u_long rval[2];
u_long args[10]; /* XXX */
- u_int hidden, nargs;
+ u_int nargs;
atomic_add_int(&uvmexp.syscalls, 1);
p = curproc;
framep->tf_regs[FRAME_SP] = alpha_pal_rdusp();
opc = framep->tf_regs[FRAME_PC] - 4;
- switch(code) {
- case SYS_syscall:
- indirect = code;
- code = framep->tf_regs[FRAME_A0];
- hidden = 1;
- break;
- default:
- hidden = 0;
- }
-
- error = 0;
- callp = sysent;
- if (code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else
+ // XXX out of range stays on syscall0, which we assume is enosys
+ if (code >= 0 || code <= SYS_MAXSYSCALL)
callp += code;
- nargs = callp->sy_narg + hidden;
+ nargs = callp->sy_narg;
switch (nargs) {
default:
if (nargs > 10) /* XXX */
rval[0] = 0;
rval[1] = 0;
- error = mi_syscall(p, code, indirect, callp, args + hidden, rval);
+ error = mi_syscall(p, code, callp, args, rval);
switch (error) {
case 0:
-/* $OpenBSD: locore.S,v 1.143 2023/12/12 07:37:20 deraadt Exp $ */
+/* $OpenBSD: locore.S,v 1.144 2023/12/12 15:30:55 deraadt Exp $ */
/* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */
/*
lfence
END(savectx)
+// XXX this should not behave like a nop
IDTVEC(syscall32)
sysret /* go away please */
END(Xsyscall32)
-/* $OpenBSD: trap.c,v 1.101 2023/07/05 12:58:55 kn Exp $ */
+/* $OpenBSD: trap.c,v 1.102 2023/12/12 15:30:55 deraadt Exp $ */
/* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */
/*-
caddr_t params;
const struct sysent *callp;
struct proc *p;
- int error, indirect = -1;
+ int error = ENOSYS;
size_t argsize, argoff;
register_t code, args[9], rval[2], *argp;
argp = &args[0];
argoff = 0;
- switch (code) {
- case SYS_syscall:
- /*
- * Code is first argument, followed by actual args.
- */
- indirect = code;
- code = frame->tf_rdi;
- argp = &args[1];
- argoff = 1;
- break;
- default:
- break;
- }
-
- callp = sysent;
- if (code < 0 || code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else
- callp += code;
-
+ if (code <= 0 || code >= SYS_MAXSYSCALL)
+ goto bad;
+ callp = sysent + code;
argsize = (callp->sy_argsize >> 3) + argoff;
if (argsize) {
switch (MIN(argsize, 6)) {
rval[0] = 0;
rval[1] = 0;
- error = mi_syscall(p, code, indirect, callp, argp, rval);
+ error = mi_syscall(p, code, callp, argp, rval);
switch (error) {
case 0:
-/* $OpenBSD: syscall.c,v 1.26 2023/02/11 23:07:26 deraadt Exp $ */
+/* $OpenBSD: syscall.c,v 1.27 2023/12/12 15:30:55 deraadt Exp $ */
/* $NetBSD: syscall.c,v 1.24 2003/11/14 19:03:17 scw Exp $ */
/*-
swi_handler(trapframe_t *frame)
{
struct proc *p = curproc;
- const struct sysent *callp;
- int code, error, indirect = -1;
+ const struct sysent *callp = sysent;
+ int code, error;
u_int nap = 4, nargs;
register_t *ap, *args, copyargs[MAXARGS], rval[2];
/* Before enabling interrupts, save FPU state */
vfp_save();
- /* Re-enable interrupts if they were enabled previously */
- if (__predict_true((frame->tf_spsr & PSR_I) == 0))
- enable_interrupts(PSR_I);
+ enable_interrupts(PSR_I);
p->p_addr->u_pcb.pcb_tf = frame;
/* Skip over speculation-blocking barrier. */
frame->tf_pc += 8;
- code = frame->tf_r12;
-
ap = &frame->tf_r0;
- switch (code) {
- case SYS_syscall:
- indirect = code;
- code = *ap++;
- nap--;
- break;
- }
-
- callp = sysent;
- if (code < 0 || code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else
+ code = frame->tf_r12;
+ // XXX out of range stays on syscall0, which we assume is enosys
+ if (code >= 0 || code <= SYS_MAXSYSCALL)
callp += code;
nargs = callp->sy_argsize / sizeof(register_t);
rval[0] = 0;
rval[1] = frame->tf_r1;
- error = mi_syscall(p, code, indirect, callp, args, rval);
+ error = mi_syscall(p, code, callp, args, rval);
switch (error) {
case 0:
frame->tf_r0 = rval[0];
frame->tf_r1 = rval[1];
-
frame->tf_spsr &= ~PSR_C; /* carry bit */
break;
-
case ERESTART:
/*
* Reconstruct the pc to point at the swi.
*/
frame->tf_pc -= 12;
break;
-
case EJUSTRETURN:
/* nothing to do */
break;
-
default:
bad:
frame->tf_r0 = error;
-/* $OpenBSD: syscall.c,v 1.14 2023/04/13 02:19:04 jsg Exp $ */
+/* $OpenBSD: syscall.c,v 1.15 2023/12/12 15:30:55 deraadt Exp $ */
/*
* Copyright (c) 2015 Dale Rahn <drahn@dalerahn.com>
*
{
struct proc *p = curproc;
const struct sysent *callp;
- int code, error, indirect = -1;
+ int code, error = ENOSYS, indirect = -1;
u_int nap = 8, nargs;
register_t *ap, *args, copyargs[MAXARGS], rval[2];
ap = &frame->tf_x[0];
- switch (code) {
- case SYS_syscall:
- indirect = code;
- code = *ap++;
- nap--;
- break;
- }
-
- callp = sysent;
if (code < 0 || code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else
- callp += code;
+ goto bad;
+ callp = sysent + code;
nargs = callp->sy_argsize / sizeof(register_t);
if (nargs <= nap) {
args = ap;
rval[0] = 0;
rval[1] = 0;
- error = mi_syscall(p, code, indirect, callp, args, rval);
+ error = mi_syscall(p, code, callp, args, rval);
switch (error) {
case 0:
frame->tf_x[0] = rval[0];
frame->tf_spsr &= ~PSR_C; /* carry bit */
break;
-
case ERESTART:
/*
* Reconstruct the pc to point at the svc.
*/
frame->tf_elr -= 12;
break;
-
case EJUSTRETURN:
/* nothing to do */
break;
-
default:
bad:
frame->tf_x[0] = error;
-/* $OpenBSD: trap.c,v 1.161 2023/02/11 23:07:26 deraadt Exp $ */
+/* $OpenBSD: trap.c,v 1.162 2023/12/12 15:30:55 deraadt Exp $ */
/*
* Copyright (c) 1998-2004 Michael Shalayeff
syscall(struct trapframe *frame)
{
struct proc *p = curproc;
- const struct sysent *callp;
- int retq, code, argsize, argoff, error, indirect = -1;
+ const struct sysent *callp = sysent;
+ int retq, code, argsize, argoff, error;
register_t args[8], rval[2];
#ifdef DIAGNOSTIC
int oldcpl = curcpu()->ci_cpl;
p->p_md.md_regs = frame;
argoff = 4; retq = 0;
- switch (code = frame->tf_t1) {
- case SYS_syscall:
- indirect = code;
- code = frame->tf_arg0;
- args[0] = frame->tf_arg1;
- args[1] = frame->tf_arg2;
- args[2] = frame->tf_arg3;
- argoff = 3;
- break;
- default:
- args[0] = frame->tf_arg0;
- args[1] = frame->tf_arg1;
- args[2] = frame->tf_arg2;
- args[3] = frame->tf_arg3;
- break;
- }
+ args[0] = frame->tf_arg0;
+ args[1] = frame->tf_arg1;
+ args[2] = frame->tf_arg2;
+ args[3] = frame->tf_arg3;
- callp = sysent;
- if (code < 0 || code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else
+ // XXX out of range stays on syscall0, which we assume is enosys
+ if (code >= 0 || code <= SYS_MAXSYSCALL)
callp += code;
if ((argsize = callp->sy_argsize)) {
rval[0] = 0;
rval[1] = frame->tf_ret1;
- error = mi_syscall(p, code, indirect, callp, args, rval);
+ error = mi_syscall(p, code, callp, args, rval);
switch (error) {
case 0:
break;
}
- ast(p);
+ ast(p); // XXX why?
mi_syscall_return(p, code, error, rval);
-/* $OpenBSD: trap.c,v 1.162 2023/04/16 06:43:49 jsg Exp $ */
+/* $OpenBSD: trap.c,v 1.163 2023/12/12 15:30:55 deraadt Exp $ */
/* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */
/*-
syscall(struct trapframe *frame)
{
caddr_t params;
- const struct sysent *callp;
- struct proc *p;
- int error, indirect = -1;
+ const struct sysent *callp = sysent;
+ struct proc *p = curproc;
+ int error;
register_t code, args[8], rval[2];
#ifdef DIAGNOSTIC
int ocpl = lapic_tpr;
}
#endif
- p = curproc;
p->p_md.md_regs = frame;
- code = frame->tf_eax;
-
- params = (caddr_t)frame->tf_esp + sizeof(int);
- switch (code) {
- case SYS_syscall:
- /*
- * Code is first argument, followed by actual args.
- */
- indirect = code;
- copyin(params, &code, sizeof(int));
- params += sizeof(int);
- break;
- default:
- break;
- }
-
- callp = sysent;
- if (code < 0 || code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else
+ code = frame->tf_eax;
+ // XXX out of range stays on syscall0, which we assume is enosys
+ if (code >= 0 || code <= SYS_MAXSYSCALL)
callp += code;
+
argsize = callp->sy_argsize;
+ params = (caddr_t)frame->tf_esp + sizeof(int);
if (argsize && (error = copyin(params, args, argsize)))
goto bad;
rval[0] = 0;
rval[1] = frame->tf_edx;
- error = mi_syscall(p, code, indirect, callp, args, rval);
+ error = mi_syscall(p, code, callp, args, rval);
switch (error) {
case 0:
-/* $OpenBSD: trap.c,v 1.128 2023/08/02 06:14:46 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.129 2023/12/12 15:30:56 deraadt Exp $ */
/*
* Copyright (c) 2004, Miodrag Vallat.
* Copyright (c) 1998 Steve Murphree, Jr.
m88100_syscall(register_t code, struct trapframe *tf)
{
int i, nap;
- const struct sysent *callp;
+ const struct sysent *callp = sysent;
struct proc *p = curproc;
- int error, indirect = -1;
+ int error;
register_t args[8] __aligned(8);
register_t rval[2] __aligned(8);
register_t *ap;
ap = &tf->tf_r[2];
nap = 8; /* r2-r9 */
- switch (code) {
- case SYS_syscall:
- indirect = code;
- code = *ap++;
- nap--;
- break;
- }
-
- callp = sysent;
- if (code < 0 || code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else
+ // XXX out of range stays on syscall0, which we assume is enosys
+ if (code >= 0 || code <= SYS_MAXSYSCALL)
callp += code;
i = callp->sy_argsize / sizeof(register_t);
rval[0] = 0;
rval[1] = tf->tf_r[3];
- error = mi_syscall(p, code, indirect, callp, args, rval);
+ error = mi_syscall(p, code, callp, args, rval);
/*
* system call will look like:
m88110_syscall(register_t code, struct trapframe *tf)
{
int i, nap;
- const struct sysent *callp;
+ const struct sysent *callp = sysent;
struct proc *p = curproc;
int error;
register_t args[8] __aligned(8);
ap = &tf->tf_r[2];
nap = 8; /* r2-r9 */
- switch (code) {
- case SYS_syscall:
- code = *ap++;
- nap--;
- break;
- }
-
- callp = sysent;
- if (code < 0 || code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else
+ // XXX out of range stays on syscall0, which we assume is enosys
+ if (code >= 0 || code <= SYS_MAXSYSCALL)
callp += code;
i = callp->sy_argsize / sizeof(register_t);
-/* $OpenBSD: trap.c,v 1.167 2023/04/26 16:53:59 claudio Exp $ */
+/* $OpenBSD: trap.c,v 1.168 2023/12/12 15:30:56 deraadt Exp $ */
/*
* Copyright (c) 1988 University of Utah.
case T_SYSCALL+T_USER:
{
struct trapframe *locr0 = p->p_md.md_regs;
- const struct sysent *callp;
- unsigned int code, indirect = -1;
+ const struct sysent *callp = sysent;
+ unsigned int code;
register_t tpc;
uint32_t branch = 0;
int error, numarg;
trapframe->pc, 0, branch);
} else
locr0->pc += 4;
- callp = sysent;
code = locr0->v0;
- switch (code) {
- case SYS_syscall:
- /*
- * Code is first argument, followed by actual args.
- */
- indirect = code;
- code = locr0->a0;
- if (code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else
- callp += code;
- numarg = callp->sy_argsize / sizeof(register_t);
- args.i[0] = locr0->a1;
- args.i[1] = locr0->a2;
- args.i[2] = locr0->a3;
- if (numarg > 3) {
- args.i[3] = locr0->a4;
- args.i[4] = locr0->a5;
- args.i[5] = locr0->a6;
- args.i[6] = locr0->a7;
- if (numarg > 7)
- if ((error = copyin((void *)locr0->sp,
- &args.i[7], sizeof(register_t))))
- goto bad;
- }
- break;
- default:
- if (code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else
- callp += code;
-
- numarg = callp->sy_narg;
- args.i[0] = locr0->a0;
- args.i[1] = locr0->a1;
- args.i[2] = locr0->a2;
- args.i[3] = locr0->a3;
- if (numarg > 4) {
- args.i[4] = locr0->a4;
- args.i[5] = locr0->a5;
- args.i[6] = locr0->a6;
- args.i[7] = locr0->a7;
- }
+
+ // XXX out of range stays on syscall0, which we assume is enosys
+ if (code >= 0 || code <= SYS_MAXSYSCALL)
+ callp += code;
+
+ numarg = callp->sy_narg;
+ args.i[0] = locr0->a0;
+ args.i[1] = locr0->a1;
+ args.i[2] = locr0->a2;
+ args.i[3] = locr0->a3;
+ if (numarg > 4) {
+ args.i[4] = locr0->a4;
+ args.i[5] = locr0->a5;
+ args.i[6] = locr0->a6;
+ args.i[7] = locr0->a7;
}
rval[0] = 0;
TRAPSIZE : trppos[ci->ci_cpuid]) - 1].code = code;
#endif
- error = mi_syscall(p, code, indirect, callp, args.i, rval);
+ error = mi_syscall(p, code, callp, args.i, rval);
switch (error) {
case 0:
locr0->v0 = rval[0];
locr0->a3 = 0;
break;
-
case ERESTART:
locr0->pc = tpc;
break;
-
case EJUSTRETURN:
break; /* nothing to do */
-
default:
bad:
locr0->v0 = error;
}
mi_syscall_return(p, code, error, rval);
-
return;
}
-/* $OpenBSD: trap.c,v 1.131 2023/02/11 23:07:27 deraadt Exp $ */
+/* $OpenBSD: trap.c,v 1.132 2023/12/12 15:30:56 deraadt Exp $ */
/* $NetBSD: trap.c,v 1.3 1996/10/13 03:31:37 christos Exp $ */
/*
struct vm_map *map;
vaddr_t va;
int access_type;
- const struct sysent *callp;
+ const struct sysent *callp = sysent;
size_t argsize;
register_t code, error;
register_t *params, rval[2], args[10];
- int n, indirect = -1;
+ int n;
if (frame->srr1 & PSL_PR) {
type |= EXC_USER;
case EXC_SC|EXC_USER:
uvmexp.syscalls++;
- code = frame->fixreg[0];
params = frame->fixreg + FIRSTARG;
- switch (code) {
- case SYS_syscall:
- /*
- * code is first argument,
- * followed by actual args.
- */
- indirect = code;
- code = *params++;
- break;
- default:
- break;
- }
+ code = frame->fixreg[0];
+ // XXX out of range stays on syscall0, which we assume is enosys
+ if (code >= 0 || code <= SYS_MAXSYSCALL)
+ callp += code;
- callp = sysent;
- if (code < 0 || code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else
- callp += code;
argsize = callp->sy_argsize;
n = NARGREG - (params - (frame->fixreg + FIRSTARG));
if (argsize > n * sizeof(register_t)) {
rval[0] = 0;
rval[1] = frame->fixreg[FIRSTARG + 1];
- error = mi_syscall(p, code, indirect, callp, params, rval);
+ error = mi_syscall(p, code, callp, params, rval);
switch (error) {
case 0:
-/* $OpenBSD: syscall.c,v 1.11 2023/02/11 23:07:27 deraadt Exp $ */
+/* $OpenBSD: syscall.c,v 1.12 2023/12/12 15:30:56 deraadt Exp $ */
/*
* Copyright (c) 2015 Dale Rahn <drahn@dalerahn.com>
syscall(struct trapframe *frame)
{
struct proc *p = curproc;
- const struct sysent *callp;
- int code, error, indirect = -1;
+ const struct sysent *callp = sysent;
+ int code, error;
int nap = 8, nargs;
register_t *ap, *args, copyargs[MAXARGS], rval[2];
- code = frame->fixreg[0];
ap = &frame->fixreg[3];
- switch (code) {
- case SYS_syscall:
- indirect = code;
- code = *ap++;
- nap--;
- break;
- }
-
- callp = sysent;
- if (code < 0 || code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else
+ code = frame->fixreg[0];
+ // XXX out of range stays on syscall0, which we assume is enosys
+ if (code >= 0 || code <= SYS_MAXSYSCALL)
callp += code;
+
nargs = callp->sy_argsize / sizeof(register_t);
if (nargs <= nap) {
args = ap;
rval[0] = 0;
rval[1] = 0;
- error = mi_syscall(p, code, indirect, callp, args, rval);
+ error = mi_syscall(p, code, callp, args, rval);
switch (error) {
case 0:
frame->fixreg[3] = rval[0];
frame->cr &= ~0x10000000;
break;
-
case ERESTART:
frame->srr0 -= 4;
break;
-
case EJUSTRETURN:
/* nothing to do */
break;
-
default:
bad:
frame->fixreg[0] = error;
-/* $OpenBSD: syscall.c,v 1.16 2023/04/13 02:19:05 jsg Exp $ */
+/* $OpenBSD: syscall.c,v 1.17 2023/12/12 15:30:56 deraadt Exp $ */
/*
* Copyright (c) 2020 Brian Bamsch <bbamsch@google.com>
svc_handler(trapframe_t *frame)
{
struct proc *p = curproc;
- const struct sysent *callp;
- int code, error, indirect = -1;
+ const struct sysent *callp = sysent;
+ int code, error;
u_int nap = 8, nargs;
register_t *ap, *args, copyargs[MAXARGS], rval[2];
uvmexp.syscalls++;
- /* Re-enable interrupts if they were enabled previously */
- if (__predict_true(frame->tf_scause & EXCP_INTR))
- intr_enable();
-
ap = &frame->tf_a[0];
code = frame->tf_t[0];
- switch (code) {
- case SYS_syscall:
- indirect = code;
- code = *ap++;
- nap--;
- break;
- }
-
- callp = sysent;
- if (code < 0 || code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else
+ // XXX out of range stays on syscall0, which we assume is enosys
+ if (code >= 0 || code <= SYS_MAXSYSCALL)
callp += code;
+
nargs = callp->sy_argsize / sizeof(register_t);
if (nargs <= nap) {
args = ap;
rval[0] = 0;
rval[1] = 0;
- error = mi_syscall(p, code, indirect, callp, args, rval);
+ error = mi_syscall(p, code, callp, args, rval);
switch (error) {
case 0:
frame->tf_a[0] = rval[0];
frame->tf_t[0] = 0; /* syscall succeeded */
break;
-
case ERESTART:
frame->tf_sepc -= 4; /* prev instruction */
break;
-
case EJUSTRETURN:
break;
-
default:
bad:
frame->tf_a[0] = error;
-/* $OpenBSD: trap.c,v 1.54 2023/02/11 23:07:27 deraadt Exp $ */
+/* $OpenBSD: trap.c,v 1.55 2023/12/12 15:30:56 deraadt Exp $ */
/* $NetBSD: exception.c,v 1.32 2006/09/04 23:57:52 uwe Exp $ */
/* $NetBSD: syscall.c,v 1.6 2006/03/07 07:21:50 thorpej Exp $ */
syscall(struct proc *p, struct trapframe *tf)
{
caddr_t params;
- const struct sysent *callp;
- int error, opc, indirect = -1;
- int argoff, argsize;
+ const struct sysent *callp = sysent;
+ int error, opc;
+ int argsize;
register_t code, args[8], rval[2];
uvmexp.syscalls++;
opc = tf->tf_spc;
- code = tf->tf_r0;
-
params = (caddr_t)tf->tf_r15;
- switch (code) {
- case SYS_syscall:
- /*
- * Code is first argument, followed by actual args.
- */
- indirect = code;
- code = tf->tf_r4;
- argoff = 1;
- break;
- default:
- argoff = 0;
- break;
- }
-
- callp = sysent;
- if (code < 0 || code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else
+ code = tf->tf_r0;
+ // XXX out of range stays on syscall0, which we assume is enosys
+ if (code >= 0 || code <= SYS_MAXSYSCALL)
callp += code;
+
argsize = callp->sy_argsize;
-#ifdef DIAGNOSTIC
- if (argsize > sizeof args) {
- callp += SYS_syscall - code;
- argsize = callp->sy_argsize;
- }
-#endif
if (argsize) {
register_t *ap;
}
ap = args;
- switch (argoff) {
- case 0: *ap++ = tf->tf_r4; argsize -= sizeof(int);
- case 1: *ap++ = tf->tf_r5; argsize -= sizeof(int);
- case 2: *ap++ = tf->tf_r6; argsize -= sizeof(int);
- /*
- * off_t args aren't split between register
- * and stack, but rather r7 is skipped and
- * the entire off_t is on the stack.
- */
- if (argoff + off_t_arg == 3)
- break;
- *ap++ = tf->tf_r7; argsize -= sizeof(int);
+
+ *ap++ = tf->tf_r4; argsize -= sizeof(int);
+ *ap++ = tf->tf_r5; argsize -= sizeof(int);
+ *ap++ = tf->tf_r6; argsize -= sizeof(int);
+ /*
+ * off_t args aren't split between register
+ * and stack, but rather r7 is skipped and
+ * the entire off_t is on the stack.
+ */
+ if (off_t_arg == 3)
break;
- }
+ *ap++ = tf->tf_r7; argsize -= sizeof(int);
if (argsize > 0) {
if ((error = copyin(params, ap, argsize)))
rval[0] = 0;
rval[1] = tf->tf_r1;
- error = mi_syscall(p, code, indirect, callp, args, rval);
+ error = mi_syscall(p, code, callp, args, rval);
switch (error) {
case 0:
-/* $OpenBSD: trap.c,v 1.115 2023/02/11 23:07:28 deraadt Exp $ */
+/* $OpenBSD: trap.c,v 1.116 2023/12/12 15:30:56 deraadt Exp $ */
/* $NetBSD: trap.c,v 1.73 2001/08/09 01:03:01 eeh Exp $ */
/*
int64_t *ap;
const struct sysent *callp;
struct proc *p = curproc;
- int error, new, indirect = -1;
+ int error = ENOSYS, new, indirect = -1;
register_t args[8];
register_t rval[2];
+ register_t *argp;
if ((tf->tf_out[6] & 1) == 0)
sigexit(p, SIGILL);
ap = &tf->tf_out[0];
nap = 6;
- switch (code) {
- case SYS_syscall:
- indirect = code;
- code = *ap++;
- nap--;
- break;
- }
-
- callp = sysent;
if (code < 0 || code >= SYS_MAXSYSCALL)
- callp += SYS_syscall;
- else {
- register_t *argp;
-
- callp += code;
- i = callp->sy_narg; /* Why divide? */
- if (i > nap) { /* usually false */
- if (i > 8)
- panic("syscall nargs");
- /* Read the whole block in */
- if ((error = copyin((caddr_t)tf->tf_out[6]
- + BIAS + offsetof(struct frame, fr_argx),
- &args[nap], (i - nap) * sizeof(register_t))))
- goto bad;
- i = nap;
- }
- /*
- * It should be faster to do <= 6 longword copies than
- * to call bcopy
- */
- for (argp = args; i--;)
- *argp++ = *ap++;
+ goto bad;
+ callp = sysent + code;
+ i = callp->sy_narg; /* Why divide? */
+ if (i > nap) { /* usually false */
+ if (i > 8)
+ panic("syscall nargs");
+ /* Read the whole block in */
+ if ((error = copyin((caddr_t)tf->tf_out[6]
+ + BIAS + offsetof(struct frame, fr_argx),
+ &args[nap], (i - nap) * sizeof(register_t))))
+ goto bad;
+ i = nap;
}
+ /*
+ * It should be faster to do <= 6 longword copies than
+ * to call bcopy
+ */
+ for (argp = args; i--;)
+ *argp++ = *ap++;
rval[0] = 0;
rval[1] = 0;
-/* $OpenBSD: kern_ktrace.c,v 1.112 2023/05/11 09:51:33 bluhm Exp $ */
+/* $OpenBSD: kern_ktrace.c,v 1.113 2023/12/12 15:30:55 deraadt Exp $ */
/* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */
/*
u_int nargs = 0;
int i;
- if ((code & KTRC_CODE_MASK) == SYS_sysctl) {
+ if (code == SYS_sysctl) {
/*
* The sysctl encoding stores the mib[]
* array because it is interesting.
-; $OpenBSD: syscalls.master,v 1.253 2023/12/10 16:59:09 deraadt Exp $
+; $OpenBSD: syscalls.master,v 1.254 2023/12/12 15:30:55 deraadt Exp $
; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
; redistributions should be placed in the reserved range at the end
; of the current calls.
-0 INDIR { int sys_syscall(int number, ...); }
+0 UNIMPL syscall
1 STD { void sys_exit(int rval); }
2 STD { int sys_fork(void); }
3 STD NOLOCK { ssize_t sys_read(int fd, void *buf, size_t nbyte); }
-/* $OpenBSD: ktrace.h,v 1.46 2023/02/23 01:33:20 deraadt Exp $ */
+/* $OpenBSD: ktrace.h,v 1.47 2023/12/12 15:30:55 deraadt Exp $ */
/* $NetBSD: ktrace.h,v 1.12 1996/02/04 02:12:29 christos Exp $ */
/*
#define KTR_SYSCALL 1
struct ktr_syscall {
int ktr_code; /* syscall number */
-#define KTRC_CODE_MASK 0x0000ffff
-#define KTRC_CODE_SYSCALL 0x20000000
int ktr_argsize; /* size of arguments */
/*
* followed by ktr_argsize/sizeof(register_t) "register_t"s
-/* $OpenBSD: syscall_mi.h,v 1.28 2023/02/11 23:07:23 deraadt Exp $ */
+/* $OpenBSD: syscall_mi.h,v 1.29 2023/12/12 15:30:55 deraadt Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
* The MD setup for a system call has been done; here's the MI part.
*/
static inline int
-mi_syscall(struct proc *p, register_t code, int indirect,
- const struct sysent *callp, register_t *argp, register_t retval[2])
+mi_syscall(struct proc *p, register_t code, const struct sysent *callp,
+ register_t *argp, register_t retval[2])
{
uint64_t tval;
int lock = !(callp->sy_flags & SY_NOLOCK);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL)) {
/* convert to mask, then include with code */
- switch (indirect) {
- case SYS_syscall:
- indirect = KTRC_CODE_SYSCALL;
- break;
- default:
- indirect = 0;
- }
KERNEL_LOCK();
- ktrsyscall(p, code | indirect, callp->sy_argsize, argp);
+ ktrsyscall(p, code, callp->sy_argsize, argp);
KERNEL_UNLOCK();
}
#endif
-/* $OpenBSD: kdump.c,v 1.159 2023/11/09 15:43:28 kn Exp $ */
+/* $OpenBSD: kdump.c,v 1.160 2023/12/12 15:30:55 deraadt Exp $ */
/*-
* Copyright (c) 1988, 1993
narg = ktr->ktr_argsize / sizeof(register_t);
sep = '\0';
- if (ktr->ktr_code & KTRC_CODE_SYSCALL)
- (void)printf("(via syscall) ");
- code = ktr->ktr_code & KTRC_CODE_MASK;
+ code = ktr->ktr_code;
if (code >= SYS_MAXSYSCALL || code < 0)
(void)printf("[%d]", code);
else