lib: sbi_trap: Set hstatus.GVA when going to HS-mode

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 setting hstatus.GVA to trap->gva when
redirecting traps to HS-mode.

Signed-off-by: Vivian Wang <dramforever@live.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Vivian Wang
2022-08-04 22:32:31 +08:00
committed by Anup Patel
parent 5a0ca098f1
commit a69eb6cc65

View File

@@ -128,6 +128,8 @@ int sbi_trap_redirect(struct sbi_trap_regs *regs,
} }
hstatus &= ~HSTATUS_SPV; hstatus &= ~HSTATUS_SPV;
hstatus |= (prev_virt) ? HSTATUS_SPV : 0; hstatus |= (prev_virt) ? HSTATUS_SPV : 0;
hstatus &= ~HSTATUS_GVA;
hstatus |= (trap->gva) ? HSTATUS_GVA : 0;
csr_write(CSR_HSTATUS, hstatus); csr_write(CSR_HSTATUS, hstatus);
csr_write(CSR_HTVAL, trap->tval2); csr_write(CSR_HTVAL, trap->tval2);
csr_write(CSR_HTINST, trap->tinst); csr_write(CSR_HTINST, trap->tinst);