summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2019-04-05 10:47:42 +0300
committerAnup Patel <anup@brainfault.org>2019-09-30 12:44:00 +0300
commit0089897d41b5b2382acba1c2c9f9386edad75228 (patch)
tree98306718a8f3cb975ecd2a9c88ef4b74a38a239a
parent1ed9eb255d865e75be2d2a87d9ef670c502294cc (diff)
downloadopensbi-0089897d41b5b2382acba1c2c9f9386edad75228.tar.xz
lib: Delegate supervisor ecall to HS-mode when H extension available
When hypervisor extension is available, we only handle hypervisor ecalls coming from HS-mode and we let hypervisor handle ecalls coming from VS-mode. Signed-off-by: Anup Patel <anup.patel@wdc.com>
-rw-r--r--lib/sbi/sbi_hart.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index 018fe85..6dac84b 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -87,6 +87,14 @@ static int delegate_traps(struct sbi_scratch *scratch, u32 hartid)
(1U << CAUSE_LOAD_PAGE_FAULT) |
(1U << CAUSE_STORE_PAGE_FAULT);
+ /*
+ * If hypervisor extension available then we only handle
+ * hypervisor calls (i.e. ecalls from HS-mode) and we let
+ * HS-mode handle supervisor calls (i.e. ecalls from VS-mode)
+ */
+ if (misa_extension('H'))
+ exceptions |= (1U << CAUSE_SUPERVISOR_ECALL);
+
csr_write(CSR_MIDELEG, interrupts);
csr_write(CSR_MEDELEG, exceptions);