lib: Don't return any invalid error from SBI ecall
authorAnup Patel <anup.patel@wdc.com>
Wed, 10 Jun 2020 13:09:53 +0000 (18:39 +0530)
committerAnup Patel <anup@brainfault.org>
Sat, 20 Jun 2020 05:06:13 +0000 (10:36 +0530)
commit2314101989684585f942b50a827aac4886825ba1
tree37f1248c1c6272d5bb62a3c6e67a64cb215ce2d5
parent9bd5f8f17d31f8989525643a04da87d090fe3033
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>
include/sbi/sbi_ecall_interface.h
include/sbi/sbi_error.h
lib/sbi/sbi_ecall.c
lib/sbi/sbi_hart.c
lib/sbi/sbi_hsm.c