mirror of
https://gitlab.com/qemu-project/qemu.git
synced 2026-08-26 22:23:12 -04:00
hw/riscv/riscv-iommu.c: fault for non-user PTE in G_STAGE
riscv-iommu spec 1.0 says:
"When checking the U bit in a second-stage PTE, the transaction
is treated as not requesting supervisor privilege."
We need to *always* fault in case we're on G_STAGE and PTE_U is cleared
since we can't be on supervisor mode at this point.
Fixes: 0c54acb824 ("hw/riscv: add RISC-V IOMMU base emulation")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3555
Signed-off-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
Message-ID: <20260701121111.537654-4-daniel.barboza@oss.qualcomm.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
b795ea0ba4
commit
9158c900ab
1 changed files with 10 additions and 0 deletions
|
|
@ -495,6 +495,16 @@ static int riscv_iommu_spa_fetch(RISCVIOMMUState *s, RISCVIOMMUContext *ctx,
|
|||
break; /* Access bit not set */
|
||||
} else if ((iotlb->perm & IOMMU_WO) && !ade && !(pte & PTE_D)) {
|
||||
break; /* Dirty bit not set */
|
||||
} else if (pass == G_STAGE && !(pte & PTE_U)) {
|
||||
/*
|
||||
* riscv-iommu spec 1.0: "When checking the U bit in a
|
||||
* second-stage PTE, the transaction is treated as
|
||||
* not requesting supervisor privilege."
|
||||
*
|
||||
* I.e. we need to fault if this is a non-user PTE since
|
||||
* we are always in user mode at this point.
|
||||
*/
|
||||
break;
|
||||
} else {
|
||||
/* Leaf PTE, translation completed. */
|
||||
sc[pass].step = sc[pass].levels;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue