From: Deepak Gupta <debug@rivosinc.com>
To: opensbi@lists.infradead.org
Cc: Deepak Gupta <debug@rivosinc.com>
Subject: [PATCH] lib: sbi: expected trap must always clear MPRV
Date: Mon, 24 Nov 2025 14:03:39 -0800 [thread overview]
Message-ID: <20251124220339.3695940-1-debug@rivosinc.com> (raw)
Expected trap must always clear MPRV. Currently it doesn't. There is a
security issue here where if firmware was doing ld/st with MPRV=1 and
since there would be a expected trap, opensbi will continue to run as
MPRV=1. Security impact is DoS where opensbi will just keep trapping.
Signed-off-by: Deepak Gupta <debug@rivosinc.com>
---
lib/sbi/sbi_expected_trap.S | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/sbi/sbi_expected_trap.S b/lib/sbi/sbi_expected_trap.S
index 99dede5f..8fbd2cb2 100644
--- a/lib/sbi/sbi_expected_trap.S
+++ b/lib/sbi/sbi_expected_trap.S
@@ -23,6 +23,8 @@
.global __sbi_expected_trap
__sbi_expected_trap:
/* Without H-extension so, MTVAL2 and MTINST CSRs and GVA not available */
+ lui a4, 0x20 /* MSTATUS_MPRV */
+ csrc CSR_MSTATUS, a4
csrr a4, CSR_MCAUSE
REG_S a4, SBI_TRAP_INFO_OFFSET(cause)(a3)
csrr a4, CSR_MTVAL
@@ -39,6 +41,8 @@ __sbi_expected_trap:
.global __sbi_expected_trap_hext
__sbi_expected_trap_hext:
/* With H-extension so, MTVAL2 and MTINST CSRs and GVA available */
+ lui a4, 0x20 /* MSTATUS_MPRV */
+ csrc CSR_MSTATUS, a4
csrr a4, CSR_MCAUSE
REG_S a4, SBI_TRAP_INFO_OFFSET(cause)(a3)
csrr a4, CSR_MTVAL
--
2.43.0
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
next reply other threads:[~2025-11-24 22:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-24 22:03 Deepak Gupta [this message]
2025-11-25 11:12 ` [PATCH] lib: sbi: expected trap must always clear MPRV Radim Krčmář
2025-11-25 18:03 ` Deepak Gupta
2025-11-25 18:51 ` Radim Krčmář
2025-11-25 19:17 ` Deepak Gupta
2025-11-25 19:48 ` Radim Krčmář
2025-11-25 20:04 ` Deepak Gupta
2025-11-26 8:21 ` Radim Krčmář
2025-12-26 11:06 ` Anup Patel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251124220339.3695940-1-debug@rivosinc.com \
--to=debug@rivosinc.com \
--cc=opensbi@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.