summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2001-08-30 18:50:57 +0000
committerdillon <dillon@FreeBSD.org>2001-08-30 18:50:57 +0000
commit08e732a88ba0d12d11fa8b38d5932c6579273aca (patch)
tree03a377cd1fcd2a2db481117b689dc177dcae6dd1
parent2b1fd9ab5e429c28b36e02f8dab6b71ca84c695c (diff)
downloadFreeBSD-src-08e732a88ba0d12d11fa8b38d5932c6579273aca.zip
FreeBSD-src-08e732a88ba0d12d11fa8b38d5932c6579273aca.tar.gz
Remove the MPSAFE keyword from the parser for syscalls.master.
Instead introduce the [M] prefix to existing keywords. e.g. MSTD is the MP SAFE version of STD. This is prepatory for a massive Giant lock pushdown. The old MPSAFE keyword made syscalls.master too messy. Begin comments MP-Safe procedures with the comment: /* * MPSAFE */ This comments means that the procedure may be called without Giant held (The procedure itself may still need to obtain Giant temporarily to do its thing). sv_prepsyscall() is now MP SAFE and assumed to be MP SAFE sv_transtrap() is now MP SAFE and assumed to be MP SAFE ktrsyscall() and ktrsysret() are now MP SAFE (Giant Pushdown) trapsignal() is now MP SAFE (Giant Pushdown) Places which used to do the if (mtx_owned(&Giant)) mtx_unlock(&Giant) test in syscall[2]() in */*/trap.c now do not. Instead they explicitly unlock Giant if they previously obtained it, and then assert that it is no longer held to catch broken system calls. Rebuild syscall tables.
-rw-r--r--sys/alpha/alpha/trap.c12
-rw-r--r--sys/amd64/amd64/trap.c28
-rw-r--r--sys/i386/i386/trap.c28
-rw-r--r--sys/i386/linux/linux_sysvec.c5
-rw-r--r--sys/kern/kern_ktrace.c10
-rw-r--r--sys/kern/kern_sig.c4
-rw-r--r--sys/kern/makesyscalls.sh37
-rw-r--r--sys/kern/subr_trap.c7
-rw-r--r--sys/kern/syscalls.master62
-rw-r--r--sys/sparc64/sparc64/trap.c16
10 files changed, 114 insertions, 95 deletions
diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c
index 99071fe..9b7d8f4 100644
--- a/sys/alpha/alpha/trap.c
+++ b/sys/alpha/alpha/trap.c
@@ -611,9 +611,7 @@ trap(a0, a1, a2, entry, framep)
framep->tf_regs[FRAME_TRAPARG_A0] = a0;
framep->tf_regs[FRAME_TRAPARG_A1] = a1;
framep->tf_regs[FRAME_TRAPARG_A2] = a2;
- mtx_lock(&Giant);
trapsignal(p, i, ucode);
- mtx_unlock(&Giant);
out:
if (user) {
framep->tf_regs[FRAME_SP] = alpha_pal_rdusp();
@@ -748,8 +746,6 @@ syscall(code, framep)
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL)) {
- if (!mtx_owned(&Giant))
- mtx_lock(&Giant);
ktrsyscall(p->p_tracep, code, (callp->sy_narg & SYF_ARGMASK), args + hidden);
}
#endif
@@ -789,17 +785,17 @@ syscall(code, framep)
userret(p, framep, sticks);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
- if (!mtx_owned(&Giant))
- mtx_lock(&Giant);
ktrsysret(p->p_tracep, code, error, p->p_retval[0]);
}
#endif
/*
- * Release Giant if we had to get it
+ * Release Giant if we had to get it. Don't use mtx_owned(),
+ * we want to catch broken syscalls.
*/
- if (mtx_owned(&Giant))
+ if ((callp->sy_narg & SYF_MPSAFE) == 0) {
mtx_unlock(&Giant);
+ }
/*
* This works because errno is findable through the
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index 11effc3..4e72f9b 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -603,7 +603,6 @@ restart:
goto out;
}
- mtx_lock(&Giant);
/* Translate fault for emulators (e.g. Linux) */
if (*p->p_sysent->sv_transtrap)
i = (*p->p_sysent->sv_transtrap)(i, type);
@@ -619,11 +618,10 @@ restart:
uprintf("\n");
}
#endif
- mtx_unlock(&Giant);
user:
userret(p, &frame, sticks);
- if (mtx_owned(&Giant))
+ if (mtx_owned(&Giant)) /* XXX why would Giant be owned here? */
mtx_unlock(&Giant);
out:
return;
@@ -1034,9 +1032,10 @@ syscall(frame)
#ifdef DIAGNOSTIC
if (ISPL(frame.tf_cs) != SEL_UPL) {
- mtx_lock(&Giant);
+ mtx_lock(&Giant); /* try to stabilize the system XXX */
panic("syscall");
/* NOT REACHED */
+ mtx_unlock(&Giant);
}
#endif
@@ -1047,11 +1046,9 @@ syscall(frame)
if (p->p_sysent->sv_prepsyscall) {
/*
- * The prep code is not MP aware.
+ * The prep code is MP aware.
*/
- mtx_lock(&Giant);
(*p->p_sysent->sv_prepsyscall)(&frame, args, &code, &params);
- mtx_unlock(&Giant);
} else {
/*
* Need to check if this is a 32 bit or 64 bit syscall.
@@ -1084,11 +1081,10 @@ syscall(frame)
narg = callp->sy_narg & SYF_ARGMASK;
/*
- * copyin is MP aware, but the tracing code is not
+ * copyin and the ktrsyscall()/ktrsysret() code is MP-aware
*/
if (params && (i = narg * sizeof(int)) &&
(error = copyin(params, (caddr_t)args, (u_int)i))) {
- mtx_lock(&Giant);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, narg, args);
@@ -1110,8 +1106,6 @@ syscall(frame)
* we are ktracing
*/
if (KTRPOINT(p, KTR_SYSCALL)) {
- if (!mtx_owned(&Giant))
- mtx_lock(&Giant);
ktrsyscall(p->p_tracep, code, narg, args);
}
#endif
@@ -1157,8 +1151,6 @@ bad:
* Traced syscall.
*/
if ((frame.tf_eflags & PSL_T) && !(frame.tf_eflags & PSL_VM)) {
- if (!mtx_owned(&Giant))
- mtx_lock(&Giant);
frame.tf_eflags &= ~PSL_T;
trapsignal(p, SIGTRAP, 0);
}
@@ -1170,17 +1162,18 @@ bad:
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
- if (!mtx_owned(&Giant))
- mtx_lock(&Giant);
ktrsysret(p->p_tracep, code, error, p->p_retval[0]);
}
#endif
/*
- * Release Giant if we had to get it
+ * Release Giant if we previously set it. Do not
+ * release based on mtx_owned() - we want to catch
+ * broken syscalls.
*/
- if (mtx_owned(&Giant))
+ if ((callp->sy_narg & SYF_MPSAFE) == 0) {
mtx_unlock(&Giant);
+ }
/*
* This works because errno is findable through the
@@ -1198,3 +1191,4 @@ bad:
mtx_assert(&sched_lock, MA_NOTOWNED);
mtx_assert(&Giant, MA_NOTOWNED);
}
+
diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c
index 11effc3..4e72f9b 100644
--- a/sys/i386/i386/trap.c
+++ b/sys/i386/i386/trap.c
@@ -603,7 +603,6 @@ restart:
goto out;
}
- mtx_lock(&Giant);
/* Translate fault for emulators (e.g. Linux) */
if (*p->p_sysent->sv_transtrap)
i = (*p->p_sysent->sv_transtrap)(i, type);
@@ -619,11 +618,10 @@ restart:
uprintf("\n");
}
#endif
- mtx_unlock(&Giant);
user:
userret(p, &frame, sticks);
- if (mtx_owned(&Giant))
+ if (mtx_owned(&Giant)) /* XXX why would Giant be owned here? */
mtx_unlock(&Giant);
out:
return;
@@ -1034,9 +1032,10 @@ syscall(frame)
#ifdef DIAGNOSTIC
if (ISPL(frame.tf_cs) != SEL_UPL) {
- mtx_lock(&Giant);
+ mtx_lock(&Giant); /* try to stabilize the system XXX */
panic("syscall");
/* NOT REACHED */
+ mtx_unlock(&Giant);
}
#endif
@@ -1047,11 +1046,9 @@ syscall(frame)
if (p->p_sysent->sv_prepsyscall) {
/*
- * The prep code is not MP aware.
+ * The prep code is MP aware.
*/
- mtx_lock(&Giant);
(*p->p_sysent->sv_prepsyscall)(&frame, args, &code, &params);
- mtx_unlock(&Giant);
} else {
/*
* Need to check if this is a 32 bit or 64 bit syscall.
@@ -1084,11 +1081,10 @@ syscall(frame)
narg = callp->sy_narg & SYF_ARGMASK;
/*
- * copyin is MP aware, but the tracing code is not
+ * copyin and the ktrsyscall()/ktrsysret() code is MP-aware
*/
if (params && (i = narg * sizeof(int)) &&
(error = copyin(params, (caddr_t)args, (u_int)i))) {
- mtx_lock(&Giant);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, narg, args);
@@ -1110,8 +1106,6 @@ syscall(frame)
* we are ktracing
*/
if (KTRPOINT(p, KTR_SYSCALL)) {
- if (!mtx_owned(&Giant))
- mtx_lock(&Giant);
ktrsyscall(p->p_tracep, code, narg, args);
}
#endif
@@ -1157,8 +1151,6 @@ bad:
* Traced syscall.
*/
if ((frame.tf_eflags & PSL_T) && !(frame.tf_eflags & PSL_VM)) {
- if (!mtx_owned(&Giant))
- mtx_lock(&Giant);
frame.tf_eflags &= ~PSL_T;
trapsignal(p, SIGTRAP, 0);
}
@@ -1170,17 +1162,18 @@ bad:
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
- if (!mtx_owned(&Giant))
- mtx_lock(&Giant);
ktrsysret(p->p_tracep, code, error, p->p_retval[0]);
}
#endif
/*
- * Release Giant if we had to get it
+ * Release Giant if we previously set it. Do not
+ * release based on mtx_owned() - we want to catch
+ * broken syscalls.
*/
- if (mtx_owned(&Giant))
+ if ((callp->sy_narg & SYF_MPSAFE) == 0) {
mtx_unlock(&Giant);
+ }
/*
* This works because errno is findable through the
@@ -1198,3 +1191,4 @@ bad:
mtx_assert(&sched_lock, MA_NOTOWNED);
mtx_assert(&Giant, MA_NOTOWNED);
}
+
diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c
index c37a03f..fbb6d6f 100644
--- a/sys/i386/linux/linux_sysvec.c
+++ b/sys/i386/linux/linux_sysvec.c
@@ -132,6 +132,8 @@ int linux_to_bsd_signal[LINUX_SIGTBLSZ] = {
/*
* If FreeBSD & Linux have a difference of opinion about what a trap
* means, deal with it here.
+ *
+ * MPSAFE
*/
static int
translate_traps(int signal, int trap_code)
@@ -687,6 +689,9 @@ linux_rt_sigreturn(p, args)
return (EJUSTRETURN);
}
+/*
+ * MPSAFE
+ */
static void
linux_prepsyscall(struct trapframe *tf, int *args, u_int *code, caddr_t *params)
{
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c
index a37ad22..9b97944 100644
--- a/sys/kern/kern_ktrace.c
+++ b/sys/kern/kern_ktrace.c
@@ -78,6 +78,9 @@ ktrgetheader(type)
return (kth);
}
+/*
+ * MPSAFE
+ */
void
ktrsyscall(vp, code, narg, args)
struct vnode *vp;
@@ -92,6 +95,7 @@ ktrsyscall(vp, code, narg, args)
register_t *argp;
int i;
+ mtx_lock(&Giant);
p->p_traceflag |= KTRFAC_ACTIVE;
kth = ktrgetheader(KTR_SYSCALL);
MALLOC(ktp, struct ktr_syscall *, len, M_KTRACE, M_WAITOK);
@@ -106,8 +110,12 @@ ktrsyscall(vp, code, narg, args)
FREE(ktp, M_KTRACE);
FREE(kth, M_KTRACE);
p->p_traceflag &= ~KTRFAC_ACTIVE;
+ mtx_unlock(&Giant);
}
+/*
+ * MPSAFE
+ */
void
ktrsysret(vp, code, error, retval)
struct vnode *vp;
@@ -118,6 +126,7 @@ ktrsysret(vp, code, error, retval)
struct ktr_sysret ktp;
struct proc *p = curproc; /* XXX */
+ mtx_lock(&Giant);
p->p_traceflag |= KTRFAC_ACTIVE;
kth = ktrgetheader(KTR_SYSRET);
ktp.ktr_code = code;
@@ -130,6 +139,7 @@ ktrsysret(vp, code, error, retval)
ktrwrite(vp, kth, NULL);
FREE(kth, M_KTRACE);
p->p_traceflag &= ~KTRFAC_ACTIVE;
+ mtx_unlock(&Giant);
}
void
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 6fcea78..49e8307 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1040,6 +1040,8 @@ pgsignal(pgrp, sig, checkctty)
* Send a signal caused by a trap to the current process.
* If it will be caught immediately, deliver it with correct code.
* Otherwise, post it normally.
+ *
+ * MPSAFE
*/
void
trapsignal(p, sig, code)
@@ -1049,6 +1051,7 @@ trapsignal(p, sig, code)
{
register struct sigacts *ps = p->p_sigacts;
+ mtx_lock(&Giant);
PROC_LOCK(p);
if ((p->p_flag & P_TRACED) == 0 && SIGISMEMBER(p->p_sigcatch, sig) &&
!SIGISMEMBER(p->p_sigmask, sig)) {
@@ -1081,6 +1084,7 @@ trapsignal(p, sig, code)
psignal(p, sig);
}
PROC_UNLOCK(p);
+ mtx_unlock(&Giant);
}
/*
diff --git a/sys/kern/makesyscalls.sh b/sys/kern/makesyscalls.sh
index bead4cc..168426e 100644
--- a/sys/kern/makesyscalls.sh
+++ b/sys/kern/makesyscalls.sh
@@ -268,13 +268,36 @@ s/\$//g
for (i = 5; i <= NF; i++)
comment = comment " " $i
}
- # if the "MPSAFE" keyword is found, note it and shift the line
- mpsafe = ""
- $2 == "MPSAFE" {
- for (i = 2; i <= NF; i++)
- $i = $(i + 1);
- NF -= 1;
- mpsafe = "SYF_MPSAFE | "
+
+ # The 'M' type prefix
+ #
+ {
+ mpsafe = "SYF_MPSAFE | ";
+ if ($2 == "MSTD") {
+ $2 = "STD";
+ } else if ($2 == "MNODEF") {
+ $2 = "NODEF";
+ } else if ($2 == "MNOARGS") {
+ $2 = "NOARGS";
+ } else if ($2 == "MNOPROTO") {
+ $2 = "NOPROTO";
+ } else if ($2 == "MNOIMPL") {
+ $2 = "NOIMPL";
+ } else if ($2 == "MNOSTD") {
+ $2 = "NOSTD";
+ } else if ($2 == "MCOMPAT") {
+ $2 = "COMPAT";
+ } else if ($2 == "MCPT_NOA") {
+ $2 = "CPT_NOA";
+ } else if ($2 == "MLIBCOMPAT") {
+ $2 = "LIBCOMPAT";
+ } else if ($2 == "MOBSOL") {
+ $2 = "OBSOL";
+ } else if ($2 == "MUNIMPL") {
+ $2 = "UNIMPL";
+ } else {
+ mpsafe = "";
+ }
}
$2 == "STD" || $2 == "NODEF" || $2 == "NOARGS" || $2 == "NOPROTO" \
|| $2 == "NOIMPL" || $2 == "NOSTD" {
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index b903660..727fe69 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -58,6 +58,8 @@
/*
* Define the code needed before returning to user mode, for
* trap and syscall.
+ *
+ * MPSAFE
*/
void
userret(p, frame, oticks)
@@ -71,8 +73,8 @@ userret(p, frame, oticks)
PROC_LOCK(p);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
- mtx_unlock(&Giant);
PROC_UNLOCK(p);
+ mtx_unlock(&Giant);
mtx_lock_spin(&sched_lock);
p->p_pri.pri_level = p->p_pri.pri_user;
@@ -166,7 +168,6 @@ ast(framep)
PCB_NPXTRAP);
ucode = npxtrap();
if (ucode != -1) {
- mtx_lock(&Giant);
trapsignal(p, SIGFPE, ucode);
}
}
@@ -178,8 +179,6 @@ ast(framep)
}
userret(p, framep, sticks);
- if (mtx_owned(&Giant))
- mtx_unlock(&Giant);
s = critical_enter();
}
mtx_assert(&Giant, MA_NOTOWNED);
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index e96bca9..b8ff694 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -4,12 +4,11 @@
; System call name/number master file.
; Processed to created init_sysent.c, syscalls.c and syscall.h.
-; Columns: number [MPSAFE] type nargs namespc name alt{name,tag,rtyp}/comments
+; Columns: number [M]type nargs namespc name alt{name,tag,rtyp}/comments
; number system call number, must be in order
-; MPSAFE optional field, specifies that syscall does not want the
-; BGL grabbed automatically (it is SMP safe).
-; type one of STD, OBSOL, UNIMPL, COMPAT, CPT_NOA, LIBCOMPAT,
-; NODEF, NOARGS, NOPROTO, NOIMPL, NOSTD
+; type one of [M]STD, [M]OBSOL, [M]UNIMPL, [M]COMPAT, [M]CPT_NOA,
+; [M]LIBCOMPAT, [M]NODEF, [M]NOARGS, [M]NOPROTO, [M]NOIMPL,
+; [M]NOSTD
; namespc one of POSIX, BSD, NOHIDE
; name psuedo-prototype of syscall routine
; If one of the following alts is different, then all appear:
@@ -19,6 +18,9 @@
; for UNIMPL/OBSOL, name continues with comments
; types:
+; [M] e.g. like MSTD -- means the system call is MP-safe. If no
+; M prefix is used, the syscall wrapper will obtain the Giant
+; lock for the syscall.
; STD always included
; COMPAT included on COMPAT #ifdef
; LIBCOMPAT included on COMPAT #ifdef, and placed in syscall.h
@@ -61,7 +63,7 @@
14 STD POSIX { int mknod(char *path, int mode, int dev); }
15 STD POSIX { int chmod(char *path, int mode); }
16 STD POSIX { int chown(char *path, int uid, int gid); }
-17 MPSAFE STD BSD { int obreak(char *nsize); } break obreak_args int
+17 MSTD BSD { int obreak(char *nsize); } break obreak_args int
18 STD BSD { int getfsstat(struct statfs *buf, long bufsize, \
int flags); }
19 COMPAT POSIX { long lseek(int fd, long offset, int whence); }
@@ -71,8 +73,8 @@
; XXX `path' should have type `const char *' but we're not ready for that.
22 STD BSD { int unmount(char *path, int flags); }
23 STD POSIX { int setuid(uid_t uid); }
-24 MPSAFE STD POSIX { uid_t getuid(void); }
-25 MPSAFE STD POSIX { uid_t geteuid(void); }
+24 MSTD POSIX { uid_t getuid(void); }
+25 MSTD POSIX { uid_t geteuid(void); }
26 STD BSD { int ptrace(int req, pid_t pid, caddr_t addr, \
int data); }
27 STD BSD { int recvmsg(int s, struct msghdr *msg, int flags); }
@@ -99,8 +101,8 @@
int pid); }
46 COMPAT POSIX { int sigaction(int signum, struct osigaction *nsa, \
struct osigaction *osa); }
-47 MPSAFE STD POSIX { gid_t getgid(void); }
-48 MPSAFE COMPAT POSIX { int sigprocmask(int how, osigset_t mask); }
+47 MSTD POSIX { gid_t getgid(void); }
+48 MCOMPAT POSIX { int sigprocmask(int how, osigset_t mask); }
; XXX note nonstandard (bogus) calling convention - the libc stub passes
; us the mask, not a pointer to it, and we return the old mask as the
; (int) return value.
@@ -115,32 +117,32 @@
57 STD POSIX { int symlink(char *path, char *link); }
58 STD POSIX { int readlink(char *path, char *buf, int count); }
59 STD POSIX { int execve(char *fname, char **argv, char **envv); }
-60 MPSAFE STD POSIX { int umask(int newmask); } umask umask_args int
+60 MSTD POSIX { int umask(int newmask); } umask umask_args int
61 STD BSD { int chroot(char *path); }
62 COMPAT POSIX { int fstat(int fd, struct ostat *sb); }
63 COMPAT BSD { int getkerninfo(int op, char *where, size_t *size, \
int arg); } getkerninfo getkerninfo_args int
-64 MPSAFE COMPAT BSD { int getpagesize(void); } \
+64 MCOMPAT BSD { int getpagesize(void); } \
getpagesize getpagesize_args int
65 STD BSD { int msync(void *addr, size_t len, int flags); }
66 STD BSD { int vfork(void); }
67 OBSOL NOHIDE vread
68 OBSOL NOHIDE vwrite
-69 MPSAFE STD BSD { int sbrk(int incr); }
-70 MPSAFE STD BSD { int sstk(int incr); }
-71 MPSAFE COMPAT BSD { int mmap(void *addr, int len, int prot, \
+69 MSTD BSD { int sbrk(int incr); }
+70 MSTD BSD { int sstk(int incr); }
+71 MCOMPAT BSD { int mmap(void *addr, int len, int prot, \
int flags, int fd, long pos); }
-72 MPSAFE STD BSD { int ovadvise(int anom); } vadvise ovadvise_args int
-73 MPSAFE STD BSD { int munmap(void *addr, size_t len); }
-74 MPSAFE STD BSD { int mprotect(const void *addr, size_t len, int prot); }
-75 MPSAFE STD BSD { int madvise(void *addr, size_t len, int behav); }
+72 MSTD BSD { int ovadvise(int anom); } vadvise ovadvise_args int
+73 MSTD BSD { int munmap(void *addr, size_t len); }
+74 MSTD BSD { int mprotect(const void *addr, size_t len, int prot); }
+75 MSTD BSD { int madvise(void *addr, size_t len, int behav); }
76 OBSOL NOHIDE vhangup
77 OBSOL NOHIDE vlimit
-78 MPSAFE STD BSD { int mincore(const void *addr, size_t len, \
+78 MSTD BSD { int mincore(const void *addr, size_t len, \
char *vec); }
79 STD POSIX { int getgroups(u_int gidsetsize, gid_t *gidset); }
80 STD POSIX { int setgroups(u_int gidsetsize, gid_t *gidset); }
-81 MPSAFE STD POSIX { int getpgrp(void); }
+81 MSTD POSIX { int getpgrp(void); }
82 STD POSIX { int setpgid(int pid, int pgid); }
83 STD BSD { int setitimer(u_int which, struct itimerval *itv, \
struct itimerval *oitv); }
@@ -188,7 +190,7 @@
113 COMPAT BSD { int recvmsg(int s, struct omsghdr *msg, int flags); }
114 COMPAT BSD { int sendmsg(int s, caddr_t msg, int flags); }
115 OBSOL NOHIDE vtrace
-116 MPSAFE STD BSD { int gettimeofday(struct timeval *tp, \
+116 MSTD BSD { int gettimeofday(struct timeval *tp, \
struct timezone *tzp); }
117 STD BSD { int getrusage(int who, struct rusage *rusage); }
118 STD BSD { int getsockopt(int s, int level, int name, \
@@ -305,7 +307,7 @@
setrlimit __setrlimit_args int
196 STD BSD { int getdirentries(int fd, char *buf, u_int count, \
long *basep); }
-197 MPSAFE STD BSD { caddr_t mmap(caddr_t addr, size_t len, int prot, \
+197 MSTD BSD { caddr_t mmap(caddr_t addr, size_t len, int prot, \
int flags, int fd, int pad, off_t pos); }
198 STD NOHIDE { int nosys(void); } __syscall __syscall_args int
199 STD POSIX { off_t lseek(int fd, int pad, off_t offset, \
@@ -317,8 +319,8 @@
__sysctl sysctl_args int
; properly, __sysctl should be a NOHIDE, but making an exception
; here allows to avoid one in libc/sys/Makefile.inc.
-203 MPSAFE STD BSD { int mlock(const void *addr, size_t len); }
-204 MPSAFE STD BSD { int munlock(const void *addr, size_t len); }
+203 MSTD BSD { int mlock(const void *addr, size_t len); }
+204 MSTD BSD { int munlock(const void *addr, size_t len); }
205 STD BSD { int undelete(char *path); }
206 STD BSD { int futimes(int fd, struct timeval *tptr); }
207 STD BSD { int getpgid(pid_t pid); }
@@ -385,7 +387,7 @@
248 UNIMPL NOHIDE nosys
249 UNIMPL NOHIDE nosys
; syscall numbers initially used in OpenBSD
-250 MPSAFE STD BSD { int minherit(void *addr, size_t len, int inherit); }
+250 MSTD BSD { int minherit(void *addr, size_t len, int inherit); }
251 STD BSD { int rfork(int flags); }
252 STD BSD { int openbsd_poll(struct pollfd *fds, u_int nfds, \
int timeout); }
@@ -413,7 +415,7 @@
274 STD BSD { int lchmod(char *path, mode_t mode); }
275 NOPROTO BSD { int lchown(char *path, uid_t uid, gid_t gid); } netbsd_lchown lchown_args int
276 STD BSD { int lutimes(char *path, struct timeval *tptr); }
-277 MPSAFE NOPROTO BSD { int msync(void *addr, size_t len, int flags); } netbsd_msync msync_args int
+277 MNOPROTO BSD { int msync(void *addr, size_t len, int flags); } netbsd_msync msync_args int
278 STD BSD { int nstat(char *path, struct nstat *ub); }
279 STD BSD { int nfstat(int fd, struct nstat *sb); }
280 STD BSD { int nlstat(char *path, struct nstat *ub); }
@@ -462,8 +464,8 @@
321 STD BSD { int yield(void); }
322 OBSOL NOHIDE thr_sleep
323 OBSOL NOHIDE thr_wakeup
-324 MPSAFE STD BSD { int mlockall(int how); }
-325 MPSAFE STD BSD { int munlockall(void); }
+324 MSTD BSD { int mlockall(int how); }
+325 MSTD BSD { int munlockall(void); }
326 STD BSD { int __getcwd(u_char *buf, u_int buflen); }
327 STD POSIX { int sched_setparam (pid_t pid, const struct sched_param *param); }
@@ -482,7 +484,7 @@
337 STD BSD { int kldsym(int fileid, int cmd, void *data); }
338 STD BSD { int jail(struct jail *jail); }
339 UNIMPL BSD pioctl
-340 MPSAFE STD POSIX { int sigprocmask(int how, const sigset_t *set, \
+340 MSTD POSIX { int sigprocmask(int how, const sigset_t *set, \
sigset_t *oset); }
341 STD POSIX { int sigsuspend(const sigset_t *sigmask); }
342 STD POSIX { int sigaction(int sig, const struct sigaction *act, \
diff --git a/sys/sparc64/sparc64/trap.c b/sys/sparc64/sparc64/trap.c
index 7de6fac..c5ca95a 100644
--- a/sys/sparc64/sparc64/trap.c
+++ b/sys/sparc64/sparc64/trap.c
@@ -221,13 +221,10 @@ trap(struct trapframe *tf)
panic("trap: %s", trap_msg[type & ~T_KERNEL]);
trapsig:
- mtx_lock(&Giant);
/* Translate fault for emulators. */
if (p->p_sysent->sv_transtrap != NULL)
sig = (p->p_sysent->sv_transtrap)(sig, type);
-
trapsignal(p, sig, ucode);
- mtx_unlock(&Giant);
user:
userret(p, tf, sticks);
if (mtx_owned(&Giant))
@@ -395,12 +392,10 @@ syscall(struct proc *p, struct trapframe *tf, u_int sticks)
if (p->p_sysent->sv_prepsyscall) {
/*
- * The prep code is not MP aware.
+ * The prep code is MP aware.
*/
#if 0
- mtx_lock(&Giant);
(*p->p_sysent->sv_prepsyscall)(tf, args, &code, &params);
- mtx_unlock(&Giant);
#endif
} else if (code == SYS_syscall || code == SYS___syscall) {
code = tf->tf_out[reg++];
@@ -444,8 +439,6 @@ syscall(struct proc *p, struct trapframe *tf, u_int sticks)
* we are ktracing
*/
if (KTRPOINT(p, KTR_SYSCALL)) {
- if (!mtx_owned(&Giant))
- mtx_lock(&Giant);
ktrsyscall(p->p_tracep, code, narg, args);
}
#endif
@@ -498,16 +491,15 @@ bad:
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET)) {
- if (!mtx_owned(&Giant))
- mtx_lock(&Giant);
ktrsysret(p->p_tracep, code, error, p->p_retval[0]);
}
#endif
/*
- * Release Giant if we had to get it
+ * Release Giant if we had to get it. Don't use mtx_owned(),
+ * we want to catch broken syscalls.
*/
- if (mtx_owned(&Giant))
+ if ((callp->sy_narg & SYF_MPSAFE) == 0)
mtx_unlock(&Giant);
/*
OpenPOWER on IntegriCloud