lib: sbi: call platform load/store emulators
authorBo Gan <ganboing@gmail.com>
Wed, 6 Mar 2024 02:35:40 +0000 (18:35 -0800)
committerAnup Patel <anup@brainfault.org>
Mon, 11 Mar 2024 05:26:02 +0000 (10:56 +0530)
commit81e3ba77a6dae8763972fffb6e4a833adccbeb1b
tree9609952f22d5fa24ebeb95c5836d9ea881a5e72a
parentddf3b649f1edd9eb5ad171c7faadf34acfb942f0
lib: sbi: call platform load/store emulators

sbi_load/store_access_handler now tries to call platform emulators
if defined. Otherwise, redirects the fault. If the platform code
returns failure, this means the H/S/U has accessed the emulated
devices in an unexpected manner, which is very likely caused by
buggy code in H/S/U. We redirect the fault, so lower privileged
level can get notified, and act accordingly. (E.g., oops in Linux)

We let the handler truly fail if the trap was originated from M mode.
In this case, something must be very wrong and we should just fail.

Signed-off-by: Bo Gan <ganboing@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
include/sbi/sbi_platform.h
lib/sbi/sbi_trap_ldst.c