>-----Original Message-----
>From: CLEMENT MATHIEU--DRIF <[email protected]>
>Subject: [PATCH 2/2] intel_iommu: Always write all the flags passed to
>vtd_set_flag_in_pte
>
>This function was initially designed to write a single flag in a pte.
>The current implementation expects it to set several flags.
>
>Fixes: 65c4f0999991 ("intel_iommu: Set accessed and dirty bits during stage-1
>translation")
>Signed-off-by: Clement Mathieu--Drif <[email protected]>

Good catch.

Reviewed-by: Zhenzhong Duan <[email protected]>

BRs,
Zhenzhong

>---
> hw/i386/intel_iommu.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
>diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
>index 56146aafc1..441c96125b 100644
>--- a/hw/i386/intel_iommu.c
>+++ b/hw/i386/intel_iommu.c
>@@ -1991,13 +1991,13 @@ static bool
>vtd_iova_fs_check_canonical(IntelIOMMUState *s, uint64_t iova,
>     }
> }
>
>-static MemTxResult vtd_set_flag_in_pte(dma_addr_t base_addr, uint32_t index,
>-                                       uint64_t pte, uint64_t flag)
>+static MemTxResult vtd_set_flags_in_pte(dma_addr_t base_addr, uint32_t index,
>+                                       uint64_t pte, uint64_t flags)
> {
>-    if (pte & flag) {
>+    if ((pte & flags) == flags) {
>         return MEMTX_OK;
>     }
>-    pte |= flag;
>+    pte |= flags;
>     pte = cpu_to_le64(pte);
>     return dma_memory_write(&address_space_memory,
>                             base_addr + index * sizeof(pte),
>@@ -2070,7 +2070,7 @@ static int vtd_iova_to_fspte(IntelIOMMUState *s,
>VTDContextEntry *ce,
>             flag_ad |= VTD_FS_D;
>         }
>
>-        if (vtd_set_flag_in_pte(addr, offset, fspte, flag_ad) != MEMTX_OK) {
>+        if (vtd_set_flags_in_pte(addr, offset, fspte, flag_ad) != MEMTX_OK) {
>             return -VTD_FR_FS_BIT_UPDATE_FAILED;
>         }
>
>--
>2.53.0

Reply via email to