]> git.ipfire.org Git - thirdparty/qemu.git/commit
target/riscv: do not set mtval2 for non guest-page faults
authorAlexei Filippov <alexei.filippov@syntacore.com>
Fri, 3 May 2024 10:30:52 +0000 (13:30 +0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Wed, 5 Jun 2024 10:05:48 +0000 (13:05 +0300)
commit37d6c6e4951ebff8da6960b0b14acdfe9451827f
tree92d0170ee5e703bcde3459971402e0fbdd330dbd
parent6da92af4f9172296ab9df9160034bacd29b1284d
target/riscv: do not set mtval2 for non guest-page faults

Previous patch fixed the PMP priority in raise_mmu_exception() but we're still
setting mtval2 incorrectly. In riscv_cpu_tlb_fill(), after pmp check in 2 stage
translation part, mtval2 will be set in case of successes 2 stage translation but
failed pmp check.

In this case we gonna set mtval2 via env->guest_phys_fault_addr in context of
riscv_cpu_tlb_fill(), as this was a guest-page-fault, but it didn't and mtval2
should be zero, according to RISCV privileged spec sect. 9.4.4: When a guest
page-fault is taken into M-mode, mtval2 is written with either zero or guest
physical address that faulted, shifted by 2 bits. *For other traps, mtval2
is set to zero...*

Signed-off-by: Alexei Filippov <alexei.filippov@syntacore.com>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20240503103052.6819-1-alexei.filippov@syntacore.com>
Cc: qemu-stable <qemu-stable@nongnu.org>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
(cherry picked from commit 6c9a344247132ac6c3d0eb9670db45149a29c88f)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
target/riscv/cpu_helper.c