linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Mark translation invalid during device detach
@ 2019-01-16  4:15 Suthikulpanit, Suravee
  2019-01-16 13:03 ` joro
  0 siblings, 1 reply; 3+ messages in thread
From: Suthikulpanit, Suravee @ 2019-01-16  4:15 UTC (permalink / raw)
  To: linux-kernel, iommu
  Cc: joro, Suthikulpanit, Suravee, Boris Ostrovsky, Singh, Brijesh

From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>

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.

Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
 drivers/iommu/amd_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 87ba23a75b38..525659b88ade 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu/amd: Mark translation invalid during device detach
  2019-01-16  4:15 [PATCH] iommu/amd: Mark translation invalid during device detach Suthikulpanit, Suravee
@ 2019-01-16 13:03 ` joro
  2019-01-16 14:35   ` Suthikulpanit, Suravee
  0 siblings, 1 reply; 3+ messages in thread
From: joro @ 2019-01-16 13:03 UTC (permalink / raw)
  To: Suthikulpanit, Suravee
  Cc: linux-kernel, iommu, Boris Ostrovsky, Singh, Brijesh

Hi Suravee,

On Wed, Jan 16, 2019 at 04:15:10AM +0000, Suthikulpanit, Suravee wrote:
> From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> 
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iommu/amd: Mark translation invalid during device detach
  2019-01-16 13:03 ` joro
@ 2019-01-16 14:35   ` Suthikulpanit, Suravee
  0 siblings, 0 replies; 3+ messages in thread
From: Suthikulpanit, Suravee @ 2019-01-16 14:35 UTC (permalink / raw)
  To: joro; +Cc: linux-kernel, iommu, Boris Ostrovsky, Singh, Brijesh

Joerg,

On 1/16/19 8:03 PM, joro@8bytes.org wrote:
> Hi Suravee,
> 
> On Wed, Jan 16, 2019 at 04:15:10AM +0000, Suthikulpanit, Suravee wrote:
>> From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>>
>> 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?

We are not currently seeing issue.

> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-16 14:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-16  4:15 [PATCH] iommu/amd: Mark translation invalid during device detach Suthikulpanit, Suravee
2019-01-16 13:03 ` joro
2019-01-16 14:35   ` Suthikulpanit, Suravee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).