[PATCH 0/5] Set hstatus.GVA for traps going to HS-mode

Vivian Wang dramforever at live.com
Wed Aug 3 20:15:50 PDT 2022


The privileged spec specifies that on a trap to HS-mode, hstatus.GVA
should be set to 1 if stval is written with a guest virtual address, and
to 0 otherwise.

Implement this by adding a field to sbi_trap_info called gva, which
indicates if tval is a guest virtual address, and set it appropriately.
When redirecting traps to HS-mode, set hstatus.GVA to trap->gva.

Patch 4 is a bugfix. The hypervisor CSRs should be set for all traps to
HS-mode, not just those coming from VS/VU-mode. Since it is closely
related to this series and makes the structure for patch 5 clearer, I
have included it in this series.

Changes since RFC:

- Fixed names used in sign-off lines
- Added more detailed commit messages
- Separated out the hypervisor CSR bugfix into a separate patch

Vivian Wang (5):
  include: Add mstatus[h].GVA encodings
  lib: sbi_trap: Save mstatus[h].GVA in trap->gva
  lib: sbi: Set gva when creating sbi_trap_info
  lib: sbi_trap: Set hypervisor CSRs for HS-mode
  lib: sbi_trap: Set hstatus.GVA when going to HS-mode

 include/sbi/riscv_encoding.h  |  4 ++++
 include/sbi/sbi_trap.h        |  6 +++++-
 lib/sbi/sbi_expected_trap.S   | 17 +++++++++++++++--
 lib/sbi/sbi_illegal_insn.c    |  1 +
 lib/sbi/sbi_misaligned_ldst.c |  2 ++
 lib/sbi/sbi_trap.c            | 21 ++++++++++++++++-----
 6 files changed, 43 insertions(+), 8 deletions(-)

-- 
2.37.1




More information about the opensbi mailing list