riscv: save the thread pointer in both modes

The contents of frame->tf_tp are uninitialized if accessed by DTrace (in
probe context), resulting in a panic when trying to access the memory
pointed to by tp. This saves the thread pointer to the trap frame when
handling both userland and kernel exceptions.

Reviewed by:	markj, mhorne
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39582
This commit is contained in:
Mark Johnston 2023-04-17 09:44:44 -04:00
parent f656a96020
commit d95fbf4e1a

View File

@ -56,6 +56,8 @@ __FBSDID("$FreeBSD$");
/* Load our pcpu */
sd tp, (TF_TP)(sp)
ld tp, (TF_SIZE)(sp)
.else
sd tp, (TF_TP)(sp)
.endif
sd t0, (TF_T + 0 * 8)(sp)