-/* $OpenBSD: trap.c,v 1.104 2022/11/02 07:20:07 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.105 2023/01/16 05:32:04 deraadt Exp $ */
/* $NetBSD: trap.c,v 1.52 2000/05/24 16:48:33 thorpej Exp $ */
/*-
{
const struct sysent *callp;
struct proc *p;
- int error;
+ int error, indirect = -1;
u_int64_t opc;
u_long rval[2];
u_long args[10]; /* XXX */
* syscall() and __syscall() are handled the same on
* the alpha, as everything is 64-bit aligned, anyway.
*/
+ indirect = code;
code = framep->tf_regs[FRAME_A0];
hidden = 1;
break;
rval[0] = 0;
rval[1] = 0;
- error = mi_syscall(p, code, callp, args + hidden, rval);
+ error = mi_syscall(p, code, indirect, callp, args + hidden, rval);
switch (error) {
case 0:
-/* $OpenBSD: trap.c,v 1.93 2022/11/07 01:41:57 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.94 2023/01/16 05:32:04 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;
+ int error, indirect = -1;
size_t argsize, argoff;
register_t code, args[9], rval[2], *argp;
/*
* Code is first argument, followed by actual args.
*/
+ indirect = code;
code = frame->tf_rdi;
argp = &args[1];
argoff = 1;
rval[0] = 0;
rval[1] = 0;
- error = mi_syscall(p, code, callp, argp, rval);
+ error = mi_syscall(p, code, indirect, callp, argp, rval);
switch (error) {
case 0:
-/* $OpenBSD: syscall.c,v 1.24 2021/12/09 00:26:11 guenther Exp $ */
+/* $OpenBSD: syscall.c,v 1.25 2023/01/16 05:32:04 deraadt Exp $ */
/* $NetBSD: syscall.c,v 1.24 2003/11/14 19:03:17 scw Exp $ */
/*-
{
struct proc *p = curproc;
const struct sysent *callp;
- int code, error;
+ int code, error, indirect = -1;
u_int nap = 4, nargs;
register_t *ap, *args, copyargs[MAXARGS], rval[2];
switch (code) {
case SYS_syscall:
+ indirect = code;
code = *ap++;
nap--;
break;
case SYS___syscall:
+ indirect = code;
code = ap[_QUAD_LOWWORD];
ap += 2;
nap -= 2;
rval[0] = 0;
rval[1] = frame->tf_r1;
- error = mi_syscall(p, code, callp, args, rval);
+ error = mi_syscall(p, code, indirect, callp, args, rval);
switch (error) {
case 0:
-/* $OpenBSD: syscall.c,v 1.11 2022/11/02 07:20:08 guenther Exp $ */
+/* $OpenBSD: syscall.c,v 1.12 2023/01/16 05:32:05 deraadt Exp $ */
/*
* Copyright (c) 2015 Dale Rahn <drahn@dalerahn.com>
*
{
struct proc *p = curproc;
const struct sysent *callp;
- int code, error;
+ int code, error, indirect = -1;
u_int nap = 8, nargs;
register_t *ap, *args, copyargs[MAXARGS], rval[2];
switch (code) {
case SYS_syscall:
- code = *ap++;
- nap--;
- break;
case SYS___syscall:
+ indirect = code;
code = *ap++;
nap--;
break;
rval[0] = 0;
rval[1] = 0;
- error = mi_syscall(p, code, callp, args, rval);
+ error = mi_syscall(p, code, indirect, callp, args, rval);
switch (error) {
case 0:
-/* $OpenBSD: trap.c,v 1.159 2022/11/02 07:20:07 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.160 2023/01/16 05:32:05 deraadt Exp $ */
/*
* Copyright (c) 1998-2004 Michael Shalayeff
{
struct proc *p = curproc;
const struct sysent *callp;
- int retq, code, argsize, argoff, error;
+ int retq, code, argsize, argoff, error, indirect = -1;
register_t args[8], rval[2];
#ifdef DIAGNOSTIC
int oldcpl = curcpu()->ci_cpl;
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;
* due to the args being laid backwards on the stack
* and then copied in words
*/
+ indirect = code;
code = frame->tf_arg0;
args[0] = frame->tf_arg2;
args[1] = frame->tf_arg3;
rval[0] = 0;
rval[1] = frame->tf_ret1;
- error = mi_syscall(p, code, callp, args, rval);
+ error = mi_syscall(p, code, indirect, callp, args, rval);
switch (error) {
case 0:
-/* $OpenBSD: trap.c,v 1.156 2021/12/09 00:26:11 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.157 2023/01/16 05:32:05 deraadt Exp $ */
/* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */
/*-
caddr_t params;
const struct sysent *callp;
struct proc *p;
- int error;
+ int error, indirect = -1;
register_t code, args[8], rval[2];
#ifdef DIAGNOSTIC
int ocpl = lapic_tpr;
/*
* Code is first argument, followed by actual args.
*/
+ indirect = code;
copyin(params, &code, sizeof(int));
params += sizeof(int);
break;
* Like syscall, but code is a quad, so as to maintain
* quad alignment for the rest of the arguments.
*/
+ indirect = code;
copyin(params + _QUAD_LOWWORD * sizeof(int), &code, sizeof(int));
params += sizeof(quad_t);
break;
rval[0] = 0;
rval[1] = frame->tf_edx;
- error = mi_syscall(p, code, callp, args, rval);
+ error = mi_syscall(p, code, indirect, callp, args, rval);
switch (error) {
case 0:
-/* $OpenBSD: trap.c,v 1.124 2023/01/09 11:18:44 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.125 2023/01/16 05:32:05 deraadt Exp $ */
/*
* Copyright (c) 2004, Miodrag Vallat.
* Copyright (c) 1998 Steve Murphree, Jr.
int i, nap;
const struct sysent *callp;
struct proc *p = curproc;
- int error;
+ int error, indirect = -1;
register_t args[8] __aligned(8);
register_t rval[2] __aligned(8);
register_t *ap;
switch (code) {
case SYS_syscall:
+ indirect = code;
code = *ap++;
nap--;
break;
case SYS___syscall:
+ indirect = code;
code = ap[_QUAD_LOWWORD];
ap += 2;
nap -= 2;
rval[0] = 0;
rval[1] = tf->tf_r[3];
- error = mi_syscall(p, code, callp, args, rval);
+ error = mi_syscall(p, code, indirect, callp, args, rval);
/*
* system call will look like:
-/* $OpenBSD: trap.c,v 1.164 2023/01/11 03:19:52 visa Exp $ */
+/* $OpenBSD: trap.c,v 1.165 2023/01/16 05:32:05 deraadt Exp $ */
/*
* Copyright (c) 1988 University of Utah.
{
struct trapframe *locr0 = p->p_md.md_regs;
const struct sysent *callp;
- unsigned int code;
+ unsigned int code, indirect = -1;
register_t tpc;
uint32_t branch = 0;
int error, numarg;
* proper alignment of 64-bit arguments on 32-bit
* platforms, which doesn't change anything here.
*/
+ indirect = code;
code = locr0->a0;
if (code >= SYS_MAXSYSCALL)
callp += SYS_syscall;
TRAPSIZE : trppos[ci->ci_cpuid]) - 1].code = code;
#endif
- error = mi_syscall(p, code, callp, args.i, rval);
+ error = mi_syscall(p, code, indirect, callp, args.i, rval);
switch (error) {
case 0:
-/* $OpenBSD: trap.c,v 1.128 2023/01/04 22:13:43 kettenis Exp $ */
+/* $OpenBSD: trap.c,v 1.129 2023/01/16 05:32:05 deraadt Exp $ */
/* $NetBSD: trap.c,v 1.3 1996/10/13 03:31:37 christos Exp $ */
/*
size_t argsize;
register_t code, error;
register_t *params, rval[2], args[10];
- int n;
+ int n, indirect = -1;
if (frame->srr1 & PSL_PR) {
type |= EXC_USER;
* code is first argument,
* followed by actual args.
*/
+ indirect = code;
code = *params++;
break;
case SYS___syscall:
* for the rest of the args.
*/
params++;
+ indirect = code;
code = *params++;
break;
default:
rval[0] = 0;
rval[1] = frame->fixreg[FIRSTARG + 1];
- error = mi_syscall(p, code, callp, params, rval);
+ error = mi_syscall(p, code, indirect, callp, params, rval);
switch (error) {
case 0:
-/* $OpenBSD: syscall.c,v 1.9 2022/11/02 07:20:08 guenther Exp $ */
+/* $OpenBSD: syscall.c,v 1.10 2023/01/16 05:32:05 deraadt Exp $ */
/*
* Copyright (c) 2015 Dale Rahn <drahn@dalerahn.com>
{
struct proc *p = curproc;
const struct sysent *callp;
- int code, error;
+ int code, error, indirect = -1;
int nap = 8, nargs;
register_t *ap, *args, copyargs[MAXARGS], rval[2];
switch (code) {
case SYS_syscall:
case SYS___syscall:
+ indirect = code;
code = *ap++;
nap--;
break;
rval[0] = 0;
rval[1] = 0;
- error = mi_syscall(p, code, callp, args, rval);
+ error = mi_syscall(p, code, indirect, callp, args, rval);
switch (error) {
case 0:
-/* $OpenBSD: syscall.c,v 1.13 2022/11/02 07:20:08 guenther Exp $ */
+/* $OpenBSD: syscall.c,v 1.14 2023/01/16 05:32:05 deraadt Exp $ */
/*
* Copyright (c) 2020 Brian Bamsch <bbamsch@google.com>
{
struct proc *p = curproc;
const struct sysent *callp;
- int code, error;
+ int code, error, indirect = -1;
u_int nap = 8, nargs;
register_t *ap, *args, copyargs[MAXARGS], rval[2];
switch (code) {
case SYS_syscall:
- code = *ap++;
- nap--;
- break;
case SYS___syscall:
+ indirect = code;
code = *ap++;
nap--;
break;
rval[0] = 0;
rval[1] = 0;
- error = mi_syscall(p, code, callp, args, rval);
+ error = mi_syscall(p, code, indirect, callp, args, rval);
switch (error) {
case 0:
-/* $OpenBSD: trap.c,v 1.52 2023/01/09 06:04:14 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.53 2023/01/16 05:32:05 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 $ */
{
caddr_t params;
const struct sysent *callp;
- int error, opc;
+ int error, opc, indirect = -1;
int argoff, argsize;
register_t code, args[8], rval[2];
/*
* Code is first argument, followed by actual args.
*/
+ indirect = code;
code = tf->tf_r4;
argoff = 1;
break;
* Like syscall, but code is a quad, so as to maintain
* quad alignment for the rest of the arguments.
*/
+ indirect = code;
#if _BYTE_ORDER == BIG_ENDIAN
code = tf->tf_r5;
#else
rval[0] = 0;
rval[1] = tf->tf_r1;
- error = mi_syscall(p, code, callp, args, rval);
+ error = mi_syscall(p, code, indirect, callp, args, rval);
switch (error) {
case 0:
-/* $OpenBSD: trap.c,v 1.112 2022/11/02 07:20:08 guenther Exp $ */
+/* $OpenBSD: trap.c,v 1.113 2023/01/16 05:32:05 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;
+ int error, new, indirect = -1;
register_t args[8];
register_t rval[2];
switch (code) {
case SYS_syscall:
case SYS___syscall:
+ indirect = code;
code = *ap++;
nap--;
break;
rval[0] = 0;
rval[1] = 0;
- error = mi_syscall(p, code, callp, args, rval);
+ error = mi_syscall(p, code, indirect, callp, args, rval);
switch (error) {
vaddr_t dest;
-/* $OpenBSD: ktrace.h,v 1.43 2022/12/29 01:36:36 guenther Exp $ */
+/* $OpenBSD: ktrace.h,v 1.44 2023/01/16 05:32:05 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
+#define KTRC_CODE__SYSCALL 0x40000000
int ktr_argsize; /* size of arguments */
/*
* followed by ktr_argsize/sizeof(register_t) "register_t"s
-/* $OpenBSD: syscall_mi.h,v 1.26 2022/06/29 12:06:11 jca Exp $ */
+/* $OpenBSD: syscall_mi.h,v 1.27 2023/01/16 05:32:05 deraadt Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
#include <sys/param.h>
#include <sys/pledge.h>
#include <sys/tracepoint.h>
+#include <sys/syscall.h>
#include <uvm/uvm_extern.h>
#ifdef KTRACE
* 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, const struct sysent *callp,
- register_t *argp, register_t retval[2])
+mi_syscall(struct proc *p, register_t code, int indirect,
+ const struct sysent *callp, register_t *argp, register_t retval[2])
{
uint64_t tval;
int lock = !(callp->sy_flags & SY_NOLOCK);
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL)) {
+ /* convert to mask, then include with code */
+ switch (indirect) {
+ case SYS_syscall:
+ indirect = KTRC_CODE_SYSCALL;
+ break;
+ case SYS___syscall:
+ indirect = KTRC_CODE__SYSCALL;
+ break;
+ default:
+ indirect = 0;
+ }
KERNEL_LOCK();
- ktrsyscall(p, code, callp->sy_argsize, argp);
+ ktrsyscall(p, code | indirect, callp->sy_argsize, argp);
KERNEL_UNLOCK();
}
#endif
-/* $OpenBSD: kdump.c,v 1.154 2023/01/07 05:26:40 guenther Exp $ */
+/* $OpenBSD: kdump.c,v 1.155 2023/01/16 05:32:05 deraadt Exp $ */
/*-
* Copyright (c) 1988, 1993
ktrsyscall(struct ktr_syscall *ktr, size_t ktrlen)
{
register_t *ap;
- int narg;
+ int narg, code;
char sep;
if (ktr->ktr_argsize > ktrlen)
narg = ktr->ktr_argsize / sizeof(register_t);
sep = '\0';
- if (ktr->ktr_code >= SYS_MAXSYSCALL || ktr->ktr_code < 0)
- (void)printf("[%d]", ktr->ktr_code);
+ if (ktr->ktr_code & KTRC_CODE_SYSCALL)
+ (void)printf("(via syscall) ");
+ else if (ktr->ktr_code & KTRC_CODE__SYSCALL)
+ (void)printf("(via __syscall) ");
+ code = ktr->ktr_code & KTRC_CODE_MASK;
+ if (code >= SYS_MAXSYSCALL || code < 0)
+ (void)printf("[%d]", code);
else
- (void)printf("%s", syscallnames[ktr->ktr_code]);
+ (void)printf("%s", syscallnames[code]);
ap = (register_t *)((char *)ktr + sizeof(struct ktr_syscall));
(void)putchar('(');
- if (ktr->ktr_code == SYS_sysctl && fancy) {
+ if (code == SYS_sysctl && fancy) {
const char *s;
int n, i, *top;
sep = ',';
ap += 2;
narg -= 2;
- } else if (ktr->ktr_code < nitems(scargs)) {
- const formatter *fmts = scargs[ktr->ktr_code];
+ } else if (code < nitems(scargs)) {
+ const formatter *fmts = scargs[code];
int fmt;
int arg = 0;