On Fri, Mar 10, 2023 at 11:48:58AM +0000, Tian, Kevin wrote:
From: Jason Gunthorpe jgg@nvidia.com Sent: Wednesday, March 8, 2023 8:36 AM
@@ -359,6 +360,76 @@ iommufd_device_do_attach(struct iommufd_device *idev, return NULL; }
+static struct iommufd_hw_pagetable * +iommufd_device_do_replace(struct iommufd_device *idev,
struct iommufd_hw_pagetable *hwpt)
+{
- struct iommufd_group *igroup = idev->igroup;
- struct iommufd_hw_pagetable *old_hwpt;
- unsigned int num_devices = 0;
- struct iommufd_device *cur;
- int rc;
- mutex_lock(&idev->igroup->lock);
- if (hwpt == igroup->hwpt) {
mutex_unlock(&idev->igroup->lock);
return NULL;
- }
- /* Try to upgrade the domain we have */
- list_for_each_entry(cur, &igroup->device_list, group_item) {
num_devices++;
if (cur->enforce_cache_coherency) {
rc = iommufd_hw_pagetable_enforce_cc(hwpt);
if (rc)
goto err_unlock;
}
- }
- old_hwpt = igroup->hwpt;
- if (hwpt->ioas != old_hwpt->ioas) {
Do we allow this function to be used as attach/detach?
No. NULL is never a valid input..
if yes old_hwpt could be NULL here.
Er that test got lost in the last version it is neeed
and looks the policy for physical attach is different from the one that Nicoline applies for access. iommufd_access_set_ioas() can behave like normal attach/detach.
Access should change.
Thanks, Jason