From 37a0d83b6d5a06fd740fcdfb5e4074c33e472a2d Mon Sep 17 00:00:00 2001 From: Vivian Wang Date: Fri, 2 Sep 2022 23:48:34 +0800 Subject: lib: sbi_trap: Add helper to get GVA in sbi_trap_regs The GVA bit is in mstatus on RV64, and in mstatush in RV32. Refactor code handling this in sbi_trap_handler into a helper function to extract GVA from sbi_trap_regs, so that future code accessing GVA can be XLEN-agnostic. Signed-off-by: Vivian Wang Reviewed-by: Andrew Jones Reviewed-by: Anup Patel --- lib/sbi/sbi_trap.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index 4c1339e6..c875c907 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -316,19 +316,7 @@ struct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs) trap.tval = mtval; trap.tval2 = mtval2; trap.tinst = mtinst; - - /* - * If the hypervisor extension is not implemented, - * mstatus[h].GVA is a WPRI field, which is guaranteed to read - * as zero. In addition, in this case we don't read mstatush and - * instead pretend it is zero, which handles privileged spec - * version < 1.12. - */ -#if __riscv_xlen == 32 - trap.gva = (regs->mstatusH & MSTATUSH_GVA) ? 1 : 0; -#else - trap.gva = (regs->mstatus & MSTATUS_GVA) ? 1 : 0; -#endif + trap.gva = sbi_regs_gva(regs); rc = sbi_trap_redirect(regs, &trap); break; -- cgit v1.3.1