summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDamien Le Moal <damien.lemoal@wdc.com>2018-12-21 13:19:54 +0300
committerAnup Patel <anup@brainfault.org>2018-12-21 14:02:30 +0300
commit27332e63faaf6d3220a9d56bcfb280921114f012 (patch)
tree10ab1d82fc03f31c851e2b38dab15929bd6be8b8 /lib
parentdb6c1fe78bebc103670becba39e1c34bcdc48185 (diff)
downloadopensbi-27332e63faaf6d3220a9d56bcfb280921114f012.tar.xz
Introduce HAS_MFAULTS_DELEGATION feature
Conditionnally delegate page fault exceptions from M mode to S mode based on the platform features. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/sbi_hart.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/sbi_hart.c b/lib/sbi_hart.c
index 01362dd..be114d6 100644
--- a/lib/sbi_hart.c
+++ b/lib/sbi_hart.c
@@ -83,8 +83,9 @@ static int fp_init(u32 hartid)
return 0;
}
-static int delegate_traps(u32 hartid)
+static int delegate_traps(struct sbi_scratch *scratch, u32 hartid)
{
+ struct sbi_platform *plat = sbi_platform_ptr(scratch);
unsigned long interrupts, exceptions;
if (!misa_extension('S')) {
@@ -95,11 +96,12 @@ static int delegate_traps(u32 hartid)
/* Send M-mode interrupts and most exceptions to S-mode */
interrupts = MIP_SSIP | MIP_STIP | MIP_SEIP;
exceptions = (1U << CAUSE_MISALIGNED_FETCH) |
- (1U << CAUSE_FETCH_PAGE_FAULT) |
(1U << CAUSE_BREAKPOINT) |
- (1U << CAUSE_LOAD_PAGE_FAULT) |
- (1U << CAUSE_STORE_PAGE_FAULT) |
(1U << CAUSE_USER_ECALL);
+ if (sbi_platform_has_mfaults_delegation(plat))
+ exceptions |= (1U << CAUSE_FETCH_PAGE_FAULT) |
+ (1U << CAUSE_LOAD_PAGE_FAULT) |
+ (1U << CAUSE_STORE_PAGE_FAULT);
}
csr_write(mideleg, interrupts);
@@ -200,7 +202,7 @@ int sbi_hart_init(struct sbi_scratch *scratch, u32 hartid)
if (rc)
return rc;
- rc = delegate_traps(hartid);
+ rc = delegate_traps(scratch, hartid);
if (rc)
return rc;