diff options
author | Anup Patel <anup.patel@wdc.com> | 2019-05-23 11:00:58 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2019-05-24 05:52:47 +0300 |
commit | a6395acd6cb2c35871481d3e4f0beaf449f8c0fd (patch) | |
tree | 4361c3454a814e49cea8f53d0a6cf3885e7f280b /include/sbi | |
parent | bb915780ac76b146f3de47f105a95359e02f158c (diff) | |
download | opensbi-a6395acd6cb2c35871481d3e4f0beaf449f8c0fd.tar.xz |
lib: Handle page/access fault caused by unpriv load/store
The unpriv load/store instruction from M-mode can cause page/access
fault to M-mode if S-mode page table did not have mappings OR it did
not have PMP access permission.
To tackle this, we redirect trap back to S-mode if unpriv load/store
instruction traps in M-mode.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'include/sbi')
-rw-r--r-- | include/sbi/riscv_unpriv.h | 20 | ||||
-rw-r--r-- | include/sbi/sbi_error.h | 1 | ||||
-rw-r--r-- | include/sbi/sbi_ipi.h | 5 |
3 files changed, 20 insertions, 6 deletions
diff --git a/include/sbi/riscv_unpriv.h b/include/sbi/riscv_unpriv.h index ed2dbcc..0fad27d 100644 --- a/include/sbi/riscv_unpriv.h +++ b/include/sbi/riscv_unpriv.h @@ -12,11 +12,23 @@ #include <sbi/sbi_types.h> -#define DECLARE_UNPRIVILEGED_LOAD_FUNCTION(type) \ - type load_##type(const type *addr); +struct sbi_scratch; -#define DECLARE_UNPRIVILEGED_STORE_FUNCTION(type) \ - void store_##type(type *addr, type val); +struct unpriv_trap { + unsigned long ilen; + unsigned long cause; + unsigned long tval; +}; + +#define DECLARE_UNPRIVILEGED_LOAD_FUNCTION(type) \ + type load_##type(const type *addr, \ + struct sbi_scratch *scratch, \ + struct unpriv_trap *trap); + +#define DECLARE_UNPRIVILEGED_STORE_FUNCTION(type) \ + void store_##type(type *addr, type val, \ + struct sbi_scratch *scratch, \ + struct unpriv_trap *trap); DECLARE_UNPRIVILEGED_LOAD_FUNCTION(u8) DECLARE_UNPRIVILEGED_LOAD_FUNCTION(u16) diff --git a/include/sbi/sbi_error.h b/include/sbi/sbi_error.h index db3d6dd..3ad78db 100644 --- a/include/sbi/sbi_error.h +++ b/include/sbi/sbi_error.h @@ -25,6 +25,7 @@ #define SBI_EILL -10 #define SBI_ENOSPC -11 #define SBI_ENOMEM -12 +#define SBI_ETRAP -13 /* clang-format on */ diff --git a/include/sbi/sbi_ipi.h b/include/sbi/sbi_ipi.h index b8afb5b..53468b2 100644 --- a/include/sbi/sbi_ipi.h +++ b/include/sbi/sbi_ipi.h @@ -10,6 +10,7 @@ #ifndef __SBI_IPI_H__ #define __SBI_IPI_H__ +#include <sbi/riscv_unpriv.h> #include <sbi/sbi_types.h> /* clang-format off */ @@ -28,8 +29,8 @@ struct sbi_ipi_data { unsigned long ipi_type; }; -int sbi_ipi_send_many(struct sbi_scratch *scratch, ulong *pmask, u32 event, - void *data); +int sbi_ipi_send_many(struct sbi_scratch *scratch, struct unpriv_trap *uptrap, + ulong *pmask, u32 event, void *data); void sbi_ipi_clear_smode(struct sbi_scratch *scratch); |