lib: sbi: Fix tval and tinst for sbi_get_insn()
authordramforever <dramforever@live.com>
Thu, 9 Jun 2022 07:07:31 +0000 (15:07 +0800)
committerAnup Patel <anup@brainfault.org>
Tue, 21 Jun 2022 03:01:56 +0000 (08:31 +0530)
commita07402ac9cea19b3af70ed6469bb6d937132a18f
tree22fcbfc17f00c75d5b507ef567dd4093f19db794
parent187127fb89b99790793d4b2663286371b59021ae
lib: sbi: Fix tval and tinst for sbi_get_insn()

We should not change trap->tval to mepc because mtval already points to
the faulting portion of the emulated instruction fetch, which is also
what stval is expected to be.

In addition, htinst is only allowed to be zero for instruction access
faults or page faults, and is only allowed to be zero or a
psuedoinstruction for instruction guest-page faults. Fix trap->tinst for
these cases.

Signed-off-by: dramforever <dramforever@live.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/sbi/sbi_unpriv.c