CVS commit: src/external/cddl/osnet/dev/fbt/x86

2021-08-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Aug 18 11:26:17 UTC 2021

Modified Files:
src/external/cddl/osnet/dev/fbt/x86: fbt_isa.c

Log Message:
PR/56355: Exclude the symbol trap, not all symbols other than trap.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c
diff -u src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c:1.5 src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c:1.6
--- src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c:1.5	Sun Aug 15 16:33:57 2021
+++ src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c	Wed Aug 18 11:26:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt_isa.c,v 1.5 2021/08/15 16:33:57 christos Exp $	*/
+/*	$NetBSD: fbt_isa.c,v 1.6 2021/08/18 11:26:17 riastradh Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -251,7 +251,7 @@ fbt_provide_module_cb(const char *name, 
 	/*
 	 * Exclude some more symbols which can be called from probe context.
 	 */
-	if (strcmp(name, "trap") ||
+	if (strcmp(name, "trap") == 0 ||
 	strcmp(name, "x86_curcpu") == 0 ||
 	strcmp(name, "x86_curlwp") == 0) {
 		return 0;



CVS commit: src/external/cddl/osnet/dev/fbt/x86

2021-08-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 15 16:33:57 UTC 2021

Modified Files:
src/external/cddl/osnet/dev/fbt/x86: fbt_isa.c

Log Message:
PR/56355: Taylor Campbell: restore strcmp() over strncmp()


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c
diff -u src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c:1.4 src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c:1.5
--- src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c:1.4	Wed Aug 11 07:16:49 2021
+++ src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c	Sun Aug 15 12:33:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt_isa.c,v 1.4 2021/08/11 11:16:49 christos Exp $	*/
+/*	$NetBSD: fbt_isa.c,v 1.5 2021/08/15 16:33:57 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -251,9 +251,9 @@ fbt_provide_module_cb(const char *name, 
 	/*
 	 * Exclude some more symbols which can be called from probe context.
 	 */
-	if (strncmp(name, "trap", 4) ||
-	strncmp(name, "x86_curcpu", 10) == 0 ||
-	strncmp(name, "x86_curlwp", 10) == 0) {
+	if (strcmp(name, "trap") ||
+	strcmp(name, "x86_curcpu") == 0 ||
+	strcmp(name, "x86_curlwp") == 0) {
 		return 0;
 	}
 #endif



CVS commit: src/external/cddl/osnet/dev/fbt/x86

2021-08-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 11 11:16:49 UTC 2021

Modified Files:
src/external/cddl/osnet/dev/fbt/x86: fbt_isa.c

Log Message:
PR/56355: Brad Harder: dtrace triggers double-fault in supervisor mode


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c
diff -u src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c:1.3 src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c:1.4
--- src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c:1.3	Sat May  2 07:37:17 2020
+++ src/external/cddl/osnet/dev/fbt/x86/fbt_isa.c	Wed Aug 11 07:16:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt_isa.c,v 1.3 2020/05/02 11:37:17 maxv Exp $	*/
+/*	$NetBSD: fbt_isa.c,v 1.4 2021/08/11 11:16:49 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -251,8 +251,9 @@ fbt_provide_module_cb(const char *name, 
 	/*
 	 * Exclude some more symbols which can be called from probe context.
 	 */
-	if (strcmp(name, "x86_curcpu") == 0 ||
-	strcmp(name, "x86_curlwp") == 0) {
+	if (strncmp(name, "trap", 4) ||
+	strncmp(name, "x86_curcpu", 10) == 0 ||
+	strncmp(name, "x86_curlwp", 10) == 0) {
 		return 0;
 	}
 #endif



CVS commit: src/external/cddl/osnet/dev/dtrace/mips

2021-04-06 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Wed Apr  7 01:54:32 UTC 2021

Modified Files:
src/external/cddl/osnet/dev/dtrace/mips: dtrace_isa.c

Log Message:
Use NAL (nop-and-link) to get the current PC.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/dev/dtrace/mips/dtrace_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/mips/dtrace_isa.c
diff -u src/external/cddl/osnet/dev/dtrace/mips/dtrace_isa.c:1.1 src/external/cddl/osnet/dev/dtrace/mips/dtrace_isa.c:1.2
--- src/external/cddl/osnet/dev/dtrace/mips/dtrace_isa.c:1.1	Mon Mar 29 05:17:09 2021
+++ src/external/cddl/osnet/dev/dtrace/mips/dtrace_isa.c	Wed Apr  7 01:54:31 2021
@@ -107,9 +107,8 @@ dtrace_getpcstack(pc_t *pcstack, int pcs
 	ra = (register_t)(intptr_t)__builtin_return_address(0);
 
	__asm __volatile(
-		"jal 99f\n"
-		"nop\n"
-		"99:\n"
+		"nal\n"
+		" nop\n"
 		"move %0, $31\n" /* get ra */
 		"move $31, %1\n" /* restore ra */
 		: "=r" (pc)



CVS commit: src/external/cddl/osnet/dev/dtrace

2021-04-06 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Apr  6 12:48:59 UTC 2021

Modified Files:
src/external/cddl/osnet/dev/dtrace/amd64: dtrace_subr.c
src/external/cddl/osnet/dev/dtrace/arm: dtrace_subr.c
src/external/cddl/osnet/dev/dtrace/i386: dtrace_subr.c

Log Message:
sizeof(*var) instead of sizeof(type)


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 \
src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c
cvs rdiff -u -r1.12 -r1.13 \
src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.14 src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.15
--- src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.14	Fri Nov  8 11:06:21 2019
+++ src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c	Tue Apr  6 12:48:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_subr.c,v 1.14 2019/11/08 11:06:21 hannken Exp $	*/
+/*	$NetBSD: dtrace_subr.c,v 1.15 2021/04/06 12:48:59 simonb Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -78,7 +78,7 @@ dtrace_invop_add(int (*func)(uintptr_t, 
 {
 	dtrace_invop_hdlr_t *hdlr;
 
-	hdlr = kmem_alloc(sizeof (dtrace_invop_hdlr_t), KM_SLEEP);
+	hdlr = kmem_alloc(sizeof(*hdlr), KM_SLEEP);
 	hdlr->dtih_func = func;
 	hdlr->dtih_next = dtrace_invop_hdlr;
 	dtrace_invop_hdlr = hdlr;
@@ -108,7 +108,7 @@ dtrace_invop_remove(int (*func)(uintptr_
 		prev->dtih_next = hdlr->dtih_next;
 	}
 
-	kmem_free(hdlr, sizeof (dtrace_invop_hdlr_t));
+	kmem_free(hdlr, sizeof(*hdlr));
 }
 
 /*ARGSUSED*/

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c:1.4 src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c:1.5
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c:1.4	Mon May 28 21:05:03 2018
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c	Tue Apr  6 12:48:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_subr.c,v 1.4 2018/05/28 21:05:03 chs Exp $	*/
+/*	$NetBSD: dtrace_subr.c,v 1.5 2021/04/06 12:48:59 simonb Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -94,7 +94,7 @@ dtrace_invop_add(int (*func)(uintptr_t, 
 {
 	dtrace_invop_hdlr_t *hdlr;
 
-	hdlr = kmem_alloc(sizeof (dtrace_invop_hdlr_t), KM_SLEEP);
+	hdlr = kmem_alloc(sizeof(*hdlr), KM_SLEEP);
 	hdlr->dtih_func = func;
 	hdlr->dtih_next = dtrace_invop_hdlr;
 	dtrace_invop_hdlr = hdlr;
@@ -124,7 +124,7 @@ dtrace_invop_remove(int (*func)(uintptr_
 		prev->dtih_next = hdlr->dtih_next;
 	}
 
-	kmem_free(hdlr, sizeof (dtrace_invop_hdlr_t));
+	kmem_free(hdlr, sizeof(*hdlr));
 }
 
 /*ARGSUSED*/

Index: src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.12 src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.13
--- src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.12	Wed Feb 13 08:46:40 2019
+++ src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c	Tue Apr  6 12:48:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_subr.c,v 1.12 2019/02/13 08:46:40 rin Exp $	*/
+/*	$NetBSD: dtrace_subr.c,v 1.13 2021/04/06 12:48:59 simonb Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -86,7 +86,7 @@ dtrace_invop_add(int (*func)(uintptr_t, 
 {
 	dtrace_invop_hdlr_t *hdlr;
 
-	hdlr = kmem_alloc(sizeof (dtrace_invop_hdlr_t), KM_SLEEP);
+	hdlr = kmem_alloc(sizeof(*hdlr), KM_SLEEP);
 	hdlr->dtih_func = func;
 	hdlr->dtih_next = dtrace_invop_hdlr;
 	dtrace_invop_hdlr = hdlr;
@@ -116,7 +116,7 @@ dtrace_invop_remove(int (*func)(uintptr_
 		prev->dtih_next = hdlr->dtih_next;
 	}
 
-	kmem_free(hdlr, sizeof (dtrace_invop_hdlr_t));
+	kmem_free(hdlr, sizeof(*hdlr));
 }
 
 void



CVS commit: src/external/cddl/osnet/dev/dtrace/aarch64

2021-04-06 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Apr  6 12:48:36 UTC 2021

Modified Files:
src/external/cddl/osnet/dev/dtrace/aarch64: dtrace_subr.c

Log Message:
sizeof(*var) instead of sizeof(type)
Call kmem_free() with size of data being freed.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.4 src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.5
--- src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.4	Thu Nov 12 02:15:56 2020
+++ src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c	Tue Apr  6 12:48:36 2021
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dtrace_subr.c,v 1.4 2020/11/12 02:15:56 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dtrace_subr.c,v 1.5 2021/04/06 12:48:36 simonb Exp $");
 
 #include 
 #include 
@@ -87,7 +87,7 @@ dtrace_invop_add(int (*func)(uintptr_t, 
 {
 	dtrace_invop_hdlr_t *hdlr;
 
-	hdlr = kmem_alloc(sizeof (dtrace_invop_hdlr_t), KM_SLEEP);
+	hdlr = kmem_alloc(sizeof(*hdlr), KM_SLEEP);
 	hdlr->dtih_func = func;
 	hdlr->dtih_next = dtrace_invop_hdlr;
 	dtrace_invop_hdlr = hdlr;
@@ -120,7 +120,7 @@ dtrace_invop_remove(int (*func)(uintptr_
 		prev->dtih_next = hdlr->dtih_next;
 	}
 
-	kmem_free(hdlr, 0);
+	kmem_free(hdlr, sizeof(*hdlr));
 }
 
 /*ARGSUSED*/



CVS commit: src/external/cddl/osnet/dev/dtrace/mips

2021-04-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr  6 12:10:21 UTC 2021

Modified Files:
src/external/cddl/osnet/dev/dtrace/mips: dtrace_subr.c

Log Message:
sizeof(*var) instead of sizeof(type)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dev/dtrace/mips/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/mips/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/mips/dtrace_subr.c:1.2 src/external/cddl/osnet/dev/dtrace/mips/dtrace_subr.c:1.3
--- src/external/cddl/osnet/dev/dtrace/mips/dtrace_subr.c:1.2	Tue Apr  6 04:19:15 2021
+++ src/external/cddl/osnet/dev/dtrace/mips/dtrace_subr.c	Tue Apr  6 08:10:21 2021
@@ -88,7 +88,7 @@ dtrace_invop_add(int (*func)(uintptr_t, 
 {
 	dtrace_invop_hdlr_t *hdlr;
 
-	hdlr = kmem_alloc(sizeof (dtrace_invop_hdlr_t), KM_SLEEP);
+	hdlr = kmem_alloc(sizeof(*hdlr), KM_SLEEP);
 	hdlr->dtih_func = func;
 	hdlr->dtih_next = dtrace_invop_hdlr;
 	dtrace_invop_hdlr = hdlr;
@@ -121,7 +121,7 @@ dtrace_invop_remove(int (*func)(uintptr_
 		prev->dtih_next = hdlr->dtih_next;
 	}
 
-	kmem_free(hdlr, sizeof (dtrace_invop_hdlr_t));
+	kmem_free(hdlr, sizeof(*hdlr));
 }
 
 /*ARGSUSED*/



CVS commit: src/external/cddl/osnet/dev/dtrace/mips

2021-04-06 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Apr  6 08:19:15 UTC 2021

Modified Files:
src/external/cddl/osnet/dev/dtrace/mips: dtrace_subr.c

Log Message:
Call kmem_free() with the size of the thing we are freeing.  Fixes panic
when unloading the ktrace module on MIPS.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/external/cddl/osnet/dev/dtrace/mips/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/mips/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/mips/dtrace_subr.c:1.1 src/external/cddl/osnet/dev/dtrace/mips/dtrace_subr.c:1.2
--- src/external/cddl/osnet/dev/dtrace/mips/dtrace_subr.c:1.1	Mon Mar 29 05:17:09 2021
+++ src/external/cddl/osnet/dev/dtrace/mips/dtrace_subr.c	Tue Apr  6 08:19:15 2021
@@ -121,7 +121,7 @@ dtrace_invop_remove(int (*func)(uintptr_
 		prev->dtih_next = hdlr->dtih_next;
 	}
 
-	kmem_free(hdlr, 0);
+	kmem_free(hdlr, sizeof (dtrace_invop_hdlr_t));
 }
 
 /*ARGSUSED*/



CVS commit: src/external/cddl/osnet/dev

2021-03-28 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Mar 29 05:17:09 UTC 2021

Added Files:
src/external/cddl/osnet/dev/dtrace/mips: dtrace_asm.S dtrace_isa.c
dtrace_subr.c regset.h
src/external/cddl/osnet/dev/fbt/mips: fbt_isa.c fbt_isa.h

Log Message:
Work in progress dtrace for MIPS.  MIPS support mostly copied from
FreeBSD, with NetBSD-specific changes largely based on aarch64 dtrace
support.  Working well enough for system call tracing.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/external/cddl/osnet/dev/dtrace/mips/dtrace_asm.S \
src/external/cddl/osnet/dev/dtrace/mips/dtrace_isa.c \
src/external/cddl/osnet/dev/dtrace/mips/dtrace_subr.c \
src/external/cddl/osnet/dev/dtrace/mips/regset.h
cvs rdiff -u -r0 -r1.1 src/external/cddl/osnet/dev/fbt/mips/fbt_isa.c \
src/external/cddl/osnet/dev/fbt/mips/fbt_isa.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/external/cddl/osnet/dev/dtrace/mips/dtrace_asm.S
diff -u /dev/null src/external/cddl/osnet/dev/dtrace/mips/dtrace_asm.S:1.1
--- /dev/null	Mon Mar 29 05:17:09 2021
+++ src/external/cddl/osnet/dev/dtrace/mips/dtrace_asm.S	Mon Mar 29 05:17:09 2021
@@ -0,0 +1,233 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * $FreeBSD$
+ */
+/*
+ * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#define _ASM
+#define _LOCORE
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+.setnoreorder   # Noreorder is default style!
+
+/*
+ * Primitives
+ */
+
+.text
+
+/*
+void dtrace_membar_producer(void)
+*/
+LEAF(dtrace_membar_producer)
+	j	ra
+	nop
+END(dtrace_membar_producer)
+
+/*
+void dtrace_membar_consumer(void)
+*/
+LEAF(dtrace_membar_consumer)
+	j	ra
+	nop
+END(dtrace_membar_consumer)
+
+/*
+dtrace_icookie_t dtrace_interrupt_disable(void)
+*/
+LEAF(dtrace_interrupt_disable)
+	mfc0	t0, MIPS_COP_0_STATUS
+	move	v0, t0
+	and	v0, v0, MIPS_SR_INT_IE
+	and	t0, t0, ~MIPS_SR_INT_IE
+	mtc0	t0, MIPS_COP_0_STATUS
+	j	ra
+	nop
+END(dtrace_interrupt_disable)
+
+/*
+void dtrace_interrupt_enable(dtrace_icookie_t cookie)
+*/
+LEAF(dtrace_interrupt_enable)
+	mfc0	t0, MIPS_COP_0_STATUS
+	beqz	a0, not_enabled
+	or	t0, t0, MIPS_SR_INT_IE
+	mtc0	t0, MIPS_COP_0_STATUS
+not_enabled:
+	j	ra
+	nop
+END(dtrace_interrupt_enable)
+
+/*
+uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
+*/
+LEAF(dtrace_cas32)
+1:
+	move	t1, a2
+	ll	t0, 0(a0)
+	bne	t0, a1, 2f
+	nop
+	sc	t1, 0(a0)
+	beqz	t1, 1b
+	nop
+2:	move	v0, t0
+	j	ra
+	nop
+END(dtrace_cas32)
+
+/*
+void *
+dtrace_casptr(void *target, void *cmp, void *new)
+*/
+LEAF(dtrace_casptr)
+1:
+	move	t1, a2
+	PTR_LL	t0, 0(a0)
+	bne	t0, a1, 2f
+	nop
+	PTR_SC	t1, 0(a0)
+	beqz	t1, 1b
+	nop
+2:	move	v0, t0
+	j	ra
+	nop
+END(dtrace_casptr)
+
+
+/*
+uintptr_t
+dtrace_fulword(void *addr)
+*/
+LEAF(dtrace_fulword)
+END(dtrace_fulword)
+
+/*
+uint8_t
+dtrace_fuword8_nocheck(void *addr)
+*/
+LEAF(dtrace_fuword8_nocheck)
+	lbu	v0, 0(a0)
+	j	ra
+	nop
+END(dtrace_fuword8_nocheck)
+
+/*
+uint16_t
+dtrace_fuword16_nocheck(void *addr)
+*/
+LEAF(dtrace_fuword16_nocheck)
+	lhu	v0, 0(a0)
+	j	ra
+	nop
+END(dtrace_fuword16_nocheck)
+
+/*
+uint32_t
+dtrace_fuword32_nocheck(void *addr)
+*/
+LEAF(dtrace_fuword32_nocheck)
+	lw	v0, 0(a0)
+	j	ra
+	nop
+END(dtrace_fuword32_nocheck)
+
+/*
+uint64_t
+dtrace_fuword64_nocheck(void *addr)
+*/
+LEAF(dtrace_fuword64_nocheck)
+#if defined(__mips_n64) || defined(__mips_n32)
+	ld	v0, 0(a0)
+#else
+	lw	v1,4(a0)
+	lw	v0,0(a0)
+#endif
+	j	ra
+	nop
+END(dtrace_fuword64_nocheck)
+
+/*
+XXX: unoptimized
+void
+dtrace_copy(uintptr_t src, uintptr_t dest, size_t size)
+*/
+LEAF(dtrace_copy)
+1:
+	beqz	a2, 2f
+	nop
+	lbu	t0, 0(a0)
+	sb	t0, 0(a1)
+	PTR_ADDU	a0, a0, 1
+	PTR_ADDU	a1, a1, 1
+	INT_SUBU	a2, a2, 1
+	j	1b
+	nop
+2:
+	j	ra
+	nop
+END(dtrace_copy)
+
+/*
+XXX: Unoptimized. Check for flags on page boundaries only(?)
+void
+dtrace_copystr(uintptr_t uaddr, uintptr_t kaddr, size_t size,
+volatile uint16_t *flags)
+*/
+LEAF(dtrace_copystr)
+1:
+	lbu	t0, 0(a0)
+	sb	t0, 

CVS commit: src/external/cddl/osnet/dev/cyclic/mips

2021-03-28 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Mar 29 03:27:38 UTC 2021

Added Files:
src/external/cddl/osnet/dev/cyclic/mips: cyclic_machdep.c

Log Message:
Add cyclic_machdep.c for MIPS

The code is identical to i386's one.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 \
src/external/cddl/osnet/dev/cyclic/mips/cyclic_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/external/cddl/osnet/dev/cyclic/mips/cyclic_machdep.c
diff -u /dev/null src/external/cddl/osnet/dev/cyclic/mips/cyclic_machdep.c:1.1
--- /dev/null	Mon Mar 29 03:27:38 2021
+++ src/external/cddl/osnet/dev/cyclic/mips/cyclic_machdep.c	Mon Mar 29 03:27:38 2021
@@ -0,0 +1,148 @@
+/*	$NetBSD: cyclic_machdep.c,v 1.1 2021/03/29 03:27:38 simonb Exp $	*/
+
+/*-
+ * Copyright 2006-2008 John Birrell 
+ *
+ * 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.
+ *
+ * $FreeBSD: head/sys/cddl/dev/cyclic/i386/cyclic_machdep.c 222813 2011-06-07 08:46:13Z attilio $
+ *
+ */
+
+static void enable(cyb_arg_t);
+static void disable(cyb_arg_t);
+static void reprogram(cyb_arg_t, hrtime_t);
+static void xcall(cyb_arg_t, cpu_t *, cyc_func_t, void *);
+
+static cyc_backend_t	be	= {
+	NULL,		/* cyb_configure */
+	NULL,		/* cyb_unconfigure */
+	enable,
+	disable,
+	reprogram,
+	xcall,
+	NULL		/* cyb_arg_t cyb_arg */
+};
+
+static void
+cyclic_ap_start(void *dummy)
+{
+	/* Initialise the rest of the CPUs. */
+	cyclic_mp_init();
+}
+
+SYSINIT(cyclic_ap_start, SI_SUB_SMP, SI_ORDER_ANY, cyclic_ap_start, NULL);
+
+/*
+ *  Machine dependent cyclic subsystem initialisation.
+ */
+static void
+cyclic_machdep_init(void)
+{
+	/* Register the cyclic backend. */
+	cyclic_init();
+#ifdef __NetBSD__
+	cyclic_ap_start(NULL);
+#endif
+}
+
+static void
+cyclic_machdep_uninit(void)
+{
+	int i;
+
+	for (i = 0; i <= mp_maxid; i++)
+		/* Reset the cyclic clock callback hook. */
+		cyclic_clock_func[i] = NULL;
+
+	/* De-register the cyclic backend. */
+	cyclic_uninit();
+}
+
+static hrtime_t exp_due[MAXCPU];
+
+/*
+ * This function is the one registered by the machine dependent
+ * initialiser as the callback for high speed timer events.
+ */
+static void
+cyclic_clock(struct clockframe *frame)
+{
+	cpu_t *c = _cpu[cpu_number()];
+
+	if (c->cpu_cyclic != NULL && gethrtime() >= exp_due[cpu_number()]) {
+		if (TRAPF_USERMODE(frame)) {
+			c->cpu_profile_pc = 0;
+			c->cpu_profile_upc = TRAPF_PC(frame);
+		} else {
+			c->cpu_profile_pc = TRAPF_PC(frame);
+			c->cpu_profile_upc = 0;
+		}
+
+		c->cpu_intr_actv = 1;
+
+		/* Fire any timers that are due. */
+		cyclic_fire(c);
+
+		c->cpu_intr_actv = 0;
+	}
+}
+
+static void enable(cyb_arg_t arg)
+{
+	/* Register the cyclic clock callback function. */
+	cyclic_clock_func[cpu_number()] = cyclic_clock;
+}
+
+static void disable(cyb_arg_t arg)
+{
+	/* Reset the cyclic clock callback function. */
+	cyclic_clock_func[cpu_number()] = NULL;
+}
+
+static void reprogram(cyb_arg_t arg, hrtime_t exp)
+{
+	exp_due[cpu_number()] = exp;
+}
+
+#ifdef __NetBSD__
+static void xcall_func(void *arg0, void *arg1)
+{
+	cyc_func_t func;
+
+	func = arg0;
+	(*func)(arg1);
+}
+#endif
+
+static void xcall(cyb_arg_t arg, cpu_t *c, cyc_func_t func, void *param)
+{
+#ifdef __NetBSD__
+	uint64_t xc;
+
+	xc = xc_unicast(XC_HIGHPRI, xcall_func, func, param, cpu_lookup(c->cpuid));
+	xc_wait(xc);
+#else
+	smp_rendezvous_cpus((cpumask_t) (1 << c->cpuid),
+	smp_no_rendevous_barrier, func, smp_no_rendevous_barrier, param);
+#endif
+}



CVS commit: src/external/cddl/osnet/dev/fbt/aarch64

2021-03-23 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Wed Mar 24 04:46:41 UTC 2021

Modified Files:
src/external/cddl/osnet/dev/fbt/aarch64: fbt_isa.c fbt_isa.h

Log Message:
Add NetBSD CVS IDs.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c
diff -u src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.6 src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.7
--- src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.6	Wed Feb 12 06:05:31 2020
+++ src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c	Wed Mar 24 04:46:41 2021
@@ -1,3 +1,5 @@
+/*	$NetBSD: fbt_isa.c,v 1.7 2021/03/24 04:46:41 simonb Exp $	*/
+
 /*
  * CDDL HEADER START
  *

Index: src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.h
diff -u src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.h:1.1 src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.h:1.2
--- src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.h:1.1	Tue Dec  3 22:10:56 2019
+++ src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.h	Wed Mar 24 04:46:41 2021
@@ -1,3 +1,5 @@
+/*	$NetBSD: fbt_isa.h,v 1.2 2021/03/24 04:46:41 simonb Exp $	*/
+
 /*
  * CDDL HEADER START
  *



CVS commit: src/external/cddl/osnet/dev/dtrace/aarch64

2020-11-11 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Nov 12 02:15:56 UTC 2020

Modified Files:
src/external/cddl/osnet/dev/dtrace/aarch64: dtrace_subr.c

Log Message:
One more catch up with ``aarch64 is not mips'' change.
Fix evbarm-aarch64 build.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.3 src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.4
--- src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.3	Wed Feb 12 06:05:23 2020
+++ src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c	Thu Nov 12 02:15:56 2020
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dtrace_subr.c,v 1.3 2020/02/12 06:05:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dtrace_subr.c,v 1.4 2020/11/12 02:15:56 rin Exp $");
 
 #include 
 #include 
@@ -128,7 +128,7 @@ void
 dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit))
 {
 
-	(*func)(0, (uintptr_t)AARCH64_KSEG_START);
+	(*func)(0, (uintptr_t)AARCH64_DIRECTMAP_START);
 	(*func)((uintptr_t)VM_KERNEL_IO_ADDRESS, ~(uintptr_t)0);
 }
 



CVS commit: src/external/cddl/osnet/dev/profile

2020-05-15 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri May 15 23:57:17 UTC 2020

Modified Files:
src/external/cddl/osnet/dev/profile: profile.c

Log Message:
Bump PROF_ARTIFICIAL_FRAMES to 4 now that cyclics are run from statclock().


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/cddl/osnet/dev/profile/profile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/profile/profile.c
diff -u src/external/cddl/osnet/dev/profile/profile.c:1.10 src/external/cddl/osnet/dev/profile/profile.c:1.11
--- src/external/cddl/osnet/dev/profile/profile.c:1.10	Fri Jun 29 11:33:46 2018
+++ src/external/cddl/osnet/dev/profile/profile.c	Fri May 15 23:57:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: profile.c,v 1.10 2018/06/29 11:33:46 kamil Exp $	*/
+/*	$NetBSD: profile.c,v 1.11 2020/05/15 23:57:17 ad Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -169,7 +169,7 @@ struct profile_probe_percpu;
 #endif /* __FreeBSD__ */
 
 #ifdef __NetBSD__
-#define	PROF_ARTIFICIAL_FRAMES	3
+#define	PROF_ARTIFICIAL_FRAMES	4
 #endif
 
 typedef struct profile_probe {



CVS commit: src/external/cddl/osnet/dev/dtrace/aarch64

2020-02-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 06:05:23 UTC 2020

Modified Files:
src/external/cddl/osnet/dev/dtrace/aarch64: dtrace_subr.c

Log Message:
Change the address ranges that aarch64 considers toxic for dtrace.

`Toxic' means dtrace forbids D scripts from even attempting to read
or write at them.

Previously we considered [0, VM_MIN_KERNEL_ADDRESS) toxic, but
VM_MIN_KERNEL_ADDRESS is only the minimum address of the kernel map;
the direct-mapped region lies below it, and with PMAP_MAP_POOLPAGE we
allocate virtual pages for pool backing directly from physical pages
through the direct-mapped region.  Also, this did not consider I/O
mappings to be toxic, which they probably should be.

Instead, treat:

[0, AARCH64_KSEG_START)
and
[VM_KERNEL_IO_ADDRESS, 0xfff...ff)

as toxic.  (The upper bound for 0xfff...ff ought to be inclusive, not
exclusive, but I think we'll need another mechanism for expressing
that to dtrace!)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.2 src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.3
--- src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.2	Wed Feb 12 01:09:38 2020
+++ src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c	Wed Feb 12 06:05:23 2020
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dtrace_subr.c,v 1.2 2020/02/12 01:09:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dtrace_subr.c,v 1.3 2020/02/12 06:05:23 riastradh Exp $");
 
 #include 
 #include 
@@ -128,7 +128,8 @@ void
 dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit))
 {
 
-	(*func)(0, (uintptr_t)VM_MIN_KERNEL_ADDRESS);
+	(*func)(0, (uintptr_t)AARCH64_KSEG_START);
+	(*func)((uintptr_t)VM_KERNEL_IO_ADDRESS, ~(uintptr_t)0);
 }
 
 static void



CVS commit: src/external/cddl/osnet/dev/fbt/aarch64

2020-02-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 06:05:31 UTC 2020

Modified Files:
src/external/cddl/osnet/dev/fbt/aarch64: fbt_isa.c

Log Message:
Switch from db_write_bytes to using direct-mapping.

This way there's no dependency on ddb.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c
diff -u src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.5 src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.6
--- src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.5	Wed Feb 12 01:10:25 2020
+++ src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c	Wed Feb 12 06:05:31 2020
@@ -37,7 +37,9 @@
 #include 
 #include 
 
-#include 
+#include 
+
+#include 
 
 #include 
 
@@ -92,9 +94,14 @@ fbt_invop(uintptr_t addr, struct trapfra
 void
 fbt_patch_tracepoint(fbt_probe_t *fbt, fbt_patchval_t val)
 {
+	paddr_t pa;
+	vaddr_t va;
 
-	db_write_bytes((db_addr_t)fbt->fbtp_patchpoint, sizeof(val),
-	(const void *));
+	if (!pmap_extract(pmap_kernel(), (vaddr_t)fbt->fbtp_patchpoint, ))
+		return;
+	if (!mm_md_direct_mapped_phys(pa, ))
+		return;
+	*(fbt_patchval_t *)va = val;
 	cpu_icache_sync_range((vm_offset_t)fbt->fbtp_patchpoint, sizeof(val));
 }
 



CVS commit: src/external/cddl/osnet/dev/fbt/aarch64

2020-02-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 01:10:25 UTC 2020

Modified Files:
src/external/cddl/osnet/dev/fbt/aarch64: fbt_isa.c

Log Message:
Count the number of artificial frames in aarch64 fbt probe correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c
diff -u src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.4 src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.5
--- src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.4	Wed Feb 12 01:09:48 2020
+++ src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c	Wed Feb 12 01:10:25 2020
@@ -52,6 +52,17 @@
 #define	FBT_ENTRY	"entry"
 #define	FBT_RETURN	"return"
 
+/*
+ * How many artificial frames appear between dtrace_probe and the
+ * interrupted function call?
+ *
+ *	fbt_invop
+ *	dtrace_invop
+ *	dtrace_invop_start
+ *	el1_trap_exit
+ */
+#define	FBT_AFRAMES	4
+
 int
 fbt_invop(uintptr_t addr, struct trapframe *frame, uintptr_t r0)
 {
@@ -152,7 +163,7 @@ fbt_provide_module_cb(const char *name, 
 #endif
 	fbt->fbtp_name = name;
 	fbt->fbtp_id = dtrace_probe_create(fbt_id, modname,
-	name, FBT_ENTRY, 3, fbt);
+	name, FBT_ENTRY, FBT_AFRAMES, fbt);
 	fbt->fbtp_patchpoint = instr;
 #ifdef __FreeBSD__
 	fbt->fbtp_ctl = lf;
@@ -206,7 +217,7 @@ again:
 	fbt->fbtp_name = name;
 	if (retfbt == NULL) {
 		fbt->fbtp_id = dtrace_probe_create(fbt_id, modname,
-		name, FBT_RETURN, 3, fbt);
+		name, FBT_RETURN, FBT_AFRAMES, fbt);
 	} else {
 		retfbt->fbtp_next = fbt;
 		fbt->fbtp_id = retfbt->fbtp_id;



CVS commit: src/external/cddl/osnet/dev/fbt/aarch64

2020-02-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 01:09:48 UTC 2020

Modified Files:
src/external/cddl/osnet/dev/fbt/aarch64: fbt_isa.c

Log Message:
Tidy up a bit: don't set things we won't use; assert nonzeroness.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c
diff -u src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.3 src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.4
--- src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.3	Wed Feb 12 01:09:39 2020
+++ src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c	Wed Feb 12 01:09:48 2020
@@ -70,6 +70,7 @@ fbt_invop(uintptr_t addr, struct trapfra
 			frame->tf_regs.r_reg[3], frame->tf_regs.r_reg[4]);
 
 			cpu->cpu_dtrace_caller = 0;
+			KASSERT(fbt->fbtp_savedval != 0);
 			return (fbt->fbtp_savedval);
 		}
 	}
@@ -142,6 +143,7 @@ fbt_provide_module_cb(const char *name, 
 
 	if (instr >= limit)
 		return (0);
+	KASSERT(*instr != 0);
 
 #ifdef __FreeBSD__
 	fbt = malloc(sizeof (fbt_probe_t), M_FBT, M_WAITOK | M_ZERO);
@@ -161,7 +163,6 @@ fbt_provide_module_cb(const char *name, 
 #endif
 	fbt->fbtp_savedval = *instr;
 	fbt->fbtp_patchval = FBT_PATCHVAL;
-	fbt->fbtp_rval = DTRACE_INVOP_PUSHM;
 	fbt->fbtp_symindx = symindx;
 
 	fbt->fbtp_hashnext = fbt_probetab[FBT_ADDR2NDX(instr)];
@@ -192,6 +193,7 @@ again:
 
 	if (instr >= limit)
 		return (0);
+	KASSERT(*instr != 0);
 
 	/*
 	 * We have a winner!
@@ -219,13 +221,10 @@ again:
 #ifdef __NetBSD__
 	fbt->fbtp_ctl = mod;
 #endif
-	fbt->fbtp_symindx = symindx;
-	if ((*instr & B_MASK) == B_INSTR)
-		fbt->fbtp_rval = DTRACE_INVOP_B;
-	else
-		fbt->fbtp_rval = DTRACE_INVOP_RET;
 	fbt->fbtp_savedval = *instr;
 	fbt->fbtp_patchval = FBT_PATCHVAL;
+	fbt->fbtp_symindx = symindx;
+
 	fbt->fbtp_hashnext = fbt_probetab[FBT_ADDR2NDX(instr)];
 	fbt_probetab[FBT_ADDR2NDX(instr)] = fbt;
 



CVS commit: src/external/cddl/osnet/dev

2020-02-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 01:09:39 UTC 2020

Modified Files:
src/external/cddl/osnet/dev/dtrace/aarch64: dtrace_subr.c
src/external/cddl/osnet/dev/fbt/aarch64: fbt_isa.c

Log Message:
Tidy up a bit.  No functional change intended.

aarch64 fbt_invop doesn't actually use the argument, but it would
make more sense for it to be the return value and/or first argument
register.  Certainly it's not `eax'!


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.1 src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.2
--- src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c:1.1	Tue Dec  3 22:10:56 2019
+++ src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c	Wed Feb 12 01:09:38 2020
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dtrace_subr.c,v 1.1 2019/12/03 22:10:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dtrace_subr.c,v 1.2 2020/02/12 01:09:38 riastradh Exp $");
 
 #include 
 #include 
@@ -69,13 +69,13 @@ typedef struct dtrace_invop_hdlr {
 dtrace_invop_hdlr_t *dtrace_invop_hdlr;
 
 int
-dtrace_invop(uintptr_t addr, struct trapframe *frame, uintptr_t eax)
+dtrace_invop(uintptr_t addr, struct trapframe *frame, uintptr_t r0)
 {
 	dtrace_invop_hdlr_t *hdlr;
 	int rval;
 
 	for (hdlr = dtrace_invop_hdlr; hdlr != NULL; hdlr = hdlr->dtih_next)
-		if ((rval = hdlr->dtih_func(addr, frame, eax)) != 0)
+		if ((rval = hdlr->dtih_func(addr, frame, r0)) != 0)
 			return (rval);
 
 	return (0);
@@ -263,7 +263,7 @@ dtrace_invop_start(struct trapframe *fra
 	int tmp;
 	int i;
 
-	invop = dtrace_invop(frame->tf_pc, frame, frame->tf_pc);
+	invop = dtrace_invop(frame->tf_pc, frame, frame->tf_regs.r_reg[0]);
 
 	tmp = (invop & LDP_STP_MASK);
 	if (tmp == STP_64 || tmp == LDP_64) {

Index: src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c
diff -u src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.2 src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.3
--- src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.2	Wed Feb 12 01:09:27 2020
+++ src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c	Wed Feb 12 01:09:39 2020
@@ -53,7 +53,7 @@
 #define	FBT_RETURN	"return"
 
 int
-fbt_invop(uintptr_t addr, struct trapframe *frame, uintptr_t rval)
+fbt_invop(uintptr_t addr, struct trapframe *frame, uintptr_t r0)
 {
 	solaris_cpu_t *cpu;
 	fbt_probe_t *fbt;



CVS commit: src/external/cddl/osnet/dev/fbt/aarch64

2020-02-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 01:09:27 UTC 2020

Modified Files:
src/external/cddl/osnet/dev/fbt/aarch64: fbt_isa.c

Log Message:
Use db_write_bytes to overwrite kernel text.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c
diff -u src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.1 src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.2
--- src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c:1.1	Tue Dec  3 22:10:56 2019
+++ src/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c	Wed Feb 12 01:09:27 2020
@@ -36,6 +36,9 @@
 #include 
 #include 
 #include 
+
+#include 
+
 #include 
 
 #include 
@@ -78,8 +81,9 @@ void
 fbt_patch_tracepoint(fbt_probe_t *fbt, fbt_patchval_t val)
 {
 
-	*fbt->fbtp_patchpoint = val;
-	cpu_icache_sync_range((vm_offset_t)fbt->fbtp_patchpoint, 4);
+	db_write_bytes((db_addr_t)fbt->fbtp_patchpoint, sizeof(val),
+	(const void *));
+	cpu_icache_sync_range((vm_offset_t)fbt->fbtp_patchpoint, sizeof(val));
 }
 
 #if defined(__FreeBSD__)



CVS commit: src/external/cddl/osnet/dev/dtrace/aarch64

2020-02-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Feb 12 01:10:16 UTC 2020

Modified Files:
src/external/cddl/osnet/dev/dtrace/aarch64: dtrace_isa.c

Log Message:
Teach dtrace about el1_trap_exit frames on aarch64.

Implement dtrace_getarg and dtrace_getreg while here.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c
diff -u src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c:1.1 src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c:1.2
--- src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c:1.1	Tue Dec  3 22:10:56 2019
+++ src/external/cddl/osnet/dev/dtrace/aarch64/dtrace_isa.c	Wed Feb 12 01:10:16 2020
@@ -89,52 +89,60 @@ void
 dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
 uint32_t *intrpc)
 {
-	struct unwind_state state;
-	int scp_offset;
-	register_t sp, fp;
-	int depth;
-
-	depth = 0;
-
-	if (intrpc != 0) {
-		pcstack[depth++] = (pc_t) intrpc;
+	extern const char el1_trap_exit[];
+	const register_t *fp;
+	int i = 0;
+
+	if (intrpc) {
+		if (i < pcstack_limit)
+			pcstack[i++] = (pc_t)intrpc;
 	}
 
-	aframes++;
-
-	__asm __volatile("mov %0, sp" : "=" (sp));
-
-	state.fp = (uint64_t)__builtin_frame_address(0);
-	state.sp = sp;
-	state.pc = (uint64_t)dtrace_getpcstack;
-
-	while (depth < pcstack_limit) {
-		if (!INKERNEL(state.pc) || !INKERNEL(state.fp))
-			break;
-
-		fp = state.fp;
-		state.sp = fp + 0x10;
-		/* FP to previous frame (X29) */
-		state.fp = *(register_t *)(fp);
-		/* LR (X30) */
-		state.pc = *(register_t *)(fp + 8) - 4;
-
-		/*
-		 * NB: Unlike some other architectures, we don't need to
-		 * explicitly insert cpu_dtrace_caller as it appears in the
-		 * normal kernel stack trace rather than a special trap frame.
-		 */
-		if (aframes > 0) {
+	/*
+	 * fp[0] = x29 (saved frame pointer)
+	 * fp[1] = x30 (saved link register == return address)
+	 */
+	fp = __builtin_frame_address(0);
+	while (i < pcstack_limit && INKERNEL(fp[0]) && INKERNEL(fp[1])) {
+		/* Skip the specified number of artificial frames.  */
+		if (aframes > 0)
 			aframes--;
+		else
+			pcstack[i++] = fp[1];
+
+		/* Check whether this frame is handling a trap.  */
+		if (fp[1] == (register_t)el1_trap_exit) {
+			/*
+			 * Trap from kernel.  The trapframe is the
+			 * saved frame pointer of the call to the trap
+			 * handler whose return address is
+			 * el1_trap_exit.  The frame pointer of the
+			 * interrupted code is in x29 stashed in the
+			 * trapframe, alongside its pc.
+			 */
+			const struct trapframe *tf = (const void *)fp[0];
+			/* x29 = frame pointer */
+			fp = (const void *)tf->tf_regs.r_reg[29];
+			if (INKERNEL(tf->tf_pc)) {
+if (i >= pcstack_limit)
+	break;
+if (aframes > 0)
+	aframes--;
+else
+	pcstack[i++] = tf->tf_pc;
+			}
 		} else {
-			pcstack[depth++] = state.pc;
+			/*
+			 * Not a trap.  Keep going with fp[0] as the
+			 * parent frame pointer.
+			 */
+			fp = (const void *)fp[0];
 		}
-
 	}
 
-	for (; depth < pcstack_limit; depth++) {
-		pcstack[depth] = 0;
-	}
+	/* Zero the rest of the return address stack.  (Paranoia?)  */
+	while (i < pcstack_limit)
+		pcstack[i++] = 0;
 }
 
 static int
@@ -282,48 +290,78 @@ dtrace_getufpstack(uint64_t *pcstack, ui
 uint64_t
 dtrace_getarg(int arg, int aframes)
 {
+	extern const char el1_trap_exit[];
+	const register_t *fp;
+	const struct trapframe *tf = NULL;
+	int i = 0;
 
-	printf("IMPLEMENT ME: %s\n", __func__);
+	/*
+	 * The first arguments are passed in x0,...,x7.  The rest are
+	 * on the stack, too much trouble to figure out.
+	 *
+	 * XXX Shouldn't we ask ctf or dwarf or something to figure
+	 * this stuff out for us?
+	 */
+	KASSERT(arg >= 0);
+	if (arg >= 8)
+		return 0;
+
+	fp = __builtin_frame_address(0);
+	while (i < 1000 && INKERNEL(fp[0]) && INKERNEL(fp[1])) {
+		if (aframes > 0)
+			aframes--;
+		else
+			i++;
+		if (fp[1] == (register_t)el1_trap_exit) {
+			tf = (const void *)fp[0];
+			break;
+		} else {
+			fp = (const void *)fp[0];
+		}
+	}
 
-	return (0);
+	/* If we didn't find a trap frame, give up.  */
+	if (tf == NULL)
+		return 0;
+
+	/* Arg0, arg1, ..., arg7 are in registers x0, x1, ..., x7.  */
+	return tf->tf_regs.r_reg[arg];
 }
 
 int
 dtrace_getstackdepth(int aframes)
 {
-	struct unwind_state state;
-	int scp_offset;
-	register_t sp;
-	int depth;
-	int done;
-
-	depth = 1;
-	done = 0;
-
-	__asm __volatile("mov %0, sp" : "=" (sp));
-
-	state.fp = (uint64_t)__builtin_frame_address(0);
-	state.sp = sp;
-	state.pc = (uint64_t)dtrace_getstackdepth;
-
-	do {
-		done = unwind_frame();
-		if (!INKERNEL(state.pc) || !INKERNEL(state.fp))
-			break;
-		depth++;
-	} while (!done);
+	extern const char el1_trap_exit[];
+	const register_t *fp;
+	int i = 0;
+
+	fp = __builtin_frame_address(0);

CVS commit: src/external/cddl/osnet/dev/dtrace/i386

2019-02-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Feb 13 08:46:40 UTC 2019

Modified Files:
src/external/cddl/osnet/dev/dtrace/i386: dtrace_subr.c

Log Message:
Fix DIAGNOSTIC build; replace FreeBSD-specific function with ours.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.11 src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.12
--- src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.11	Mon Jun  4 21:35:29 2018
+++ src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c	Wed Feb 13 08:46:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_subr.c,v 1.11 2018/06/04 21:35:29 christos Exp $	*/
+/*	$NetBSD: dtrace_subr.c,v 1.12 2019/02/13 08:46:40 rin Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -424,7 +424,8 @@ dtrace_trap(struct trapframe *frame, u_i
 	 */
 	nofault = (cpu_core[cpuid].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0;
 	if (nofault) {
-		KASSERTMSG((read_eflags() & PSL_I) == 0, "interrupts enabled");
+		KASSERTMSG((x86_read_flags() & PSL_I) == 0,
+		"interrupts enabled");
 
 		/*
 		 * There are only a couple of trap types that are expected.



CVS commit: src/external/cddl/osnet/dev/lockstat

2019-02-12 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Feb 12 14:31:45 UTC 2019

Modified Files:
src/external/cddl/osnet/dev/lockstat: lockstat.c

Log Message:
Fix build with DIAGNOSTIC:
ASSERT() is enabled ifdef DEBUG, not DIAGNOSTIC.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/dev/lockstat/lockstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/lockstat/lockstat.c
diff -u src/external/cddl/osnet/dev/lockstat/lockstat.c:1.9 src/external/cddl/osnet/dev/lockstat/lockstat.c:1.10
--- src/external/cddl/osnet/dev/lockstat/lockstat.c:1.9	Mon May 28 21:05:03 2018
+++ src/external/cddl/osnet/dev/lockstat/lockstat.c	Tue Feb 12 14:31:45 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: lockstat.c,v 1.9 2018/05/28 21:05:03 chs Exp $	*/
+/*	$NetBSD: lockstat.c,v 1.10 2019/02/12 14:31:45 rin Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: lockstat.c,v 1.9 2018/05/28 21:05:03 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lockstat.c,v 1.10 2019/02/12 14:31:45 rin Exp $");
 
 #include 
 #include 
@@ -210,7 +210,7 @@ static int
 lockstat_fini(void)
 {
 	int error;
-	bool ok __diagused;
+	bool ok __debugused;
 
 	error = dtrace_unregister(lockstat_id);
 	if (error) {



CVS commit: src/external/cddl/osnet/dev/dtrace/amd64

2019-01-12 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jan 12 10:41:31 UTC 2019

Modified Files:
src/external/cddl/osnet/dev/dtrace/amd64: dtrace_subr.c

Log Message:
There is no such function read_rflags(), probably meant x86_read_flags().


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.11 src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.12
--- src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.11	Thu Aug 16 14:14:51 2018
+++ src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c	Sat Jan 12 10:41:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_subr.c,v 1.11 2018/08/16 14:14:51 christos Exp $	*/
+/*	$NetBSD: dtrace_subr.c,v 1.12 2019/01/12 10:41:31 hannken Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -412,7 +412,7 @@ dtrace_trap(struct trapframe *frame, u_i
 	 */
 	nofault = (cpu_core[cpuid].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0;
 	if (nofault) {
-		KASSERTMSG((read_rflags() & PSL_I) == 0, "interrupts enabled");
+		KASSERTMSG((x86_read_flags() & PSL_I) == 0, "interrupts enabled");
 
 		/*
 		 * There are only a couple of trap types that are expected.



CVS commit: src/external/cddl/osnet/dev/dtrace/amd64

2018-08-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Aug 16 14:14:52 UTC 2018

Modified Files:
src/external/cddl/osnet/dev/dtrace/amd64: dtrace_isa.c dtrace_subr.c

Log Message:
get rid of kernelbase


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c
cvs rdiff -u -r1.10 -r1.11 \
src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c
diff -u src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c:1.9 src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c:1.10
--- src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c:1.9	Sun Aug 12 12:07:27 2018
+++ src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c	Thu Aug 16 10:14:51 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_isa.c,v 1.9 2018/08/12 16:07:27 christos Exp $	*/
+/*	$NetBSD: dtrace_isa.c,v 1.10 2018/08/16 14:14:51 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -45,12 +45,6 @@ uint16_t dtrace_fuword16_nocheck(void *)
 uint32_t dtrace_fuword32_nocheck(void *);
 uint64_t dtrace_fuword64_nocheck(void *);
 
-#ifdef VM_MIN_KERNEL_ADDRESS_DEFAULT
-__strong_alias(kernelbase, vm_min_kernel_address)
-#else
-uintptr_t kernelbase = (uintptr_t)VM_MIN_KERNEL_ADDRESS;
-#endif
-
 #define INKERNEL(va) ((intptr_t)(va) < 0) /* XXX horror */
 
 struct amd64_frame {

Index: src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.10 src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.11
--- src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.10	Tue Jun  5 08:04:19 2018
+++ src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c	Thu Aug 16 10:14:51 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_subr.c,v 1.10 2018/06/05 12:04:19 christos Exp $	*/
+/*	$NetBSD: dtrace_subr.c,v 1.11 2018/08/16 14:14:51 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -48,8 +48,6 @@
 #include 
 #include 
 
-extern uintptr_t 	kernelbase;
-
 int dtrace_invop(uintptr_t, struct trapframe *, uintptr_t);
 
 typedef struct dtrace_invop_hdlr {
@@ -117,7 +115,7 @@ dtrace_invop_remove(int (*func)(uintptr_
 void
 dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit))
 {
-	(*func)(0, kernelbase);
+	(*func)(0, VM_MIN_KERNEL_ADDRESS);
 }
 
 static void



CVS commit: src/external/cddl/osnet/dev/dtrace/amd64

2018-08-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 12 16:07:27 UTC 2018

Modified Files:
src/external/cddl/osnet/dev/dtrace/amd64: dtrace_isa.c

Log Message:
handle variable kernel vm min address


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c
diff -u src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c:1.8 src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c:1.9
--- src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c:1.8	Fri Jul 27 03:32:59 2018
+++ src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c	Sun Aug 12 12:07:27 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_isa.c,v 1.8 2018/07/27 07:32:59 maxv Exp $	*/
+/*	$NetBSD: dtrace_isa.c,v 1.9 2018/08/12 16:07:27 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -45,7 +45,11 @@ uint16_t dtrace_fuword16_nocheck(void *)
 uint32_t dtrace_fuword32_nocheck(void *);
 uint64_t dtrace_fuword64_nocheck(void *);
 
+#ifdef VM_MIN_KERNEL_ADDRESS_DEFAULT
+__strong_alias(kernelbase, vm_min_kernel_address)
+#else
 uintptr_t kernelbase = (uintptr_t)VM_MIN_KERNEL_ADDRESS;
+#endif
 
 #define INKERNEL(va) ((intptr_t)(va) < 0) /* XXX horror */
 



CVS commit: src/external/cddl/osnet/dev/dtrace/amd64

2018-07-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Jul 27 07:32:59 UTC 2018

Modified Files:
src/external/cddl/osnet/dev/dtrace/amd64: dtrace_isa.c

Log Message:
Replace KERN_BASE by VM_MIN_KERNEL_ADDRESS. Also add XXX on INKERNEL.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c
diff -u src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c:1.7 src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c:1.8
--- src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c:1.7	Mon May 28 21:05:03 2018
+++ src/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c	Fri Jul 27 07:32:59 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_isa.c,v 1.7 2018/05/28 21:05:03 chs Exp $	*/
+/*	$NetBSD: dtrace_isa.c,v 1.8 2018/07/27 07:32:59 maxv Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -45,9 +45,9 @@ uint16_t dtrace_fuword16_nocheck(void *)
 uint32_t dtrace_fuword32_nocheck(void *);
 uint64_t dtrace_fuword64_nocheck(void *);
 
-uintptr_t kernelbase = (uintptr_t)KERN_BASE;
+uintptr_t kernelbase = (uintptr_t)VM_MIN_KERNEL_ADDRESS;
 
-#define INKERNEL(va) ((intptr_t)(va) < 0)
+#define INKERNEL(va) ((intptr_t)(va) < 0) /* XXX horror */
 
 struct amd64_frame {
 	struct amd64_frame	*f_frame;



CVS commit: src/external/cddl/osnet/dev/systrace

2018-06-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Jun  6 17:47:10 UTC 2018

Modified Files:
src/external/cddl/osnet/dev/systrace: systrace.c

Log Message:
Correct compilation of osnet/dev/systrace/systrace.c under Clang

Mark arguments to dtrace_probe_lookup() with __UNCONST().
The proper fix constifying it causes pollution of const in too many files.

This could be done with -W flags, but they are incompatible between
compilers.

This is a step forward functional MKLLVM=yes HAVE_LLVM=yes build.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/external/cddl/osnet/dev/systrace/systrace.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/systrace/systrace.c
diff -u src/external/cddl/osnet/dev/systrace/systrace.c:1.10 src/external/cddl/osnet/dev/systrace/systrace.c:1.11
--- src/external/cddl/osnet/dev/systrace/systrace.c:1.10	Mon May 28 21:05:04 2018
+++ src/external/cddl/osnet/dev/systrace/systrace.c	Wed Jun  6 17:47:10 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: systrace.c,v 1.10 2018/05/28 21:05:04 chs Exp $	*/
+/*	$NetBSD: systrace.c,v 1.11 2018/06/06 17:47:10 kamil Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -356,7 +356,7 @@ systrace_provide(void *arg, dtrace_probe
 #else
 		const char *name = ALTSYSCALLNAMES[i] ? ALTSYSCALLNAMES[i] :
 		SYSCALLNAMES[i];
-		if (dtrace_probe_lookup(systrace_id, NULL, name, "entry") != 0)
+		if (dtrace_probe_lookup(systrace_id, NULL, __UNCONST(name), __UNCONST("entry")) != 0)
 			continue;
 
 		(void) dtrace_probe_create(systrace_id, NULL,



CVS commit: src/external/cddl/osnet/dev/profile

2018-06-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Jun  6 17:19:49 UTC 2018

Modified Files:
src/external/cddl/osnet/dev/profile: profile.c

Log Message:
Correct compilation of osnet/dev/profile/profile.c under Clang

Constify char* types when initialized with liternals.

This could be done with -W flags, but they are incompatible between
compilers.

This is a step forward functional MKLLVM=yes HAVE_LLVM=yes build.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/dev/profile/profile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/profile/profile.c
diff -u src/external/cddl/osnet/dev/profile/profile.c:1.8 src/external/cddl/osnet/dev/profile/profile.c:1.9
--- src/external/cddl/osnet/dev/profile/profile.c:1.8	Mon May 28 21:05:03 2018
+++ src/external/cddl/osnet/dev/profile/profile.c	Wed Jun  6 17:19:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: profile.c,v 1.8 2018/05/28 21:05:03 chs Exp $	*/
+/*	$NetBSD: profile.c,v 1.9 2018/06/06 17:19:49 kamil Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -434,7 +434,7 @@ profile_provide(void *arg, dtrace_probed
 	char *name, *suffix = NULL;
 
 	const struct {
-		char *prefix;
+		const char *prefix;
 		int kind;
 	} types[] = {
 		{ PROF_PREFIX_PROFILE, PROF_PROFILE },
@@ -443,7 +443,7 @@ profile_provide(void *arg, dtrace_probed
 	};
 
 	const struct {
-		char *name;
+		const char *name;
 		hrtime_t mult;
 	} suffixes[] = {
 		{ "ns", 	NANOSEC / NANOSEC },



CVS commit: src/external/cddl/osnet/dev/dtrace/x86

2018-06-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Jun  6 17:16:56 UTC 2018

Modified Files:
src/external/cddl/osnet/dev/dtrace/x86: dis_tables.c

Log Message:
Correct compilation of osnet/dev/dtrace/x86/dis_tables.c under Clang

Constify dgr_suffix.

This could be done with -W flags, but they are incompatible between
compilers.

This is a step forward functional MKLLVM=yes HAVE_LLVM=yes build.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/dev/dtrace/x86/dis_tables.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/x86/dis_tables.c
diff -u src/external/cddl/osnet/dev/dtrace/x86/dis_tables.c:1.1 src/external/cddl/osnet/dev/dtrace/x86/dis_tables.c:1.2
--- src/external/cddl/osnet/dev/dtrace/x86/dis_tables.c:1.1	Mon May 28 23:47:39 2018
+++ src/external/cddl/osnet/dev/dtrace/x86/dis_tables.c	Wed Jun  6 17:16:56 2018
@@ -2345,7 +2345,7 @@ typedef struct dis_gather_regs {
 	uint_t dgr_arg0;	/* src reg */
 	uint_t dgr_arg1;	/* vsib reg */
 	uint_t dgr_arg2;	/* dst reg */
-	char   *dgr_suffix;	/* suffix to append */
+	const char   *dgr_suffix;	/* suffix to append */
 } dis_gather_regs_t;
 
 static dis_gather_regs_t dis_vgather[4][2][2] = {



CVS commit: src/external/cddl/osnet/dev/dtrace

2018-06-06 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Jun  6 15:54:03 UTC 2018

Modified Files:
src/external/cddl/osnet/dev/dtrace: dtrace_hacks.c

Log Message:
Correct compilation of osnet/dev/dtrace/dtrace_hacks.c under Clang

Use __UNCONST() to remove const from an argument.

This could be done with -W flags, but they are incompatible between
compilers.

This is a step forward functional MKLLVM=yes HAVE_LLVM=yes build.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dev/dtrace/dtrace_hacks.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/dtrace_hacks.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_hacks.c:1.6 src/external/cddl/osnet/dev/dtrace/dtrace_hacks.c:1.7
--- src/external/cddl/osnet/dev/dtrace/dtrace_hacks.c:1.6	Mon May 28 21:05:03 2018
+++ src/external/cddl/osnet/dev/dtrace/dtrace_hacks.c	Wed Jun  6 15:54:03 2018
@@ -1,13 +1,15 @@
-/*	$NetBSD: dtrace_hacks.c,v 1.6 2018/05/28 21:05:03 chs Exp $	*/
+/*	$NetBSD: dtrace_hacks.c,v 1.7 2018/06/06 15:54:03 kamil Exp $	*/
 
 /* $FreeBSD: head/sys/cddl/dev/dtrace/dtrace_hacks.c 281916 2015-04-24 03:19:30Z markj $ */
 /* XXX Hacks */
 
+#include 
+
 dtrace_cacheid_t dtrace_predcache_id;
 
 boolean_t
 priv_policy_only(const cred_t *cr, int b, boolean_t c)
 {
 
-	return kauth_authorize_generic(cr, KAUTH_GENERIC_ISSUSER, NULL) == 0;
+	return kauth_authorize_generic(__UNCONST(cr), KAUTH_GENERIC_ISSUSER, NULL) == 0;
 }



CVS commit: src/external/cddl/osnet/dev/dtrace/amd64

2018-06-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jun  5 12:04:19 UTC 2018

Modified Files:
src/external/cddl/osnet/dev/dtrace/amd64: dtrace_subr.c

Log Message:
remove  done in the dtrace header now.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.9 src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.10
--- src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c:1.9	Mon May 28 17:05:03 2018
+++ src/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c	Tue Jun  5 08:04:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_subr.c,v 1.9 2018/05/28 21:05:03 chs Exp $	*/
+/*	$NetBSD: dtrace_subr.c,v 1.10 2018/06/05 12:04:19 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -33,7 +33,6 @@
  * Copyright (c) 2011, Joyent, Inc. All rights reserved.
  */
 
-#include 
 #include 
 #include 
 #include 



CVS commit: src/external/cddl/osnet/dev/dtrace/i386

2018-06-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun  4 21:35:29 UTC 2018

Modified Files:
src/external/cddl/osnet/dev/dtrace/i386: dtrace_subr.c

Log Message:
better to put this () in the dtrace header where the definitions
are needed.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 \
src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.10 src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.11
--- src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.10	Mon Jun  4 16:12:45 2018
+++ src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c	Mon Jun  4 17:35:29 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_subr.c,v 1.10 2018/06/04 20:12:45 kre Exp $	*/
+/*	$NetBSD: dtrace_subr.c,v 1.11 2018/06/04 21:35:29 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -33,7 +33,6 @@
  * Copyright (c) 2011, Joyent, Inc. All rights reserved.
  */
 
-#include 
 #include 
 #include 
 #include 



CVS commit: src/external/cddl/osnet/dev/dtrace/i386

2018-06-04 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Jun  4 20:12:46 UTC 2018

Modified Files:
src/external/cddl/osnet/dev/dtrace/i386: dtrace_subr.c

Log Message:
The (dtrace version of)  is needed for kthread_t
(same as the amd64 version).   This should fix (one of) the
current i386 build breakages.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.9 src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.10
--- src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.9	Mon May 28 21:05:03 2018
+++ src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c	Mon Jun  4 20:12:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_subr.c,v 1.9 2018/05/28 21:05:03 chs Exp $	*/
+/*	$NetBSD: dtrace_subr.c,v 1.10 2018/06/04 20:12:45 kre Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -33,6 +33,7 @@
  * Copyright (c) 2011, Joyent, Inc. All rights reserved.
  */
 
+#include 
 #include 
 #include 
 #include 



CVS commit: src/external/cddl/osnet/dev/fbt

2017-11-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov  6 04:43:50 UTC 2017

Modified Files:
src/external/cddl/osnet/dev/fbt: fbt.c

Log Message:
kill another wrong ELFSIZE setting.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/external/cddl/osnet/dev/fbt/fbt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/fbt.c
diff -u src/external/cddl/osnet/dev/fbt/fbt.c:1.22 src/external/cddl/osnet/dev/fbt/fbt.c:1.23
--- src/external/cddl/osnet/dev/fbt/fbt.c:1.22	Mon Feb 27 01:47:00 2017
+++ src/external/cddl/osnet/dev/fbt/fbt.c	Sun Nov  5 23:43:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt.c,v 1.22 2017/02/27 06:47:00 chs Exp $	*/
+/*	$NetBSD: fbt.c,v 1.23 2017/11/06 04:43:50 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -72,7 +72,6 @@
 #include 
 #endif
 
-#define ELFSIZE ARCH_ELFSIZE
 #include 
 
 #include 



CVS commit: src/external/cddl/osnet/dev/cyclic

2017-02-01 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Feb  1 21:59:09 UTC 2017

Modified Files:
src/external/cddl/osnet/dev/cyclic: cyclic.c

Log Message:
put back the include of dtrace_bsd.h, it actually is needed.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dev/cyclic/cyclic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/cyclic/cyclic.c
diff -u src/external/cddl/osnet/dev/cyclic/cyclic.c:1.6 src/external/cddl/osnet/dev/cyclic/cyclic.c:1.7
--- src/external/cddl/osnet/dev/cyclic/cyclic.c:1.6	Wed Feb  1 20:06:21 2017
+++ src/external/cddl/osnet/dev/cyclic/cyclic.c	Wed Feb  1 21:59:09 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cyclic.c,v 1.6 2017/02/01 20:06:21 chs Exp $	*/
+/*	$NetBSD: cyclic.c,v 1.7 2017/02/01 21:59:09 chs Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -336,6 +336,7 @@
 #include 
 #include 
 #include 
+#include 
 #ifdef __FreeBSD__
 #include 
 #endif



CVS commit: src/external/cddl/osnet/dev/cyclic

2017-02-01 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Feb  1 20:06:21 UTC 2017

Modified Files:
src/external/cddl/osnet/dev/cyclic: cyclic.c

Log Message:
fix this module to depend on the solaris module rather than the dtrace module.
remove an unneeded header.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dev/cyclic/cyclic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/cyclic/cyclic.c
diff -u src/external/cddl/osnet/dev/cyclic/cyclic.c:1.5 src/external/cddl/osnet/dev/cyclic/cyclic.c:1.6
--- src/external/cddl/osnet/dev/cyclic/cyclic.c:1.5	Sat Apr  9 14:50:08 2016
+++ src/external/cddl/osnet/dev/cyclic/cyclic.c	Wed Feb  1 20:06:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cyclic.c,v 1.5 2016/04/09 14:50:08 riastradh Exp $	*/
+/*	$NetBSD: cyclic.c,v 1.6 2017/02/01 20:06:21 chs Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -336,7 +336,6 @@
 #include 
 #include 
 #include 
-#include 
 #ifdef __FreeBSD__
 #include 
 #endif
@@ -1466,5 +1465,5 @@ cyclic_modcmd(modcmd_t cmd, void *data)
 	}
 }
 
-MODULE(MODULE_CLASS_MISC, cyclic, "dtrace");
+MODULE(MODULE_CLASS_MISC, cyclic, "solaris");
 #endif



CVS commit: src/external/cddl/osnet/dev/dtrace

2016-06-23 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Jun 23 06:44:52 UTC 2016

Modified Files:
src/external/cddl/osnet/dev/dtrace: dtrace_hacks.c

Log Message:
One more removal of a redefined symbol while loading dtrace module.

Should finish the issues with PR kern/51265


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/dtrace/dtrace_hacks.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/dtrace_hacks.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_hacks.c:1.4 src/external/cddl/osnet/dev/dtrace/dtrace_hacks.c:1.5
--- src/external/cddl/osnet/dev/dtrace/dtrace_hacks.c:1.4	Thu Jun 23 04:35:35 2016
+++ src/external/cddl/osnet/dev/dtrace/dtrace_hacks.c	Thu Jun 23 06:44:52 2016
@@ -1,12 +1,10 @@
-/*	$NetBSD: dtrace_hacks.c,v 1.4 2016/06/23 04:35:35 pgoyette Exp $	*/
+/*	$NetBSD: dtrace_hacks.c,v 1.5 2016/06/23 06:44:52 pgoyette Exp $	*/
 
 /* $FreeBSD: src/sys/cddl/dev/dtrace/dtrace_hacks.c,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $ */
 /* XXX Hacks */
 
 dtrace_cacheid_t dtrace_predcache_id;
 
-cpu_core_t	cpu_core[MAXCPUS];
-
 boolean_t
 priv_policy_only(const cred_t *a, int b, boolean_t c)
 {



CVS commit: src/external/cddl/osnet/dev/sdt

2016-06-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Jun 16 06:08:06 UTC 2016

Modified Files:
src/external/cddl/osnet/dev/sdt: sdt.c

Log Message:
Make assertion of linker_file #ifdef __FreeBSD__. Fixes DIAGNOSTIC build.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/external/cddl/osnet/dev/sdt/sdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/sdt/sdt.c
diff -u src/external/cddl/osnet/dev/sdt/sdt.c:1.15 src/external/cddl/osnet/dev/sdt/sdt.c:1.16
--- src/external/cddl/osnet/dev/sdt/sdt.c:1.15	Sat Feb  6 18:19:59 2016
+++ src/external/cddl/osnet/dev/sdt/sdt.c	Thu Jun 16 06:08:06 2016
@@ -39,7 +39,7 @@
  * unloaded; in particular, probes may not span multiple kernel modules.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdt.c,v 1.15 2016/02/06 18:19:59 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdt.c,v 1.16 2016/06/16 06:08:06 mlelstv Exp $");
 
 #include 
 #include 
@@ -257,7 +257,9 @@ sdt_disable(void *arg __unused, dtrace_i
 {
 	struct sdt_probe *probe = parg;
 
+#ifdef __FreeBSD__
 	SDT_KASSERT(probe->sdtp_lf->nenabled > 0, ("no probes enabled"));
+#endif
 
 #ifdef SDT_DEBUG
 	printf("sdt: %s\n", __func__);



CVS commit: src/external/cddl/osnet/dev

2016-04-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Apr  9 15:18:48 UTC 2016

Modified Files:
src/external/cddl/osnet/dev: prototype.c

Log Message:
Add autounload logic to dtrace module prototype.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dev/prototype.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/prototype.c
diff -u src/external/cddl/osnet/dev/prototype.c:1.3 src/external/cddl/osnet/dev/prototype.c:1.4
--- src/external/cddl/osnet/dev/prototype.c:1.3	Mon Mar  9 03:43:02 2015
+++ src/external/cddl/osnet/dev/prototype.c	Sat Apr  9 15:18:48 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: prototype.c,v 1.3 2015/03/09 03:43:02 riastradh Exp $	*/
+/*	$NetBSD: prototype.c,v 1.4 2016/04/09 15:18:48 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: prototype.c,v 1.3 2015/03/09 03:43:02 riastradh Exp $");
+__RCSID("$NetBSD: prototype.c,v 1.4 2016/04/09 15:18:48 riastradh Exp $");
 
 #include 
 #include 
@@ -168,6 +168,10 @@ dtrace_prototype_modcmd(modcmd_t cmd, vo
 		return prototype_init();
 	case MODULE_CMD_FINI:
 		return prototype_fini();
+	case MODULE_CMD_AUTOUNLOAD:
+		if (prototype_users)
+			return EBUSY;
+		return 0;
 	default:
 		return ENOTTY;
 	}



CVS commit: src/external/cddl/osnet/dev/profile

2016-04-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Apr  9 15:17:58 UTC 2016

Modified Files:
src/external/cddl/osnet/dev/profile: profile.c

Log Message:
Disable autoload if there are any profile probes.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dev/profile/profile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/profile/profile.c
diff -u src/external/cddl/osnet/dev/profile/profile.c:1.5 src/external/cddl/osnet/dev/profile/profile.c:1.6
--- src/external/cddl/osnet/dev/profile/profile.c:1.5	Mon Apr  4 05:15:07 2016
+++ src/external/cddl/osnet/dev/profile/profile.c	Sat Apr  9 15:17:58 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: profile.c,v 1.5 2016/04/04 05:15:07 riastradh Exp $	*/
+/*	$NetBSD: profile.c,v 1.6 2016/04/09 15:17:58 riastradh Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -576,6 +576,11 @@ dtrace_profile_modcmd(modcmd_t cmd, void
 		profile_unload();
 		return 0;
 
+	case MODULE_CMD_AUTOUNLOAD:
+		if (profile_total)
+			return EBUSY;
+		return 0;
+
 	default:
 		return ENOTTY;
 	}



CVS commit: src/external/cddl/osnet/dev/cyclic

2016-04-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Apr  9 14:50:08 UTC 2016

Modified Files:
src/external/cddl/osnet/dev/cyclic: cyclic.c

Log Message:
Prevent autounload while cyclics are still in use.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/cyclic/cyclic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/cyclic/cyclic.c
diff -u src/external/cddl/osnet/dev/cyclic/cyclic.c:1.4 src/external/cddl/osnet/dev/cyclic/cyclic.c:1.5
--- src/external/cddl/osnet/dev/cyclic/cyclic.c:1.4	Sun Dec  2 01:05:16 2012
+++ src/external/cddl/osnet/dev/cyclic/cyclic.c	Sat Apr  9 14:50:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: cyclic.c,v 1.4 2012/12/02 01:05:16 chs Exp $	*/
+/*	$NetBSD: cyclic.c,v 1.5 2016/04/09 14:50:08 riastradh Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -1455,6 +1455,12 @@ cyclic_modcmd(modcmd_t cmd, void *data)
 	case MODULE_CMD_FINI:
 		cyclic_unload();
 		return 0;
+
+	case MODULE_CMD_AUTOUNLOAD:
+		if (cyclic_id_head != NULL)
+			return EBUSY;
+		return 0;
+
 	default:
 		return ENOTTY;
 	}



CVS commit: src/external/cddl/osnet/dev/profile

2016-04-03 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Apr  4 05:15:07 UTC 2016

Modified Files:
src/external/cddl/osnet/dev/profile: profile.c

Log Message:
Fix module name of dtrace_profile.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/profile/profile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/profile/profile.c
diff -u src/external/cddl/osnet/dev/profile/profile.c:1.4 src/external/cddl/osnet/dev/profile/profile.c:1.5
--- src/external/cddl/osnet/dev/profile/profile.c:1.4	Fri Dec  7 03:11:17 2012
+++ src/external/cddl/osnet/dev/profile/profile.c	Mon Apr  4 05:15:07 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: profile.c,v 1.4 2012/12/07 03:11:17 chs Exp $	*/
+/*	$NetBSD: profile.c,v 1.5 2016/04/04 05:15:07 riastradh Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -565,7 +565,7 @@ MODULE_DEPEND(profile, opensolaris, 1, 1
 #ifdef __NetBSD__
 
 static int
-profile_modcmd(modcmd_t cmd, void *data)
+dtrace_profile_modcmd(modcmd_t cmd, void *data)
 {
 	switch (cmd) {
 	case MODULE_CMD_INIT:
@@ -581,6 +581,6 @@ profile_modcmd(modcmd_t cmd, void *data)
 	}
 }
 
-MODULE(MODULE_CLASS_MISC, profile, "dtrace,cyclic");
+MODULE(MODULE_CLASS_MISC, dtrace_profile, "dtrace,cyclic");
 
 #endif



CVS commit: src/external/cddl/osnet/dev/sdt

2016-02-06 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sat Feb  6 18:20:00 UTC 2016

Modified Files:
src/external/cddl/osnet/dev/sdt: sdt.c

Log Message:
SDT is not a disease. Use const consistently.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/external/cddl/osnet/dev/sdt/sdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/sdt/sdt.c
diff -u src/external/cddl/osnet/dev/sdt/sdt.c:1.14 src/external/cddl/osnet/dev/sdt/sdt.c:1.15
--- src/external/cddl/osnet/dev/sdt/sdt.c:1.14	Fri Oct  2 17:13:32 2015
+++ src/external/cddl/osnet/dev/sdt/sdt.c	Sat Feb  6 18:19:59 2016
@@ -39,7 +39,7 @@
  * unloaded; in particular, probes may not span multiple kernel modules.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdt.c,v 1.14 2015/10/02 17:13:32 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdt.c,v 1.15 2016/02/06 18:19:59 joerg Exp $");
 
 #include 
 #include 
@@ -408,8 +408,8 @@ sdt_linker_file_cb(linker_file_t lf, voi
  */
 #undef __weak
 #define __weak
-__link_set_decl(sdt_providers_set, struct std_provider);
-__link_set_decl(sdt_probes_set, struct std_probe);
+__link_set_decl(sdt_providers_set, struct sdt_provider);
+__link_set_decl(sdt_probes_set, struct sdt_probe);
 __link_set_decl(sdt_argtypes_set, struct sdt_argtype);
 
 /*
@@ -422,8 +422,8 @@ static void
 sdt_link_set_load(void)
 {
 	struct sdt_provider * const *provider;
-	struct sdt_probe **probe;
-	struct sdt_argtype **argtype;
+	struct sdt_probe * const *probe;
+	struct sdt_argtype * const *argtype;
 
 	__link_set_foreach(provider, sdt_providers_set) {
 		sdt_create_provider(*provider);
@@ -445,7 +445,7 @@ sdt_link_set_load(void)
 static void
 sdt_link_set_unload(void)
 {
-	struct sdt_provider **curr, *prov, *tmp;
+	struct sdt_provider * const *curr, *prov, *tmp;
 
 	/*
 	 * Go through all the providers declared in this linker file and



CVS commit: src/external/cddl/osnet/dev/dtrace

2015-11-28 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Nov 28 22:41:36 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/dtrace: dtrace_modevent.c

Log Message:
When loading the module, if devsw_attach() fails, call dtrace_unload()
to undo the effects of dtrace_load().  And if dtrace_unload() fails,
panic (since we can't get the system back to its earlier stable state).

When unloading the module, call devsw_detach() first, to lock out any
new access.  Then call dtrace_unload().  If dgtrace_unload() fails,
reattach the devsw, and if that fails, panic.

Implements fixes described in PR kern/43032


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/dtrace/dtrace_modevent.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/dtrace_modevent.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_modevent.c:1.4 src/external/cddl/osnet/dev/dtrace/dtrace_modevent.c:1.5
--- src/external/cddl/osnet/dev/dtrace/dtrace_modevent.c:1.4	Thu Feb 26 09:10:52 2015
+++ src/external/cddl/osnet/dev/dtrace/dtrace_modevent.c	Sat Nov 28 22:41:36 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_modevent.c,v 1.4 2015/02/26 09:10:52 ozaki-r Exp $	*/
+/*	$NetBSD: dtrace_modevent.c,v 1.5 2015/11/28 22:41:36 pgoyette Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -34,13 +34,26 @@ dtrace_modcmd(modcmd_t cmd, void *data)
 	switch (cmd) {
 	case MODULE_CMD_INIT:
 		dtrace_load(NULL);
-		return devsw_attach("dtrace", NULL, ,
+		error = devsw_attach("dtrace", NULL, ,
 		_cdevsw, );
+		if (error != 0)
+			if (dtrace_unload() != 0)
+panic("failed to unload dtrace");
+		return error;
+
 	case MODULE_CMD_FINI:
-		error = dtrace_unload();
+		error = devsw_detach(NULL, _cdevsw);
 		if (error != 0)
 			return error;
-		return devsw_detach(NULL, _cdevsw);
+
+		error = dtrace_unload();
+		if (error != 0) {
+			if (devsw_attach("dtrace", NULL, ,
+	 _cdevsw, ) != 0)
+panic("failed to reattach dtrace_devsw");
+		}
+		return error;
+
 	case MODULE_CMD_AUTOUNLOAD:
 		return EBUSY;
 	default:



CVS commit: src/external/cddl/osnet/dev/sdt

2015-10-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  2 16:59:24 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/sdt: sdt.c

Log Message:
Adapt to NetBSD modules and link set access.
XXX: We don't have an event system so that we can issue callback that
 will be run on construction or destruction to enable and disable probes
XXX: We don't have a way to use link_sets across modules properly.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/cddl/osnet/dev/sdt/sdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/sdt/sdt.c
diff -u src/external/cddl/osnet/dev/sdt/sdt.c:1.12 src/external/cddl/osnet/dev/sdt/sdt.c:1.13
--- src/external/cddl/osnet/dev/sdt/sdt.c:1.12	Wed Sep 30 16:59:44 2015
+++ src/external/cddl/osnet/dev/sdt/sdt.c	Fri Oct  2 12:59:23 2015
@@ -1,74 +1,91 @@
-/*	$NetBSD: sdt.c,v 1.12 2015/09/30 20:59:44 christos Exp $	*/
-
-/*-
- * Copyright (c) 2010 The NetBSD Foundation, Inc.
- * All rights reserved.
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
  *
- * This code is derived from software contributed to The NetBSD Foundation
- * by CoyotePoint Systems, Inc. It was developed under contract to 
- * CoyotePoint by Darran Hunt.
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [] [name of copyright owner]
  *
- * 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.
+ * CDDL HEADER END
  *
+ * Portions Copyright 2006-2008 John Birrell j...@freebsd.org
+ *
+ * $FreeBSD: head/sys/cddl/dev/sdt/sdt.c 285703 2015-07-19 22:14:09Z markj $
  *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 THE FOUNDATION 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.
  */
 
-#ifdef _KERNEL_OPT
-#include "opt_dtrace.h"
-#endif
+/*
+ * This file contains a reimplementation of the statically-defined tracing (SDT)
+ * framework for DTrace. Probes and SDT providers are defined using the macros
+ * in sys/sdt.h, which append all the needed structures to linker sets. When
+ * this module is loaded, it iterates over all of the loaded modules and
+ * registers probes and providers with the DTrace framework based on the
+ * contents of these linker sets.
+ *
+ * A list of SDT providers is maintained here since a provider may span multiple
+ * modules. When a kernel module is unloaded, a provider defined in that module
+ * is unregistered only if no other modules refer to it. The DTrace framework is
+ * responsible for destroying individual probes when a kernel module is
+ * unloaded; in particular, probes may not span multiple kernel modules.
+ */
 
 #include 
 #include 
 #include 
+
 #include 
+#include 
 #include 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
-
-#include 
-
-#define KDTRACE_HOOKS
+#include 
 #include 
 
-#undef SDT_DEBUG
-
-static dev_type_open(sdt_open);
+#include 
+#include 
 
-static int	sdt_unload(void);
+/* DTrace methods. */
 static void	sdt_getargdesc(void *, dtrace_id_t, void *, dtrace_argdesc_t *);
-static void	sdt_provide(void *, const dtrace_probedesc_t *);
+static void	

CVS commit: src/external/cddl/osnet/dev/sdt

2015-10-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  2 17:13:32 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/sdt: sdt.c

Log Message:
Merge conflicts


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/external/cddl/osnet/dev/sdt/sdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/sdt/sdt.c
diff -u src/external/cddl/osnet/dev/sdt/sdt.c:1.13 src/external/cddl/osnet/dev/sdt/sdt.c:1.14
--- src/external/cddl/osnet/dev/sdt/sdt.c:1.13	Fri Oct  2 12:59:23 2015
+++ src/external/cddl/osnet/dev/sdt/sdt.c	Fri Oct  2 13:13:32 2015
@@ -38,23 +38,33 @@
  * responsible for destroying individual probes when a kernel module is
  * unloaded; in particular, probes may not span multiple kernel modules.
  */
+#include 
+__KERNEL_RCSID(0, "$NetBSD: sdt.c,v 1.14 2015/10/02 17:13:32 christos Exp $");
 
 #include 
 #include 
 #include 
 
 #include 
+#ifdef __FreeBSD__
 #include 
+#endif
 #include 
 #include 
+#ifdef __FreeBSD__
 #include 
 #include 
+#endif
 #include 
+#ifdef __FreeBSD__
 #include 
+#endif
 #include 
+#include 
 #include 
 #include 
 #include 
+#define KDTRACE_HOOKS
 #include 
 
 #include 
@@ -62,19 +72,23 @@
 
 /* DTrace methods. */
 static void	sdt_getargdesc(void *, dtrace_id_t, void *, dtrace_argdesc_t *);
-static void	sdt_provide_probes(void *, dtrace_probedesc_t *);
+static void	sdt_provide_probes(void *, const dtrace_probedesc_t *);
 static void	sdt_destroy(void *, dtrace_id_t, void *);
-static void	sdt_enable(void *, dtrace_id_t, void *);
+static int	sdt_enable(void *, dtrace_id_t, void *);
 static void	sdt_disable(void *, dtrace_id_t, void *);
 
 static void	sdt_load(void);
 static int	sdt_unload(void);
 static void	sdt_create_provider(struct sdt_provider *);
 static void	sdt_create_probe(struct sdt_probe *);
+#ifdef __FreeBSD__
 static void	sdt_kld_load(void *, struct linker_file *);
 static void	sdt_kld_unload_try(void *, struct linker_file *, int *);
+#endif
 
-static MALLOC_DEFINE(M_SDT, "SDT", "DTrace SDT providers");
+MALLOC_DECLARE(M_SDT);
+MALLOC_DEFINE(M_SDT, "SDT", "DTrace SDT providers");
+#define SDT_KASSERT(cond, msg)	KASSERT(cond)
 
 static dtrace_pattr_t sdt_attr = {
 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
@@ -97,10 +111,37 @@ static dtrace_pops_t sdt_pops = {
 	sdt_destroy,
 };
 
+#ifdef __NetBSD__
+static int
+sdt_open(dev_t dev, int flags, int mode, struct lwp *l)
+{
+	return (0);
+}
+
+static const struct cdevsw sdt_cdevsw = {
+	sdt_open, noclose, noread, nowrite, noioctl,
+	nostop, notty, nopoll, nommap, nokqfilter, nodiscard,
+	D_OTHER
+};
+#endif
+
 static TAILQ_HEAD(, sdt_provider) sdt_prov_list;
 
+#ifdef __FreeBSD__
 eventhandler_tag	sdt_kld_load_tag;
 eventhandler_tag	sdt_kld_unload_try_tag;
+#endif
+
+#ifdef __NetBSD__
+static char *
+strdup(const char *s, const struct malloc_type *m)
+{
+	size_t l = strlen(s) + 1;
+	char *d = malloc(l, m, M_WAITOK);
+	memcpy(d, s, l);
+	return d;
+}
+#endif
 
 static void
 sdt_create_provider(struct sdt_provider *prov)
@@ -145,14 +186,16 @@ sdt_create_probe(struct sdt_probe *probe
 		if (strcmp(prov->name, probe->prov->name) == 0)
 			break;
 
-	KASSERT(prov != NULL, ("probe defined without a provider"));
+	SDT_KASSERT(prov != NULL, ("probe defined without a provider"));
 
+#ifdef __FreeBSD__
 	/* If no module name was specified, use the module filename. */
 	if (*probe->mod == 0) {
 		len = strlcpy(mod, probe->sdtp_lf->filename, sizeof(mod));
 		if (len > 3 && strcmp(mod + len - 3, ".ko") == 0)
 			mod[len - 3] = '\0';
 	} else
+#endif
 		strlcpy(mod, probe->mod, sizeof(mod));
 
 	/*
@@ -187,19 +230,26 @@ sdt_create_probe(struct sdt_probe *probe
  * requires one of provide_probes and provide_module to be defined.
  */
 static void
-sdt_provide_probes(void *arg, dtrace_probedesc_t *desc)
+sdt_provide_probes(void *arg, const dtrace_probedesc_t *desc)
 {
 }
 
-static void
+static int
 sdt_enable(void *arg __unused, dtrace_id_t id, void *parg)
 {
 	struct sdt_probe *probe = parg;
 
+#ifdef SDT_DEBUG
+	printf("sdt: %s\n", __func__);
+#endif
+
 	probe->id = id;
+#ifdef __FreeBSD__
 	probe->sdtp_lf->nenabled++;
 	if (strcmp(probe->prov->name, "lockstat") == 0)
 		lockstat_enabled++;
+#endif
+	return 1;
 }
 
 static void
@@ -207,12 +257,18 @@ sdt_disable(void *arg __unused, dtrace_i
 {
 	struct sdt_probe *probe = parg;
 
-	KASSERT(probe->sdtp_lf->nenabled > 0, ("no probes enabled"));
+	SDT_KASSERT(probe->sdtp_lf->nenabled > 0, ("no probes enabled"));
+
+#ifdef SDT_DEBUG
+	printf("sdt: %s\n", __func__);
+#endif
 
+#ifdef __FreeBSD__
 	if (strcmp(probe->prov->name, "lockstat") == 0)
 		lockstat_enabled--;
-	probe->id = 0;
 	probe->sdtp_lf->nenabled--;
+#endif
+	probe->id = 0;
 }
 
 static void
@@ -221,6 +277,16 @@ sdt_getargdesc(void *arg, dtrace_id_t id
 	struct sdt_argtype *argtype;
 	struct sdt_probe *probe = parg;
 
+#ifdef SDT_DEBUG
+	

CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2015-10-02 Thread Jeff Rizzo
Module Name:src
Committed By:   riz
Date:   Fri Oct  2 22:15:18 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_isa.c

Log Message:
Update signature of unimplemented function to match prototype.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.4 src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.5
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.4	Sat Mar 15 07:43:01 2014
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c	Fri Oct  2 22:15:18 2015
@@ -225,7 +225,7 @@ dtrace_getstackdepth(int aframes)
 }
 
 ulong_t
-dtrace_getreg(struct regs *regs, uint_t reg)
+dtrace_getreg(struct trapframe *rp, uint_t reg)
 {
 
 	return (0);



CVS commit: src/external/cddl/osnet/dev/sdt

2015-09-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 30 20:59:44 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/sdt: sdt.c

Log Message:
Add proc:::exit
XXX: I am going to kill that soon and make the providers register automagically
with linker sets. This can't scale.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/external/cddl/osnet/dev/sdt/sdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/sdt/sdt.c
diff -u src/external/cddl/osnet/dev/sdt/sdt.c:1.11 src/external/cddl/osnet/dev/sdt/sdt.c:1.12
--- src/external/cddl/osnet/dev/sdt/sdt.c:1.11	Thu Feb 26 05:31:52 2015
+++ src/external/cddl/osnet/dev/sdt/sdt.c	Wed Sep 30 16:59:44 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdt.c,v 1.11 2015/02/26 10:31:52 ozaki-r Exp $	*/
+/*	$NetBSD: sdt.c,v 1.12 2015/09/30 20:59:44 christos Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -95,6 +95,7 @@ static struct cdev		*sdt_cdev;
 /* declare all probes belonging to the provider */
 SDT_PROBE_DECLARE(proc,,,create);
 SDT_PROBE_DECLARE(proc,,,exec);
+SDT_PROBE_DECLARE(proc,,,exit);
 SDT_PROBE_DECLARE(proc,,,exec_success);
 SDT_PROBE_DECLARE(proc,,,exec_failure);
 SDT_PROBE_DECLARE(proc,,,signal_send);
@@ -121,6 +122,7 @@ static sdt_provider_t proc_provider = {
 	{ 
 		_NAME(proc,,,create),
 		_NAME(proc,,,exec),
+		_NAME(proc,,,exit),
 		_NAME(proc,,,exec_success),
 		_NAME(proc,,,exec_failure),
 		_NAME(proc,,,signal_send),



CVS commit: src/external/cddl/osnet/dev/dtrace

2015-09-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 30 20:59:13 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/dtrace: dtrace_ioctl.c

Log Message:
recognize the proc provider as belonging to sdt


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c:1.5 src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c:1.6
--- src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c:1.5	Thu Jun 18 22:33:00 2015
+++ src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c	Wed Sep 30 16:59:13 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_ioctl.c,v 1.5 2015/06/19 02:33:00 riastradh Exp $	*/
+/*	$NetBSD: dtrace_ioctl.c,v 1.6 2015/09/30 20:59:13 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -660,9 +660,14 @@ again:
 
 		if (pvp == NULL && error == 0) {
 			char name[NAME_MAX];
+			const char *provider;
+			if (strcmp(pvd->dtvd_name, "proc") == 0)
+provider = "sdt";
+			else
+provider = pvd->dtvd_name;
 
 			if (snprintf(name, sizeof name, "dtrace_%s",
-			pvd->dtvd_name) < sizeof name) {
+			provider) < sizeof name) {
 error = module_autoload(name,
 MODULE_CLASS_MISC);
 if (error == 0)



CVS commit: src/external/cddl/osnet/dev/systrace

2015-09-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep 24 14:26:44 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/systrace: systrace.c

Log Message:
use the alternate syscall names if available


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/cddl/osnet/dev/systrace/systrace.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/systrace/systrace.c
diff -u src/external/cddl/osnet/dev/systrace/systrace.c:1.7 src/external/cddl/osnet/dev/systrace/systrace.c:1.8
--- src/external/cddl/osnet/dev/systrace/systrace.c:1.7	Tue Mar 10 08:17:50 2015
+++ src/external/cddl/osnet/dev/systrace/systrace.c	Thu Sep 24 10:26:44 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: systrace.c,v 1.7 2015/03/10 12:17:50 christos Exp $	*/
+/*	$NetBSD: systrace.c,v 1.8 2015/09/24 14:26:44 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -63,19 +63,23 @@
 
 #ifndef NATIVE
 extern const char	* const CONCAT(emulname,_syscallnames)[];
+extern const char	* const CONCAT(alt,CONCAT(emulname,_syscallnames))[];
 extern 	struct sysent 	CONCAT(emulname,_sysent)[];
 #define	MODNAME		CONCAT(dtrace_syscall_,emulname)
 #define	MODDEP		"dtrace_syscall,compat_" STRING(emulname)
 #define	MAXSYSCALL	CONCAT(EMULNAME,_SYS_MAXSYSCALL)
 #define	SYSCALLNAMES	CONCAT(emulname,_syscallnames)
+#define	ALTSYSCALLNAMES	CONCAT(alt,CONCAT(emulname,_syscallnames))
 #define	SYSENT		CONCAT(emulname,_sysent)
 #define	PROVNAME	STRING(emulname) "_syscall"
 #else
 extern const char	* const syscallnames[];
+extern const char	* const altsyscallnames[];
 #define	MODNAME		dtrace_syscall
 #define	MODDEP		"dtrace"
 #define	MAXSYSCALL	SYS_MAXSYSCALL
 #define	SYSCALLNAMES	syscallnames
+#define	ALTSYSCALLNAMES	altsyscallnames
 #define	SYSENT		sysent
 #define	PROVNAME	"syscall"
 #endif
@@ -181,15 +185,16 @@ systrace_provide(void *arg, const dtrace
 		return;
 
 	for (i = 0; i < MAXSYSCALL; i++) {
-		if (dtrace_probe_lookup(systrace_id, NULL,
-		SYSCALLNAMES[i], "entry") != 0)
+		const char *name = ALTSYSCALLNAMES[i] ? ALTSYSCALLNAMES[i] :
+		SYSCALLNAMES[i];
+		if (dtrace_probe_lookup(systrace_id, NULL, name, "entry") != 0)
 			continue;
 
 		(void) dtrace_probe_create(systrace_id, NULL,
-		SYSCALLNAMES[i], "entry", SYSTRACE_ARTIFICIAL_FRAMES,
+		name, "entry", SYSTRACE_ARTIFICIAL_FRAMES,
 		(void *)(intptr_t)SYSTRACE_ENTRY(i));
 		(void) dtrace_probe_create(systrace_id, NULL,
-		SYSCALLNAMES[i], "return", SYSTRACE_ARTIFICIAL_FRAMES,
+		name, "return", SYSTRACE_ARTIFICIAL_FRAMES,
 		(void *)(intptr_t)SYSTRACE_RETURN(i));
 	}
 }



CVS commit: src/external/cddl/osnet/dev/dtrace

2015-06-18 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Jun 19 02:33:00 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/dtrace: dtrace_ioctl.c

Log Message:
Fix dtrace module autoload.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c:1.4 src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c:1.5
--- src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c:1.4	Sun Mar  3 18:16:35 2013
+++ src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c	Fri Jun 19 02:33:00 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_ioctl.c,v 1.4 2013/03/03 18:16:35 christos Exp $	*/
+/*	$NetBSD: dtrace_ioctl.c,v 1.5 2015/06/19 02:33:00 riastradh Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -659,10 +659,15 @@ again:
 		mutex_exit(dtrace_provider_lock);
 
 		if (pvp == NULL  error == 0) {
-			error = module_autoload(pvd-dtvd_name,
-			MODULE_CLASS_MISC);
-			if (error == 0)
-goto again;
+			char name[NAME_MAX];
+
+			if (snprintf(name, sizeof name, dtrace_%s,
+			pvd-dtvd_name)  sizeof name) {
+error = module_autoload(name,
+MODULE_CLASS_MISC);
+if (error == 0)
+	goto again;
+			}
 		}
 
 		if (pvp == NULL)



CVS commit: src/external/cddl/osnet/dev/dtrace/amd64

2015-05-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon May 18 14:41:41 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/dtrace/amd64: dtrace_asm.S

Log Message:
don't re-define END() now that amd64 defines it


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S
diff -u src/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S:1.4 src/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S:1.5
--- src/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S:1.4	Mon Jun 11 11:18:05 2012
+++ src/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S	Mon May 18 10:41:41 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_asm.S,v 1.4 2012/06/11 15:18:05 chs Exp $	*/
+/*	$NetBSD: dtrace_asm.S,v 1.5 2015/05/18 14:41:41 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -35,7 +35,6 @@
 #include sys/cpuvar_defs.h
 #include sys/dtrace.h
 #include machine/asm.h
-#define END(a)
 #define MEXITCOUNT
 
 #include assym.h



CVS commit: src/external/cddl/osnet/dev/systrace

2015-03-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 10 12:17:50 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/systrace: systrace.c

Log Message:
fix reversed test.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dev/systrace/systrace.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/systrace/systrace.c
diff -u src/external/cddl/osnet/dev/systrace/systrace.c:1.6 src/external/cddl/osnet/dev/systrace/systrace.c:1.7
--- src/external/cddl/osnet/dev/systrace/systrace.c:1.6	Sat Mar  7 12:47:09 2015
+++ src/external/cddl/osnet/dev/systrace/systrace.c	Tue Mar 10 08:17:50 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: systrace.c,v 1.6 2015/03/07 17:47:09 christos Exp $	*/
+/*	$NetBSD: systrace.c,v 1.7 2015/03/10 12:17:50 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -142,7 +142,7 @@ systrace_probe(uint32_t id, register_t s
 	uintptr_t	uargs[SYS_MAXSYSARGS + 3];
 
 	memset(uargs, 0, sizeof(uargs));
-	if (ret) {
+	if (ret == NULL) {
 		/* entry syscall, convert params */
 		systrace_args(sysnum, params, uargs, n_args);
 	} else {



CVS commit: src/external/cddl/osnet/dev/lockstat

2015-03-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  9 00:53:39 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/lockstat: lockstat.c

Log Message:
- remove device stuff
- compress ops
- terminate array of probes


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dev/lockstat/lockstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/lockstat/lockstat.c
diff -u src/external/cddl/osnet/dev/lockstat/lockstat.c:1.5 src/external/cddl/osnet/dev/lockstat/lockstat.c:1.6
--- src/external/cddl/osnet/dev/lockstat/lockstat.c:1.5	Sun Mar  8 19:56:59 2015
+++ src/external/cddl/osnet/dev/lockstat/lockstat.c	Sun Mar  8 20:53:39 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: lockstat.c,v 1.5 2015/03/08 23:56:59 riastradh Exp $	*/
+/*	$NetBSD: lockstat.c,v 1.6 2015/03/09 00:53:39 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: lockstat.c,v 1.5 2015/03/08 23:56:59 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: lockstat.c,v 1.6 2015/03/09 00:53:39 christos Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -36,6 +36,7 @@ __KERNEL_RCSID(0, $NetBSD: lockstat.c,v
 #include sys/mutex.h
 #include sys/systm.h
 #include sys/xcall.h
+#include sys/atomic.h
 
 #include dev/lockstat.h
 
@@ -57,6 +58,7 @@ lockstat_probe_t lockstat_probes[] = {
 	{ rwlock, spin,		LB_RWLOCK	| LB_SPIN,	0 },
 	{ kernel, spin,		LB_KERNEL_LOCK	| LB_SPIN,	0 },
 	{ lwp, spin,		LB_NOPREEMPT	| LB_SPIN,	0 },
+	{ NULL, NULL,			0,0 },
 };
 
 static dtrace_provider_id_t lockstat_id;
@@ -67,9 +69,10 @@ lockstat_enable(void *arg, dtrace_id_t i
 {
 	lockstat_probe_t *probe = parg;
 
-	ASSERT(!lockstat_probemap[probe-lsp_probe]);
+	ASSERT(!lockstat_probemap[LS_COMPRESS(probe-lsp_probe)]);
 
-	lockstat_probemap[probe-lsp_probe] = id;
+printf(%s: %x %jd\n, __func__, LS_COMPRESS(probe-lsp_probe), (intmax_t)id);
+	lockstat_probemap[LS_COMPRESS(probe-lsp_probe)] = id;
 
 	return 0;
 }
@@ -80,34 +83,12 @@ lockstat_disable(void *arg, dtrace_id_t 
 {
 	lockstat_probe_t *probe = parg;
 
-	ASSERT(lockstat_probemap[probe-lsp_probe]);
+	ASSERT(lockstat_probemap[LS_COMPRESS(probe-lsp_probe)]);
 
-	lockstat_probemap[probe-lsp_probe] = 0;
+printf(%s: %x %jd\n, __func__, LS_COMPRESS(probe-lsp_probe), (intmax_t)id);
+	lockstat_probemap[LS_COMPRESS(probe-lsp_probe)] = 0;
 }
 
-static int
-lockstat_open(dev_t dev __unused, int flags __unused, int mode __unused,
-struct lwp *l __unused)
-{
-
-	return 0;
-}
-
-static const struct cdevsw lockstat_cdevsw = {
-	.d_open = lockstat_open,
-	.d_close = noclose,
-	.d_read = noread,
-	.d_write = nowrite,
-	.d_ioctl = noioctl,
-	.d_stop = nostop,
-	.d_tty = notty,
-	.d_poll = nopoll,
-	.d_mmap = nommap,
-	.d_kqfilter = nokqfilter,
-	.d_discard = nodiscard,
-	.d_flag = D_OTHER,
-};
-
 /*ARGSUSED*/
 static void
 lockstat_provide(void *arg, const dtrace_probedesc_t *desc)
@@ -188,7 +169,6 @@ lockstat_cas_probe(dtrace_probe_func_t o
 static int
 lockstat_init(void)
 {
-	int bmaj = -1, cmaj = -1;
 	int error;
 	bool ok;
 
@@ -200,13 +180,6 @@ lockstat_init(void)
 		goto fail0;
 	}
 
-	/* Create a character device.  */
-	error = devsw_attach(lockstat, NULL, bmaj, lockstat_cdevsw, cmaj);
-	if (error) {
-		printf(dtrace_lockstat: failed to attach devsw: %d\n, error);
-		goto fail1;
-	}
-
 	/* Everything is in place.  Register a dtrace provider.  */
 	ASSERT(lockstat_id == 0);
 	error = dtrace_register(lockstat, lockstat_attr, DTRACE_PRIV_USER,
@@ -214,14 +187,11 @@ lockstat_init(void)
 	if (error) {
 		printf(dtrace_lockstat: failed to register dtrace provider
 		: %d\n, error);
-		goto fail2;
+		goto fail1;
 	}
-	ASSERT(lockstat_id != 0);
-
 	/* Success!  */
 	return 0;
 
-fail2:	devsw_detach(NULL, lockstat_cdevsw);
 fail1:	ok = lockstat_cas_probe(dtrace_probe, lockstat_probe_stub);
 	ASSERT(ok);
 fail0:	ASSERT(error);
@@ -249,14 +219,6 @@ lockstat_fini(void)
 		lockstat_id = 0;
 	}
 
-	/* Detach the device.  */
-	error = devsw_detach(NULL, lockstat_cdevsw);
-	if (error) {
-		printf(dtrace_lockstat: failed to detach device: %d\n,
-		error);
-		return error;
-	}
-
 	/* Unhook the probe.  */
 	ok = lockstat_cas_probe(dtrace_probe, lockstat_probe_stub);
 	ASSERT(ok);



CVS commit: src/external/cddl/osnet/dev/lockstat

2015-03-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar  9 01:07:27 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/lockstat: lockstat.c

Log Message:
Remove debug prints, simplify fini logic.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dev/lockstat/lockstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/lockstat/lockstat.c
diff -u src/external/cddl/osnet/dev/lockstat/lockstat.c:1.6 src/external/cddl/osnet/dev/lockstat/lockstat.c:1.7
--- src/external/cddl/osnet/dev/lockstat/lockstat.c:1.6	Mon Mar  9 00:53:39 2015
+++ src/external/cddl/osnet/dev/lockstat/lockstat.c	Mon Mar  9 01:07:27 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: lockstat.c,v 1.6 2015/03/09 00:53:39 christos Exp $	*/
+/*	$NetBSD: lockstat.c,v 1.7 2015/03/09 01:07:27 riastradh Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: lockstat.c,v 1.6 2015/03/09 00:53:39 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: lockstat.c,v 1.7 2015/03/09 01:07:27 riastradh Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -71,7 +71,6 @@ lockstat_enable(void *arg, dtrace_id_t i
 
 	ASSERT(!lockstat_probemap[LS_COMPRESS(probe-lsp_probe)]);
 
-printf(%s: %x %jd\n, __func__, LS_COMPRESS(probe-lsp_probe), (intmax_t)id);
 	lockstat_probemap[LS_COMPRESS(probe-lsp_probe)] = id;
 
 	return 0;
@@ -85,7 +84,6 @@ lockstat_disable(void *arg, dtrace_id_t 
 
 	ASSERT(lockstat_probemap[LS_COMPRESS(probe-lsp_probe)]);
 
-printf(%s: %x %jd\n, __func__, LS_COMPRESS(probe-lsp_probe), (intmax_t)id);
 	lockstat_probemap[LS_COMPRESS(probe-lsp_probe)] = 0;
 }
 
@@ -204,19 +202,12 @@ lockstat_fini(void)
 	int error;
 	bool ok __diagused;
 
-	/*
-	 * If we haven't previously tried to detach and failed,
-	 * unregister the dtrace provider.
-	 */
-	if (lockstat_id != 0) {
-		error = dtrace_unregister(lockstat_id);
-		if (error) {
-			printf(dtrace_lockstat
-			: failed to unregister dtrace provider: %d\n,
-			error);
-			return error;
-		}
-		lockstat_id = 0;
+	error = dtrace_unregister(lockstat_id);
+	if (error) {
+		printf(dtrace_lockstat: failed to unregister dtrace provider
+		: %d\n,
+		error);
+		return error;
 	}
 
 	/* Unhook the probe.  */



CVS commit: src/external/cddl/osnet/dev

2015-03-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar  9 03:43:02 UTC 2015

Modified Files:
src/external/cddl/osnet/dev: prototype.c

Log Message:
Rewrite dtrace provider prototype from scratch.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/dev/prototype.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/prototype.c
diff -u src/external/cddl/osnet/dev/prototype.c:1.2 src/external/cddl/osnet/dev/prototype.c:1.3
--- src/external/cddl/osnet/dev/prototype.c:1.2	Sun Feb 21 01:46:32 2010
+++ src/external/cddl/osnet/dev/prototype.c	Mon Mar  9 03:43:02 2015
@@ -1,146 +1,176 @@
-/*	$NetBSD: prototype.c,v 1.2 2010/02/21 01:46:32 darran Exp $	*/
+/*	$NetBSD: prototype.c,v 1.3 2015/03/09 03:43:02 riastradh Exp $	*/
 
-/*
- * This file is freeware. You are free to use it and add your own
- * license.
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
  *
- * $FreeBSD: src/sys/cddl/dev/prototype.c,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $
+ * 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 THE NETBSD FOUNDATION, INC. 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 THE FOUNDATION 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 sys/cdefs.h
+__RCSID($NetBSD: prototype.c,v 1.3 2015/03/09 03:43:02 riastradh Exp $);
+
+#include sys/types.h
 #include sys/param.h
-#include sys/systm.h
 #include sys/conf.h
-#include sys/kernel.h
-#include sys/module.h
-
 #include sys/dtrace.h
+#include sys/module.h
+#include sys/systm.h
 
-static d_open_t	prototype_open;
-static int	prototype_unload(void);
-static void	prototype_getargdesc(void *, dtrace_id_t, void *, dtrace_argdesc_t *);
-static void	prototype_provide(void *, dtrace_probedesc_t *);
-static void	prototype_destroy(void *, dtrace_id_t, void *);
-static void	prototype_enable(void *, dtrace_id_t, void *);
-static void	prototype_disable(void *, dtrace_id_t, void *);
-static void	prototype_load(void *);
-
-static struct cdevsw prototype_cdevsw = {
-	.d_version	= D_VERSION,
-	.d_open		= prototype_open,
-	.d_name		= prototype,
-};
-
-static dtrace_pattr_t prototype_attr = {
-{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
-{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
-{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
-{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
-{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_ISA },
-};
-
-static dtrace_pops_t prototype_pops = {
-	prototype_provide,
-	NULL,
-	prototype_enable,
-	prototype_disable,
-	NULL,
-	NULL,
-	prototype_getargdesc,
-	NULL,
-	NULL,
-	prototype_destroy
-};
-
-static struct cdev		*prototype_cdev;
-static dtrace_provider_id_t	prototype_id;
+static dtrace_provider_id_t prototype_id;
 
 static void
-prototype_getargdesc(void *arg, dtrace_id_t id, void *parg, dtrace_argdesc_t *desc)
+prototype_enable(void *arg, dtrace_id_t id, void *parg)
 {
+	/* Enable the probe for id.  */
 }
 
 static void
-prototype_provide(void *arg, dtrace_probedesc_t *desc)
+prototype_disable(void *arg, dtrace_id_t id, void *parg)
 {
+	/* Disable the probe for id.  */
 }
 
 static void
-prototype_destroy(void *arg, dtrace_id_t id, void *parg)
+prototype_getargdesc(void *arg, dtrace_id_t id, void *parg,
+dtrace_argdesc_t *desc)
 {
+	/* Get the argument descriptions for the probe id.  */
 }
 
-static void
-prototype_enable(void *arg, dtrace_id_t id, void *parg)
+static uint64_t
+prototype_getargval(void *arg, dtrace_id_t id, void *parg, int argno,
+int aframes)
 {
+	/* Get the value for the argno'th argument to the probe id.  */
 }
 
 static void
-prototype_disable(void *arg, 

CVS commit: src/external/cddl/osnet/dev/lockstat

2015-03-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar  8 23:56:59 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/lockstat: lockstat.c

Log Message:
Rewrite dtrace lockstat from the Solaris version and simplify.

- Fix mutex_adaptive probes to use the right lockstat flags.
- Install lockstat_probe_func on module load, not trace enable.
- Use a more sensible memory barrier arrangement.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/lockstat/lockstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/lockstat/lockstat.c
diff -u src/external/cddl/osnet/dev/lockstat/lockstat.c:1.4 src/external/cddl/osnet/dev/lockstat/lockstat.c:1.5
--- src/external/cddl/osnet/dev/lockstat/lockstat.c:1.4	Sun Mar  8 04:13:46 2015
+++ src/external/cddl/osnet/dev/lockstat/lockstat.c	Sun Mar  8 23:56:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: lockstat.c,v 1.4 2015/03/08 04:13:46 christos Exp $	*/
+/*	$NetBSD: lockstat.c,v 1.5 2015/03/08 23:56:59 riastradh Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -19,183 +19,47 @@
  * information: Portions Copyright [] [name of copyright owner]
  *
  * CDDL HEADER END
- *
- * Portions Copyright (c) 2008-2009 Stacey Son s...@freebsd.org 
- *
- * $FreeBSD: src/sys/cddl/dev/lockstat/lockstat.c,v 1.2.2.1 2009/08/03 08:13:06 kensmith Exp $
- *
  */
-
 /*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
 #include sys/cdefs.h
+__KERNEL_RCSID(0, $NetBSD: lockstat.c,v 1.5 2015/03/08 23:56:59 riastradh Exp $);
+
+#include sys/types.h
 #include sys/param.h
-#include sys/systm.h
 #include sys/conf.h
-#include sys/kernel.h
-#include sys/limits.h
-#include sys/lock.h
-#include sys/linker.h
+#include sys/dtrace.h
 #include sys/module.h
 #include sys/mutex.h
-#ifdef __NetBSD__
-#include sys/atomic.h
+#include sys/systm.h
 #include sys/xcall.h
-#endif
 
-#include sys/dtrace.h
-#ifdef __NetBSD__
 #include dev/lockstat.h
-#else
-#include sys/lockstat.h
-#endif
 
-#ifdef __NetBSD__
 #define	ASSERT	KASSERT
-#endif
-
-#if defined(__i386__) || defined(__amd64__) || defined(__arm__)
-#define LOCKSTAT_AFRAMES 1
-#else
-#error architecture not supported
-#endif
-
-#if defined(__FreeBSD__)
-static d_open_t lockstat_open;
-#elif defined(__NetBSD__)  0
-static dev_type_open(lockstat_open);
-#endif
-static void	lockstat_provide(void *, const dtrace_probedesc_t *);
-static void	lockstat_destroy(void *, dtrace_id_t, void *);
-static int	lockstat_enable(void *, dtrace_id_t, void *);
-static void	lockstat_disable(void *, dtrace_id_t, void *);
-static void	lockstat_load(void *);
-static int	lockstat_unload(void);
-
 
 typedef struct lockstat_probe {
 	const char	*lsp_func;
 	const char	*lsp_name;
 	int		lsp_probe;
 	dtrace_id_t	lsp_id;
-#ifdef __FreeBSD__
-	int		lsp_frame;
-#endif
 } lockstat_probe_t;
 
-#if defined(__FreeBSD__)
-lockstat_probe_t lockstat_probes[] =
-{
-  /* Spin Locks */
-  { LS_MTX_SPIN_LOCK,	LSS_ACQUIRE,	LS_MTX_SPIN_LOCK_ACQUIRE,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  { LS_MTX_SPIN_LOCK, 	LSS_SPIN,	LS_MTX_SPIN_LOCK_SPIN,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  { LS_MTX_SPIN_UNLOCK,	LSS_RELEASE,	LS_MTX_SPIN_UNLOCK_RELEASE,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  /* Adaptive Locks */
-  { LS_MTX_LOCK,	LSA_ACQUIRE,	LS_MTX_LOCK_ACQUIRE,
-	  DTRACE_IDNONE, (LOCKSTAT_AFRAMES + 1) },
-  { LS_MTX_LOCK,	LSA_BLOCK,	LS_MTX_LOCK_BLOCK,
-	  DTRACE_IDNONE, (LOCKSTAT_AFRAMES + 1) },
-  { LS_MTX_LOCK,	LSA_SPIN,	LS_MTX_LOCK_SPIN,
-	  DTRACE_IDNONE, (LOCKSTAT_AFRAMES + 1) },
-  { LS_MTX_UNLOCK,	LSA_RELEASE,	LS_MTX_UNLOCK_RELEASE,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  { LS_MTX_TRYLOCK,	LSA_ACQUIRE,	LS_MTX_TRYLOCK_ACQUIRE,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  /* Reader/Writer Locks */
-  { LS_RW_RLOCK,	LSR_ACQUIRE,	LS_RW_RLOCK_ACQUIRE,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  { LS_RW_RLOCK,	LSR_BLOCK,	LS_RW_RLOCK_BLOCK,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  { LS_RW_RLOCK,	LSR_SPIN,	LS_RW_RLOCK_SPIN,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  { LS_RW_RUNLOCK,	LSR_RELEASE,	LS_RW_RUNLOCK_RELEASE,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  { LS_RW_WLOCK,	LSR_ACQUIRE,	LS_RW_WLOCK_ACQUIRE,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  { LS_RW_WLOCK,	LSR_BLOCK,	LS_RW_WLOCK_BLOCK,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  { LS_RW_WLOCK,	LSR_SPIN,	LS_RW_WLOCK_SPIN,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  { LS_RW_WUNLOCK,	LSR_RELEASE,	LS_RW_WUNLOCK_RELEASE,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  { LS_RW_TRYUPGRADE,	LSR_UPGRADE,   	LS_RW_TRYUPGRADE_UPGRADE,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  { LS_RW_DOWNGRADE,	LSR_DOWNGRADE, 	LS_RW_DOWNGRADE_DOWNGRADE,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  /* Shared/Exclusive Locks */
-  { LS_SX_SLOCK,	LSX_ACQUIRE,	LS_SX_SLOCK_ACQUIRE,
-	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
-  

CVS commit: src/external/cddl/osnet/dev/lockstat

2015-03-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  9 01:42:26 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/lockstat: lockstat.c

Log Message:
keep track of the number of enabled probes and set the lockstat_dtrace_enabled
flag appropriately.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/cddl/osnet/dev/lockstat/lockstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/lockstat/lockstat.c
diff -u src/external/cddl/osnet/dev/lockstat/lockstat.c:1.7 src/external/cddl/osnet/dev/lockstat/lockstat.c:1.8
--- src/external/cddl/osnet/dev/lockstat/lockstat.c:1.7	Sun Mar  8 21:07:27 2015
+++ src/external/cddl/osnet/dev/lockstat/lockstat.c	Sun Mar  8 21:42:26 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: lockstat.c,v 1.7 2015/03/09 01:07:27 riastradh Exp $	*/
+/*	$NetBSD: lockstat.c,v 1.8 2015/03/09 01:42:26 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: lockstat.c,v 1.7 2015/03/09 01:07:27 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: lockstat.c,v 1.8 2015/03/09 01:42:26 christos Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -38,6 +38,7 @@ __KERNEL_RCSID(0, $NetBSD: lockstat.c,v
 #include sys/xcall.h
 #include sys/atomic.h
 
+#define NLOCKSTAT 1
 #include dev/lockstat.h
 
 #define	ASSERT	KASSERT
@@ -62,6 +63,7 @@ lockstat_probe_t lockstat_probes[] = {
 };
 
 static dtrace_provider_id_t lockstat_id;
+static size_t lockstat_dtrace_count;
 
 /*ARGSUSED*/
 static int
@@ -72,6 +74,10 @@ lockstat_enable(void *arg, dtrace_id_t i
 	ASSERT(!lockstat_probemap[LS_COMPRESS(probe-lsp_probe)]);
 
 	lockstat_probemap[LS_COMPRESS(probe-lsp_probe)] = id;
+	if (lockstat_dtrace_count++ == 0) {
+		lockstat_dtrace_enabled = LB_DTRACE;
+		LOCKSTAT_ENABLED_UPDATE();
+	}
 
 	return 0;
 }
@@ -84,6 +90,11 @@ lockstat_disable(void *arg, dtrace_id_t 
 
 	ASSERT(lockstat_probemap[LS_COMPRESS(probe-lsp_probe)]);
 
+	if (--lockstat_dtrace_count == 0) {
+		lockstat_dtrace_enabled = 0;
+		LOCKSTAT_ENABLED_UPDATE();
+	}
+
 	lockstat_probemap[LS_COMPRESS(probe-lsp_probe)] = 0;
 }
 



CVS commit: src/external/cddl/osnet/dev/systrace

2015-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  7 15:14:09 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/systrace: systrace.c

Log Message:
- cleanup FreeBSD ifdefs
- remove unused code
- adjust to NetBSD struct emul and types.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/systrace/systrace.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/systrace/systrace.c
diff -u src/external/cddl/osnet/dev/systrace/systrace.c:1.4 src/external/cddl/osnet/dev/systrace/systrace.c:1.5
--- src/external/cddl/osnet/dev/systrace/systrace.c:1.4	Sun Jan 12 12:49:30 2014
+++ src/external/cddl/osnet/dev/systrace/systrace.c	Sat Mar  7 10:14:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: systrace.c,v 1.4 2014/01/12 17:49:30 riz Exp $	*/
+/*	$NetBSD: systrace.c,v 1.5 2015/03/07 15:14:09 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -38,9 +38,6 @@
 #include sys/cpuvar.h
 #include sys/fcntl.h
 #include sys/filio.h
-#ifdef __FreeBSD__
-#include sys/kdb.h
-#endif
 #include sys/kernel.h
 #include sys/kmem.h
 #include sys/kthread.h
@@ -53,44 +50,40 @@
 #include sys/poll.h
 #include sys/proc.h
 #include sys/selinfo.h
-#ifdef __FreeBSD__
-#include sys/smp.h
-#include sys/sysproto.h
-#include sys/sysent.h
-#endif
 #include sys/syscallargs.h
 #include sys/uio.h
 #include sys/unistd.h
 
 #include sys/dtrace.h
 
-#ifdef LINUX_SYSTRACE
-#include linux.h
-#include linux_syscall.h
-#include linux_proto.h
-#include linux_syscallnames.c
-#include linux_systrace.c
-extern struct sysent linux_sysent[];
-#define	DEVNAME		dtrace/linsystrace
-#define	PROVNAME	linsyscall
-#define	MAXSYSCALL	LINUX_SYS_MAXSYSCALL
-#define	SYSCALLNAMES	linux_syscallnames
-#define	SYSENT		linux_sysent
+#include emultrace.h
+
+#define	CONCAT(x,y)	__CONCAT(x,y)
+#define	STRING(s)	__STRING(s)
+
+#ifndef NATIVE
+extern const char	* const CONCAT(emulname,_syscallnames)[];
+extern 	struct sysent 	CONCAT(emulname,_sysent)[];
+#define	MODNAME		CONCAT(dtrace_syscall_,emulname)
+#define	MODDEP		dtrace_syscall,compat_ STRING(emulname)
+#define	MAXSYSCALL	CONCAT(EMULNAME,_SYS_MAXSYSCALL)
+#define	SYSCALLNAMES	CONCAT(emulname,_syscallnames)
+#define	SYSENT		CONCAT(emulname,_sysent)
+#define	PROVNAME	STRING(emulname) _syscall
 #else
-/*
- * The syscall arguments are processed into a DTrace argument array
- * using a generated function. See sys/kern/makesyscalls.sh.
- */
-#include sys/syscall.h
-#include kern/systrace_args.c
 extern const char	* const syscallnames[];
-#define	DEVNAME		dtrace/systrace
-#define	PROVNAME	syscall
+#define	MODNAME		dtrace_syscall
+#define	MODDEP		dtrace
 #define	MAXSYSCALL	SYS_MAXSYSCALL
 #define	SYSCALLNAMES	syscallnames
 #define	SYSENT		sysent
+#define	PROVNAME	syscall
 #endif
 
+#define	MODCMD		CONCAT(MODNAME,_modcmd)
+#define EMUL		CONCAT(emul_,emulname)
+extern struct emul 	EMUL;
+
 #define	SYSTRACE_ARTIFICIAL_FRAMES	1
 
 #define	SYSTRACE_SHIFT			16
@@ -103,9 +96,6 @@ extern const char	* const syscallnames[]
 #error 1  SYSTRACE_SHIFT must exceed number of system calls
 #endif
 
-#ifdef __FreeBSD__
-static d_open_t	systrace_open;
-#endif
 static int	systrace_unload(void);
 static void	systrace_getargdesc(void *, dtrace_id_t, void *, dtrace_argdesc_t *);
 static void	systrace_provide(void *, const dtrace_probedesc_t *);
@@ -114,23 +104,6 @@ static int	systrace_enable(void *, dtrac
 static void	systrace_disable(void *, dtrace_id_t, void *);
 static void	systrace_load(void *);
 
-#ifdef __FreeBSD__
-static struct cdevsw systrace_cdevsw = {
-	.d_version	= D_VERSION,
-	.d_open		= systrace_open,
-#ifdef LINUX_SYSTRACE
-	.d_name		= linsystrace,
-#else
-	.d_name		= systrace,
-#endif
-};
-#endif
-
-static union	{
-	const char	* const *p_constnames;
-	char		**pp_syscallnames;
-} uglyhack = { SYSCALLNAMES };
-
 static dtrace_pattr_t systrace_attr = {
 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
 { DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
@@ -152,12 +125,8 @@ static dtrace_pops_t systrace_pops = {
 	systrace_destroy
 };
 
-#ifdef __FreeBSD__
-static struct cdev		*systrace_cdev;
-#endif
 static dtrace_provider_id_t	systrace_id;
 
-#if !defined(LINUX_SYSTRACE)
 /*
  * Probe callback function.
  *
@@ -166,48 +135,40 @@ static dtrace_provider_id_t	systrace_id;
  *   compat syscall from something like Linux.
  */
 static void
-systrace_probe(u_int32_t id, int sysnum, struct sysent *se, void *params)
+systrace_probe(uint32_t id, register_t sysnum, const struct sysent *se,
+const void *params, const register_t *ret, int error)
 {
-	int		n_args	= 0;
-	union systrace_probe_args_un	uargs[SYS_MAXSYSARGS];
+	size_t		n_args	= 0;
+	uintptr_t	uargs[SYS_MAXSYSARGS];
 
-	/*
-	 * Check if this syscall has an argument conversion function
-	 * registered.
-	 */
-	if (se-sy_systrace_args_func != NULL)
-		/*
-		 * Convert the 

CVS commit: src/external/cddl/osnet/dev/systrace

2015-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  7 17:47:09 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/systrace: systrace.c

Log Message:
we have space for 2 more arguments so use it.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dev/systrace/systrace.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/systrace/systrace.c
diff -u src/external/cddl/osnet/dev/systrace/systrace.c:1.5 src/external/cddl/osnet/dev/systrace/systrace.c:1.6
--- src/external/cddl/osnet/dev/systrace/systrace.c:1.5	Sat Mar  7 10:14:09 2015
+++ src/external/cddl/osnet/dev/systrace/systrace.c	Sat Mar  7 12:47:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: systrace.c,v 1.5 2015/03/07 15:14:09 christos Exp $	*/
+/*	$NetBSD: systrace.c,v 1.6 2015/03/07 17:47:09 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -139,17 +139,18 @@ systrace_probe(uint32_t id, register_t s
 const void *params, const register_t *ret, int error)
 {
 	size_t		n_args	= 0;
-	uintptr_t	uargs[SYS_MAXSYSARGS];
+	uintptr_t	uargs[SYS_MAXSYSARGS + 3];
 
 	memset(uargs, 0, sizeof(uargs));
-	if (params) {
+	if (ret) {
 		/* entry syscall, convert params */
 		systrace_args(sysnum, params, uargs, n_args);
 	} else {
-		/* return syscall, set values (XXX: errno?) */
+		/* return syscall, set values and params: */
 		uargs[0] = ret[0];
 		uargs[1] = ret[1];
 		uargs[2] = error;
+		systrace_args(sysnum, params, uargs + 3, n_args);
 	}
 	/* Process the probe using the converted argments. */
 	/* XXX: fix for more arguments! */



CVS commit: src/external/cddl/osnet/dev/lockstat

2015-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  8 04:13:46 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/lockstat: lockstat.c

Log Message:
preliminary support from riastradh (does not work yet, toxic)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dev/lockstat/lockstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/lockstat/lockstat.c
diff -u src/external/cddl/osnet/dev/lockstat/lockstat.c:1.3 src/external/cddl/osnet/dev/lockstat/lockstat.c:1.4
--- src/external/cddl/osnet/dev/lockstat/lockstat.c:1.3	Fri Jun 21 15:16:00 2013
+++ src/external/cddl/osnet/dev/lockstat/lockstat.c	Sat Mar  7 23:13:46 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: lockstat.c,v 1.3 2013/06/21 19:16:00 christos Exp $	*/
+/*	$NetBSD: lockstat.c,v 1.4 2015/03/08 04:13:46 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -31,8 +31,6 @@
  * Use is subject to license terms.
  */
 
-#include opt_kdtrace.h
-
 #include sys/cdefs.h
 #include sys/param.h
 #include sys/systm.h
@@ -43,9 +41,21 @@
 #include sys/linker.h
 #include sys/module.h
 #include sys/mutex.h
+#ifdef __NetBSD__
+#include sys/atomic.h
+#include sys/xcall.h
+#endif
 
 #include sys/dtrace.h
+#ifdef __NetBSD__
+#include dev/lockstat.h
+#else
 #include sys/lockstat.h
+#endif
+
+#ifdef __NetBSD__
+#define	ASSERT	KASSERT
+#endif
 
 #if defined(__i386__) || defined(__amd64__) || defined(__arm__)
 #define LOCKSTAT_AFRAMES 1
@@ -53,18 +63,22 @@
 #error architecture not supported
 #endif
 
+#if defined(__FreeBSD__)
 static d_open_t lockstat_open;
-static void lockstat_provide(void *, dtrace_probedesc_t *);
-static void lockstat_destroy(void *, dtrace_id_t, void *);
-static void lockstat_enable(void *, dtrace_id_t, void *);
-static void lockstat_disable(void *, dtrace_id_t, void *);
-static void lockstat_load(void *);
-static int 	lockstat_unload(void);
+#elif defined(__NetBSD__)  0
+static dev_type_open(lockstat_open);
+#endif
+static void	lockstat_provide(void *, const dtrace_probedesc_t *);
+static void	lockstat_destroy(void *, dtrace_id_t, void *);
+static int	lockstat_enable(void *, dtrace_id_t, void *);
+static void	lockstat_disable(void *, dtrace_id_t, void *);
+static void	lockstat_load(void *);
+static int	lockstat_unload(void);
 
 
 typedef struct lockstat_probe {
-	char		*lsp_func;
-	char		*lsp_name;
+	const char	*lsp_func;
+	const char	*lsp_name;
 	int		lsp_probe;
 	dtrace_id_t	lsp_id;
 #ifdef __FreeBSD__
@@ -72,7 +86,7 @@ typedef struct lockstat_probe {
 #endif
 } lockstat_probe_t;
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__)
 lockstat_probe_t lockstat_probes[] =
 {
   /* Spin Locks */
@@ -140,11 +154,23 @@ lockstat_probe_t lockstat_probes[] =
 	  DTRACE_IDNONE, LOCKSTAT_AFRAMES },
   { NULL }
 };
+#elif defined(__NetBSD__)
+lockstat_probe_t lockstat_probes[] = {
+	{ mutex_spin, spin,		LB_SPIN_MUTEX	| LB_SPIN,	0 },
+	{ mutex_adaptive, sleep,	LB_SPIN_MUTEX	| LB_SLEEP1,	0 },
+	{ mutex_adaptive, spin,	LB_SPIN_MUTEX	| LB_SPIN,	0 },
+	{ rwlock, sleep_writer,	LB_RWLOCK	| LB_SLEEP1,	0 },
+	{ rwlock, sleep_reader,	LB_RWLOCK	| LB_SLEEP2,	0 },
+	{ rwlock, spin,		LB_RWLOCK	| LB_SPIN,	0 },
+	{ kernel, spin,		LB_KERNEL_LOCK	| LB_SPIN,	0 },
+	{ lwp, spin,		LB_NOPREEMPT	| LB_SPIN,	0 },
+};
 #else
 #error OS not supported
 #endif
 
 
+#if defined(__FreeBSD__)
 static struct cdevsw lockstat_cdevsw = {
 	.d_version	= D_VERSION,
 	.d_open		= lockstat_open,
@@ -152,28 +178,41 @@ static struct cdevsw lockstat_cdevsw = {
 };
 
 static struct cdev		*lockstat_cdev; 
+#elif defined(__NetBSD__)  0
+static struct cdevsw lockstat_cdevsw = {
+	.d_open = lockstat_open,
+	.d_close = noclose,
+	.d_read = noread,
+	.d_write = nowrite,
+	.d_ioctl = noioctl,
+	.d_stop = nostop,
+	.d_tty = notty,
+	.d_poll = nopoll,
+	.d_mmap = nommap,
+	.d_kqfilter = nokqfilter,
+	.d_discard = nodiscard,
+	.d_flag = D_OTHER,
+};
+#endif
+
 static dtrace_provider_id_t 	lockstat_id;
 
 /*ARGSUSED*/
-static void
+static int
 lockstat_enable(void *arg, dtrace_id_t id, void *parg)
 {
 	lockstat_probe_t *probe = parg;
 
 	ASSERT(!lockstat_probemap[probe-lsp_probe]);
-
+	if (lockstat_probe_func == lockstat_probe_stub) {
+		lockstat_probe_func = dtrace_probe;
+		membar_producer();
+	} else {
+		ASSERT(lockstat_probe_func == dtrace_probe);
+	}
 	lockstat_probemap[probe-lsp_probe] = id;
-#ifdef DOODAD
-	membar_producer();
-#endif
 
-	lockstat_probe_func = dtrace_probe;
-#ifdef DOODAD
-	membar_producer();
-
-	lockstat_hot_patch();
-	membar_producer();
-#endif
+	return 0;
 }
 
 /*ARGSUSED*/
@@ -183,13 +222,10 @@ lockstat_disable(void *arg, dtrace_id_t 
 	lockstat_probe_t *probe = parg;
 	int i;
 
+	ASSERT(lockstat_probe_func == dtrace_probe);
 	ASSERT(lockstat_probemap[probe-lsp_probe]);
-
 	lockstat_probemap[probe-lsp_probe] = 0;
-#ifdef DOODAD
-	lockstat_hot_patch();
 	membar_producer();
-#endif
 
 	/*
 	 * See if we have 

CVS commit: src/external/cddl/osnet/dev

2015-02-26 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Feb 26 09:10:53 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/dtrace: dtrace_modevent.c dtrace_unload.c
src/external/cddl/osnet/dev/fbt: fbt.c
src/external/cddl/osnet/dev/sdt: sdt.c

Log Message:
Fix module unload of dtrace, sdt and fbt

- Don't unload when there are users of dtrace
- Forbid auto unloading (not supported for now)

PR 49695


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dev/dtrace/dtrace_modevent.c
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dev/dtrace/dtrace_unload.c
cvs rdiff -u -r1.16 -r1.17 src/external/cddl/osnet/dev/fbt/fbt.c
cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/dev/sdt/sdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/dtrace_modevent.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_modevent.c:1.3 src/external/cddl/osnet/dev/dtrace/dtrace_modevent.c:1.4
--- src/external/cddl/osnet/dev/dtrace/dtrace_modevent.c:1.3	Sat Mar 13 22:31:15 2010
+++ src/external/cddl/osnet/dev/dtrace/dtrace_modevent.c	Thu Feb 26 09:10:52 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_modevent.c,v 1.3 2010/03/13 22:31:15 christos Exp $	*/
+/*	$NetBSD: dtrace_modevent.c,v 1.4 2015/02/26 09:10:52 ozaki-r Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -29,6 +29,7 @@ static int
 dtrace_modcmd(modcmd_t cmd, void *data)
 {
 	int bmajor = -1, cmajor = -1;
+	int error;
 
 	switch (cmd) {
 	case MODULE_CMD_INIT:
@@ -36,8 +37,12 @@ dtrace_modcmd(modcmd_t cmd, void *data)
 		return devsw_attach(dtrace, NULL, bmajor,
 		dtrace_cdevsw, cmajor);
 	case MODULE_CMD_FINI:
-		dtrace_unload();
+		error = dtrace_unload();
+		if (error != 0)
+			return error;
 		return devsw_detach(NULL, dtrace_cdevsw);
+	case MODULE_CMD_AUTOUNLOAD:
+		return EBUSY;
 	default:
 		return ENOTTY;
 	}

Index: src/external/cddl/osnet/dev/dtrace/dtrace_unload.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_unload.c:1.5 src/external/cddl/osnet/dev/dtrace/dtrace_unload.c:1.6
--- src/external/cddl/osnet/dev/dtrace/dtrace_unload.c:1.5	Tue Jul 26 12:26:33 2011
+++ src/external/cddl/osnet/dev/dtrace/dtrace_unload.c	Thu Feb 26 09:10:52 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_unload.c,v 1.5 2011/07/26 12:26:33 yamt Exp $	*/
+/*	$NetBSD: dtrace_unload.c,v 1.6 2015/02/26 09:10:52 ozaki-r Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -37,9 +37,7 @@ dtrace_unload()
 	mutex_enter(dtrace_lock);
 	mutex_enter(cpu_lock);
 
-	ASSERT(dtrace_opens == 0);
-
-	if (dtrace_helpers  0) {
+	if (dtrace_opens  0 || dtrace_helpers  0) {
 		mutex_exit(cpu_lock);
 		mutex_exit(dtrace_lock);
 		mutex_exit(dtrace_provider_lock);

Index: src/external/cddl/osnet/dev/fbt/fbt.c
diff -u src/external/cddl/osnet/dev/fbt/fbt.c:1.16 src/external/cddl/osnet/dev/fbt/fbt.c:1.17
--- src/external/cddl/osnet/dev/fbt/fbt.c:1.16	Sat Jul 26 04:54:20 2014
+++ src/external/cddl/osnet/dev/fbt/fbt.c	Thu Feb 26 09:10:52 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt.c,v 1.16 2014/07/26 04:54:20 ryoon Exp $	*/
+/*	$NetBSD: fbt.c,v 1.17 2015/02/26 09:10:52 ozaki-r Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -2107,6 +2107,7 @@ static int
 fbt_modcmd(modcmd_t cmd, void *data)
 {
 	int bmajor = -1, cmajor = -1;
+	int error;
 
 	switch (cmd) {
 	case MODULE_CMD_INIT:
@@ -2114,8 +2115,12 @@ fbt_modcmd(modcmd_t cmd, void *data)
 		return devsw_attach(fbt, NULL, bmajor,
 		fbt_cdevsw, cmajor);
 	case MODULE_CMD_FINI:
-		fbt_unload();
+		error = fbt_unload();
+		if (error != 0)
+			return error;
 		return devsw_detach(NULL, fbt_cdevsw);
+	case MODULE_CMD_AUTOUNLOAD:
+		return EBUSY;
 	default:
 		return ENOTTY;
 	}

Index: src/external/cddl/osnet/dev/sdt/sdt.c
diff -u src/external/cddl/osnet/dev/sdt/sdt.c:1.9 src/external/cddl/osnet/dev/sdt/sdt.c:1.10
--- src/external/cddl/osnet/dev/sdt/sdt.c:1.9	Sat Jul 26 04:54:20 2014
+++ src/external/cddl/osnet/dev/sdt/sdt.c	Thu Feb 26 09:10:53 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdt.c,v 1.9 2014/07/26 04:54:20 ryoon Exp $	*/
+/*	$NetBSD: sdt.c,v 1.10 2015/02/26 09:10:53 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -433,7 +433,7 @@ sdt_unload(void)
 			printf(%s: failed to unregister %s error = %d\n,
 			sdt_list[ind]-name, res);
 #endif
-			error = res;
+			return res;
 		} else {
 #ifdef SDT_DEBUG
 			printf(sdt: unregistered %s id = %d\n,
@@ -453,6 +453,7 @@ static int
 sdt_modcmd(modcmd_t cmd, void *data)
 {
 	int bmajor = -1, cmajor = -1;
+	int error;
 
 	switch (cmd) {
 	case MODULE_CMD_INIT:
@@ -460,8 +461,12 @@ sdt_modcmd(modcmd_t cmd, void *data)
 		return devsw_attach(sdt, NULL, bmajor,
 		sdt_cdevsw, cmajor);
 	case MODULE_CMD_FINI:
-		sdt_unload();
+		error = sdt_unload();
+		if (error != 0)
+			return error;
 		return devsw_detach(NULL, sdt_cdevsw);
+	case MODULE_CMD_AUTOUNLOAD:
+		return EBUSY;
 	default:
 		return ENOTTY;
 	}



CVS commit: src/external/cddl/osnet/dev

2015-02-26 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Feb 26 10:31:52 UTC 2015

Modified Files:
src/external/cddl/osnet/dev/fbt: fbt.c
src/external/cddl/osnet/dev/sdt: sdt.c

Log Message:
Fix inconsistency between module and internal names of sdt and fbt

PR 49697
OK wiz@


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/external/cddl/osnet/dev/fbt/fbt.c
cvs rdiff -u -r1.10 -r1.11 src/external/cddl/osnet/dev/sdt/sdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/fbt.c
diff -u src/external/cddl/osnet/dev/fbt/fbt.c:1.17 src/external/cddl/osnet/dev/fbt/fbt.c:1.18
--- src/external/cddl/osnet/dev/fbt/fbt.c:1.17	Thu Feb 26 09:10:52 2015
+++ src/external/cddl/osnet/dev/fbt/fbt.c	Thu Feb 26 10:31:52 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt.c,v 1.17 2015/02/26 09:10:52 ozaki-r Exp $	*/
+/*	$NetBSD: fbt.c,v 1.18 2015/02/26 10:31:52 ozaki-r Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -2104,7 +2104,7 @@ fbt_unload(void)
 
 
 static int
-fbt_modcmd(modcmd_t cmd, void *data)
+dtrace_fbt_modcmd(modcmd_t cmd, void *data)
 {
 	int bmajor = -1, cmajor = -1;
 	int error;
@@ -2132,4 +2132,4 @@ fbt_open(dev_t dev, int flags, int mode,
 	return (0);
 }
 
-MODULE(MODULE_CLASS_MISC, fbt, dtrace);
+MODULE(MODULE_CLASS_MISC, dtrace_fbt, dtrace);

Index: src/external/cddl/osnet/dev/sdt/sdt.c
diff -u src/external/cddl/osnet/dev/sdt/sdt.c:1.10 src/external/cddl/osnet/dev/sdt/sdt.c:1.11
--- src/external/cddl/osnet/dev/sdt/sdt.c:1.10	Thu Feb 26 09:10:53 2015
+++ src/external/cddl/osnet/dev/sdt/sdt.c	Thu Feb 26 10:31:52 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdt.c,v 1.10 2015/02/26 09:10:53 ozaki-r Exp $	*/
+/*	$NetBSD: sdt.c,v 1.11 2015/02/26 10:31:52 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -450,7 +450,7 @@ sdt_unload(void)
 }
 
 static int
-sdt_modcmd(modcmd_t cmd, void *data)
+dtrace_sdt_modcmd(modcmd_t cmd, void *data)
 {
 	int bmajor = -1, cmajor = -1;
 	int error;
@@ -478,4 +478,4 @@ sdt_open(dev_t dev, int flags, int mode,
 	return (0);
 }
 
-MODULE(MODULE_CLASS_MISC, sdt, dtrace);
+MODULE(MODULE_CLASS_MISC, dtrace_sdt, dtrace);



CVS commit: src/external/cddl/osnet/dev/fbt

2014-03-19 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar 19 11:14:12 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/fbt: fbt.c

Log Message:
Exclude mvsoctmr_* functions from FBT targets

Probing them doesn't work for DTrace/arm for some reason.

Anyway with this fix, DTrace/arm works on SHEEVAPLUG
as well as BEAGLEBONE.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/external/cddl/osnet/dev/fbt/fbt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/fbt.c
diff -u src/external/cddl/osnet/dev/fbt/fbt.c:1.14 src/external/cddl/osnet/dev/fbt/fbt.c:1.15
--- src/external/cddl/osnet/dev/fbt/fbt.c:1.14	Sat Mar 15 08:00:19 2014
+++ src/external/cddl/osnet/dev/fbt/fbt.c	Wed Mar 19 11:14:12 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt.c,v 1.14 2014/03/15 08:00:19 ozaki-r Exp $	*/
+/*	$NetBSD: fbt.c,v 1.15 2014/03/19 11:14:12 ozaki-r Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -756,12 +756,13 @@ fbt_provide_module_cb(const char *name, 
 	|| strncmp(name, kauth_, 5) == 0 /* CRED XXX for now */
 	/* Sensitive functions on ARM */
 	|| strncmp(name, _spl, 4) == 0
-	|| strncmp(name, dmt_, 4) == 0
 	|| strcmp(name, binuptime) == 0
 	|| strcmp(name, dosoftints) == 0
 	|| strcmp(name, fbt_emulate) == 0
 	|| strcmp(name, nanouptime) == 0
 	|| strcmp(name, undefinedinstruction) == 0
+	|| strncmp(name, dmt_, 4) == 0 /* omap */
+	|| strncmp(name, mvsoctmr_, 9) == 0 /* marvell */
 	) {
 		return 0;
 	}



CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Mar 15 07:43:01 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_isa.c

Log Message:
Make arm/dtrace_isa.c buildable

This is a band-aid for build, but it works anyway.
We have to do a real fix in the future.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.3 src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.4
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.3	Sat Mar  8 11:46:01 2014
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c	Sat Mar 15 07:43:01 2014
@@ -39,6 +39,17 @@
 #include ddb/db_sym.h
 #include ddb/ddb.h
 
+uintptr_t kernelbase = (uintptr_t)KERNEL_BASE;
+
+/* TODO: support AAPCS */
+/* XXX: copied from sys/arch/arm/arm/db_trace.c */
+#define INKERNEL(va)	(((vaddr_t)(va)) = VM_MIN_KERNEL_ADDRESS)
+
+#define FR_SCP	(0)
+#define FR_RLV	(-1)
+#define FR_RSP	(-2)
+#define FR_RFP	(-3)
+
 #include regset.h
 
 /*



CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Mar 15 07:49:15 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_asm.S

Log Message:
Enable invop handler on module load

It sets a fbt handler to dtrace_invop_jump_addr on module load,
which is used to call the dtrace probing function from the trap
handler.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.4 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.5
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.4	Mon Mar 10 06:38:22 2014
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S	Sat Mar 15 07:49:15 2014
@@ -202,13 +202,24 @@ END(dtrace_copystr)
 void dtrace_invop_init(void)
 */
 ENTRY(dtrace_invop_init)
+	ldr	r1, .Ldtrace_invop
+	ldr	r2, .Ldtrace_invop_jump_addr
+	str	r1, [r2]
 	RET
+	.align	0
+.Ldtrace_invop:
+	.word	dtrace_invop
+.Ldtrace_invop_jump_addr:
+	.word	dtrace_invop_jump_addr
 END(dtrace_invop_init)
 
 /*
 void dtrace_invop_uninit(void)
 */
 ENTRY(dtrace_invop_uninit)
+	mov	r0, #0
+	ldr	r1, .Ldtrace_invop_jump_addr
+	str	r0, [r1]
 	RET
 END(dtrace_invop_uninit)
 



CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-10 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Mar 10 06:38:22 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_asm.S

Log Message:
Fix header inclusions


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.3 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.4
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.3	Wed Mar  5 03:09:17 2014
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S	Mon Mar 10 06:38:22 2014
@@ -34,8 +34,7 @@
 #include sys/dtrace.h
 
 #include machine/asm.h
-
-#include assym.s
+#include arm/armreg.h
 
 /*
 void dtrace_membar_producer(void)



CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-09 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Mar 10 03:04:57 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_subr.c

Log Message:
Make arm/dtrace_subr.c buildable

The change just imports the code from
http://people.freebsd.org/~gonzo/arm/dtrace-arm.diff
and tweaks for NetBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c:1.1 src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c:1.2
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c:1.1	Fri Jun 21 19:16:00 2013
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_subr.c	Mon Mar 10 03:04:57 2014
@@ -1,3 +1,5 @@
+/*	$NetBSD: dtrace_subr.c,v 1.2 2014/03/10 03:04:57 ozaki-r Exp $	*/
+
 /*
  * CDDL HEADER START
  *
@@ -27,25 +29,25 @@
  * Use is subject to license terms.
  */
 
-#include sys/cdefs.h
-__FBSDID($FreeBSD$);
-
 #include sys/param.h
 #include sys/systm.h
 #include sys/types.h
 #include sys/kernel.h
 #include sys/malloc.h
 #include sys/kmem.h
-#include sys/smp.h
+#include sys/xcall.h
+#include sys/cpu.h
+#include sys/cpuvar.h
 #include sys/dtrace_impl.h
 #include sys/dtrace_bsd.h
-#include machine/clock.h
+#include machine/cpu.h
 #include machine/frame.h
-#include machine/trap.h
-#include vm/pmap.h
+#include machine/vmparam.h
+#include uvm/uvm_pglist.h
+#include uvm/uvm_prot.h
+#include uvm/uvm_pmap.h
 
-#define	DELAYBRANCH(x)	((int)(x)  0)
-		
+extern uintptr_t 	kernelbase;
 extern uintptr_t 	dtrace_in_probe_addr;
 extern int		dtrace_in_probe;
 extern dtrace_id_t	dtrace_probeid_error;
@@ -59,6 +61,8 @@ typedef struct dtrace_invop_hdlr {
 
 dtrace_invop_hdlr_t *dtrace_invop_hdlr;
 
+void dtrace_gethrtime_init(void *arg);
+
 int
 dtrace_invop(uintptr_t addr, uintptr_t *stack, uintptr_t eax)
 {
@@ -72,26 +76,76 @@ dtrace_invop(uintptr_t addr, uintptr_t *
 	return (0);
 }
 
+void
+dtrace_invop_add(int (*func)(uintptr_t, uintptr_t *, uintptr_t))
+{
+	dtrace_invop_hdlr_t *hdlr;
+
+	hdlr = kmem_alloc(sizeof (dtrace_invop_hdlr_t), KM_SLEEP);
+	hdlr-dtih_func = func;
+	hdlr-dtih_next = dtrace_invop_hdlr;
+	dtrace_invop_hdlr = hdlr;
+}
+
+void
+dtrace_invop_remove(int (*func)(uintptr_t, uintptr_t *, uintptr_t))
+{
+	dtrace_invop_hdlr_t *hdlr = dtrace_invop_hdlr, *prev = NULL;
+
+	for (;;) {
+		if (hdlr == NULL)
+			panic(attempt to remove non-existent invop handler);
+
+		if (hdlr-dtih_func == func)
+			break;
+
+		prev = hdlr;
+		hdlr = hdlr-dtih_next;
+	}
+
+	if (prev == NULL) {
+		ASSERT(dtrace_invop_hdlr == hdlr);
+		dtrace_invop_hdlr = hdlr-dtih_next;
+	} else {
+		ASSERT(dtrace_invop_hdlr != hdlr);
+		prev-dtih_next = hdlr-dtih_next;
+	}
+
+	kmem_free(hdlr, sizeof (dtrace_invop_hdlr_t));
+}
 
-/*ARGSUSED*/
 void
 dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit))
 {
-	printf(IMPLEMENT ME: dtrace_toxic_ranges\n);
+	(*func)(0, kernelbase);
+}
+
+static void
+xcall_func(void *arg0, void *arg1)
+{
+	dtrace_xcall_t func = arg0;
+
+	(*func)(arg1);
 }
 
 void
 dtrace_xcall(processorid_t cpu, dtrace_xcall_t func, void *arg)
 {
-	cpuset_t cpus;
+	uint64_t where;
 
-	if (cpu == DTRACE_CPUALL)
-		cpus = all_cpus;
-	else
-		CPU_SETOF(cpu, cpus);
+	if (cpu == DTRACE_CPUALL) {
+		where = xc_broadcast(0, xcall_func, func, arg);
+	} else {
+		struct cpu_info *cinfo = cpu_lookup(cpu);
 
-	smp_rendezvous_cpus(cpus, smp_no_rendevous_barrier, func,
-	smp_no_rendevous_barrier, arg);
+		KASSERT(cinfo != NULL);
+		where = xc_unicast(0, xcall_func, func, arg, cinfo);
+	}
+	xc_wait(where);
+
+	/* XXX Q. Do we really need the other cpus to wait also? 
+	 * (see solaris:xc_sync())
+	 */
 }
 
 static void
@@ -133,10 +187,12 @@ dtrace_gethrestime(void)
 	return (curtime.tv_sec * 10UL + curtime.tv_nsec);
 }
 
-/* Function to handle DTrace traps during probes. See amd64/amd64/trap.c */
+/* Function to handle DTrace traps during probes. Not used on ARM yet */
 int
 dtrace_trap(struct trapframe *frame, u_int type)
 {
+	cpuid_t cpuid = cpu_number();	/* current cpu id */
+
 	/*
 	 * A trap can occur while DTrace executes a probe. Before
 	 * executing the probe, DTrace blocks re-scheduling and sets
@@ -147,7 +203,8 @@ dtrace_trap(struct trapframe *frame, u_i
 	 * Check if DTrace has enabled 'no-fault' mode:
 	 *
 	 */
-	if ((cpu_core[curcpu].cpuc_dtrace_flags  CPU_DTRACE_NOFAULT) != 0) {
+
+	if ((cpu_core[cpuid].cpuc_dtrace_flags  CPU_DTRACE_NOFAULT) != 0) {
 		/*
 		 * There are only a couple of trap types that are expected.
 		 * All the rest will be handled in the usual way.
@@ -156,8 +213,8 @@ dtrace_trap(struct trapframe *frame, u_i
 		/* Page fault. */
 		case 0:
 			/* Flag a bad address. */
-			cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR;
-			

CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-08 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Sat Mar  8 11:46:01 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_isa.c

Log Message:
Prepare dtrace_isa.c for build

- Tidy up header file inclusions
- Replace curcpu with cpu_number()
- Fix argument of dtrace_getreg
- Tweak for gcc 4.8

Note that the file is still not buildable.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.2 src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.3
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.2	Wed Mar  5 02:00:24 2014
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c	Sat Mar  8 11:46:01 2014
@@ -30,24 +30,14 @@
 #include sys/param.h
 #include sys/systm.h
 #include sys/kernel.h
-#include sys/stack.h
-#include sys/pcpu.h
 
 #include machine/frame.h
-#include machine/md_var.h
 #include machine/reg.h
 
-#include vm/vm.h
-#include vm/vm_param.h
-#include vm/pmap.h
-
 #include machine/db_machdep.h
-#include machine/md_var.h
 #include machine/vmparam.h
-#include machine/stack.h
 #include ddb/db_sym.h
 #include ddb/ddb.h
-#include sys/kdb.h
 
 #include regset.h
 
@@ -69,9 +59,11 @@ dtrace_getpcstack(pc_t *pcstack, int pcs
 uint32_t *intrpc)
 {
 	uint32_t	*frame, *lastframe;
+#if 0
 	int	scp_offset;
+#endif
 	int	depth = 0;
-	pc_t caller = (pc_t) solaris_cpu[curcpu].cpu_dtrace_caller;
+	pc_t caller = (pc_t) solaris_cpu[cpu_number()].cpu_dtrace_caller;
 
 	if (intrpc != 0)
 		pcstack[depth++] = (pc_t) intrpc;
@@ -80,7 +72,9 @@ dtrace_getpcstack(pc_t *pcstack, int pcs
 
 	frame = (uint32_t *)__builtin_frame_address(0);;
 	lastframe = NULL;
+#if 0
 	scp_offset = -(get_pc_str_offset()  2);
+#endif
 
 	while ((frame != NULL)  (depth  pcstack_limit)) {
 		db_addr_t	scp;
@@ -178,27 +172,18 @@ int
 dtrace_getstackdepth(int aframes)
 {
 	uint32_t	*frame, *lastframe;
-	int	scp_offset;
 	int	depth = 1;
 
 	frame = (uint32_t *)__builtin_frame_address(0);;
 	lastframe = NULL;
-	scp_offset = -(get_pc_str_offset()  2);
 
 	while (frame != NULL) {
-		db_addr_t	scp;
 #if 0 
 		uint32_t	savecode;
 		int		r;
 		uint32_t	*rp;
 #endif
 
-		/*
-		 * In theory, the SCP isn't guaranteed to be in the function
-		 * that generated the stack frame.  We hope for the best.
-		 */
-		scp = frame[FR_SCP];
-
 		depth++;
 
 		/*
@@ -229,7 +214,7 @@ dtrace_getstackdepth(int aframes)
 }
 
 ulong_t
-dtrace_getreg(struct trapframe *rp, uint_t reg)
+dtrace_getreg(struct regs *regs, uint_t reg)
 {
 
 	return (0);
@@ -241,7 +226,7 @@ dtrace_copycheck(uintptr_t uaddr, uintpt
 
 	if (uaddr + size  VM_MAXUSER_ADDRESS || uaddr + size  uaddr) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
-		cpu_core[curcpu].cpuc_dtrace_illval = uaddr;
+		cpu_core[cpu_number()].cpuc_dtrace_illval = uaddr;
 		return (0);
 	}
 
@@ -285,7 +270,7 @@ dtrace_fuword8(void *uaddr)
 {
 	if ((uintptr_t)uaddr  VM_MAXUSER_ADDRESS) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
-		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
+		cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr;
 		return (0);
 	}
 	return (dtrace_fuword8_nocheck(uaddr));
@@ -296,7 +281,7 @@ dtrace_fuword16(void *uaddr)
 {
 	if ((uintptr_t)uaddr  VM_MAXUSER_ADDRESS) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
-		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
+		cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr;
 		return (0);
 	}
 	return (dtrace_fuword16_nocheck(uaddr));
@@ -307,7 +292,7 @@ dtrace_fuword32(void *uaddr)
 {
 	if ((uintptr_t)uaddr  VM_MAXUSER_ADDRESS) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
-		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
+		cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr;
 		return (0);
 	}
 	return (dtrace_fuword32_nocheck(uaddr));
@@ -318,7 +303,7 @@ dtrace_fuword64(void *uaddr)
 {
 	if ((uintptr_t)uaddr  VM_MAXUSER_ADDRESS) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
-		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
+		cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr;
 		return (0);
 	}
 	return (dtrace_fuword64_nocheck(uaddr));



CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Mar  4 11:07:40 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_asm.S

Log Message:
Add missing END for each function


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.1 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.2
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.1	Fri Jun 21 19:16:00 2013
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S	Tue Mar  4 11:07:40 2014
@@ -42,12 +42,14 @@ void dtrace_membar_producer(void)
 */
 ENTRY(dtrace_membar_producer)
 	RET
+END(dtrace_membar_producer)
 
 /*
 void dtrace_membar_consumer(void)
 */
 ENTRY(dtrace_membar_consumer)
 	RET
+END(dtrace_membar_consumer)
 
 /*
 dtrace_icookie_t dtrace_interrupt_disable(void)
@@ -58,6 +60,8 @@ ENTRY(dtrace_interrupt_disable)
 	orr	r1, r1, #(I32_bit|F32_bit)
 	msr	cpsr_c, r1
 	RET
+END(dtrace_interrupt_disable)
+
 /*
 void dtrace_interrupt_enable(dtrace_icookie_t cookie)
 */
@@ -68,6 +72,7 @@ ENTRY(dtrace_interrupt_enable)
 	orr	r1, r1, r0
 	msr	cpsr_c, r1
 	RET
+END(dtrace_interrupt_enable)
 
 /*
 uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
@@ -95,6 +100,8 @@ ENTRY(dtrace_cas32)
 	msr	cpsr_c, r3
 	ldmfd	sp!, {r4, r5}
 	RET
+END(dtrace_cas32)
+END(dtrace_casptr)
 
 /*
 uint8_t
@@ -104,6 +111,7 @@ ENTRY(dtrace_fuword8_nocheck)
 	ldrb	r3, [r0]
 	mov 	r0, r3
 	RET
+END(dtrace_fuword8_nocheck)
 
 /*
 uint16_t
@@ -113,6 +121,7 @@ ENTRY(dtrace_fuword16_nocheck)
 	ldrh	r3, [r0]
 	mov 	r0, r3
 	RET
+END(dtrace_fuword16_nocheck)
 
 /*
 uint32_t
@@ -122,6 +131,7 @@ ENTRY(dtrace_fuword32_nocheck)
 	ldr	r3, [r0]
 	mov 	r0, r3
 	RET
+END(dtrace_fuword32_nocheck)
 
 /*
 uint64_t
@@ -142,6 +152,7 @@ ENTRY(dtrace_fuword64_nocheck)
 	mov	r1, r2
 #endif
 	RET
+END(dtrace_fuword64_nocheck)
 
 /*
 void
@@ -161,6 +172,7 @@ ENTRY(dtrace_copy)
 
 2:	ldmfd   sp!, {r4-r5}			/* stack is 8 byte aligned */
 	RET
+END(dtrace_copy)
 
 
 /*
@@ -184,6 +196,7 @@ ENTRY(dtrace_copystr)
 
 2:	ldmfd   sp!, {r4-r5}			/* stack is 8 byte aligned */
 	RET
+END(dtrace_copystr)
 
 
 /*
@@ -191,12 +204,14 @@ void dtrace_invop_init(void)
 */
 ENTRY(dtrace_invop_init)
 	RET
+END(dtrace_invop_init)
 
 /*
 void dtrace_invop_uninit(void)
 */
 ENTRY(dtrace_invop_uninit)
 	RET
+END(dtrace_invop_uninit)
 
 /*
 void
@@ -205,6 +220,7 @@ vpanic(const char *format, va_list alist
 ENTRY(vpanic)/* Initial stack layout: */
 vpanic_common:
 	RET
+END(vpanic)
 
 /*
 void
@@ -212,6 +228,7 @@ dtrace_vpanic(const char *format, va_lis
 */
 ENTRY(dtrace_vpanic)			/* Initial stack layout: */
 	RET
+END(dtrace_vpanic)
 
 /*
 uintptr_t
@@ -220,3 +237,4 @@ dtrace_caller(int aframes)
 ENTRY(dtrace_caller)
 	mov	r0, #-1
 	RET
+END(dtrace_caller)



CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar  5 02:00:24 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_isa.c

Log Message:
Use uint32_t instead of u_int32_t


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.1 src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.2
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c:1.1	Fri Jun 21 19:16:00 2013
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_isa.c	Wed Mar  5 02:00:24 2014
@@ -68,7 +68,7 @@ void
 dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
 uint32_t *intrpc)
 {
-	u_int32_t	*frame, *lastframe;
+	uint32_t	*frame, *lastframe;
 	int	scp_offset;
 	int	depth = 0;
 	pc_t caller = (pc_t) solaris_cpu[curcpu].cpu_dtrace_caller;
@@ -78,16 +78,16 @@ dtrace_getpcstack(pc_t *pcstack, int pcs
 
 	aframes++;
 
-	frame = (u_int32_t *)__builtin_frame_address(0);;
+	frame = (uint32_t *)__builtin_frame_address(0);;
 	lastframe = NULL;
 	scp_offset = -(get_pc_str_offset()  2);
 
 	while ((frame != NULL)  (depth  pcstack_limit)) {
 		db_addr_t	scp;
 #if 0 
-		u_int32_t	savecode;
+		uint32_t	savecode;
 		int		r;
-		u_int32_t	*rp;
+		uint32_t	*rp;
 #endif
 
 		/*
@@ -109,7 +109,7 @@ dtrace_getpcstack(pc_t *pcstack, int pcs
 		}
 
 #if 0
-		savecode = ((u_int32_t *)scp)[scp_offset];
+		savecode = ((uint32_t *)scp)[scp_offset];
 		if ((savecode  0x0e10) == 0x0800) {
 			/* Looks like an STM */
 			rp = frame - 4;
@@ -128,7 +128,7 @@ dtrace_getpcstack(pc_t *pcstack, int pcs
 			break; /* Top of stack */
 
 		lastframe = frame;
-		frame = (u_int32_t *)(frame[FR_RFP]);
+		frame = (uint32_t *)(frame[FR_RFP]);
 
 		if (INKERNEL((int)frame)) {
 			/* staying in kernel */
@@ -177,20 +177,20 @@ dtrace_getarg(int arg, int aframes)
 int
 dtrace_getstackdepth(int aframes)
 {
-	u_int32_t	*frame, *lastframe;
+	uint32_t	*frame, *lastframe;
 	int	scp_offset;
 	int	depth = 1;
 
-	frame = (u_int32_t *)__builtin_frame_address(0);;
+	frame = (uint32_t *)__builtin_frame_address(0);;
 	lastframe = NULL;
 	scp_offset = -(get_pc_str_offset()  2);
 
 	while (frame != NULL) {
 		db_addr_t	scp;
 #if 0 
-		u_int32_t	savecode;
+		uint32_t	savecode;
 		int		r;
-		u_int32_t	*rp;
+		uint32_t	*rp;
 #endif
 
 		/*
@@ -208,7 +208,7 @@ dtrace_getstackdepth(int aframes)
 			break; /* Top of stack */
 
 		lastframe = frame;
-		frame = (u_int32_t *)(frame[FR_RFP]);
+		frame = (uint32_t *)(frame[FR_RFP]);
 
 		if (INKERNEL((int)frame)) {
 			/* staying in kernel */



CVS commit: src/external/cddl/osnet/dev/dtrace/arm

2014-03-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar  5 03:09:17 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace/arm: dtrace_asm.S

Log Message:
Fix dtrace_cas32 logic

- compare with cmp, not new
- return old value


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S
diff -u src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.2 src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.3
--- src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S:1.2	Tue Mar  4 11:07:40 2014
+++ src/external/cddl/osnet/dev/dtrace/arm/dtrace_asm.S	Wed Mar  5 03:09:17 2014
@@ -89,12 +89,12 @@ ENTRY(dtrace_cas32)
 	msr	cpsr_c, r4
 
 	ldr	r5, [r0]
-	cmp	r5, r2
-	movne	r0, #0
+	cmp	r5, r1
+	movne	r0, r5
 	bne	2f
 
 	str	r2, [r0]
-	mov	r0, #1
+	mov	r0, r5
 
 2:
 	msr	cpsr_c, r3



CVS commit: src/external/cddl/osnet/dev/dtrace

2014-03-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar  5 06:06:42 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace: dtrace_debug.c

Log Message:
Use native atomic function instead of DTrace's own one

So we don't need to implement it for each architecture.

This change is from FreeBSD (not as-is though).


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/cddl/osnet/dev/dtrace/dtrace_debug.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/dtrace_debug.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.7 src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.8
--- src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.7	Tue Mar  4 03:20:49 2014
+++ src/external/cddl/osnet/dev/dtrace/dtrace_debug.c	Wed Mar  5 06:06:42 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_debug.c,v 1.7 2014/03/04 03:20:49 ozaki-r Exp $	*/
+/*	$NetBSD: dtrace_debug.c,v 1.8 2014/03/05 06:06:42 ozaki-r Exp $	*/
 
 /*-
  * Copyright (C) 2008 John Birrell j...@freebsd.org.
@@ -36,62 +36,6 @@ static char const hex2ascii_data[] = 01
 
 #ifdef DEBUG
 
-#if defined(__amd64__)
-static __inline int
-dtrace_cmpset_long(volatile u_long *dst, u_long exp, u_long src)
-{
-	u_char res;
-
-	__asm __volatile(
-		 lock ; 		
-		cmpxchgq %2,%1 ;	
-	   sete	%0 ;		
-	1:
-	# dtrace_cmpset_long
-	: =a (res),			/* 0 */
-	  =m (*dst)			/* 1 */
-	: r (src),			/* 2 */
-	  a (exp),			/* 3 */
-	  m (*dst)			/* 4 */
-	: memory);
-
-	return (res);
-}
-#elif defined(__i386__)
-static __inline int
-dtrace_cmpset_long(volatile u_long *dst, u_long exp, u_long src)
-{
-	u_char res;
-
-	__asm __volatile(
-	lock ;	
-	   cmpxchgl %2,%1 ;
-	   sete%0 ;
-	1: 
-	# dtrace_cmpset_long
-	: =a (res),   /* 0 */
-	  =m (*dst)   /* 1 */
-	: r (src),/* 2 */
-	  a (exp),/* 3 */
-	  m (*dst)/* 4 */
-	: memory);
-
-	return (res);
-}
-#elif defined(__arm__)
-static __inline int
-dtrace_cmpset_long(volatile u_long *dst, u_long exp, u_long src)
-{
-	u_char res;
-	if (*dst == src) {
-		res = *dst;
-		*dst = src;
-		return res;
-	}
-	return exp;
-}
-#endif
-
 #define DTRACE_DEBUG_BUFR_SIZE	(32 * 1024)
 
 struct dtrace_debug_data {
@@ -108,7 +52,8 @@ static volatile u_long	dtrace_debug_flag
 static void
 dtrace_debug_lock(int cpu)
 {
-	while (dtrace_cmpset_long(dtrace_debug_flag[cpu], 0, 1) == 0)
+	/* FIXME: use atomic_cmpset_ulong once we have it  */
+	while (atomic_cas_ulong(dtrace_debug_flag[cpu], 0, 1) == 0)
 		/* Loop until the lock is obtained. */
 		;
 }



CVS commit: src/external/cddl/osnet/dev/cyclic/arm

2014-03-04 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Mar  5 06:35:44 UTC 2014

Added Files:
src/external/cddl/osnet/dev/cyclic/arm: cyclic_machdep.c

Log Message:
Add cyclic_machdep.c for ARM

The code is still almost same as i386's one.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 \
src/external/cddl/osnet/dev/cyclic/arm/cyclic_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/external/cddl/osnet/dev/cyclic/arm/cyclic_machdep.c
diff -u /dev/null src/external/cddl/osnet/dev/cyclic/arm/cyclic_machdep.c:1.1
--- /dev/null	Wed Mar  5 06:35:44 2014
+++ src/external/cddl/osnet/dev/cyclic/arm/cyclic_machdep.c	Wed Mar  5 06:35:44 2014
@@ -0,0 +1,150 @@
+/*	$NetBSD: cyclic_machdep.c,v 1.1 2014/03/05 06:35:44 ozaki-r Exp $	*/
+
+/*
+ * Copyright 2006-2008 John Birrell j...@freebsd.org
+ *
+ * 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.
+ *
+ * $FreeBSD$
+ *
+ */
+
+#include arm/armreg.h
+
+static void enable(cyb_arg_t);
+static void disable(cyb_arg_t);
+static void reprogram(cyb_arg_t, hrtime_t);
+static void xcall(cyb_arg_t, cpu_t *, cyc_func_t, void *);
+
+static cyc_backend_t	be	= {
+	NULL,		/* cyb_configure */
+	NULL,		/* cyb_unconfigure */
+	enable,
+	disable,
+	reprogram,
+	xcall,
+	NULL		/* cyb_arg_t cyb_arg */
+};
+
+static void
+cyclic_ap_start(void *dummy)
+{
+	/* Initialise the rest of the CPUs. */
+	cyclic_mp_init();
+}
+
+SYSINIT(cyclic_ap_start, SI_SUB_SMP, SI_ORDER_ANY, cyclic_ap_start, NULL);
+
+/*
+ *  Machine dependent cyclic subsystem initialisation.
+ */
+static void
+cyclic_machdep_init(void)
+{
+	/* Register the cyclic backend. */
+	cyclic_init(be);
+#ifdef __NetBSD__
+	cyclic_ap_start(NULL);
+#endif
+}
+
+static void
+cyclic_machdep_uninit(void)
+{
+	int i;
+
+	for (i = 0; i = mp_maxid; i++)
+		/* Reset the cyclic clock callback hook. */
+		cyclic_clock_func[i] = NULL;
+
+	/* De-register the cyclic backend. */
+	cyclic_uninit();
+}
+
+static hrtime_t exp_due[MAXCPU];
+
+/*
+ * This function is the one registered by the machine dependent
+ * initialiser as the callback for high speed timer events.
+ */
+static void
+cyclic_clock(struct clockframe *frame)
+{
+	cpu_t *c = solaris_cpu[cpu_number()];
+
+	if (c-cpu_cyclic != NULL  gethrtime() = exp_due[cpu_number()]) {
+		if (TRAPF_USERMODE(frame)) {
+			c-cpu_profile_pc = 0;
+			c-cpu_profile_upc = TRAPF_PC(frame);
+		} else {
+			c-cpu_profile_pc = TRAPF_PC(frame);
+			c-cpu_profile_upc = 0;
+		}
+
+		c-cpu_intr_actv = 1;
+
+		/* Fire any timers that are due. */
+		cyclic_fire(c);
+
+		c-cpu_intr_actv = 0;
+	}
+}
+
+static void enable(cyb_arg_t arg)
+{
+	/* Register the cyclic clock callback function. */
+	cyclic_clock_func[cpu_number()] = cyclic_clock;
+}
+
+static void disable(cyb_arg_t arg)
+{
+	/* Reset the cyclic clock callback function. */
+	cyclic_clock_func[cpu_number()] = NULL;
+}
+
+static void reprogram(cyb_arg_t arg, hrtime_t exp)
+{
+	exp_due[cpu_number()] = exp;
+}
+
+#ifdef __NetBSD__
+static void xcall_func(void *arg0, void *arg1)
+{
+	cyc_func_t func;
+
+	func = arg0;
+	(*func)(arg1);
+}
+#endif
+
+static void xcall(cyb_arg_t arg, cpu_t *c, cyc_func_t func, void *param)
+{
+#ifdef __NetBSD__
+	uint64_t xc;
+
+	xc = xc_unicast(XC_HIGHPRI, xcall_func, func, param, cpu_lookup(c-cpuid));
+	xc_wait(xc);
+#else
+	smp_rendezvous_cpus((cpumask_t) (1  c-cpuid),
+	smp_no_rendevous_barrier, func, smp_no_rendevous_barrier, param);
+#endif
+}



CVS commit: src/external/cddl/osnet/dev/dtrace

2014-03-03 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue Mar  4 03:20:49 UTC 2014

Modified Files:
src/external/cddl/osnet/dev/dtrace: dtrace_debug.c

Log Message:
Fix wrong conditional statement in dtrace_debug_output

Reported in PR kern/48547 by ozaki-r.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dev/dtrace/dtrace_debug.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/dtrace_debug.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.6 src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.7
--- src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.6	Sun Apr 14 16:39:59 2013
+++ src/external/cddl/osnet/dev/dtrace/dtrace_debug.c	Tue Mar  4 03:20:49 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_debug.c,v 1.6 2013/04/14 16:39:59 christos Exp $	*/
+/*	$NetBSD: dtrace_debug.c,v 1.7 2014/03/04 03:20:49 ozaki-r Exp $	*/
 
 /*-
  * Copyright (C) 2008 John Birrell j...@freebsd.org.
@@ -167,7 +167,7 @@ dtrace_debug_output(void)
 
 			for (p = d-first; p  d-next; p++)
 *p1++ = *p;
-		} else if (d-next  d-first) {
+		} else if (d-first  d-next) {
 			char *p1 = dtrace_debug_bufr;
 
 			count = (uintptr_t) d-last - (uintptr_t) d-first;



CVS commit: src/external/cddl/osnet/dev/dtrace

2013-04-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr 14 16:39:59 UTC 2013

Modified Files:
src/external/cddl/osnet/dev/dtrace: dtrace_debug.c

Log Message:
add a stub for arm


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dev/dtrace/dtrace_debug.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/dtrace_debug.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.5 src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.6
--- src/external/cddl/osnet/dev/dtrace/dtrace_debug.c:1.5	Sat Jun 16 13:31:47 2012
+++ src/external/cddl/osnet/dev/dtrace/dtrace_debug.c	Sun Apr 14 12:39:59 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_debug.c,v 1.5 2012/06/16 17:31:47 chs Exp $	*/
+/*	$NetBSD: dtrace_debug.c,v 1.6 2013/04/14 16:39:59 christos Exp $	*/
 
 /*-
  * Copyright (C) 2008 John Birrell j...@freebsd.org.
@@ -78,6 +78,18 @@ dtrace_cmpset_long(volatile u_long *dst,
 
 	return (res);
 }
+#elif defined(__arm__)
+static __inline int
+dtrace_cmpset_long(volatile u_long *dst, u_long exp, u_long src)
+{
+	u_char res;
+	if (*dst == src) {
+		res = *dst;
+		*dst = src;
+		return res;
+	}
+	return exp;
+}
 #endif
 
 #define DTRACE_DEBUG_BUFR_SIZE	(32 * 1024)



CVS commit: src/external/cddl/osnet/dev/dtrace

2013-03-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  3 18:16:35 UTC 2013

Modified Files:
src/external/cddl/osnet/dev/dtrace: dtrace_ioctl.c

Log Message:
autoload tracing modules.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c:1.3 src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c:1.4
--- src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c:1.3	Wed Aug 31 17:57:16 2011
+++ src/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c	Sun Mar  3 13:16:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_ioctl.c,v 1.3 2011/08/31 21:57:16 christos Exp $	*/
+/*	$NetBSD: dtrace_ioctl.c,v 1.4 2013/03/03 18:16:35 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -647,6 +647,8 @@ dtrace_ioctl(struct file *fp, u_long cmd
 		DTRACE_IOCTL_PRINTF(%s(%d): DTRACEIOC_PROVIDER\n,__func__,__LINE__);
 
 		pvd-dtvd_name[DTRACE_PROVNAMELEN - 1] = '\0';
+		error = 0;
+again:
 		mutex_enter(dtrace_provider_lock);
 
 		for (pvp = dtrace_provider; pvp != NULL; pvp = pvp-dtpv_next) {
@@ -656,6 +658,13 @@ dtrace_ioctl(struct file *fp, u_long cmd
 
 		mutex_exit(dtrace_provider_lock);
 
+		if (pvp == NULL  error == 0) {
+			error = module_autoload(pvd-dtvd_name,
+			MODULE_CLASS_MISC);
+			if (error == 0)
+goto again;
+		}
+
 		if (pvp == NULL)
 			return (ESRCH);
 
@@ -758,16 +767,15 @@ dtrace_ioctl(struct file *fp, u_long cmd
 		return (0);
 	}
 	case DTRACEIOC_STOP: {
-		int rval;
 		processorid_t *cpuid = (processorid_t *) addr;
 
 		DTRACE_IOCTL_PRINTF(%s(%d): DTRACEIOC_STOP\n,__func__,__LINE__);
 
 		mutex_enter(dtrace_lock);
-		rval = dtrace_state_stop(state, cpuid);
+		error = dtrace_state_stop(state, cpuid);
 		mutex_exit(dtrace_lock);
 
-		return (rval);
+		return (error);
 	}
 	default:
 		error = ENOTTY;



CVS commit: src/external/cddl/osnet/dev/fbt

2013-03-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  3 18:18:13 UTC 2013

Modified Files:
src/external/cddl/osnet/dev/fbt: fbt.c

Log Message:
print the function name that was not found.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/external/cddl/osnet/dev/fbt/fbt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/fbt.c
diff -u src/external/cddl/osnet/dev/fbt/fbt.c:1.11 src/external/cddl/osnet/dev/fbt/fbt.c:1.12
--- src/external/cddl/osnet/dev/fbt/fbt.c:1.11	Sat Jun 16 13:31:47 2012
+++ src/external/cddl/osnet/dev/fbt/fbt.c	Sun Mar  3 13:18:13 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt.c,v 1.11 2012/06/16 17:31:47 chs Exp $	*/
+/*	$NetBSD: fbt.c,v 1.12 2013/03/03 18:18:13 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -1463,12 +1463,14 @@ fbt_getargdesc(void *arg __unused, dtrac
 	n = CTF_INFO_VLEN(info);
 
 	if (kind == CTF_K_UNKNOWN  n == 0) {
-		printf(%s(%d): Unknown function!\n,__func__,__LINE__);
+		printf(%s(%d): Unknown function %s!\n,__func__,__LINE__,
+		fbt-fbtp_name);
 		return;
 	}
 
 	if (kind != CTF_K_FUNCTION) {
-		printf(%s(%d): Expected a function!\n,__func__,__LINE__);
+		printf(%s(%d): Expected a function %s!\n,__func__,__LINE__,
+		fbt-fbtp_name);
 		return;
 	}
 



CVS commit: src/external/cddl/osnet/dev/profile

2012-12-06 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Fri Dec  7 03:11:17 UTC 2012

Modified Files:
src/external/cddl/osnet/dev/profile: profile.c

Log Message:
adapt the profile dtrace provider to netbsd.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dev/profile/profile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/profile/profile.c
diff -u src/external/cddl/osnet/dev/profile/profile.c:1.3 src/external/cddl/osnet/dev/profile/profile.c:1.4
--- src/external/cddl/osnet/dev/profile/profile.c:1.3	Sun Jul 17 20:54:33 2011
+++ src/external/cddl/osnet/dev/profile/profile.c	Fri Dec  7 03:11:17 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: profile.c,v 1.3 2011/07/17 20:54:33 joerg Exp $	*/
+/*	$NetBSD: profile.c,v 1.4 2012/12/07 03:11:17 chs Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -38,7 +38,9 @@
 #include sys/cpuvar.h
 #include sys/fcntl.h
 #include sys/filio.h
+#ifdef __FreeBSD__
 #include sys/kdb.h
+#endif
 #include sys/kernel.h
 #include sys/kmem.h
 #include sys/kthread.h
@@ -51,10 +53,18 @@
 #include sys/poll.h
 #include sys/proc.h
 #include sys/selinfo.h
+#ifdef __FreeBSD__
 #include sys/smp.h
+#endif
 #include sys/uio.h
 #include sys/unistd.h
 
+#ifdef __NetBSD__
+#include sys/atomic.h
+#include sys/cpu.h
+#define ASSERT(x) KASSERT(x)
+#endif
+
 #include sys/cyclic.h
 #include sys/dtrace.h
 #include sys/dtrace_bsd.h
@@ -97,6 +107,7 @@
  * and the static definition doesn't seem to be overly brittle.  Still, we
  * allow for a manual override in case we get it completely wrong.
  */
+#ifdef __FreeBSD__
 #ifdef __amd64
 #define	PROF_ARTIFICIAL_FRAMES	7
 #else
@@ -112,6 +123,11 @@
 #endif
 #endif
 #endif
+#endif
+
+#ifdef __NetBSD__
+#define	PROF_ARTIFICIAL_FRAMES	3
+#endif
 
 typedef struct profile_probe {
 	char		prof_name[PROF_NAMELEN];
@@ -127,14 +143,16 @@ typedef struct profile_probe_percpu {
 	profile_probe_t	*profc_probe;
 } profile_probe_percpu_t;
 
+#ifdef __FreeBSD__
 static d_open_t	profile_open;
+#endif
 static int	profile_unload(void);
 static void	profile_create(hrtime_t, char *, int);
 static void	profile_destroy(void *, dtrace_id_t, void *);
-static void	profile_enable(void *, dtrace_id_t, void *);
+static int	profile_enable(void *, dtrace_id_t, void *);
 static void	profile_disable(void *, dtrace_id_t, void *);
 static void	profile_load(void *);
-static void	profile_provide(void *, dtrace_probedesc_t *);
+static void	profile_provide(void *, const dtrace_probedesc_t *);
 
 static int profile_rates[] = {
 97, 199, 499, 997, 1999,
@@ -161,11 +179,13 @@ static uint32_t profile_max = PROFILE_MA
 	/* maximum number of profile probes */
 static uint32_t profile_total;		/* current number of profile probes */
 
+#ifdef __FreeBSD__
 static struct cdevsw profile_cdevsw = {
 	.d_version	= D_VERSION,
 	.d_open		= profile_open,
 	.d_name		= profile,
 };
+#endif
 
 static dtrace_pattr_t profile_attr = {
 { DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
@@ -188,7 +208,9 @@ static dtrace_pops_t profile_pops = {
 	profile_destroy
 };
 
+#ifdef __FreeBSD__
 static struct cdev		*profile_cdev;
+#endif
 static dtrace_provider_id_t	profile_id;
 static hrtime_t			profile_interval_min = NANOSEC / 5000;	/* 5000 hz */
 static int			profile_aframes = 0;			/* override */
@@ -199,7 +221,7 @@ profile_fire(void *arg)
 	profile_probe_percpu_t *pcpu = arg;
 	profile_probe_t *prof = pcpu-profc_probe;
 	hrtime_t late;
-	solaris_cpu_t *c = solaris_cpu[curcpu];
+	solaris_cpu_t *c = solaris_cpu[cpu_number()];
 
 	late = gethrtime() - pcpu-profc_expected;
 	pcpu-profc_expected += pcpu-profc_interval;
@@ -212,7 +234,7 @@ static void
 profile_tick(void *arg)
 {
 	profile_probe_t *prof = arg;
-	solaris_cpu_t *c = solaris_cpu[curcpu];
+	solaris_cpu_t *c = solaris_cpu[cpu_number()];
 
 	dtrace_probe(prof-prof_id, c-cpu_profile_pc,
 	c-cpu_profile_upc, 0, 0, 0);
@@ -247,14 +269,14 @@ profile_create(hrtime_t interval, char *
 
 /*ARGSUSED*/
 static void
-profile_provide(void *arg, dtrace_probedesc_t *desc)
+profile_provide(void *arg, const dtrace_probedesc_t *desc)
 {
 	int i, j, rate, kind;
 	hrtime_t val = 0, mult = 1, len = 0;
 	char *name, *suffix = NULL;
 
 	const struct {
-		char *prefix;
+		const char *prefix;
 		int kind;
 	} types[] = {
 		{ PROF_PREFIX_PROFILE, PROF_PROFILE },
@@ -263,7 +285,7 @@ profile_provide(void *arg, dtrace_probed
 	};
 
 	const struct {
-		char *name;
+		const char *name;
 		hrtime_t mult;
 	} suffixes[] = {
 		{ ns, 	NANOSEC / NANOSEC },
@@ -281,7 +303,7 @@ profile_provide(void *arg, dtrace_probed
 		{ d,		NANOSEC * (hrtime_t)(24 * 60 * 60) },
 		{ day,	NANOSEC * (hrtime_t)(24 * 60 * 60) },
 		{ hz,		0 },
-		{ NULL }
+		{ NULL,		0 }
 	};
 
 	if (desc == NULL) {
@@ -311,7 +333,7 @@ profile_provide(void *arg, dtrace_probed
 		return;
 	}
 
-	name = desc-dtpd_name;
+	name = (char *)desc-dtpd_name;
 
 	for (i = 

CVS commit: src/external/cddl/osnet/dev/fbt

2011-10-19 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Wed Oct 19 10:55:50 UTC 2011

Modified Files:
src/external/cddl/osnet/dev/fbt: fbt.c

Log Message:
fbt_provide_module_cb: exclude some functions known unsafe to probe


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/dev/fbt/fbt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/fbt.c
diff -u src/external/cddl/osnet/dev/fbt/fbt.c:1.9 src/external/cddl/osnet/dev/fbt/fbt.c:1.10
--- src/external/cddl/osnet/dev/fbt/fbt.c:1.9	Wed Aug 31 21:57:16 2011
+++ src/external/cddl/osnet/dev/fbt/fbt.c	Wed Oct 19 10:55:50 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt.c,v 1.9 2011/08/31 21:57:16 christos Exp $	*/
+/*	$NetBSD: fbt.c,v 1.10 2011/10/19 10:55:50 yamt Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -268,6 +268,21 @@ fbt_provide_module_cb(const char *name, 
 	if (name[0] == '_'  name[1] == '_')
 		return (0);
 
+	/*
+	 * Exclude some more symbols which can be called from probe context.
+	 */
+	if (strcmp(name, x86_curcpu) == 0 /* CPU */
+	|| strcmp(name, x86_curlwp) == 0 /* curproc, curlwp, curthread */
+	|| strcmp(name, cpu_index) == 0 /* cpu_number, curcpu_id */
+	|| strncmp(name, db_, 3) == 0 /* debugger */
+	|| strncmp(name, ddb_, 4) == 0 /* debugger */
+	|| strncmp(name, kdb_, 4) == 0 /* debugger */
+	|| strncmp(name, lockdebug_, 10) == 0 /* lockdebug XXX for now */
+	|| strncmp(name, kauth_, 5) == 0 /* CRED XXX for now */
+	) {
+		return 0;
+	}
+
 	instr = (u_int8_t *) value;
 	limit = (u_int8_t *) value + symsize;
 



CVS commit: src/external/cddl/osnet/dev/dtrace/i386

2011-09-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep  9 17:48:39 UTC 2011

Modified Files:
src/external/cddl/osnet/dev/dtrace/i386: dtrace_subr.c

Log Message:
fix a shadow variable warning.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.5 src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.6
--- src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.5	Fri Apr 23 07:39:53 2010
+++ src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c	Fri Sep  9 13:48:39 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_subr.c,v 1.5 2010/04/23 11:39:53 ahoka Exp $	*/
+/*	$NetBSD: dtrace_subr.c,v 1.6 2011/09/09 17:48:39 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -131,11 +131,11 @@
 }
 
 void
-dtrace_xcall(processorid_t cpu, dtrace_xcall_t func, void *arg)
+dtrace_xcall(processorid_t xcpu, dtrace_xcall_t func, void *arg)
 {
 	uint64_t where;
 
-	if (cpu == DTRACE_CPUALL) {
+	if (xcpu == DTRACE_CPUALL) {
 		where = xc_broadcast(0, xcall_func, func, arg);
 	} else {
 		struct cpu_info *cinfo = cpu_lookup(cpu);



CVS commit: src/external/cddl/osnet/dev/sdt

2011-07-30 Thread Masao Uebayashi
Module Name:src
Committed By:   uebayasi
Date:   Sat Jul 30 10:12:14 UTC 2011

Modified Files:
src/external/cddl/osnet/dev/sdt: sdt.c

Log Message:
Fix a local var name.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/cddl/osnet/dev/sdt/sdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/sdt/sdt.c
diff -u src/external/cddl/osnet/dev/sdt/sdt.c:1.7 src/external/cddl/osnet/dev/sdt/sdt.c:1.8
--- src/external/cddl/osnet/dev/sdt/sdt.c:1.7	Fri Jul 29 13:10:23 2011
+++ src/external/cddl/osnet/dev/sdt/sdt.c	Sat Jul 30 10:12:14 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdt.c,v 1.7 2011/07/29 13:10:23 uebayasi Exp $	*/
+/*	$NetBSD: sdt.c,v 1.8 2011/07/30 10:12:14 uebayasi Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -106,7 +106,7 @@
 SDT_PROBE_DECLARE(proc,,,lwp_exit);
 
 /* define the provider */
-static sdt_provider_t l7_provider = {
+static sdt_provider_t proc_provider = {
 	proc,		/* provider name */
 	0,		/* registered ID - leave as 0 */
 	{
@@ -136,7 +136,7 @@
 
 /* list of local providers to register with DTrace */
 static sdt_provider_t *sdt_providers[] = {
-	l7_provider,
+	proc_provider,
 	NULL		/* NULL terminated list */
 };
 



CVS commit: src/external/cddl/osnet/dev/sdt

2011-07-29 Thread Masao Uebayashi
Module Name:src
Committed By:   uebayasi
Date:   Fri Jul 29 13:10:23 UTC 2011

Modified Files:
src/external/cddl/osnet/dev/sdt: sdt.c

Log Message:
KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/external/cddl/osnet/dev/sdt/sdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/sdt/sdt.c
diff -u src/external/cddl/osnet/dev/sdt/sdt.c:1.6 src/external/cddl/osnet/dev/sdt/sdt.c:1.7
--- src/external/cddl/osnet/dev/sdt/sdt.c:1.6	Sat Mar 13 22:31:15 2010
+++ src/external/cddl/osnet/dev/sdt/sdt.c	Fri Jul 29 13:10:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdt.c,v 1.6 2010/03/13 22:31:15 christos Exp $	*/
+/*	$NetBSD: sdt.c,v 1.7 2011/07/29 13:10:23 uebayasi Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -107,37 +107,37 @@
 
 /* define the provider */
 static sdt_provider_t l7_provider = {
-proc,	/* provider name */
-0,		/* registered ID - leave as 0 */
-{
-	{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
-	{ DTRACE_STABILITY_PRIVATE,  DTRACE_STABILITY_PRIVATE,  DTRACE_CLASS_UNKNOWN },
-	{ DTRACE_STABILITY_PRIVATE,  DTRACE_STABILITY_PRIVATE,  DTRACE_CLASS_ISA },
-	{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
-	{ DTRACE_STABILITY_PRIVATE,  DTRACE_STABILITY_PRIVATE,  DTRACE_CLASS_ISA },
-},
-
-/* list all probes belonging to the provider */
-{ 
-	SDT_NAME(proc,,,create),
-	SDT_NAME(proc,,,exec),
-	SDT_NAME(proc,,,exec_success),
-	SDT_NAME(proc,,,exec_failure),
-	SDT_NAME(proc,,,signal_send),
-	SDT_NAME(proc,,,signal_discard),
-	SDT_NAME(proc,,,signal_clear),
-	SDT_NAME(proc,,,signal_handle),
-	SDT_NAME(proc,,,lwp_create),
-	SDT_NAME(proc,,,lwp_start),
-	SDT_NAME(proc,,,lwp_exit),
-	NULL	/* NULL terminated list */
-}
+	proc,		/* provider name */
+	0,		/* registered ID - leave as 0 */
+	{
+		{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
+		{ DTRACE_STABILITY_PRIVATE,  DTRACE_STABILITY_PRIVATE,  DTRACE_CLASS_UNKNOWN },
+		{ DTRACE_STABILITY_PRIVATE,  DTRACE_STABILITY_PRIVATE,  DTRACE_CLASS_ISA },
+		{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_COMMON },
+		{ DTRACE_STABILITY_PRIVATE,  DTRACE_STABILITY_PRIVATE,  DTRACE_CLASS_ISA },
+	},
+
+	/* list all probes belonging to the provider */
+	{ 
+		SDT_NAME(proc,,,create),
+		SDT_NAME(proc,,,exec),
+		SDT_NAME(proc,,,exec_success),
+		SDT_NAME(proc,,,exec_failure),
+		SDT_NAME(proc,,,signal_send),
+		SDT_NAME(proc,,,signal_discard),
+		SDT_NAME(proc,,,signal_clear),
+		SDT_NAME(proc,,,signal_handle),
+		SDT_NAME(proc,,,lwp_create),
+		SDT_NAME(proc,,,lwp_start),
+		SDT_NAME(proc,,,lwp_exit),
+		NULL/* NULL terminated list */
+	}
 };
 
 /* list of local providers to register with DTrace */
 static sdt_provider_t *sdt_providers[] = {
-l7_provider,
-NULL		/* NULL terminated list */
+	l7_provider,
+	NULL		/* NULL terminated list */
 };
 
 static sdt_provider_t **sdt_list = NULL;	/* registered provider list */
@@ -167,7 +167,7 @@
 			sizeof(desc-dtargd_native));
 		desc-dtargd_mapping = desc-dtargd_ndx;
 		if (sprobe-argx[desc-dtargd_ndx] != NULL) {
-		strncpy(desc-dtargd_xlate, sprobe-argx[desc-dtargd_ndx],
+			strncpy(desc-dtargd_xlate, sprobe-argx[desc-dtargd_ndx],
 			sizeof(desc-dtargd_xlate));
 		}
 #ifdef SDT_DEBUG
@@ -197,16 +197,16 @@
 static void
 sdt_provide(void *arg, const dtrace_probedesc_t *desc)
 {
-	sdt_provider_t *sprov = arg;
+	sdt_provider_t *sprov = arg;
 	int res;
 	int ind;
-	int num_probes=0;
+	int num_probes = 0;
 
 #ifdef SDT_DEBUG
 	if (desc == NULL) {
 		printf(sdt: provide null\n);
 	} else {
-	printf(sdt: provide %d %02x:%02x:%02x:%02x\n,
+		printf(sdt: provide %d %02x:%02x:%02x:%02x\n,
 		desc-dtpd_id,
 		desc-dtpd_provider[0],
 		desc-dtpd_mod[0],
@@ -215,7 +215,7 @@
 	}
 #endif
 
-	for (ind=0; sprov-probes[ind] != NULL; ind++) {
+	for (ind = 0; sprov-probes[ind] != NULL; ind++) {
 		if (sprov-probes[ind]-created == 0) {
 			res = dtrace_probe_create(sprov-id,
 sprov-probes[ind]-module,
@@ -241,14 +241,14 @@
 static void
 sdt_destroy(void *arg, dtrace_id_t id, void *parg)
 {
-	sdt_provider_t *sprov = arg;
-	int ind;
+	sdt_provider_t *sprov = arg;
+	int ind;
 
 #ifdef SDT_DEBUG
 	printf(sdt: %s\n, __func__);
 #endif
 
-	for (ind=0; sprov-probes[ind] != NULL; ind++) {
+	for (ind = 0; sprov-probes[ind] != NULL; ind++) {
 		if (sprov-probes[ind]-id == id) {
 #ifdef SDT_DEBUG
 			printf(%s: destroying probe %d (%s:%s:%s:%s)\n,
@@ -269,14 +269,14 @@
 static int
 sdt_enable(void *arg, dtrace_id_t id, void *parg)
 {
-	sdt_provider_t *sprov = arg;
-	int ind;
+	sdt_provider_t *sprov = arg;
+	int ind;
 
 #ifdef SDT_DEBUG
 	printf(sdt: %s\n, __func__);
 #endif
 
-	for (ind=0; sprov-probes[ind] != NULL; ind++) {
+	for (ind = 0; sprov-probes[ind] != NULL; ind++) {
 	

CVS commit: src/external/cddl/osnet/dev/dtrace

2011-07-26 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Tue Jul 26 12:26:33 UTC 2011

Modified Files:
src/external/cddl/osnet/dev/dtrace: dtrace_unload.c

Log Message:
fix a kmem_alloc/free size mismatch


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/cddl/osnet/dev/dtrace/dtrace_unload.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/dtrace_unload.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_unload.c:1.4 src/external/cddl/osnet/dev/dtrace/dtrace_unload.c:1.5
--- src/external/cddl/osnet/dev/dtrace/dtrace_unload.c:1.4	Fri Apr 23 16:44:10 2010
+++ src/external/cddl/osnet/dev/dtrace/dtrace_unload.c	Tue Jul 26 12:26:33 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_unload.c,v 1.4 2010/04/23 16:44:10 ahoka Exp $	*/
+/*	$NetBSD: dtrace_unload.c,v 1.5 2011/07/26 12:26:33 yamt Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -92,7 +92,8 @@
 	vmem_destroy(dtrace_arena);
 
 	if (dtrace_toxrange != NULL) {
-		kmem_free(dtrace_toxrange, sizeof (dtrace_toxrange_t *));
+		kmem_free(dtrace_toxrange,
+		dtrace_toxranges_max * sizeof (dtrace_toxrange_t));
 		dtrace_toxrange = NULL;
 		dtrace_toxranges = 0;
 		dtrace_toxranges_max = 0;



CVS commit: src/external/cddl/osnet/dev/dtrace/i386

2011-07-20 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Wed Jul 20 19:51:57 UTC 2011

Modified Files:
src/external/cddl/osnet/dev/dtrace/i386: dis_tables.c

Log Message:
Fix uninitialized variables reported by GCC 4.5.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/dev/dtrace/i386/dis_tables.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/i386/dis_tables.c
diff -u src/external/cddl/osnet/dev/dtrace/i386/dis_tables.c:1.2 src/external/cddl/osnet/dev/dtrace/i386/dis_tables.c:1.3
--- src/external/cddl/osnet/dev/dtrace/i386/dis_tables.c:1.2	Sun Feb 21 01:46:33 2010
+++ src/external/cddl/osnet/dev/dtrace/i386/dis_tables.c	Wed Jul 20 19:51:57 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: dis_tables.c,v 1.2 2010/02/21 01:46:33 darran Exp $	*/
+/*	$NetBSD: dis_tables.c,v 1.3 2011/07/20 19:51:57 tron Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -1716,9 +1716,9 @@
 	uint_t opcode2;		/* low nibble of 1st byte */
 	uint_t opcode3;		/* extra opcode bits usually from ModRM byte */
 	uint_t opcode4;		/* high nibble of 2nd byte */
-	uint_t opcode5;		/* low nibble of 2ne byte */
+	uint_t opcode5 = 0xff;	/* low nibble of 2nd byte */
 	uint_t opcode6;		/* high nibble of 3rd byte */
-	uint_t opcode7;		/* low nibble of 3rd byte */
+	uint_t opcode7 = 0xff;	/* low nibble of 3rd byte */
 	uint_t opcode_bytes = 1;
 
 	/*



CVS commit: src/external/cddl/osnet/dev/dtrace/amd64

2011-07-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jul 18 00:42:40 UTC 2011

Modified Files:
src/external/cddl/osnet/dev/dtrace/amd64: dis_tables.c

Log Message:
fix uninitialized gcc variables


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dev/dtrace/amd64/dis_tables.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/amd64/dis_tables.c
diff -u src/external/cddl/osnet/dev/dtrace/amd64/dis_tables.c:1.2 src/external/cddl/osnet/dev/dtrace/amd64/dis_tables.c:1.3
--- src/external/cddl/osnet/dev/dtrace/amd64/dis_tables.c:1.2	Sat Feb 20 20:46:33 2010
+++ src/external/cddl/osnet/dev/dtrace/amd64/dis_tables.c	Sun Jul 17 20:42:40 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: dis_tables.c,v 1.2 2010/02/21 01:46:33 darran Exp $	*/
+/*	$NetBSD: dis_tables.c,v 1.3 2011/07/18 00:42:40 christos Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -1716,9 +1716,9 @@
 	uint_t opcode2;		/* low nibble of 1st byte */
 	uint_t opcode3;		/* extra opcode bits usually from ModRM byte */
 	uint_t opcode4;		/* high nibble of 2nd byte */
-	uint_t opcode5;		/* low nibble of 2ne byte */
+	uint_t opcode5 = 0;	/* low nibble of 2ne byte */	/* XXX: gcc */
 	uint_t opcode6;		/* high nibble of 3rd byte */
-	uint_t opcode7;		/* low nibble of 3rd byte */
+	uint_t opcode7 = 0;	/* low nibble of 3rd byte */	/* XXX: gcc */
 	uint_t opcode_bytes = 1;
 
 	/*



CVS commit: src/external/cddl/osnet/dev/fbt

2010-05-03 Thread Darran Hunt
Module Name:src
Committed By:   darran
Date:   Mon May  3 09:28:38 UTC 2010

Modified Files:
src/external/cddl/osnet/dev/fbt: fbt.c

Log Message:
DTrace: print a warning no CTF section is found when processing arguments.
This should help diagnose problems such as netbsd images without CTF
sections and old boot loaders.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/cddl/osnet/dev/fbt/fbt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/fbt.c
diff -u src/external/cddl/osnet/dev/fbt/fbt.c:1.5 src/external/cddl/osnet/dev/fbt/fbt.c:1.6
--- src/external/cddl/osnet/dev/fbt/fbt.c:1.5	Sat Mar 13 22:31:15 2010
+++ src/external/cddl/osnet/dev/fbt/fbt.c	Mon May  3 09:28:38 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt.c,v 1.5 2010/03/13 22:31:15 christos Exp $	*/
+/*	$NetBSD: fbt.c,v 1.6 2010/05/03 09:28:38 darran Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -1399,6 +1399,12 @@
 
 	/* Get a pointer to the CTF data and it's length. */
 	if (mod_ctf_get(ctl, mc) != 0) {
+		static int report=0;
+		if (report  1) {
+		report++;
+		printf(FBT: Error no CTF section found in module \%s\\n,
+			ctl-mod_info-mi_name);
+		}
 		/* No CTF data? Something wrong? *shrug* */
 		return;
 	}



CVS commit: src/external/cddl/osnet/dev/dtrace

2010-04-23 Thread Adam Hoka
Module Name:src
Committed By:   ahoka
Date:   Fri Apr 23 16:44:10 UTC 2010

Modified Files:
src/external/cddl/osnet/dev/dtrace: dtrace_unload.c

Log Message:
Add a missing parentheses.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dev/dtrace/dtrace_unload.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/dtrace_unload.c
diff -u src/external/cddl/osnet/dev/dtrace/dtrace_unload.c:1.3 src/external/cddl/osnet/dev/dtrace/dtrace_unload.c:1.4
--- src/external/cddl/osnet/dev/dtrace/dtrace_unload.c:1.3	Fri Apr 23 11:39:52 2010
+++ src/external/cddl/osnet/dev/dtrace/dtrace_unload.c	Fri Apr 23 16:44:10 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_unload.c,v 1.3 2010/04/23 11:39:52 ahoka Exp $	*/
+/*	$NetBSD: dtrace_unload.c,v 1.4 2010/04/23 16:44:10 ahoka Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -92,7 +92,7 @@
 	vmem_destroy(dtrace_arena);
 
 	if (dtrace_toxrange != NULL) {
-		kmem_free(dtrace_toxrange, sizeof (dtrace_toxrange_t *);
+		kmem_free(dtrace_toxrange, sizeof (dtrace_toxrange_t *));
 		dtrace_toxrange = NULL;
 		dtrace_toxranges = 0;
 		dtrace_toxranges_max = 0;



CVS commit: src/external/cddl/osnet/dev/dtrace/i386

2010-03-18 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Thu Mar 18 11:00:03 UTC 2010

Modified Files:
src/external/cddl/osnet/dev/dtrace/i386: dtrace_subr.c

Log Message:
Fix the build:
1.) ifdef-out unused functions and global variables.
2.) Include x86/include/cpu_counter.h for amd64 and i386 to get the
prototype of cpu_frequency.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c
diff -u src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.2 src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.3
--- src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c:1.2	Sun Feb 21 01:46:33 2010
+++ src/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c	Thu Mar 18 11:00:03 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: dtrace_subr.c,v 1.2 2010/02/21 01:46:33 darran Exp $	*/
+/*	$NetBSD: dtrace_subr.c,v 1.3 2010/03/18 11:00:03 tron Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -48,6 +48,10 @@
 #include uvm/uvm_prot.h
 #include uvm/uvm_pmap.h
 
+#if defined(__amd64__) || defined(__i386__)
+#include x86/include/cpu_counter.h
+#endif
+
 extern uintptr_t 	kernelbase;
 extern uintptr_t 	dtrace_in_probe_addr;
 extern int		dtrace_in_probe;
@@ -61,6 +65,8 @@
 
 dtrace_invop_hdlr_t *dtrace_invop_hdlr;
 
+void dtrace_gethrtime_init(void *arg);
+
 int
 dtrace_invop(uintptr_t addr, uintptr_t *stack, uintptr_t eax)
 {
@@ -372,8 +378,10 @@
 }
 #endif
 
+#if 0
 static int64_t	tgt_cpu_tsc;
 static int64_t	hst_cpu_tsc;
+#endif
 static int64_t	tsc_skew[MAXCPUS];
 static uint64_t	nsec_scale;
 
@@ -389,6 +397,7 @@
 	return (rv);
 }
 
+#if 0
 static void
 dtrace_gethrtime_init_sync(void *arg)
 {
@@ -408,7 +417,9 @@
 	}
 #endif
 }
+#endif
 
+#if 0
 static void
 dtrace_gethrtime_init_cpu(void *arg)
 {
@@ -419,6 +430,7 @@
 	else
 		hst_cpu_tsc = dtrace_rdtsc();
 }
+#endif
 
 void
 dtrace_gethrtime_init(void *arg)



CVS commit: src/external/cddl/osnet/dev/fbt

2010-03-12 Thread Darran Hunt
Module Name:src
Committed By:   darran
Date:   Sat Mar 13 01:10:01 UTC 2010

Modified Files:
src/external/cddl/osnet/dev/fbt: fbt.c

Log Message:
DTrace: fix a sign problem with instruction size handling.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/dev/fbt/fbt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/cddl/osnet/dev/fbt/fbt.c
diff -u src/external/cddl/osnet/dev/fbt/fbt.c:1.3 src/external/cddl/osnet/dev/fbt/fbt.c:1.4
--- src/external/cddl/osnet/dev/fbt/fbt.c:1.3	Fri Mar 12 21:53:15 2010
+++ src/external/cddl/osnet/dev/fbt/fbt.c	Sat Mar 13 01:10:01 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: fbt.c,v 1.3 2010/03/12 21:53:15 darran Exp $	*/
+/*	$NetBSD: fbt.c,v 1.4 2010/03/13 01:10:01 darran Exp $	*/
 
 /*
  * CDDL HEADER START
@@ -237,7 +237,7 @@
 
 static int
 fbt_provide_module_cb(const char *name, int symindx, void *value,
-	uint32_t size, int type, void *opaque)
+	uint32_t symsize, int type, void *opaque)
 {
 	fbt_probe_t *fbt, *retfbt;
 	u_int8_t *instr, *limit;
@@ -245,6 +245,7 @@
 	const char *modname = mod-mod_info-mi_name;
 	int j;
 	int ind;
+	int size;
 
 	/* got a function? */
 	if (ELF_ST_TYPE(type) != STT_FUNC) {
@@ -266,7 +267,7 @@
 		return (0);
 
 	instr = (u_int8_t *) value;
-	limit = (u_int8_t *) value + size;
+	limit = (u_int8_t *) value + symsize;
 
 #ifdef __amd64__
 	while (instr  limit) {