git: 7756232199ad - main - riscv: improve KTR_TRAP trace entries
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 20 Jun 2023 14:54:22 UTC
The branch main has been updated by mhorne:
URL: https://cgit.FreeBSD.org/src/commit/?id=7756232199adf60343ae0b940e2b27fe363905bc
commit 7756232199adf60343ae0b940e2b27fe363905bc
Author: Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2023-06-20 14:52:26 +0000
Commit: Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2023-06-20 14:54:14 +0000
riscv: improve KTR_TRAP trace entries
For more informative records of exceptions, include key details such as
the exception code and stval register contents. Remove the curthread
argument as it is redundant (saved with every ktr entry), and the
trapframe as it is somewhat meaningless.
Add a new KTR_TRAP trace record for interrupts.
Reviewed by: markj, jhb
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40584
---
sys/riscv/riscv/intr_machdep.c | 3 +++
sys/riscv/riscv/trap.c | 8 ++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/sys/riscv/riscv/intr_machdep.c b/sys/riscv/riscv/intr_machdep.c
index d84f4ea1cb91..1ee2c0984205 100644
--- a/sys/riscv/riscv/intr_machdep.c
+++ b/sys/riscv/riscv/intr_machdep.c
@@ -163,6 +163,9 @@ riscv_cpu_intr(struct trapframe *frame)
active_irq = frame->tf_scause & SCAUSE_CODE;
+ CTR3(KTR_TRAP, "%s: irq=%d, umode=%d", __func__, active_irq,
+ TRAPF_USERMODE(frame));
+
switch (active_irq) {
case IRQ_SOFTWARE_USER:
case IRQ_SOFTWARE_SUPERVISOR:
diff --git a/sys/riscv/riscv/trap.c b/sys/riscv/riscv/trap.c
index 11ecfa702054..ac481c313e15 100644
--- a/sys/riscv/riscv/trap.c
+++ b/sys/riscv/riscv/trap.c
@@ -291,8 +291,8 @@ do_trap_supervisor(struct trapframe *frame)
return;
#endif
- CTR3(KTR_TRAP, "do_trap_supervisor: curthread: %p, sepc: %lx, frame: %p",
- curthread, frame->tf_sepc, frame);
+ CTR4(KTR_TRAP, "%s: exception=%lu, sepc=%lx, stval=%lx", __func__,
+ exception, frame->tf_sepc, frame->tf_stval);
switch (exception) {
case SCAUSE_LOAD_ACCESS_FAULT:
@@ -365,8 +365,8 @@ do_trap_user(struct trapframe *frame)
}
intr_enable();
- CTR3(KTR_TRAP, "do_trap_user: curthread: %p, sepc: %lx, frame: %p",
- curthread, frame->tf_sepc, frame);
+ CTR4(KTR_TRAP, "%s: exception=%lu, sepc=%lx, stval=%lx", __func__,
+ exception, frame->tf_sepc, frame->tf_stval);
switch (exception) {
case SCAUSE_LOAD_ACCESS_FAULT: