1. May 07, 2024
  2. Apr 10, 2024
  3. Apr 08, 2024
  4. Apr 07, 2024
  5. Apr 05, 2024
  6. Mar 20, 2024
  7. Mar 19, 2024
  8. Mar 11, 2024
    • Bo Gan's avatar
      lib: sbi: call platform load/store emulators · 81e3ba77
      Bo Gan authored
      
      
      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: default avatarBo Gan <ganboing@gmail.com>
      Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
      81e3ba77
    • Bo Gan's avatar
      include: sbi: add emulate_load/store handler to platform ops · ddf3b649
      Bo Gan authored
      
      
      This patch allows the platform to define load/store emulators. This
      enables a platform to trap-and-emulate special devices or filter
      access to existing physical devices.
      
      Signed-off-by: default avatarBo Gan <ganboing@gmail.com>
      Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
      ddf3b649
    • Bo Gan's avatar
      lib: sbi: abstract out insn decoding to unify mem fault handlers · 4c112650
      Bo Gan authored
      
      
      This patch abstracts out the instruction decoding part of misaligned ld/st
      fault handlers, so it can be reused by ld/st access fault handlers.
      Also Added lb/lbu/sb decoding. (previously unreachable by misaligned fault)
      
      sbi_trap_emulate_load/store is now the common handler which takes a `emu`
      parameter that is responsible for emulating the misaligned or access fault.
      The `emu` callback is expected to fixup the fault, and based on the return
      code of `emu`, sbi_trap_emulate_load/store will:
      
        r/wlen => the fixup is successful and regs/mepc needs to be updated.
        0      => the fixup is successful, but regs/mepc should be left untouched
                  (this is usually used if `emu` does `sbi_trap_redirect`)
        -err   => failed, sbi_trap_error will be called
      
      For now, load/store access faults are blindly redirected. It will be
      enhanced in the following patches.
      
      Signed-off-by: default avatarBo Gan <ganboing@gmail.com>
      Reviewed-by: default avatarAnup Patel <anup@brainfault.org>
      4c112650