Arrange to update cached LWP credentials in userret() rather than during

syscall/trap entry, eliminating a test+branch on every syscall/trap.

This wasn't possible in the 3.99.x timeframe when l->l_cred came about
because there wasn't a reliable/timely way to force an ONPROC LWP running on
a remote CPU into the kernel (which is just about the only new thing in
this scheme).
This commit is contained in:
ad 2023-10-05 19:41:03 +00:00
parent 5e6f75a121
commit 68fa584377
51 changed files with 135 additions and 237 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: aarch32_syscall.c,v 1.7 2023/02/25 00:40:22 riastradh Exp $ */
/* $NetBSD: aarch32_syscall.c,v 1.8 2023/10/05 19:41:03 ad Exp $ */
/*
* Copyright (c) 2018 Ryo Shimizu <ryo@nerv.org>
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: aarch32_syscall.c,v 1.7 2023/02/25 00:40:22 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: aarch32_syscall.c,v 1.8 2023/10/05 19:41:03 ad Exp $");
#include <sys/param.h>
#include <sys/ktrace.h>
@ -67,8 +67,6 @@ EMULNAME(syscall)(struct trapframe *tf)
int error, i;
bool do_trace, thumbmode;
LWP_CACHE_CREDS(l, p);
curcpu()->ci_data.cpu_nsyscall++; /* XXX unsafe curcpu() */
thumbmode = (tf->tf_spsr & SPSR_A32_T) ? true : false;

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.12 2023/02/25 00:40:22 riastradh Exp $ */
/* $NetBSD: syscall.c,v 1.13 2023/10/05 19:41:03 ad Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -58,7 +58,7 @@
#define EMULNAME(x) (x)
#define EMULNAMEU(x) (x)
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.12 2023/02/25 00:40:22 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.13 2023/10/05 19:41:03 ad Exp $");
void
cpu_spawn_return(struct lwp *l)
@ -92,8 +92,6 @@ EMULNAME(syscall)(struct trapframe *tf)
register_t args[10];
int error;
LWP_CACHE_CREDS(l, p);
curcpu()->ci_data.cpu_nsyscall++; /* XXX unsafe curcpu() */
register_t *params = (void *)tf->tf_reg;

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_syscall.c,v 1.33 2015/03/07 18:51:44 christos Exp $ */
/* $NetBSD: linux_syscall.c,v 1.34 2023/10/05 19:41:03 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -89,7 +89,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: linux_syscall.c,v 1.33 2015/03/07 18:51:44 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_syscall.c,v 1.34 2023/10/05 19:41:03 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -147,8 +147,6 @@ linux_syscall_plain(struct lwp *l, uint64_t code, struct trapframe *framep)
u_int hidden, nargs;
struct proc *p = l->l_proc;
LWP_CACHE_CREDS(l, p);
curcpu()->ci_data.cpu_nsyscall++;
l->l_md.md_tf = framep;
@ -231,8 +229,6 @@ linux_syscall_fancy(struct lwp *l, uint64_t code, struct trapframe *framep)
u_int hidden, nargs;
struct proc *p = l->l_proc;
LWP_CACHE_CREDS(l, p);
curcpu()->ci_data.cpu_nsyscall++;
l->l_md.md_tf = framep;

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.44 2019/04/06 11:54:19 kamil Exp $ */
/* $NetBSD: syscall.c,v 1.45 2023/10/05 19:41:03 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -89,7 +89,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.44 2019/04/06 11:54:19 kamil Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.45 2023/10/05 19:41:03 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -137,8 +137,6 @@ syscall(struct lwp *l, uint64_t code, struct trapframe *tf)
u_int hidden, nargs;
struct proc * const p = l->l_proc;
LWP_CACHE_CREDS(l, p);
curcpu()->ci_data.cpu_nsyscall++;
l->l_md.md_tf = tf;

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.138 2021/07/23 04:19:50 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.139 2023/10/05 19:41:03 ad Exp $ */
/*-
* Copyright (c) 2000, 2001, 2021 The NetBSD Foundation, Inc.
@ -95,7 +95,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.138 2021/07/23 04:19:50 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.139 2023/10/05 19:41:03 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -267,7 +267,6 @@ trap(const u_long a0, const u_long a1, const u_long a2, const u_long entry,
l->l_md.md_tf = framep;
p = l->l_proc;
(void)memset(&ksi, 0, sizeof(ksi));
LWP_CACHE_CREDS(l, p);
} else {
p = NULL;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: linux32_syscall.c,v 1.32 2015/03/07 18:41:40 christos Exp $ */
/* $NetBSD: linux32_syscall.c,v 1.33 2023/10/05 19:41:03 ad Exp $ */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux32_syscall.c,v 1.32 2015/03/07 18:41:40 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux32_syscall.c,v 1.33 2023/10/05 19:41:03 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -45,8 +45,6 @@ linux32_syscall(struct trapframe *frame)
code = frame->tf_rax;
LWP_CACHE_CREDS(l, p);
callp = p->p_emul->e_sysent;
code &= (LINUX32_SYS_NSYSENT - 1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_syscall.c,v 1.32 2015/03/07 18:41:40 christos Exp $ */
/* $NetBSD: linux_syscall.c,v 1.33 2023/10/05 19:41:03 ad Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_syscall.c,v 1.32 2015/03/07 18:41:40 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_syscall.c,v 1.33 2023/10/05 19:41:03 ad Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_linux.h"
@ -85,8 +85,6 @@ linux_syscall(struct trapframe *frame)
code = frame->tf_rax;
LWP_CACHE_CREDS(l, p);
callp = p->p_emul->e_sysent;
code &= (LINUX_SYS_NSYSENT - 1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_syscall.c,v 1.33 2015/03/07 18:41:40 christos Exp $ */
/* $NetBSD: netbsd32_syscall.c,v 1.34 2023/10/05 19:41:03 ad Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
#endif
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_syscall.c,v 1.33 2015/03/07 18:41:40 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_syscall.c,v 1.34 2023/10/05 19:41:03 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -79,8 +79,6 @@ netbsd32_syscall(struct trapframe *frame)
code = frame->tf_rax & (SYS_NSYSENT - 1);
callp = p->p_emul->e_sysent + code;
LWP_CACHE_CREDS(l, p);
SYSCALL_COUNT(syscall_counts, code);
SYSCALL_TIME_SYS_ENTRY(l, syscall_times, code);

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.128 2020/09/05 07:26:37 maxv Exp $ */
/* $NetBSD: trap.c,v 1.129 2023/10/05 19:41:03 ad Exp $ */
/*
* Copyright (c) 1998, 2000, 2017 The NetBSD Foundation, Inc.
@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.128 2020/09/05 07:26:37 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.129 2023/10/05 19:41:03 ad Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -282,7 +282,6 @@ trap(struct trapframe *frame)
if (!KERNELMODE(frame->tf_cs)) {
type |= T_USER;
l->l_md.md_regs = frame;
LWP_CACHE_CREDS(l, p);
}
#ifdef KDTRACE_HOOKS

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.139 2020/08/10 10:51:21 rin Exp $ */
/* $NetBSD: trap.c,v 1.140 2023/10/05 19:41:03 ad Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -45,7 +45,7 @@
#include "opt_m68k_arch.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.139 2020/08/10 10:51:21 rin Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.140 2023/10/05 19:41:03 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -522,7 +522,6 @@ trap(struct frame *fp, int type, u_int code, u_int v)
type |= T_USER;
sticks = p->p_sticks;
l->l_md.md_regs = fp->f_regs;
LWP_CACHE_CREDS(l, p);
}
#ifdef DDB

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.68 2021/02/01 19:31:34 skrll Exp $ */
/* $NetBSD: syscall.c,v 1.69 2023/10/05 19:41:03 ad Exp $ */
/*-
* Copyright (c) 2000, 2003 The NetBSD Foundation, Inc.
@ -71,7 +71,7 @@
#include <sys/param.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.68 2021/02/01 19:31:34 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.69 2023/10/05 19:41:03 ad Exp $");
#include <sys/cpu.h>
#include <sys/device.h>
@ -167,7 +167,6 @@ swi_handler(trapframe_t *tf)
curcpu()->ci_data.cpu_nsyscall++;
LWP_CACHE_CREDS(l, l->l_proc);
(*l->l_proc->p_md.md_syscall)(tf, l, insn);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: undefined.c,v 1.74 2022/01/08 09:01:00 skrll Exp $ */
/* $NetBSD: undefined.c,v 1.75 2023/10/05 19:41:03 ad Exp $ */
/*
* Copyright (c) 2001 Ben Harris.
@ -50,7 +50,7 @@
#include "opt_kgdb.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: undefined.c,v 1.74 2022/01/08 09:01:00 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: undefined.c,v 1.75 2023/10/05 19:41:03 ad Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@ -340,7 +340,6 @@ undefinedinstruction(trapframe_t *tf)
if ((tf->tf_spsr & PSR_MODE) == PSR_USR32_MODE) {
user = 1;
LWP_CACHE_CREDS(l, l->l_proc);
} else
user = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: fault.c,v 1.116 2021/02/01 19:31:34 skrll Exp $ */
/* $NetBSD: fault.c,v 1.117 2023/10/05 19:41:03 ad Exp $ */
/*
* Copyright 2003 Wasabi Systems, Inc.
@ -82,7 +82,7 @@
#include "opt_multiprocessor.h"
#include <sys/types.h>
__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.116 2021/02/01 19:31:34 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.117 2023/10/05 19:41:03 ad Exp $");
#include <sys/param.h>
@ -268,8 +268,6 @@ data_abort_handler(trapframe_t *tf)
/* Data abort came from user mode? */
bool user = (TRAP_USERMODE(tf) != 0);
if (user)
LWP_CACHE_CREDS(l, l->l_proc);
/* Grab the current pcb */
struct pcb * const pcb = lwp_getpcb(l);
@ -822,9 +820,6 @@ prefetch_abort_handler(trapframe_t *tf)
l = curlwp;
pcb = lwp_getpcb(l);
if ((user = TRAP_USERMODE(tf)) != 0)
LWP_CACHE_CREDS(l, l->l_proc);
/*
* Enable IRQ's (disabled by the abort) This always comes
* from user mode so we know interrupts were not disabled.

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.118 2023/01/06 10:28:27 tsutsui Exp $ */
/* $NetBSD: trap.c,v 1.119 2023/10/05 19:41:03 ad Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.118 2023/01/06 10:28:27 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.119 2023/10/05 19:41:03 ad Exp $");
#include "opt_ddb.h"
#include "opt_execfmt.h"
@ -345,7 +345,6 @@ trap(struct frame *fp, int type, u_int code, u_int v)
type |= T_USER;
sticks = p->p_sticks;
l->l_md.md_regs = fp->f_regs;
LWP_CACHE_CREDS(l, p);
}
switch (type) {
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.61 2021/09/25 19:16:31 tsutsui Exp $ */
/* $NetBSD: trap.c,v 1.62 2023/10/05 19:41:04 ad Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.61 2021/09/25 19:16:31 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.62 2023/10/05 19:41:04 ad Exp $");
#include "opt_ddb.h"
#include "opt_execfmt.h"
@ -276,7 +276,6 @@ trap(struct frame *fp, int type, unsigned code, unsigned v)
type |= T_USER;
sticks = p->p_sticks;
l->l_md.md_regs = fp->f_regs;
LWP_CACHE_CREDS(l, p);
}
switch (type) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.157 2023/04/21 23:01:59 tsutsui Exp $ */
/* $NetBSD: trap.c,v 1.158 2023/10/05 19:41:04 ad Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.157 2023/04/21 23:01:59 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.158 2023/10/05 19:41:04 ad Exp $");
#include "opt_ddb.h"
#include "opt_execfmt.h"
@ -272,7 +272,6 @@ trap(struct frame *fp, int type, u_int code, u_int v)
type |= T_USER;
sticks = p->p_sticks;
l->l_md.md_regs = fp->f_regs;
LWP_CACHE_CREDS(l, p);
}
switch (type) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.122 2023/07/23 10:09:36 skrll Exp $ */
/* $NetBSD: trap.c,v 1.123 2023/10/05 19:41:04 ad Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.122 2023/07/23 10:09:36 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.123 2023/10/05 19:41:04 ad Exp $");
/* #define INTRDEBUG */
/* #define TRAPDEBUG */
@ -603,8 +603,6 @@ trap(int type, struct trapframe *frame)
KASSERT(curlwp != NULL);
l = curlwp;
p = l->l_proc;
if ((type & T_USER) != 0)
LWP_CACHE_CREDS(l, p);
#ifdef DIAGNOSTIC
/*
@ -1294,7 +1292,6 @@ syscall(struct trapframe *frame, int *args)
nsys = p->p_emul->e_nsysent;
callp = p->p_emul->e_sysent;
code = frame->tf_t1;
LWP_CACHE_CREDS(l, p);
/*
* Restarting a system call is touchy on the HPPA, because syscall

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_syscall.c,v 1.54 2018/08/10 21:44:58 pgoyette Exp $ */
/* $NetBSD: linux_syscall.c,v 1.55 2023/10/05 19:41:04 ad Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_syscall.c,v 1.54 2018/08/10 21:44:58 pgoyette Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_syscall.c,v 1.55 2023/10/05 19:41:04 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -76,7 +76,6 @@ linux_syscall(struct trapframe *frame)
register_t code, args[6], rval[2];
l = curlwp;
LWP_CACHE_CREDS(l, l->l_proc);
code = frame->tf_eax & (LINUX_SYS_NSYSENT - 1);
callp = linux_sysent;

View File

@ -1,5 +1,5 @@
/* $NetBSD: trap.c,v 1.308 2022/08/20 23:48:50 riastradh Exp $ */
/* $NetBSD: trap.c,v 1.309 2023/10/05 19:41:04 ad Exp $ */
/*-
* Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.308 2022/08/20 23:48:50 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.309 2023/10/05 19:41:04 ad Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -314,7 +314,6 @@ trap(struct trapframe *frame)
type |= T_USER;
l->l_md.md_regs = frame;
pcb->pcb_cr2 = 0;
LWP_CACHE_CREDS(l, p);
}
#ifdef KDTRACE_HOOKS

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.15 2021/07/24 21:31:33 andvar Exp $ */
/* $NetBSD: trap.c,v 1.16 2023/10/05 19:41:04 ad Exp $ */
/*-
* Copyright (c) 2005 Marcel Moolenaar
@ -61,7 +61,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.15 2021/07/24 21:31:33 andvar Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.16 2023/10/05 19:41:04 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -397,7 +397,6 @@ trap(int vector, struct trapframe *tf)
ia64_set_fpsr(IA64_FPSR_DEFAULT);
p = l->l_proc;
l->l_md.md_tf = tf;
LWP_CACHE_CREDS(l, p);
} else {
p = NULL;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.77 2023/09/17 12:30:00 andvar Exp $ */
/* $NetBSD: trap.c,v 1.78 2023/10/05 19:41:04 ad Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.77 2023/09/17 12:30:00 andvar Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.78 2023/10/05 19:41:04 ad Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -242,7 +242,6 @@ trap(struct frame *fp, int type, unsigned code, unsigned v)
type |= T_USER;
sticks = p->p_sticks;
l->l_md.md_regs = fp->f_regs;
LWP_CACHE_CREDS(l, p);
}
switch (type) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: m68k_syscall.c,v 1.54 2019/04/06 11:54:20 kamil Exp $ */
/* $NetBSD: m68k_syscall.c,v 1.55 2023/10/05 19:41:04 ad Exp $ */
/*-
* Portions Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: m68k_syscall.c,v 1.54 2019/04/06 11:54:20 kamil Exp $");
__KERNEL_RCSID(0, "$NetBSD: m68k_syscall.c,v 1.55 2023/10/05 19:41:04 ad Exp $");
#include "opt_execfmt.h"
#include "opt_compat_netbsd.h"
@ -119,7 +119,6 @@ syscall(register_t code, struct frame frame)
p = l->l_proc;
sticks = p->p_sticks;
l->l_md.md_regs = frame.f_regs;
LWP_CACHE_CREDS(l, p);
(p->p_md.md_syscall)(code, l, &frame);

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.152 2021/09/25 19:16:31 tsutsui Exp $ */
/* $NetBSD: trap.c,v 1.153 2023/10/05 19:41:04 ad Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.152 2021/09/25 19:16:31 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.153 2023/10/05 19:41:04 ad Exp $");
#include "opt_ddb.h"
#include "opt_execfmt.h"
@ -254,7 +254,6 @@ trap(struct frame *fp, int type, u_int code, u_int v)
type |= T_USER;
sticks = p->p_sticks;
l->l_md.md_regs = fp->f_regs;
LWP_CACHE_CREDS(l, p);
} else
sticks = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.50 2020/08/09 06:43:29 skrll Exp $ */
/* $NetBSD: syscall.c,v 1.51 2023/10/05 19:41:04 ad Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.50 2020/08/09 06:43:29 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.51 2023/10/05 19:41:04 ad Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@ -138,8 +138,6 @@ EMULNAME(syscall)(struct lwp *l, u_int status, u_int cause, vaddr_t pc)
size_t i;
#endif
LWP_CACHE_CREDS(l, p);
curcpu()->ci_data.cpu_nsyscall++;
if (cause & MIPS_CR_BR_DELAY)

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.263 2023/09/14 03:24:07 rin Exp $ */
/* $NetBSD: trap.c,v 1.264 2023/10/05 19:41:04 ad Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.263 2023/09/14 03:24:07 rin Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.264 2023/10/05 19:41:04 ad Exp $");
#include "opt_cputype.h" /* which mips CPU levels do we support? */
#include "opt_ddb.h"
@ -194,7 +194,6 @@ trap(uint32_t status, uint32_t cause, vaddr_t vaddr, vaddr_t pc,
if (USERMODE(status)) {
tf = utf;
type |= T_USER;
LWP_CACHE_CREDS(l, p);
}
#ifdef KDTRACE_HOOKS

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.113 2023/09/30 21:00:43 andvar Exp $ */
/* $NetBSD: trap.c,v 1.114 2023/10/05 19:41:05 ad Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.113 2023/09/30 21:00:43 andvar Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.114 2023/10/05 19:41:05 ad Exp $");
#include "opt_ddb.h"
#include "opt_execfmt.h"
@ -296,7 +296,6 @@ trap(struct frame *fp, int type, unsigned int code, unsigned int v)
type |= T_USER;
sticks = p->p_sticks;
l->l_md.md_regs = fp->f_regs;
LWP_CACHE_CREDS(l, p);
}
switch (type) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.75 2023/10/01 19:28:36 andvar Exp $ */
/* $NetBSD: trap.c,v 1.76 2023/10/05 19:41:05 ad Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.75 2023/10/01 19:28:36 andvar Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.76 2023/10/05 19:41:05 ad Exp $");
#include "opt_ddb.h"
#include "opt_execfmt.h"
@ -265,7 +265,6 @@ trap(struct frame *fp, int type, u_int code, u_int v)
type |= T_USER;
sticks = p->p_sticks;
l->l_md.md_regs = fp->f_regs;
LWP_CACHE_CREDS(l, p);
}
switch (type) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.93 2023/02/03 23:13:01 tsutsui Exp $ */
/* $NetBSD: trap.c,v 1.94 2023/10/05 19:41:05 ad Exp $ */
/*
* This file was taken from mvme68k/mvme68k/trap.c
@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.93 2023/02/03 23:13:01 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.94 2023/10/05 19:41:05 ad Exp $");
#include "opt_ddb.h"
#include "opt_execfmt.h"
@ -282,7 +282,6 @@ trap(struct frame *fp, int type, unsigned code, unsigned v)
type |= T_USER;
sticks = p->p_sticks;
l->l_md.md_regs = fp->f_regs;
LWP_CACHE_CREDS(l, p);
}
switch (type) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.101 2022/10/05 08:18:00 rin Exp $ */
/* $NetBSD: trap.c,v 1.102 2023/10/05 19:41:05 ad Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@ -69,7 +69,7 @@
#define __UFETCHSTORE_PRIVATE
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.101 2022/10/05 08:18:00 rin Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.102 2023/10/05 19:41:05 ad Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@ -150,7 +150,6 @@ trap(struct trapframe *tf)
KASSERT(l->l_stat == LSONPROC);
if (tf->tf_srr1 & PSL_PR) {
LWP_CACHE_CREDS(l, p);
type |= EXC_USER;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.57 2020/07/06 11:07:39 rin Exp $ */
/* $NetBSD: syscall.c,v 1.58 2023/10/05 19:41:05 ad Exp $ */
/*
* Copyright (C) 2002 Matt Thomas
@ -59,7 +59,7 @@
#define EMULNAME(x) (x)
#define EMULNAMEU(x) (x)
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.57 2020/07/06 11:07:39 rin Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.58 2023/10/05 19:41:05 ad Exp $");
void
md_child_return(struct lwp *l)
@ -91,8 +91,6 @@ EMULNAME(syscall)(struct trapframe *tf)
int error;
int n;
LWP_CACHE_CREDS(l, p);
curcpu()->ci_ev_scalls.ev_count++;
code = tf->tf_fixreg[0];

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.163 2020/07/15 08:58:52 rin Exp $ */
/* $NetBSD: trap.c,v 1.164 2023/10/05 19:41:05 ad Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -35,7 +35,7 @@
#define __UCAS_PRIVATE
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.163 2020/07/15 08:58:52 rin Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.164 2023/10/05 19:41:05 ad Exp $");
#ifdef _KERNEL_OPT
#include "opt_altivec.h"
@ -111,7 +111,6 @@ trap(struct trapframe *tf)
panic("trap: user trap %d with lwp = %p, proc = %p",
type, l, p);
#endif
LWP_CACHE_CREDS(l, p);
}
ci->ci_data.cpu_ntrap++;

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.4 2023/05/07 12:41:49 skrll Exp $ */
/* $NetBSD: syscall.c,v 1.5 2023/10/05 19:41:05 ad Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.4 2023/05/07 12:41:49 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.5 2023/10/05 19:41:05 ad Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@ -88,8 +88,6 @@ EMULNAME(syscall)(struct trapframe *tf)
register_t copyargs[EMULNAME(SYS_MAXSYSARGS)];
#endif
LWP_CACHE_CREDS(l, p);
curcpu()->ci_data.cpu_nsyscall++;
callp = p->p_emul->e_sysent;

View File

@ -1,4 +1,4 @@
/* $NetBSD: exception.c,v 1.74 2021/09/15 11:03:24 rin Exp $ */
/* $NetBSD: exception.c,v 1.75 2023/10/05 19:41:05 ad Exp $ */
/*-
* Copyright (c) 2002, 2019 The NetBSD Foundation, Inc. All rights reserved.
@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.74 2021/09/15 11:03:24 rin Exp $");
__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.75 2023/10/05 19:41:05 ad Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -165,7 +165,6 @@ general_exception(struct lwp *l, struct trapframe *tf, uint32_t va)
if (usermode) {
KDASSERT(l->l_md.md_regs == tf); /* check exception depth */
expevt |= EXP_USER;
LWP_CACHE_CREDS(l, l->l_proc);
}
switch (expevt) {
@ -329,7 +328,6 @@ tlb_exception(struct lwp *l, struct trapframe *tf, uint32_t va)
ksi.ksi_code = SEGV_ACCERR;
ksi.ksi_addr = (void *)va;
splx(tf->tf_ssr & PSL_IMASK);
LWP_CACHE_CREDS(l, l->l_proc);
goto user_fault;
} else {
TLB_ASSERT(l && onfault != NULL,
@ -377,8 +375,6 @@ tlb_exception(struct lwp *l, struct trapframe *tf, uint32_t va)
/* Page not found. call fault handler */
splx(tf->tf_ssr & PSL_IMASK);
if (usermode)
LWP_CACHE_CREDS(l, l->l_proc);
pcb->pcb_onfault = NULL;
err = uvm_fault(map, va, ftype);
pcb->pcb_onfault = onfault;

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.32 2023/03/20 11:19:29 hannken Exp $ */
/* $NetBSD: syscall.c,v 1.33 2023/10/05 19:41:05 ad Exp $ */
/*
* Copyright (c) 1996
@ -49,7 +49,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.32 2023/03/20 11:19:29 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.33 2023/10/05 19:41:05 ad Exp $");
#include "opt_sparc_arch.h"
#include "opt_multiprocessor.h"
@ -224,7 +224,6 @@ syscall(register_t code, struct trapframe *tf, register_t pc)
curcpu()->ci_data.cpu_nsyscall++; /* XXXSMP */
l = curlwp;
p = l->l_proc;
LWP_CACHE_CREDS(l, p);
sticks = p->p_sticks;
l->l_md.md_tf = tf;

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.200 2021/01/24 07:36:54 mrg Exp $ */
/* $NetBSD: trap.c,v 1.201 2023/10/05 19:41:05 ad Exp $ */
/*
* Copyright (c) 1996
@ -49,7 +49,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.200 2021/01/24 07:36:54 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.201 2023/10/05 19:41:05 ad Exp $");
#include "opt_ddb.h"
#include "opt_compat_sunos.h"
@ -307,7 +307,6 @@ trap(unsigned type, int psr, int pc, struct trapframe *tf)
if ((l = curlwp) == NULL)
l = &lwp0;
p = l->l_proc;
LWP_CACHE_CREDS(l, p);
sticks = p->p_sticks;
pcb = lwp_getpcb(l);
l->l_md.md_tf = tf; /* for ptrace/signals */
@ -779,7 +778,6 @@ mem_access_fault(unsigned type, int ser, u_int v, int pc, int psr,
pcb = lwp_getpcb(l);
onfault = (vaddr_t)pcb->pcb_onfault;
LWP_CACHE_CREDS(l, p);
sticks = p->p_sticks;
#ifdef FPU_DEBUG
@ -994,7 +992,6 @@ mem_access_fault4m(unsigned type, u_int sfsr, u_int sfva, struct trapframe *tf)
l = curlwp;
p = l->l_proc;
LWP_CACHE_CREDS(l, p);
sticks = p->p_sticks;
pcb = lwp_getpcb(l);
onfault = (vaddr_t)pcb->pcb_onfault;

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.48 2019/04/06 11:54:20 kamil Exp $ */
/* $NetBSD: syscall.c,v 1.49 2023/10/05 19:41:06 ad Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.48 2019/04/06 11:54:20 kamil Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.49 2023/10/05 19:41:06 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -287,7 +287,6 @@ syscall(struct trapframe64 *tf, register_t code, register_t pc)
vaddr_t opc, onpc;
int s64;
LWP_CACHE_CREDS(l, p);
curcpu()->ci_data.cpu_nsyscall++;
sticks = p->p_sticks;
l->l_md.md_tf = tf;

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.194 2022/05/16 21:28:05 mrg Exp $ */
/* $NetBSD: trap.c,v 1.195 2023/10/05 19:41:06 ad Exp $ */
/*
* Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved.
@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.194 2022/05/16 21:28:05 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.195 2023/10/05 19:41:06 ad Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -571,7 +571,6 @@ trap(struct trapframe64 *tf, unsigned int type, vaddr_t pc, long tstate)
}
l = curlwp;
p = l->l_proc;
LWP_CACHE_CREDS(l, p);
sticks = p->p_sticks;
pcb = lwp_getpcb(l);
l->l_md.md_tf = tf; /* for ptrace/signals */
@ -1093,7 +1092,6 @@ data_access_fault(struct trapframe64 *tf, unsigned int type, vaddr_t pc,
p = l->l_proc;
pcb = lwp_getpcb(l);
onfault = (vaddr_t)pcb->pcb_onfault;
LWP_CACHE_CREDS(l, p);
sticks = p->p_sticks;
tstate = tf->tf_tstate;
@ -1373,7 +1371,6 @@ data_access_error(struct trapframe64 *tf, unsigned int type, vaddr_t afva,
l = curlwp;
pcb = lwp_getpcb(l);
LWP_CACHE_CREDS(l, l->l_proc);
sticks = l->l_proc->p_sticks;
printf("data error type %x sfsr=%lx sfva=%lx afsr=%lx afva=%lx tf=%p\n",
@ -1501,7 +1498,6 @@ text_access_fault(struct trapframe64 *tf, unsigned int type, vaddr_t pc,
curcpu()->ci_data.cpu_ntrap++;
l = curlwp;
p = l->l_proc;
LWP_CACHE_CREDS(l, p);
sticks = p->p_sticks;
tstate = tf->tf_tstate;
va = trunc_page(pc);
@ -1620,7 +1616,6 @@ text_access_error(struct trapframe64 *tf, unsigned int type, vaddr_t pc,
curcpu()->ci_data.cpu_ntrap++;
l = curlwp;
p = l->l_proc;
LWP_CACHE_CREDS(l, p);
sticks = p->p_sticks;
tstate = tf->tf_tstate;

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.46 2019/11/21 19:24:01 ad Exp $ */
/* $NetBSD: trap.c,v 1.47 2023/10/05 19:41:06 ad Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.46 2019/11/21 19:24:01 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.47 2023/10/05 19:41:06 ad Exp $");
#include "opt_ddb.h"
#include "opt_execfmt.h"
@ -263,7 +263,6 @@ trap(struct trapframe *tf, int type, u_int code, u_int v)
type |= T_USER;
sticks = p->p_sticks;
l->l_md.md_regs = tf->tf_regs;
LWP_CACHE_CREDS(l, p);
} else {
sticks = 0;
/* XXX: Detect trap recursion? */

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.147 2020/08/10 10:51:21 rin Exp $ */
/* $NetBSD: trap.c,v 1.148 2023/10/05 19:41:06 ad Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.147 2020/08/10 10:51:21 rin Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.148 2023/10/05 19:41:06 ad Exp $");
#include "opt_ddb.h"
#include "opt_execfmt.h"
@ -270,7 +270,6 @@ trap(struct trapframe *tf, int type, u_int code, u_int v)
type |= T_USER;
sticks = p->p_sticks;
l->l_md.md_regs = tf->tf_regs;
LWP_CACHE_CREDS(l, p);
} else {
sticks = 0;
/* XXX: Detect trap recursion? */

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.26 2023/04/03 17:58:41 gutteridge Exp $ */
/* $NetBSD: syscall.c,v 1.27 2023/10/05 19:41:06 ad Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.26 2023/04/03 17:58:41 gutteridge Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.27 2023/10/05 19:41:06 ad Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -96,7 +96,6 @@ syscall(void)
/* system call accounting */
curcpu()->ci_data.cpu_nsyscall++;
LWP_CACHE_CREDS(l, l->l_proc);
/* XXX do we want do do emulation? */
md_syscall_get_opcode(ucp, &opcode);

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.26 2019/04/06 11:54:21 kamil Exp $ */
/* $NetBSD: syscall.c,v 1.27 2023/10/05 19:41:06 ad Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@ -28,7 +28,7 @@
/* All bugs are subject to removal without further notice */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.26 2019/04/06 11:54:21 kamil Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.27 2023/10/05 19:41:06 ad Exp $");
#include "opt_multiprocessor.h"
@ -76,8 +76,6 @@ syscall(struct trapframe *tf)
curcpu()->ci_data.cpu_nsyscall++;
LWP_CACHE_CREDS(l, p);
l->l_md.md_utf = tf;
if ((unsigned long) tf->tf_code >= emul->e_nsysent)

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.137 2022/12/11 18:02:40 oster Exp $ */
/* $NetBSD: trap.c,v 1.138 2023/10/05 19:41:06 ad Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@ -28,7 +28,7 @@
/* All bugs are subject to removal without further notice */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.137 2022/12/11 18:02:40 oster Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.138 2023/10/05 19:41:06 ad Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -107,7 +107,6 @@ trap(struct trapframe *tf)
type |= T_USER;
oticks = p->p_sticks;
l->l_md.md_utf = tf;
LWP_CACHE_CREDS(l, p);
}
type &= ~(T_WRITE|T_PTEFETCH);

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.111 2023/09/16 20:53:18 andvar Exp $ */
/* $NetBSD: trap.c,v 1.112 2023/10/05 19:41:06 ad Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.111 2023/09/16 20:53:18 andvar Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.112 2023/10/05 19:41:06 ad Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -275,7 +275,6 @@ trap(struct frame *fp, int type, unsigned code, unsigned v)
type |= T_USER;
sticks = p->p_sticks;
l->l_md.md_regs = fp->f_regs;
LWP_CACHE_CREDS(l, p);
}
switch (type) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.21 2022/03/17 22:22:49 riastradh Exp $ */
/* $NetBSD: syscall.c,v 1.22 2023/10/05 19:41:06 ad Exp $ */
/*-
* Copyright (c) 1998, 2000, 2009 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.21 2022/03/17 22:22:49 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.22 2023/10/05 19:41:06 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -106,7 +106,6 @@ syscall(struct trapframe *frame)
l = curlwp;
p = l->l_proc;
LWP_CACHE_CREDS(l, p);
code = X86_TF_RAX(frame) & (SYS_NSYSENT - 1);
callp = p->p_emul->e_sysent + code;

View File

@ -1,4 +1,4 @@
/* $NetBSD: freebsd_syscall.c,v 1.6 2019/04/06 17:42:28 kre Exp $ */
/* $NetBSD: freebsd_syscall.c,v 1.7 2023/10/05 19:41:06 ad Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: freebsd_syscall.c,v 1.6 2019/04/06 17:42:28 kre Exp $");
__KERNEL_RCSID(0, "$NetBSD: freebsd_syscall.c,v 1.7 2023/10/05 19:41:06 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -77,7 +77,6 @@ freebsd_syscall(struct trapframe *frame)
l = curlwp;
p = l->l_proc;
LWP_CACHE_CREDS(l, p);
code = frame->tf_eax;
callp = p->p_emul->e_sysent;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_lwp.c,v 1.264 2023/10/05 13:05:18 riastradh Exp $ */
/* $NetBSD: kern_lwp.c,v 1.265 2023/10/05 19:41:06 ad Exp $ */
/*-
* Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019, 2020, 2023
@ -217,7 +217,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.264 2023/10/05 13:05:18 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.265 2023/10/05 19:41:06 ad Exp $");
#include "opt_ddb.h"
#include "opt_lockdebug.h"
@ -1533,32 +1533,6 @@ lwp_find(struct proc *p, lwpid_t id)
return l;
}
/*
* Update an LWP's cached credentials to mirror the process' master copy.
*
* This happens early in the syscall path, on user trap, and on LWP
* creation. A long-running LWP can also voluntarily choose to update
* its credentials by calling this routine. This may be called from
* LWP_CACHE_CREDS(), which checks l->l_prflag & LPR_CRMOD beforehand.
*/
void
lwp_update_creds(struct lwp *l)
{
kauth_cred_t oc;
struct proc *p;
p = l->l_proc;
oc = l->l_cred;
mutex_enter(p->p_lock);
kauth_cred_hold(p->p_cred);
l->l_cred = p->p_cred;
l->l_prflag &= ~LPR_CRMOD;
mutex_exit(p->p_lock);
if (oc != NULL)
kauth_cred_free(oc);
}
/*
* Verify that an LWP is locked, and optionally verify that the lock matches
* one we specify.
@ -1730,6 +1704,20 @@ lwp_userret(struct lwp *l)
return;
}
/*
* Start out with the correct credentials.
*/
if ((f & LW_CACHECRED) != 0) {
kauth_cred_t oc = l->l_cred;
mutex_enter(p->p_lock);
l->l_cred = kauth_cred_hold(p->p_cred);
lwp_lock(l);
l->l_flag &= ~LW_CACHECRED;
lwp_unlock(l);
mutex_exit(p->p_lock);
kauth_cred_free(oc);
}
/*
* Process pending signals first, unless the process
* is dumping core or exiting, where we will instead

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_proc.c,v 1.273 2023/10/04 22:17:09 ad Exp $ */
/* $NetBSD: kern_proc.c,v 1.274 2023/10/05 19:41:07 ad Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007, 2008, 2020, 2023
@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.273 2023/10/04 22:17:09 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.274 2023/10/05 19:41:07 ad Exp $");
#ifdef _KERNEL_OPT
#include "opt_kstack.h"
@ -1839,14 +1839,17 @@ proc_crmod_leave(kauth_cred_t scred, kauth_cred_t fcred, bool sugid)
if (scred != NULL) {
p->p_cred = scred;
LIST_FOREACH(l2, &p->p_lwps, l_sibling) {
if (l2 != l)
l2->l_prflag |= LPR_CRMOD;
if (l2 != l) {
lwp_lock(l2);
l2->l_flag |= LW_CACHECRED;
lwp_need_userret(l2);
lwp_unlock(l2);
}
}
/* Ensure the LWP cached credentials are up to date. */
if ((oc = l->l_cred) != scred) {
kauth_cred_hold(scred);
l->l_cred = scred;
l->l_cred = kauth_cred_hold(scred);
}
} else
oc = NULL; /* XXXgcc */

View File

@ -1,4 +1,4 @@
/* $NetBSD: lwproc.c,v 1.56 2023/10/04 20:29:18 ad Exp $ */
/* $NetBSD: lwproc.c,v 1.57 2023/10/05 19:41:07 ad Exp $ */
/*
* Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved.
@ -28,7 +28,7 @@
#define RUMP__CURLWP_PRIVATE
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.56 2023/10/04 20:29:18 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.57 2023/10/05 19:41:07 ad Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@ -98,25 +98,6 @@ lwp_find(struct proc *p, lwpid_t id)
return l;
}
void
lwp_update_creds(struct lwp *l)
{
struct proc *p;
kauth_cred_t oldcred;
p = l->l_proc;
oldcred = l->l_cred;
l->l_prflag &= ~LPR_CRMOD;
mutex_enter(p->p_lock);
kauth_cred_hold(p->p_cred);
l->l_cred = p->p_cred;
mutex_exit(p->p_lock);
if (oldcred != NULL)
kauth_cred_free(oldcred);
}
void
rump_lwproc_init(void)
{
@ -374,7 +355,7 @@ lwproc_makelwp(struct proc *p, bool doswitch, bool procmake)
TAILQ_INIT(&l->l_ld_locks);
mutex_exit(p->p_lock);
lwp_update_creds(l);
l->l_cred = kauth_cred_hold(p->p_cred);
lwp_initspecific(l);
PSREF_DEBUG_INIT_LWP(l);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump.c,v 1.360 2023/09/23 18:21:11 ad Exp $ */
/* $NetBSD: rump.c,v 1.361 2023/10/05 19:41:07 ad Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.360 2023/09/23 18:21:11 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.361 2023/10/05 19:41:07 ad Exp $");
#include <sys/systm.h>
#define ELFSIZE ARCH_ELFSIZE
@ -327,7 +327,7 @@ rump_init_callback(void (*cpuinit_callback) (void))
chgproccnt(0, 1);
l->l_proc = &proc0;
lwp_update_creds(l);
l->l_cred = kauth_cred_hold(l->l_proc->p_cred);
lwpinit_specificdata();
lwp_initspecific(&lwp0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: scheduler.c,v 1.54 2023/10/04 20:28:06 ad Exp $ */
/* $NetBSD: scheduler.c,v 1.55 2023/10/05 19:41:07 ad Exp $ */
/*
* Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: scheduler.c,v 1.54 2023/10/04 20:28:06 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: scheduler.c,v 1.55 2023/10/05 19:41:07 ad Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@ -255,8 +255,15 @@ rump_schedule()
* start a real thread.
*/
if (__predict_true((l = curlwp) != NULL)) {
struct proc *p = l->l_proc;
rump_schedule_cpu(l);
LWP_CACHE_CREDS(l, l->l_proc);
if (l->l_cred != p->p_cred) {
kauth_cred_t oc = l->l_cred;
mutex_enter(p->p_lock);
l->l_cred = kauth_cred_hold(p->p_cred);
mutex_exit(p->p_lock);
kauth_cred_free(oc);
}
} else {
lwp0busy();

View File

@ -1,4 +1,4 @@
/* $NetBSD: lwp.h,v 1.226 2023/10/04 20:29:18 ad Exp $ */
/* $NetBSD: lwp.h,v 1.227 2023/10/05 19:41:07 ad Exp $ */
/*
* Copyright (c) 2001, 2006, 2007, 2008, 2009, 2010, 2019, 2020, 2023
@ -263,6 +263,7 @@ extern int maxlwp __read_mostly; /* max number of lwps */
#define LW_WEXIT 0x00100000 /* Exit before return to user */
#define LW_PENDSIG 0x01000000 /* Pending signal for us */
#define LW_CANCELLED 0x02000000 /* tsleep should not sleep */
#define LW_CACHECRED 0x04000000 /* Cache new process credential */
#define LW_WREBOOT 0x08000000 /* System is rebooting, please suspend */
#define LW_UNPARKED 0x10000000 /* Unpark op pending */
#define LW_RUMP_CLEAR 0x40000000 /* Clear curlwp in RUMP scheduler */
@ -295,15 +296,14 @@ extern int maxlwp __read_mostly; /* max number of lwps */
* with p_lock held.
*/
#define LPR_DETACHED 0x00800000 /* Won't be waited for. */
#define LPR_CRMOD 0x00000100 /* Credentials modified */
#define LPR_DRAINING 0x80000000 /* Draining references before exiting */
/*
* Mask indicating that there is "exceptional" work to be done on return to
* user.
*/
#define LW_USERRET \
(LW_WEXIT | LW_PENDSIG | LW_WREBOOT | LW_WSUSPEND | LW_WCORE | LW_LWPCTL)
#define LW_USERRET (LW_WEXIT | LW_PENDSIG | LW_WREBOOT | LW_WSUSPEND \
| LW_WCORE | LW_LWPCTL | LW_CACHECRED)
/*
* Status values.
@ -334,13 +334,6 @@ lwp_getpcb(struct lwp *l)
#endif /* _KERNEL || _KMEMUSER */
#ifdef _KERNEL
#define LWP_CACHE_CREDS(l, p) \
do { \
(void)p; \
if (__predict_false((l)->l_prflag & LPR_CRMOD)) \
lwp_update_creds(l); \
} while (/* CONSTCOND */ 0)
void lwpinit(void);
void lwp0_init(void);
@ -371,7 +364,6 @@ void lwp_exit(lwp_t *);
int lwp_suspend(lwp_t *, lwp_t *);
int lwp_create1(lwp_t *, const void *, size_t, u_long, lwpid_t *);
void lwp_start(lwp_t *, int);
void lwp_update_creds(lwp_t *);
void lwp_migrate(lwp_t *, struct cpu_info *);
lwp_t * lwp_find2(pid_t, lwpid_t);
lwp_t * lwp_find(proc_t *, int);