Skip to contentSkip to conversation

intel_iommu: Fixes for FSTS

PATCH RESEND New Clément MATHIEU--DRIF 1 participant 3 messages Sep 3

lore
Share & tools
lore
#0 lore raw

cover intel_iommu: Fixes for FSTS

This series seems to have been lost since we approved it. Resend for integration during the next round.

Clement Mathieu--Drif (2):
intel_iommu: Only set dirty bit when PTE exposes write permission
intel_iommu: Always write all the flags passed to vtd_set_flag_in_pte

 hw/i386/intel_iommu.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH RESEND 1/2 intel_iommu: Only set dirty bit when PTE exposes write permission

Setting the dirty bit without the write bit in vIOMMU creates a spoofed shadow stack PTE that misleads the guest OS. This results in infinite PRI requests from the device, as no actual write permission is ever granted - the guest OS treats the PTE as a legitimate shadow stack entry and considers the permissions already correct.

Fixes 65c4f0999991 ("intel_iommu: Set accessed and dirty bits during stage-1 translation")
---
 hw/i386/intel_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/intel_iommu.c +1 -1
index 921a258b52..114b1d7cac 100644
@@ -2039,7 +2039,7 @@ static int vtd_iova_to_fspte(IntelIOMMUState *s, VTDContextEntry *ce,
             return -VTD_FR_FS_PAGING_ENTRY_RSVD;
         }
 
-        if (vtd_is_last_pte(fspte, *fspte_level) && is_write) {
+        if (vtd_is_last_pte(fspte, *fspte_level) && *writes && is_write) {
             flag_ad |= VTD_FS_D;
         }
 
Signature · 1 line
2.54.0
#2 lore raw

PATCH RESEND 2/2 intel_iommu: Always write all the flags passed to vtd_set_flag_in_pte

In reply to Clément MATHIEU--DRIF

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")
---
 hw/i386/intel_iommu.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
hw/i386/intel_iommu.c +5 -5
index 114b1d7cac..350d2b7753 100644
@@ -1964,13 +1964,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),
@@ -2043,7 +2043,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;
         }
 
Signature · 1 line
2.54.0