@@ -534,6 +534,10 @@ void intel_pasid_tear_down_entry(struct intel_iommu *iommu, struct device *dev,
534
534
devtlb_invalidation_with_pasid (iommu , dev , pasid );
535
535
}
536
536
537
+ /*
538
+ * This function flushes cache for a newly setup pasid table entry.
539
+ * Caller of it should not modify the in-use pasid table entries.
540
+ */
537
541
static void pasid_flush_caches (struct intel_iommu * iommu ,
538
542
struct pasid_entry * pte ,
539
543
u32 pasid , u16 did )
@@ -585,6 +589,10 @@ int intel_pasid_setup_first_level(struct intel_iommu *iommu,
585
589
if (WARN_ON (!pte ))
586
590
return - EINVAL ;
587
591
592
+ /* Caller must ensure PASID entry is not in use. */
593
+ if (pasid_pte_is_present (pte ))
594
+ return - EBUSY ;
595
+
588
596
pasid_clear_entry (pte );
589
597
590
598
/* Setup the first level page table pointer: */
@@ -684,6 +692,10 @@ int intel_pasid_setup_second_level(struct intel_iommu *iommu,
684
692
return - ENODEV ;
685
693
}
686
694
695
+ /* Caller must ensure PASID entry is not in use. */
696
+ if (pasid_pte_is_present (pte ))
697
+ return - EBUSY ;
698
+
687
699
pasid_clear_entry (pte );
688
700
pasid_set_domain_id (pte , did );
689
701
pasid_set_slptr (pte , pgd_val );
@@ -723,6 +735,10 @@ int intel_pasid_setup_pass_through(struct intel_iommu *iommu,
723
735
return - ENODEV ;
724
736
}
725
737
738
+ /* Caller must ensure PASID entry is not in use. */
739
+ if (pasid_pte_is_present (pte ))
740
+ return - EBUSY ;
741
+
726
742
pasid_clear_entry (pte );
727
743
pasid_set_domain_id (pte , did );
728
744
pasid_set_address_width (pte , iommu -> agaw );
0 commit comments