Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jan 2018 16:17:31 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r327551 - in stable/11/sys: amd64/amd64 cddl/contrib/opensolaris/uts/common/sys cddl/contrib/opensolaris/uts/intel/dtrace cddl/contrib/opensolaris/uts/powerpc/dtrace i386/i386 powerpc/p...
Message-ID:  <201801041617.w04GHViu050729@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Thu Jan  4 16:17:31 2018
New Revision: 327551
URL: https://svnweb.freebsd.org/changeset/base/327551

Log:
  MFC r326774, r326811:
  Pass the trap frame to fasttrap hooks.

Modified:
  stable/11/sys/amd64/amd64/trap.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h
  stable/11/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
  stable/11/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c
  stable/11/sys/i386/i386/trap.c
  stable/11/sys/powerpc/powerpc/trap.c
  stable/11/sys/sys/dtrace_bsd.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/amd64/trap.c
==============================================================================
--- stable/11/sys/amd64/amd64/trap.c	Thu Jan  4 15:57:49 2018	(r327550)
+++ stable/11/sys/amd64/amd64/trap.c	Thu Jan  4 16:17:31 2018	(r327551)
@@ -162,9 +162,6 @@ SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG
 void
 trap(struct trapframe *frame)
 {
-#ifdef KDTRACE_HOOKS
-	struct reg regs;
-#endif
 	ksiginfo_t ksi;
 	struct thread *td;
 	struct proc *p;
@@ -276,9 +273,8 @@ trap(struct trapframe *frame)
 			enable_intr();
 #ifdef KDTRACE_HOOKS
 			if (type == T_BPTFLT) {
-				fill_frame_regs(frame, &regs);
 				if (dtrace_pid_probe_ptr != NULL &&
-				    dtrace_pid_probe_ptr(&regs) == 0)
+				    dtrace_pid_probe_ptr(frame) == 0)
 					return;
 			}
 #endif
@@ -404,9 +400,8 @@ trap(struct trapframe *frame)
 #ifdef KDTRACE_HOOKS
 		case T_DTRACE_RET:
 			enable_intr();
-			fill_frame_regs(frame, &regs);
 			if (dtrace_return_probe_ptr != NULL)
-				dtrace_return_probe_ptr(&regs);
+				dtrace_return_probe_ptr(frame);
 			return;
 #endif
 		}

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h
==============================================================================
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h	Thu Jan  4 15:57:49 2018	(r327550)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap_impl.h	Thu Jan  4 16:17:31 2018	(r327551)
@@ -221,9 +221,9 @@ extern int fasttrap_tracepoint_init(proc_t *, fasttrap
 extern int fasttrap_tracepoint_install(proc_t *, fasttrap_tracepoint_t *);
 extern int fasttrap_tracepoint_remove(proc_t *, fasttrap_tracepoint_t *);
 
-struct reg;
-extern int fasttrap_pid_probe(struct reg *);
-extern int fasttrap_return_probe(struct reg *);
+struct trapframe;
+extern int fasttrap_pid_probe(struct trapframe *);
+extern int fasttrap_return_probe(struct trapframe *);
 
 extern uint64_t fasttrap_pid_getarg(void *, dtrace_id_t, void *, int, int);
 extern uint64_t fasttrap_usdt_getarg(void *, dtrace_id_t, void *, int, int);

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
==============================================================================
--- stable/11/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c	Thu Jan  4 15:57:49 2018	(r327550)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c	Thu Jan  4 16:17:31 2018	(r327551)
@@ -967,14 +967,12 @@ fasttrap_do_seg(fasttrap_tracepoint_t *tp, struct reg 
 }
 
 int
-fasttrap_pid_probe(struct reg *rp)
+fasttrap_pid_probe(struct trapframe *tf)
 {
-	proc_t *p = curproc;
-#ifndef illumos
+	struct reg reg, *rp;
+	proc_t *p = curproc, *pp;
 	struct rm_priotracker tracker;
-	proc_t *pp;
-#endif
-	uintptr_t pc = rp->r_rip - 1;
+	uintptr_t pc;
 	uintptr_t new_pc = 0;
 	fasttrap_bucket_t *bucket;
 #ifdef illumos
@@ -985,6 +983,11 @@ fasttrap_pid_probe(struct reg *rp)
 	dtrace_icookie_t cookie;
 	uint_t is_enabled = 0;
 
+	fill_frame_regs(tf, &reg);
+	rp = &reg;
+
+	pc = rp->r_rip - 1;
+
 	/*
 	 * It's possible that a user (in a veritable orgy of bad planning)
 	 * could redirect this thread's flow of control before it reached the
@@ -1796,12 +1799,16 @@ done:
 }
 
 int
-fasttrap_return_probe(struct reg *rp)
+fasttrap_return_probe(struct trapframe *tf)
 {
+	struct reg reg, *rp;
 	proc_t *p = curproc;
 	uintptr_t pc = curthread->t_dtrace_pc;
 	uintptr_t npc = curthread->t_dtrace_npc;
 
+	fill_frame_regs(tf, &reg);
+	rp = &reg;
+
 	curthread->t_dtrace_pc = 0;
 	curthread->t_dtrace_npc = 0;
 	curthread->t_dtrace_scrpc = 0;
@@ -1821,9 +1828,7 @@ fasttrap_return_probe(struct reg *rp)
 	/*
 	 * We set rp->r_rip to the address of the traced instruction so
 	 * that it appears to dtrace_probe() that we're on the original
-	 * instruction, and so that the user can't easily detect our
-	 * complex web of lies. dtrace_return_probe() (our caller)
-	 * will correctly set %pc after we return.
+	 * instruction.
 	 */
 	rp->r_rip = pc;
 

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c
==============================================================================
--- stable/11/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c	Thu Jan  4 15:57:49 2018	(r327550)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c	Thu Jan  4 16:17:31 2018	(r327551)
@@ -328,11 +328,12 @@ fasttrap_branch_taken(int bo, int bi, struct reg *regs
 
 
 int
-fasttrap_pid_probe(struct reg *rp)
+fasttrap_pid_probe(struct trapframe *frame)
 {
+	struct reg reg, *rp;
 	struct rm_priotracker tracker;
 	proc_t *p = curproc;
-	uintptr_t pc = rp->pc;
+	uintptr_t pc;
 	uintptr_t new_pc = 0;
 	fasttrap_bucket_t *bucket;
 	fasttrap_tracepoint_t *tp, tp_local;
@@ -340,6 +341,10 @@ fasttrap_pid_probe(struct reg *rp)
 	dtrace_icookie_t cookie;
 	uint_t is_enabled = 0;
 
+	fill_regs(curthread, &reg);
+	rp = &reg;
+	pc = rp->pc;
+
 	/*
 	 * It's possible that a user (in a veritable orgy of bad planning)
 	 * could redirect this thread's flow of control before it reached the
@@ -515,8 +520,9 @@ done:
 }
 
 int
-fasttrap_return_probe(struct reg *rp)
+fasttrap_return_probe(struct trapframe *tf)
 {
+	struct reg reg, *rp;
 	proc_t *p = curproc;
 	uintptr_t pc = curthread->t_dtrace_pc;
 	uintptr_t npc = curthread->t_dtrace_npc;
@@ -526,12 +532,13 @@ fasttrap_return_probe(struct reg *rp)
 	curthread->t_dtrace_scrpc = 0;
 	curthread->t_dtrace_astpc = 0;
 
+	fill_regs(curthread, &reg);
+	rp = &reg;
+
 	/*
 	 * We set rp->pc to the address of the traced instruction so
 	 * that it appears to dtrace_probe() that we're on the original
-	 * instruction, and so that the user can't easily detect our
-	 * complex web of lies. dtrace_return_probe() (our caller)
-	 * will correctly set %pc after we return.
+	 * instruction.
 	 */
 	rp->pc = pc;
 
@@ -539,4 +546,3 @@ fasttrap_return_probe(struct reg *rp)
 
 	return (0);
 }
-

Modified: stable/11/sys/i386/i386/trap.c
==============================================================================
--- stable/11/sys/i386/i386/trap.c	Thu Jan  4 15:57:49 2018	(r327550)
+++ stable/11/sys/i386/i386/trap.c	Thu Jan  4 16:17:31 2018	(r327551)
@@ -175,9 +175,6 @@ SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG
 void
 trap(struct trapframe *frame)
 {
-#ifdef KDTRACE_HOOKS
-	struct reg regs;
-#endif
 	ksiginfo_t ksi;
 	struct thread *td;
 	struct proc *p;
@@ -325,9 +322,8 @@ trap(struct trapframe *frame)
 			enable_intr();
 #ifdef KDTRACE_HOOKS
 			if (type == T_BPTFLT) {
-				fill_frame_regs(frame, &regs);
 				if (dtrace_pid_probe_ptr != NULL &&
-				    dtrace_pid_probe_ptr(&regs) == 0)
+				    dtrace_pid_probe_ptr(frame) == 0)
 					return;
 			}
 #endif
@@ -495,9 +491,8 @@ user_trctrap_out:
 #ifdef KDTRACE_HOOKS
 		case T_DTRACE_RET:
 			enable_intr();
-			fill_frame_regs(frame, &regs);
 			if (dtrace_return_probe_ptr != NULL)
-				dtrace_return_probe_ptr(&regs);
+				dtrace_return_probe_ptr(frame);
 			return;
 #endif
 		}

Modified: stable/11/sys/powerpc/powerpc/trap.c
==============================================================================
--- stable/11/sys/powerpc/powerpc/trap.c	Thu Jan  4 15:57:49 2018	(r327550)
+++ stable/11/sys/powerpc/powerpc/trap.c	Thu Jan  4 16:17:31 2018	(r327551)
@@ -299,9 +299,7 @@ trap(struct trapframe *frame)
 				inst = fuword32((const void *)frame->srr0);
 				if (inst == 0x0FFFDDDD &&
 				    dtrace_pid_probe_ptr != NULL) {
-					struct reg regs;
-					fill_regs(td, &regs);
-					(*dtrace_pid_probe_ptr)(&regs);
+					(*dtrace_pid_probe_ptr)(frame);
 					break;
 				}
 #endif

Modified: stable/11/sys/sys/dtrace_bsd.h
==============================================================================
--- stable/11/sys/sys/dtrace_bsd.h	Thu Jan  4 15:57:49 2018	(r327550)
+++ stable/11/sys/sys/dtrace_bsd.h	Thu Jan  4 16:17:31 2018	(r327551)
@@ -37,7 +37,6 @@ struct trapframe;
 struct thread;
 struct vattr;
 struct vnode;
-struct reg;
 
 int dtrace_trap(struct trapframe *, u_int);
 
@@ -58,9 +57,9 @@ typedef void (*dtrace_doubletrap_func_t)(void);
 extern	dtrace_doubletrap_func_t	dtrace_doubletrap_func;
 
 /* Pid provider hooks */
-typedef int (*dtrace_pid_probe_ptr_t)(struct reg *);
+typedef int (*dtrace_pid_probe_ptr_t)(struct trapframe *);
 extern	dtrace_pid_probe_ptr_t	dtrace_pid_probe_ptr;
-typedef int (*dtrace_return_probe_ptr_t)(struct reg *);
+typedef int (*dtrace_return_probe_ptr_t)(struct trapframe *);
 extern	dtrace_return_probe_ptr_t	dtrace_return_probe_ptr;
 
 /* Virtual time hook function type. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801041617.w04GHViu050729>