[PATCH 0/3] Fixes for tval/tinst when using sbi_trap_redirect()

dramforever dramforever at live.com
Thu Jun 9 00:06:29 PDT 2022


I went through usages of sbi_trap_redirect() and saw some cases where
after redirecting, stval/htinst could be set to incorrect values. I
tried fixing what I noticed.

Note that these patches are *UNTESTED*.

- For the htinst fixes, no current implementation (QEMU or Spike) of the
  hypervisor extension writes mtinst/htinst to non-zero values, so the
  code paths are unused.
- The sbi_get_insn() fix requires a rare occasion where the instruction
  is fetched normally then unmapped from memory before OpenSBI can load
  it again, and I have not been reproduce.

Please bear in mind when reviewing.

dramforever (3):
  include: sbi: Add mtinst/htinst psuedoinstructions
  lib: sbi: Fixup tinst for exceptions in sbi_misaligned_*()
  lib: sbi: Fix tval and tinst for sbi_get_insn()

 include/sbi/riscv_encoding.h  | 20 ++++++++++++++++++++
 lib/sbi/sbi_misaligned_ldst.c | 16 ++++++++++++++++
 lib/sbi/sbi_unpriv.c          |  8 +++++---
 3 files changed, 41 insertions(+), 3 deletions(-)

-- 
2.36.0




More information about the opensbi mailing list