Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Jul 2020 07:41:37 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r363383 - in head/sys/cddl/dev: dtrace/arm fbt/arm
Message-ID:  <202007210741.06L7fbZ3060915@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Tue Jul 21 07:41:36 2020
New Revision: 363383
URL: https://svnweb.freebsd.org/changeset/base/363383

Log:
  dtrace/fbt: fix return probe arguments on arm
  
  arg0 should be an offset of the return point within the function, arg1
  should be the return value.  Previously the return probe had arguments as
  if for the entry probe.
  
  Tested on armv7.
  
  andrew noted that the same problem seems to be present on arm64, mips,
  and riscv.
  I am not sure if I will get around to fixing those.  So, platform users
  or anyone looking to make a contribution please be aware of this
  opportunity.
  
  Reviewed by:	markj
  MFC after:	1 week
  Differential Revision: https://reviews.freebsd.org/D25685

Modified:
  head/sys/cddl/dev/dtrace/arm/dtrace_subr.c
  head/sys/cddl/dev/fbt/arm/fbt_isa.c

Modified: head/sys/cddl/dev/dtrace/arm/dtrace_subr.c
==============================================================================
--- head/sys/cddl/dev/dtrace/arm/dtrace_subr.c	Tue Jul 21 07:35:03 2020	(r363382)
+++ head/sys/cddl/dev/dtrace/arm/dtrace_subr.c	Tue Jul 21 07:41:36 2020	(r363383)
@@ -248,7 +248,7 @@ dtrace_invop_start(struct trapframe *frame)
 	register_t *r0, *sp;
 	int data, invop, reg, update_sp;
 
-	invop = dtrace_invop(frame->tf_pc, frame, frame->tf_pc);
+	invop = dtrace_invop(frame->tf_pc, frame, frame->tf_r0);
 	switch (invop & DTRACE_INVOP_MASK) {
 	case DTRACE_INVOP_PUSHM:
 		sp = (register_t *)frame->tf_svc_sp;

Modified: head/sys/cddl/dev/fbt/arm/fbt_isa.c
==============================================================================
--- head/sys/cddl/dev/fbt/arm/fbt_isa.c	Tue Jul 21 07:35:03 2020	(r363382)
+++ head/sys/cddl/dev/fbt/arm/fbt_isa.c	Tue Jul 21 07:41:36 2020	(r363383)
@@ -56,9 +56,12 @@ fbt_invop(uintptr_t addr, struct trapframe *frame, uin
 	register_t fifthparam;
 
 	for (; fbt != NULL; fbt = fbt->fbtp_hashnext) {
-		if ((uintptr_t)fbt->fbtp_patchpoint == addr) {
-			cpu->cpu_dtrace_caller = addr;
+		if ((uintptr_t)fbt->fbtp_patchpoint != addr)
+			continue;
 
+		cpu->cpu_dtrace_caller = addr;
+
+		if (fbt->fbtp_roffset == 0) {
 			/* Get 5th parameter from stack */
 			DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
 			fifthparam = *(register_t *)frame->tf_svc_sp;
@@ -67,11 +70,13 @@ fbt_invop(uintptr_t addr, struct trapframe *frame, uin
 			dtrace_probe(fbt->fbtp_id, frame->tf_r0,
 			    frame->tf_r1, frame->tf_r2,
 			    frame->tf_r3, fifthparam);
-
-			cpu->cpu_dtrace_caller = 0;
-
-			return (fbt->fbtp_rval | (fbt->fbtp_savedval << DTRACE_INVOP_SHIFT));
+		} else {
+			dtrace_probe(fbt->fbtp_id, fbt->fbtp_roffset, rval,
+			    0, 0, 0);
 		}
+
+		cpu->cpu_dtrace_caller = 0;
+		return (fbt->fbtp_rval | (fbt->fbtp_savedval << DTRACE_INVOP_SHIFT));
 	}
 
 	return (0);
@@ -178,6 +183,7 @@ again:
 		fbt->fbtp_rval = DTRACE_INVOP_B;
 	else
 		fbt->fbtp_rval = DTRACE_INVOP_POPM;
+	fbt->fbtp_roffset = (uintptr_t)instr - (uintptr_t)symval->value;
 	fbt->fbtp_savedval = *instr;
 	fbt->fbtp_patchval = FBT_BREAKPOINT;
 	fbt->fbtp_hashnext = fbt_probetab[FBT_ADDR2NDX(instr)];



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