[PATCH] hw/riscv: Synchronize IOMMU FCTL state after MMIO writes

Tan Chi posted 1 patch 2 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261107131510.102469-1-tanchi25@mails.ucas.ac.cn
Maintainers: Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Chao Liu <chao.liu@processmission.com>
hw/riscv/riscv-iommu.c | 9 +++++++++
1 file changed, 9 insertions(+)
[PATCH] hw/riscv: Synchronize IOMMU FCTL state after MMIO writes
Posted by Tan Chi 2 weeks, 1 day ago
MMIO writes to FCTL only update the register storage, leaving
s->fctl unchanged. As a result, setting FCTL.GXL does not enable
Sv32x4 translation in the page-table walkers.

Synchronize s->fctl with the guest-visible FCTL register after
MMIO writes, following the existing register processing mechanism.

Signed-off-by: Tan Chi <tanchi25@mails.ucas.ac.cn>
---
 hw/riscv/riscv-iommu.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/hw/riscv/riscv-iommu.c b/hw/riscv/riscv-iommu.c
index 3f999bf292..6ef2e3ae6f 100644
--- a/hw/riscv/riscv-iommu.c
+++ b/hw/riscv/riscv-iommu.c
@@ -2398,6 +2398,11 @@ static void riscv_iommu_process_dbg(RISCVIOMMUState *s)
 
 typedef void riscv_iommu_process_fn(RISCVIOMMUState *s);
 
+static void riscv_iommu_process_fctl(RISCVIOMMUState *s)
+{
+    s->fctl = riscv_iommu_reg_get32(s, RISCV_IOMMU_REG_FCTL);
+}
+
 static void riscv_iommu_update_icvec(RISCVIOMMUState *s, uint64_t data)
 {
     uint64_t icvec = 0;
@@ -2538,6 +2543,10 @@ static MemTxResult riscv_iommu_mmio_write(void *opaque, hwaddr addr,
 
     /* Track actionable MMIO write. */
     switch (regb) {
+    case RISCV_IOMMU_REG_FCTL:
+        process_fn = riscv_iommu_process_fctl;
+        break;
+
     case RISCV_IOMMU_REG_DDTP:
     case RISCV_IOMMU_REG_DDTP + 4:
         process_fn = riscv_iommu_process_ddtp;
-- 
2.53.0
Re: [PATCH] hw/riscv: Synchronize IOMMU FCTL state after MMIO writes
Posted by Daniel Henrique Barboza 1 week, 5 days ago

On 11/7/2026 10:15 AM, Tan Chi wrote:
> MMIO writes to FCTL only update the register storage, leaving
> s->fctl unchanged. As a result, setting FCTL.GXL does not enable
> Sv32x4 translation in the page-table walkers.
> 
> Synchronize s->fctl with the guest-visible FCTL register after
> MMIO writes, following the existing register processing mechanism.
> 
> Signed-off-by: Tan Chi <tanchi25@mails.ucas.ac.cn>
> ---

Reviewed-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>

>   hw/riscv/riscv-iommu.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/hw/riscv/riscv-iommu.c b/hw/riscv/riscv-iommu.c
> index 3f999bf292..6ef2e3ae6f 100644
> --- a/hw/riscv/riscv-iommu.c
> +++ b/hw/riscv/riscv-iommu.c
> @@ -2398,6 +2398,11 @@ static void riscv_iommu_process_dbg(RISCVIOMMUState *s)
>   
>   typedef void riscv_iommu_process_fn(RISCVIOMMUState *s);
>   
> +static void riscv_iommu_process_fctl(RISCVIOMMUState *s)
> +{
> +    s->fctl = riscv_iommu_reg_get32(s, RISCV_IOMMU_REG_FCTL);
> +}
> +
>   static void riscv_iommu_update_icvec(RISCVIOMMUState *s, uint64_t data)
>   {
>       uint64_t icvec = 0;
> @@ -2538,6 +2543,10 @@ static MemTxResult riscv_iommu_mmio_write(void *opaque, hwaddr addr,
>   
>       /* Track actionable MMIO write. */
>       switch (regb) {
> +    case RISCV_IOMMU_REG_FCTL:
> +        process_fn = riscv_iommu_process_fctl;
> +        break;
> +
>       case RISCV_IOMMU_REG_DDTP:
>       case RISCV_IOMMU_REG_DDTP + 4:
>           process_fn = riscv_iommu_process_ddtp;