Re: [PATCH v3 2/5] iommu/amd: Fix DTE clearing and rename iommu_ignore_device()
Samiullah Khawaja <[email protected]>
| Newsgroups | dev.linux.lists.iommu,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Aug 24, 2026 at 12:23:44PM +0000, Pranjal Shrivastava wrote:
>The iommu_ignore_device() function currently uses memset() to manually
>clear the primary Device Table Entry (DTE), which risks torn writes as
>the hardware reads DTEs as atomic 256-bit qwords. Furthermore, clearing
>the primary devid in the lookup table before calling setup_aliases()
>causes rlookup_amd_iommu() to fail for aliases. This prevents clearing
>the DTEs for DMA aliases.
>
>Fix this by replacing the manual memset with a dedicated helper that
>invalidates the DTE by clearing the lower 128 bits (having the Valid bit)
>first, followed by the upper 128 bits. The cleared state is then
>explicitly cloned to all aliases before the lookup tables are nullified.
>
>Rename the function to iommu_disable_device() more accurately
>reflects its intent, as we still support IRQ remapping for these devices)
>
>Fixes: 99fc4ac3d297 ("iommu/amd: Introduce per PCI segment alias_table")
>Reported-by: [email protected]
>Closes: https://lore.kernel.org/all/[email protected]/
>Suggested-by: Jason Gunthorpe <[email protected]>
>Signed-off-by: Pranjal Shrivastava <[email protected]>
>---
> drivers/iommu/amd/iommu.c | 53 ++++++++++++++++++++++++++-------------
> 1 file changed, 36 insertions(+), 17 deletions(-)
>
Reviewed-by: Samiullah Khawaja <[email protected]>