From: Pope B.Lei <popeblei@gmail.com>
To: opensbi@lists.infradead.org
Subject: [PATCH] lib: sbi: Refine the settings for switching to Virtual Supervisor Mode.
Date: Tue, 9 Apr 2024 17:23:04 +0800 [thread overview]
Message-ID: <20240409092304.569-1-popeblei@gmail.com> (raw)
Although Mstatus.MPV is set, before executing mret, access to VS mode
registers should use the actual register addresses, not the pseudonyms
of S registers.
Signed-off-by: Pope B.Lei <popeblei@gmail.com>
---
V1 -> V2: Simplify the if condition
-
lib/sbi/sbi_hart.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index 3d13694..ccdd12f 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -1041,10 +1041,17 @@ sbi_hart_switch_mode(unsigned long arg0, unsigned long arg1,
csr_write(CSR_MEPC, next_addr);
if (next_mode == PRV_S) {
- csr_write(CSR_STVEC, next_addr);
- csr_write(CSR_SSCRATCH, 0);
- csr_write(CSR_SIE, 0);
- csr_write(CSR_SATP, 0);
+ if (next_virt) {
+ csr_write(CSR_VSTVEC, next_addr);
+ csr_write(CSR_VSSCRATCH, 0);
+ csr_write(CSR_VSIE, 0);
+ csr_write(CSR_VSATP, 0);
+ } else {
+ csr_write(CSR_STVEC, next_addr);
+ csr_write(CSR_SSCRATCH, 0);
+ csr_write(CSR_SIE, 0);
+ csr_write(CSR_SATP, 0);
+ }
} else if (next_mode == PRV_U) {
if (misa_extension('N')) {
csr_write(CSR_UTVEC, next_addr);
--
2.35.2.windows.1
next reply other threads:[~2024-04-09 9:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-09 9:23 Pope B.Lei [this message]
2024-04-09 10:34 ` [PATCH] lib: sbi: Refine the settings for switching to Virtual Supervisor Mode Xiang W
2024-04-09 13:34 ` Andrew Jones
-- strict thread matches above, loose matches on Subject: below --
2024-04-09 2:24 Pope B.Lei
2024-04-09 2:27 ` Pope B.Lei
2024-04-09 7:44 ` Andreas Schwab
2024-04-09 2:18 Pope B.Lei
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=20240409092304.569-1-popeblei@gmail.com \
--to=popeblei@gmail.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.