aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2021-04-21 20:57:20 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2021-04-21 20:57:20 +0000
commit6a3a6fe34bf36b6e745b3e9ad1a991de057729c7 (patch)
tree6ee1f1669475c8ebeeeac992542195102aac2a7a
parent753bcca440a4d2c95f48536b586131b84c0bb87e (diff)
downloadsrc-6a3a6fe34bf36b6e745b3e9ad1a991de057729c7.tar.gz
src-6a3a6fe34bf36b6e745b3e9ad1a991de057729c7.zip
riscv: Assert that SUM is not set in SSTATUS for exceptions.
Reviewed by: mhorne Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D29764
-rw-r--r--sys/riscv/riscv/trap.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/riscv/riscv/trap.c b/sys/riscv/riscv/trap.c
index 599fd64b56be..0aaaf46eb629 100644
--- a/sys/riscv/riscv/trap.c
+++ b/sys/riscv/riscv/trap.c
@@ -274,6 +274,9 @@ do_trap_supervisor(struct trapframe *frame)
KASSERT((csr_read(sstatus) & (SSTATUS_SPP | SSTATUS_SIE)) ==
SSTATUS_SPP, ("Came from S mode with interrupts enabled"));
+ KASSERT((csr_read(sstatus) & (SSTATUS_SUM)) == 0,
+ ("Came from S mode with SUM enabled"));
+
exception = frame->tf_scause & SCAUSE_CODE;
if ((frame->tf_scause & SCAUSE_INTR) != 0) {
/* Interrupt */
@@ -342,6 +345,9 @@ do_trap_user(struct trapframe *frame)
KASSERT((csr_read(sstatus) & (SSTATUS_SPP | SSTATUS_SIE)) == 0,
("Came from U mode with interrupts enabled"));
+ KASSERT((csr_read(sstatus) & (SSTATUS_SUM)) == 0,
+ ("Came from U mode with SUM enabled"));
+
exception = frame->tf_scause & SCAUSE_CODE;
if ((frame->tf_scause & SCAUSE_INTR) != 0) {
/* Interrupt */