From 834f77bfedd96362776e4ba1db824e80283f4b27 Mon Sep 17 00:00:00 2001 From: markj Date: Sun, 2 Oct 2016 01:14:26 +0000 Subject: MFC r306304: Move implementations of uread() and uwrite() to the illumos compat layer. --- .../compat/opensolaris/kern/opensolaris_proc.c | 57 ++++++++++++++++++++++ sys/cddl/compat/opensolaris/sys/proc.h | 3 ++ .../opensolaris/uts/intel/dtrace/fasttrap_isa.c | 28 +---------- .../opensolaris/uts/powerpc/dtrace/fasttrap_isa.c | 26 ---------- 4 files changed, 61 insertions(+), 53 deletions(-) create mode 100644 sys/cddl/compat/opensolaris/kern/opensolaris_proc.c (limited to 'sys/cddl') diff --git a/sys/cddl/compat/opensolaris/kern/opensolaris_proc.c b/sys/cddl/compat/opensolaris/kern/opensolaris_proc.c new file mode 100644 index 0000000..652fa89 --- /dev/null +++ b/sys/cddl/compat/opensolaris/kern/opensolaris_proc.c @@ -0,0 +1,57 @@ +/*- + * Copyright 2016 Mark Johnston + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR 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 AUTHOR 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +int +uread(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr) +{ + ssize_t n; + + PHOLD(p); + n = proc_readmem(curthread, p, uaddr, kaddr, len); + PRELE(p); + if (n != len) + return (ENOMEM); + return (0); +} + +int +uwrite(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr) +{ + ssize_t n; + + PHOLD(p); + n = proc_writemem(curthread, p, uaddr, kaddr, len); + PRELE(p); + if (n != len) + return (ENOMEM); + return (0); +} diff --git a/sys/cddl/compat/opensolaris/sys/proc.h b/sys/cddl/compat/opensolaris/sys/proc.h index 5c9e8de..ce503cf 100644 --- a/sys/cddl/compat/opensolaris/sys/proc.h +++ b/sys/cddl/compat/opensolaris/sys/proc.h @@ -92,6 +92,9 @@ do_thread_create(caddr_t stk, size_t stksize, void (*proc)(void *), void *arg, do_thread_create(stk, stksize, proc, arg, len, pp, state, pri) #define thread_exit() kthread_exit() +int uread(proc_t *, void *, size_t, uintptr_t); +int uwrite(proc_t *, void *, size_t, uintptr_t); + #endif /* _KERNEL */ #endif /* _OPENSOLARIS_SYS_PROC_H_ */ diff --git a/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c b/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c index 5b3f485..4f2619d 100644 --- a/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c +++ b/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c @@ -59,34 +59,8 @@ #include #else #include - -static int -uread(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr) -{ - ssize_t n; - - PHOLD(p); - n = proc_readmem(curthread, p, uaddr, kaddr, len); - PRELE(p); - if (n != len) - return (ENOMEM); - return (0); -} - -static int -uwrite(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr) -{ - ssize_t n; - - PHOLD(p); - n = proc_writemem(curthread, p, uaddr, kaddr, len); - PRELE(p); - if (n != len) - return (ENOMEM); - return (0); -} - #endif /* illumos */ + #ifdef __i386__ #define r_rax r_eax #define r_rbx r_ebx diff --git a/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c b/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c index e8dd684..b0fc581 100644 --- a/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c +++ b/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c @@ -44,32 +44,6 @@ #define OP_RA(x) (((x) & 0x001F0000) >> 16) #define OP_RB(x) (((x) & 0x0000F100) >> 11) -static int -uread(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr) -{ - ssize_t n; - - PHOLD(p); - n = proc_readmem(curthread, p, uaddr, kaddr, len); - PRELE(p); - if (n <= 0 || n < len) - return (ENOMEM); - return (0); -} - -static int -uwrite(proc_t *p, void *kaddr, size_t len, uintptr_t uaddr) -{ - ssize_t n; - - PHOLD(p); - n = proc_writemem(curthread, p, uaddr, kaddr, len); - PRELE(p); - if (n <= 0 || n < len) - return (ENOMEM); - return (0); -} - int fasttrap_tracepoint_install(proc_t *p, fasttrap_tracepoint_t *tp) { -- cgit v1.1