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/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 *)&val);
+	if (!pmap_extract(pmap_kernel(), (vaddr_t)fbt->fbtp_patchpoint, &pa))
+		return;
+	if (!mm_md_direct_mapped_phys(pa, &va))
+		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/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 *)&val);
+	cpu_icache_sync_range((vm_offset_t)fbt->fbtp_patchpoint, sizeof(val));
 }
 
 #if defined(__FreeBSD__)