Make copy{in,out}_proc work on all processes (including curproc) by
special-casing the curproc case. Use copy{in,out}_proc directly instead of checking for curproc each time. Discussed with thorpej.
This commit is contained in:
parent
32bff6afc2
commit
de124326cb
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: core_elf32.c,v 1.20 2005/07/06 20:56:49 kleink Exp $ */
|
||||
/* $NetBSD: core_elf32.c,v 1.21 2005/07/06 22:30:42 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||
|
@ -40,7 +40,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.20 2005/07/06 20:56:49 kleink Exp $");
|
||||
__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.21 2005/07/06 22:30:42 christos Exp $");
|
||||
|
||||
/* If not included by core_elf64.c, ELFSIZE won't be defined. */
|
||||
#ifndef ELFSIZE
|
||||
|
@ -268,12 +268,8 @@ ELFNAMEEND(coredump_writeseghdrs)(struct proc *p, void *iocookie,
|
|||
int i;
|
||||
|
||||
end -= slen;
|
||||
if (__predict_true(p == curproc))
|
||||
error = copyin((void *) end, buf, slen);
|
||||
else
|
||||
error = copyin_proc(p, (void *) end, buf, slen);
|
||||
if (error)
|
||||
return (error);
|
||||
if ((error = copyin_proc(p, (void *)end, buf, slen)) != 0)
|
||||
return error;
|
||||
|
||||
ep = (const long *) &buf[slen / sizeof(buf[0])];
|
||||
for (i = 0, ep--; buf <= ep; ep--, i++) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_subr.c,v 1.117 2005/06/23 23:15:12 thorpej Exp $ */
|
||||
/* $NetBSD: kern_subr.c,v 1.118 2005/07/06 22:30:42 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -86,7 +86,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.117 2005/06/23 23:15:12 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.118 2005/07/06 22:30:42 christos Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_md.h"
|
||||
|
@ -170,19 +170,10 @@ uiomove(void *buf, size_t n, struct uio *uio)
|
|||
if (curcpu()->ci_schedstate.spc_flags &
|
||||
SPCF_SHOULDYIELD)
|
||||
preempt(1);
|
||||
if (__predict_true(p == curproc)) {
|
||||
if (uio->uio_rw == UIO_READ)
|
||||
error = copyout(cp, iov->iov_base, cnt);
|
||||
error = copyout_proc(p, cp, iov->iov_base, cnt);
|
||||
else
|
||||
error = copyin(iov->iov_base, cp, cnt);
|
||||
} else {
|
||||
if (uio->uio_rw == UIO_READ)
|
||||
error = copyout_proc(p, cp,
|
||||
iov->iov_base, cnt);
|
||||
else
|
||||
error = copyin_proc(p, iov->iov_base,
|
||||
cp, cnt);
|
||||
}
|
||||
error = copyin_proc(p, iov->iov_base, cp, cnt);
|
||||
if (error)
|
||||
goto out;
|
||||
break;
|
||||
|
@ -276,6 +267,9 @@ copyin_proc(struct proc *p, const void *uaddr, void *kaddr, size_t len)
|
|||
if (len == 0)
|
||||
return (0);
|
||||
|
||||
if (__predict_true(p == curproc))
|
||||
return copyin(uaddr, kaddr, len);
|
||||
|
||||
iov.iov_base = kaddr;
|
||||
iov.iov_len = len;
|
||||
uio.uio_iov = &iov;
|
||||
|
@ -309,6 +303,9 @@ copyout_proc(struct proc *p, const void *kaddr, void *uaddr, size_t len)
|
|||
if (len == 0)
|
||||
return (0);
|
||||
|
||||
if (__predict_true(p == curproc))
|
||||
return copyout(kaddr, uaddr, len);
|
||||
|
||||
iov.iov_base = __UNCONST(kaddr); /* XXXUNCONST cast away const */
|
||||
iov.iov_len = len;
|
||||
uio.uio_iov = &iov;
|
||||
|
|
Loading…
Reference in New Issue