lib: sbi: factorize previous virtualization mode read from regs

The same pattern is used at multiple places to verify in which mode
the exception was actually taken. Factorize it.

Signed-off-by: Clément Léger <cleger@rivosinc.com>
Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
This commit is contained in:
Clément Léger authored and Anup Patel committed 2024-10-25 23:52:51 +05:30
1 parent b919daf495
commit daa282573f
3 files changed
+12 -15

No files matched your search

+1 -5
View File
@@ -104,11 +104,7 @@ int sbi_trap_redirect(struct sbi_trap_regs *regs,
{
ulong hstatus, vsstatus, prev_mode;
bool elp = false;
#if __riscv_xlen == 32
bool prev_virt = (regs->mstatusH & MSTATUSH_MPV) ? true : false;
#else
bool prev_virt = (regs->mstatus & MSTATUS_MPV) ? true : false;
#endif
bool prev_virt = sbi_regs_from_virt(regs);
/* By default, we redirect to HS-mode */
bool next_virt = false;