Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Sep 2023 16:12:49 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 3b35d2a8af43 - main - riscv: Save gp in the trapframe in both modes
Message-ID:  <202309051612.385GCncx058935@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhb:

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

commit 3b35d2a8af43c2e3ea8cb5e1363ac87ec5eadeaf
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-09-05 16:04:54 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-09-05 16:04:54 +0000

    riscv: Save gp in the trapframe in both modes
    
    Similar to d95fbf4e1a12565908b04b442263fe60c9e890b4, always save gp in
    the trapframe even though it is only restored when returning to user
    mode.  This is mostly a debugging aid so that dump_regs() doesn't
    print out random stack garbage as the value of gp for kernel faults
    (e.g. sysctl debug.kdb.trap=1) as well as keeping kgdb's trapframe
    unwinder from reporting bogus values of $gp for lower frames.
    
    Reviewed by:    mhorne, jrtc27, markj
    Sponsored by:   DARPA
    Differential Revision:  https://reviews.freebsd.org/D41699
---
 sys/riscv/riscv/exception.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/riscv/riscv/exception.S b/sys/riscv/riscv/exception.S
index 1aee009a4e00..8acb5cd691d4 100644
--- a/sys/riscv/riscv/exception.S
+++ b/sys/riscv/riscv/exception.S
@@ -43,9 +43,9 @@
 
 	sd	ra, (TF_RA)(sp)
 	sd	tp, (TF_TP)(sp)
+	sd	gp, (TF_GP)(sp)
 
 .if \mode == 0	/* We came from userspace. */
-	sd	gp, (TF_GP)(sp)
 .option push
 .option norelax
 	/* Load the kernel's global pointer */



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