git: ed44d21ee847 - stable/13 - dtrace: Fix RISC-V user stack unwinder

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Wed, 15 Feb 2023 16:43:06 UTC
The branch stable/13 has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=ed44d21ee8473f7b73d8160287e2012e2f797bea

commit ed44d21ee8473f7b73d8160287e2012e2f797bea
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2023-02-06 18:30:57 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2023-02-15 16:41:39 +0000

    dtrace: Fix RISC-V user stack unwinder
    
    The unwind logic was copied from AArch64 which follows the peculiar
    AACPS (where, unlike typical RISC architectures, its frame pointer
    follows an x86/stack machine-like convention where the frame pointer
    points at the bottom of the frame record, not the top). Delete the
    pointless riscv_frame struct and fix this.
    
    Reviewed by:    mhorne
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D28054
    
    (cherry picked from commit 38720107324b3903f342bcb0306c72c4e4235053)
---
 sys/cddl/dev/dtrace/riscv/dtrace_isa.c | 5 ++---
 sys/riscv/include/frame.h              | 5 -----
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/sys/cddl/dev/dtrace/riscv/dtrace_isa.c b/sys/cddl/dev/dtrace/riscv/dtrace_isa.c
index bc8426a752df..6d44a0cee9ee 100644
--- a/sys/cddl/dev/dtrace/riscv/dtrace_isa.c
+++ b/sys/cddl/dev/dtrace/riscv/dtrace_isa.c
@@ -150,9 +150,8 @@ dtrace_getustack_common(uint64_t *pcstack, int pcstack_limit, uintptr_t pc,
 		if (fp == 0)
 			break;
 
-		pc = dtrace_fuword64((void *)(fp +
-		    offsetof(struct riscv_frame, f_retaddr)));
-		fp = dtrace_fuword64((void *)fp);
+		pc = dtrace_fuword64((void *)(fp - 1 * sizeof(uint64_t)));
+		fp = dtrace_fuword64((void *)(fp - 2 * sizeof(uint64_t)));
 
 		if (fp == oldfp) {
 			*flags |= CPU_DTRACE_BADSTACK;
diff --git a/sys/riscv/include/frame.h b/sys/riscv/include/frame.h
index 3917aebfac76..a822a285996c 100644
--- a/sys/riscv/include/frame.h
+++ b/sys/riscv/include/frame.h
@@ -59,11 +59,6 @@ struct trapframe {
 	uint64_t tf_scause;
 };
 
-struct riscv_frame {
-	struct riscv_frame	*f_frame;
-	u_long			f_retaddr;
-};
-
 /*
  * Signal frame. Pushed onto user stack before calling sigcode.
  */