Fix a mode-to-capability comparison error in
riscv_iommu_validate_device_ctx.  The code was comparing fsc_mode (a
value) against a capability bitmask, making the SV32 support check
ineffective.

This issue was discovered and reported by SpecHunter, an AI-driven
architecture specification analysis tool.

Link: 
https://github.com/yizishun/rv-isa-sec/blob/master/output/riscv-iommu/pr-694/qemu.txt
Signed-off-by: Zishun Yi <[email protected]>
---
 hw/riscv/riscv-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/riscv/riscv-iommu.c b/hw/riscv/riscv-iommu.c
index 7ba32405522b..ba6090e1078c 100644
--- a/hw/riscv/riscv-iommu.c
+++ b/hw/riscv/riscv-iommu.c
@@ -777,7 +777,7 @@ static bool riscv_iommu_validate_device_ctx(RISCVIOMMUState 
*s,
         }
 
         if (ctx->tc & RISCV_IOMMU_DC_TC_SXL) {
-            if (fsc_mode == RISCV_IOMMU_CAP_SV32 &&
+            if (fsc_mode == RISCV_IOMMU_DC_FSC_IOSATP_MODE_SV32 &&
                 !(s->cap & RISCV_IOMMU_CAP_SV32)) {
                 return false;
             }
-- 
2.51.2


Reply via email to