@@ -2462,6 +2462,29 @@ void amd_iommu_domain_free(struct iommu_domain *dom)
2462
2462
protection_domain_free (domain );
2463
2463
}
2464
2464
2465
+ static int blocked_domain_attach_device (struct iommu_domain * domain ,
2466
+ struct device * dev )
2467
+ {
2468
+ struct iommu_dev_data * dev_data = dev_iommu_priv_get (dev );
2469
+
2470
+ if (dev_data -> domain )
2471
+ detach_device (dev );
2472
+
2473
+ /* Clear DTE and flush the entry */
2474
+ spin_lock (& dev_data -> lock );
2475
+ amd_iommu_dev_update_dte (dev_data , false);
2476
+ spin_unlock (& dev_data -> lock );
2477
+
2478
+ return 0 ;
2479
+ }
2480
+
2481
+ static struct iommu_domain blocked_domain = {
2482
+ .type = IOMMU_DOMAIN_BLOCKED ,
2483
+ .ops = & (const struct iommu_domain_ops ) {
2484
+ .attach_dev = blocked_domain_attach_device ,
2485
+ }
2486
+ };
2487
+
2465
2488
static int amd_iommu_attach_device (struct iommu_domain * dom ,
2466
2489
struct device * dev )
2467
2490
{
@@ -2859,6 +2882,7 @@ static int amd_iommu_dev_disable_feature(struct device *dev,
2859
2882
2860
2883
const struct iommu_ops amd_iommu_ops = {
2861
2884
.capable = amd_iommu_capable ,
2885
+ .blocked_domain = & blocked_domain ,
2862
2886
.domain_alloc = amd_iommu_domain_alloc ,
2863
2887
.domain_alloc_user = amd_iommu_domain_alloc_user ,
2864
2888
.domain_alloc_sva = amd_iommu_domain_alloc_sva ,
0 commit comments