[PATCH v2 5/5] lib: sbi_trap: Set hstatus.GVA when going to HS-mode
Anup Patel
anup at brainfault.org
Sun Aug 21 20:19:48 PDT 2022
On Thu, Aug 4, 2022 at 9:13 PM Vivian Wang <dramforever at live.com> wrote:
>
> 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 at live.com>
> Reviewed-by: Andrew Jones <ajones at ventanamicro.com>
Looks good to me.
Reviewed-by: Anup Patel <anup at brainfault.org>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
> ---
> lib/sbi/sbi_trap.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c
> index 1cf2e6f..925840f 100644
> --- a/lib/sbi/sbi_trap.c
> +++ b/lib/sbi/sbi_trap.c
> @@ -128,6 +128,8 @@ int sbi_trap_redirect(struct sbi_trap_regs *regs,
> }
> hstatus &= ~HSTATUS_SPV;
> hstatus |= (prev_virt) ? HSTATUS_SPV : 0;
> + hstatus &= ~HSTATUS_GVA;
> + hstatus |= (trap->gva) ? HSTATUS_GVA : 0;
> csr_write(CSR_HSTATUS, hstatus);
> csr_write(CSR_HTVAL, trap->tval2);
> csr_write(CSR_HTINST, trap->tinst);
> --
> 2.37.1
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
More information about the opensbi
mailing list