diff options
author | Georg Kotheimer <georg.kotheimer@tu-dresden.de> | 2020-08-15 00:01:29 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-08-17 15:47:42 +0300 |
commit | 9d56961b2314f31f9d66e53204c02e01fada7c32 (patch) | |
tree | a1a44ae477e36fd0a59e043adcc7eb775325abeb /lib | |
parent | 4b18a2acc2f4568746efc82ec25705f33c4ae31e (diff) | |
download | opensbi-9d56961b2314f31f9d66e53204c02e01fada7c32.tar.xz |
lib: sbi_trap: Fix hstatus.SPVP update in sbi_trap_redirect()
When redirecting from VS/VU-mode to HS-mode, hstatus.SPVP was set
to the value of mstatus.SPP, as according to the specification both
flags should be set to the same value.
However, the assignment of SPVP takes place before SPP itself is
updated, which results in SPVP having an outdated value.
Signed-off-by: Georg Kotheimer <georg.kotheimer@tu-dresden.de>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sbi/sbi_trap.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index 930119d..c2bd061 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -123,7 +123,7 @@ int sbi_trap_redirect(struct sbi_trap_regs *regs, /* Update HSTATUS SPVP and SPV bits */ hstatus = csr_read(CSR_HSTATUS); hstatus &= ~HSTATUS_SPVP; - hstatus |= (regs->mstatus & MSTATUS_SPP) ? HSTATUS_SPVP : 0; + hstatus |= (prev_mode == PRV_S) ? HSTATUS_SPVP : 0; hstatus &= ~HSTATUS_SPV; hstatus |= (prev_virt) ? HSTATUS_SPV : 0; csr_write(CSR_HSTATUS, hstatus); |