Skip to contentSkip to conversation

iommu/amd: Mark translation invalid during device detach

PATCH In review Suthikulpanit, Suravee 2 participants 3 messages Jan 16, 2019 IOMMU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/amd: Mark translation invalid during device detach

From: Suravee Suthikulpanit <[email protected]>

When a device switches domain, IOMMU driver detach device from the old domain, and attach device to the new domain. During this period the host table root pointer is not set, which means DMA translation should be marked as invalid (clear TV bit).

So, clear the TV bit when detach the device. The TV bit will be set again when attaching device to the new domain.

---
 drivers/iommu/amd_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/amd_iommu.c +1 -1
index 87ba23a75b38..525659b88ade 100644
@@ -1956,7 +1956,7 @@ static void set_dte_entry(u16 devid, struct protection_domain *domain,
 static void clear_dte_entry(u16 devid)
 {
 	/* remove entry from the device table seen by the hardware */
-	amd_iommu_dev_table[devid].data[0]  = DTE_FLAG_V | DTE_FLAG_TV;
+	amd_iommu_dev_table[devid].data[0]  = DTE_FLAG_V;
 	amd_iommu_dev_table[devid].data[1] &= DTE_FLAG_MASK;
 
 	amd_iommu_apply_erratum_63(devid);
Signature · 1 line
2.17.1
#1 lore raw

Hi Suravee,

Quoted 9 lines · Suravee

From: Suravee Suthikulpanit <[email protected]>

When a device switches domain, IOMMU driver detach device from the old domain, and attach device to the new domain. During this period the host table root pointer is not set, which means DMA translation should be marked as invalid (clear TV bit).

So, clear the TV bit when detach the device. The TV bit will be set again when attaching device to the new domain.

Is there a specific problem with setting the TV bit?

Note that the update will clear all other fields in the first 128 bits of the DTE, which means that IR, IW and Mode are all set to 0. This effectivly blocks all DMA requests from the device, which is by design.

Regards,

Joerg

#2 lore raw

Joerg,

Quoted 10 lines · On 1/16/19 8:03 PM, [email protected] wrote:

Hi Suravee,

Quoted 7 lines · Suravee

From: Suravee Suthikulpanit <[email protected]>

When a device switches domain, IOMMU driver detach device from the old domain, and attach device to the new domain. During this period the host table root pointer is not set, which means DMA translation should be marked as invalid (clear TV bit).

Quoted 4 lines
Quoted 2 lines

So, clear the TV bit when detach the device. The TV bit will be set again when attaching device to the new domain.

Is there a specific problem with setting the TV bit?

We are not currently seeing issue.

Quoted 3 lines

Note that the update will clear all other fields in the first 128 bits of the DTE, which means that IR, IW and Mode are all set to 0. This effectivly blocks all DMA requests from the device, which is by design.

Ahh.. This makes sense now. I missed the IR/IW/Mode=0 part. It was not clear to us earlier. Thanks for clarification.

Regards,
Suravee