]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iommu/amd: Preserve default DTE fields when updating Host Page Table Root
authorAlejandro Jimenez <alejandro.j.jimenez@oracle.com>
Mon, 6 Jan 2025 19:14:13 +0000 (19:14 +0000)
committerJoerg Roedel <jroedel@suse.de>
Fri, 28 Feb 2025 11:18:00 +0000 (12:18 +0100)
When updating the page table root field on the DTE, avoid overwriting any
bits that are already set. The earlier call to make_clear_dte() writes
default values that all DTEs must have set (currently DTE[V]), and those
must be preserved.

Currently this doesn't cause problems since the page table root update is
the first field that is set after make_clear_dte() is called, and
DTE_FLAG_V is set again later along with the permission bits (IR/IW).
Remove this redundant assignment too.

Fixes: fd5dff9de4be ("iommu/amd: Modify set_dte_entry() to use 256-bit DTE helpers")
Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Reviewed-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Link: https://lore.kernel.org/r/20250106191413.3107140-1-alejandro.j.jimenez@oracle.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd/iommu.c

index b48a72bd7b23df7adb1a2c81a2440d084daff2cd..cd5116d8c3b2831655c1966e203fa90b9de6fae5 100644 (file)
@@ -2043,12 +2043,12 @@ static void set_dte_entry(struct amd_iommu *iommu,
        make_clear_dte(dev_data, dte, &new);
 
        if (domain->iop.mode != PAGE_MODE_NONE)
-               new.data[0] = iommu_virt_to_phys(domain->iop.root);
+               new.data[0] |= iommu_virt_to_phys(domain->iop.root);
 
        new.data[0] |= (domain->iop.mode & DEV_ENTRY_MODE_MASK)
                    << DEV_ENTRY_MODE_SHIFT;
 
-       new.data[0] |= DTE_FLAG_IR | DTE_FLAG_IW | DTE_FLAG_V;
+       new.data[0] |= DTE_FLAG_IR | DTE_FLAG_IW;
 
        /*
         * When SNP is enabled, we can only support TV=1 with non-zero domain ID.