From: Christoph Hellwig <hch@infradead.org> To: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: Lu Baolu <baolu.lu@linux.intel.com>, iommu@lists.linux-foundation.org, LKML <linux-kernel@vger.kernel.org>, Joerg Roedel <joro@8bytes.org>, David Woodhouse <dwmw2@infradead.org>, Jean-Philippe Brucker <jean-philippe@linaro.com>, Eric Auger <eric.auger@redhat.com>, Yi Liu <yi.l.liu@intel.com>, "Tian, Kevin" <kevin.tian@intel.com>, Raj Ashok <ashok.raj@intel.com>, Alex Williamson <alex.williamson@redhat.com>, Christoph Hellwig <hch@infradead.org>, Jonathan Cameron <jic23@kernel.org> Subject: Re: [PATCH v13 4/8] iommu/vt-d: Add bind guest PASID support Date: Wed, 13 May 2020 22:59:30 -0700 [thread overview] Message-ID: <20200514055930.GD22388@infradead.org> (raw) In-Reply-To: <1589410909-38925-5-git-send-email-jacob.jun.pan@linux.intel.com> > + if (dev_is_pci(dev)) { > + /* VT-d supports devices with full 20 bit PASIDs only */ > + if (pci_max_pasids(to_pci_dev(dev)) != PASID_MAX) > + return -EINVAL; > + } else { > + return -ENOTSUPP; > + } This looks strange. Why not: if (!dev_is_pci(dev)) { return -ENOTSUPP; /* VT-d supports devices with full 20 bit PASIDs only */ if (pci_max_pasids(to_pci_dev(dev)) != PASID_MAX) return -EINVAL; > + for_each_svm_dev(sdev, svm, dev) { > + /* > + * For devices with aux domains, we should allow multiple > + * bind calls with the same PASID and pdev. > + */ > + if (iommu_dev_feature_enabled(dev, IOMMU_DEV_FEAT_AUX)) { > + sdev->users++; > + } else { > + dev_warn_ratelimited(dev, "Already bound with PASID %u\n", > + svm->pasid); > + ret = -EBUSY; > + } > + goto out; Is this intentionally a for loop that jumps out of the loop after the first device? > + /* > + * PASID table is per device for better security. Therefore, for > + * each bind of a new device even with an existing PASID, we need to > + * call the nested mode setup function here. > + */ > + spin_lock(&iommu->lock); > + ret = intel_pasid_setup_nested(iommu, > + dev, > + (pgd_t *)data->gpgd, > + data->hpasid, > + &data->vtd, > + dmar_domain, > + data->addr_width); Why not: et = intel_pasid_setup_nested(iommu, dev, (pgd_t *)data->gpgd, data->hpasid, &data->vtd, dmar_domain, data->addr_width); ? > + for_each_svm_dev(sdev, svm, dev) { > + ret = 0; ... > + break; > + } Same only looks at the first device style. Why dos it only care about the first device? That needs at least a comment, and probably a first_svm_dev or so heper to make it explicit.
WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@infradead.org> To: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: "Tian, Kevin" <kevin.tian@intel.com>, Alex Williamson <alex.williamson@redhat.com>, Raj Ashok <ashok.raj@intel.com>, David Woodhouse <dwmw2@infradead.org>, LKML <linux-kernel@vger.kernel.org>, Christoph Hellwig <hch@infradead.org>, iommu@lists.linux-foundation.org, Jean-Philippe Brucker <jean-philippe@linaro.com>, Jonathan Cameron <jic23@kernel.org> Subject: Re: [PATCH v13 4/8] iommu/vt-d: Add bind guest PASID support Date: Wed, 13 May 2020 22:59:30 -0700 [thread overview] Message-ID: <20200514055930.GD22388@infradead.org> (raw) In-Reply-To: <1589410909-38925-5-git-send-email-jacob.jun.pan@linux.intel.com> > + if (dev_is_pci(dev)) { > + /* VT-d supports devices with full 20 bit PASIDs only */ > + if (pci_max_pasids(to_pci_dev(dev)) != PASID_MAX) > + return -EINVAL; > + } else { > + return -ENOTSUPP; > + } This looks strange. Why not: if (!dev_is_pci(dev)) { return -ENOTSUPP; /* VT-d supports devices with full 20 bit PASIDs only */ if (pci_max_pasids(to_pci_dev(dev)) != PASID_MAX) return -EINVAL; > + for_each_svm_dev(sdev, svm, dev) { > + /* > + * For devices with aux domains, we should allow multiple > + * bind calls with the same PASID and pdev. > + */ > + if (iommu_dev_feature_enabled(dev, IOMMU_DEV_FEAT_AUX)) { > + sdev->users++; > + } else { > + dev_warn_ratelimited(dev, "Already bound with PASID %u\n", > + svm->pasid); > + ret = -EBUSY; > + } > + goto out; Is this intentionally a for loop that jumps out of the loop after the first device? > + /* > + * PASID table is per device for better security. Therefore, for > + * each bind of a new device even with an existing PASID, we need to > + * call the nested mode setup function here. > + */ > + spin_lock(&iommu->lock); > + ret = intel_pasid_setup_nested(iommu, > + dev, > + (pgd_t *)data->gpgd, > + data->hpasid, > + &data->vtd, > + dmar_domain, > + data->addr_width); Why not: et = intel_pasid_setup_nested(iommu, dev, (pgd_t *)data->gpgd, data->hpasid, &data->vtd, dmar_domain, data->addr_width); ? > + for_each_svm_dev(sdev, svm, dev) { > + ret = 0; ... > + break; > + } Same only looks at the first device style. Why dos it only care about the first device? That needs at least a comment, and probably a first_svm_dev or so heper to make it explicit. _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2020-05-14 5:59 UTC|newest] Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-13 23:01 [PATCH v13 0/8] Nested Shared Virtual Address (SVA) VT-d support Jacob Pan 2020-05-13 23:01 ` Jacob Pan 2020-05-13 23:01 ` [PATCH v13 1/8] iommu/vt-d: Move domain helper to header Jacob Pan 2020-05-13 23:01 ` Jacob Pan 2020-05-13 23:01 ` [PATCH v13 2/8] iommu/vt-d: Use a helper function to skip agaw for SL Jacob Pan 2020-05-13 23:01 ` Jacob Pan 2020-05-14 5:51 ` Christoph Hellwig 2020-05-14 5:51 ` Christoph Hellwig 2020-05-14 15:20 ` Jacob Pan 2020-05-14 15:20 ` Jacob Pan 2020-05-13 23:01 ` [PATCH v13 3/8] iommu/vt-d: Add nested translation helper function Jacob Pan 2020-05-13 23:01 ` Jacob Pan 2020-05-14 5:54 ` Christoph Hellwig 2020-05-14 5:54 ` Christoph Hellwig 2020-05-14 15:31 ` Jacob Pan 2020-05-14 15:31 ` Jacob Pan 2020-05-13 23:01 ` [PATCH v13 4/8] iommu/vt-d: Add bind guest PASID support Jacob Pan 2020-05-13 23:01 ` Jacob Pan 2020-05-14 5:59 ` Christoph Hellwig [this message] 2020-05-14 5:59 ` Christoph Hellwig 2020-05-14 15:57 ` Jacob Pan 2020-05-14 15:57 ` Jacob Pan 2020-05-15 1:01 ` Lu Baolu 2020-05-15 1:01 ` Lu Baolu 2020-05-16 6:02 ` Lu Baolu 2020-05-16 6:02 ` Lu Baolu 2020-05-13 23:01 ` [PATCH v13 5/8] iommu/vt-d: Support flushing more translation cache types Jacob Pan 2020-05-13 23:01 ` Jacob Pan 2020-05-13 23:01 ` [PATCH v13 6/8] iommu/vt-d: Add svm/sva invalidate function Jacob Pan 2020-05-13 23:01 ` Jacob Pan 2020-05-13 23:01 ` [PATCH v13 7/8] iommu/vt-d: Enlightened PASID allocation Jacob Pan 2020-05-13 23:01 ` Jacob Pan 2020-05-13 23:01 ` [PATCH v13 8/8] iommu/vt-d: Add custom allocator for IOASID Jacob Pan 2020-05-13 23:01 ` Jacob Pan 2020-05-16 6:31 ` [PATCH v13 0/8] Nested Shared Virtual Address (SVA) VT-d support Lu Baolu 2020-05-16 6:31 ` Lu Baolu 2020-05-16 4:59 [PATCH v13 4/8] iommu/vt-d: Add bind guest PASID support kbuild test robot
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200514055930.GD22388@infradead.org \ --to=hch@infradead.org \ --cc=alex.williamson@redhat.com \ --cc=ashok.raj@intel.com \ --cc=baolu.lu@linux.intel.com \ --cc=dwmw2@infradead.org \ --cc=eric.auger@redhat.com \ --cc=iommu@lists.linux-foundation.org \ --cc=jacob.jun.pan@linux.intel.com \ --cc=jean-philippe@linaro.com \ --cc=jic23@kernel.org \ --cc=joro@8bytes.org \ --cc=kevin.tian@intel.com \ --cc=linux-kernel@vger.kernel.org \ --cc=yi.l.liu@intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.