summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnup Patel <[email protected]>2019-12-12 07:00:59 +0530
committerAnup Patel <[email protected]>2019-12-16 14:48:16 +0530
commit6590a7dab9d7182b659a13338043889350d9c6bb (patch)
tree6e63e0021a537d9ecd966c3584b56156b84c3c9f
parentbd732ae612407a05c3394bc19ede98013b0b35d5 (diff)
lib: Delegate guest page faults to HS-mode
As-per RISC-V hypervisor v0.5 spec, we have new guest page faults which need to be delegated to HS-mode. Also, we can have bits in in MIDELEG and MEDELEG hardwired to 1 which means we need to fix the sainty check on these CSRs at the end of delegate_traps() function. Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Alistair Francis <[email protected]>
-rw-r--r--lib/sbi/sbi_hart.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index dee2e216..493e7fcb 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -88,19 +88,25 @@ static int delegate_traps(struct sbi_scratch *scratch, u32 hartid)
(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 hypervisor extension available then we only handle hypervisor
+ * calls (i.e. ecalls from HS-mode) in M-mode.
+ *
+ * The HS-mode will additionally handle supervisor calls (i.e. ecalls
+ * from VS-mode), Guest page faults and Virtual interrupts.
*/
- if (misa_extension('H'))
+ if (misa_extension('H')) {
exceptions |= (1U << CAUSE_SUPERVISOR_ECALL);
+ exceptions |= (1U << CAUSE_FETCH_GUEST_PAGE_FAULT);
+ exceptions |= (1U << CAUSE_LOAD_GUEST_PAGE_FAULT);
+ exceptions |= (1U << CAUSE_STORE_GUEST_PAGE_FAULT);
+ }
csr_write(CSR_MIDELEG, interrupts);
csr_write(CSR_MEDELEG, exceptions);
- if (csr_read(CSR_MIDELEG) != interrupts)
+ if ((csr_read(CSR_MIDELEG) & interrupts) != interrupts)
return SBI_EFAIL;
- if (csr_read(CSR_MEDELEG) != exceptions)
+ if ((csr_read(CSR_MEDELEG) & exceptions) != exceptions)
return SBI_EFAIL;
return 0;