git: c8c2d908dd47 - stable/13 - arm64, riscv: Fix TRAF_PC() to return the PC, not the return address.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 23 Nov 2021 23:48:56 UTC
The branch stable/13 has been updated by jhb:

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

commit c8c2d908dd477d6413eaf1f788df88c73ae73c5b
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2021-10-01 18:53:12 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2021-11-23 23:48:07 +0000

    arm64, riscv: Fix TRAF_PC() to return the PC, not the return address.
    
    Reviewed by:    mhorne
    Obtained from:  CheriBSD
    Sponsored by:   DARPA
    Differential Revision:  https://reviews.freebsd.org/D31969
    
    (cherry picked from commit 0177102173f39e17366a32eb22653aeb5248c355)
---
 sys/arm64/include/cpu.h | 2 +-
 sys/riscv/include/cpu.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/arm64/include/cpu.h b/sys/arm64/include/cpu.h
index 0b1aa2d93b03..c926372a0ec6 100644
--- a/sys/arm64/include/cpu.h
+++ b/sys/arm64/include/cpu.h
@@ -45,7 +45,7 @@
 #include <machine/frame.h>
 #include <machine/armreg.h>
 
-#define	TRAPF_PC(tfp)		((tfp)->tf_lr)
+#define	TRAPF_PC(tfp)		((tfp)->tf_elr)
 #define	TRAPF_USERMODE(tfp)	(((tfp)->tf_spsr & PSR_M_MASK) == PSR_M_EL0t)
 
 #define	cpu_getstack(td)	((td)->td_frame->tf_sp)
diff --git a/sys/riscv/include/cpu.h b/sys/riscv/include/cpu.h
index 79c6f730f2a6..453a6af1a0f8 100644
--- a/sys/riscv/include/cpu.h
+++ b/sys/riscv/include/cpu.h
@@ -41,7 +41,7 @@
 #include <machine/cpufunc.h>
 #include <machine/frame.h>
 
-#define	TRAPF_PC(tfp)		((tfp)->tf_ra)
+#define	TRAPF_PC(tfp)		((tfp)->tf_sepc)
 #define	TRAPF_USERMODE(tfp)	(((tfp)->tf_sstatus & SSTATUS_SPP) == 0)
 
 #define	cpu_getstack(td)	((td)->td_frame->tf_sp)