diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-06-10 18:39:53 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-06-20 10:36:13 +0530 |
commit | 2314101989684585f942b50a827aac4886825ba1 (patch) | |
tree | 37f1248c1c6272d5bb62a3c6e67a64cb215ce2d5 /lib/sbi/sbi_hart.c | |
parent | 9bd5f8f17d31f8989525643a04da87d090fe3033 (diff) |
lib: Don't return any invalid error from SBI ecall
We should only return valid error codes from SBI ecalls as
defined by the RISC-V SBI spec.
To achieve this:
1. We use SBI_Exxxx defines for OpenSBI internal errors with
error values starting from -1000
2. We use SBI_ERR_xxxx defines for errors defined by SBI spec
3. We map some of the SBI_Exxxx defines to SBI_ERR_xxxx defines
which are semantically same
4. We throw a error print and force return error code to
SBI_ERR_FAILED in sbi_ecall_handler() if we see an invalid
error code being returned to S-mode
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_hart.c')
-rw-r--r-- | lib/sbi/sbi_hart.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index 1d1c6d6..fa20bd2 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -200,7 +200,7 @@ int sbi_hart_pmp_check_addr(struct sbi_scratch *scratch, unsigned long addr, continue; if (tempaddr <= addr && addr <= tempaddr + size) if (!(prot & attr)) - return SBI_INVALID_ADDR; + return SBI_EINVALID_ADDR; } return SBI_OK; |