@samitouri / QOSamiQemu / commits / 79616dd6e4

hw/riscv/riscv-iommu.c: update ioval2 when faulting in spa_fetch()

riscv_iommu_translate(), the only caller of riscv_iommu_spa_fetch(), will use riscv_iommu_report_fault() for all faults it detects. And it will use iotlb->translated_addr as 'iotval2' every time. At this moment we're updating iotlb->translated_addr only after a translation step is completed, meaning any fault that occur before that will have a zeroed iotlb->translated_addr, and as a result iotval2 will also be zero later on. Keep iotlb->translated_addr updated with the latest translated addr we have. Fixes: 0c54acb8243d ("hw/riscv: add RISC-V IOMMU base emulation") Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3559 Signed-off-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com> Acked-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <20260702171202.1322493-1-daniel.barboza@oss.qualcomm.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

Daniel Henrique Barboza committed Jul 2, 2026 at 14:12 UTC 79616dd6e499c4eed0af534872f3ff0e3c133c04
1 file changed +8
hw/riscv/riscv-iommu.c
+8
@@ -574,6 +574,14 @@ static int riscv_iommu_spa_fetch(RISCVIOMMUState *s, RISCVIOMMUContext *ctx,
574 }
575 } while (1);
576
577 + /*
578 + * riscv_iommu_translate() will receive a fault and then call
579 + * riscv_iommu_report_fault() using iotlb->translated_addr
580 + * as iotval2. Update translated_addr it with the latest
581 + * translated addr we have.
582 + */
583 + iotlb->translated_addr = addr;
584 +
585 return (iotlb->perm & IOMMU_WO) ?
586 (pass ? RISCV_IOMMU_FQ_CAUSE_WR_FAULT_VS :
587 RISCV_IOMMU_FQ_CAUSE_WR_FAULT_S) :