From: Will Deacon <will@kernel.org>
To: Lu Baolu <baolu.lu@linux.intel.com>
Cc: Ashok Raj <ashok.raj@intel.com>,
linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
Robin Murphy <robin.murphy@arm.com>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v9 1/4] iommu: Move def_domain type check for untrusted device into core
Date: Mon, 23 Nov 2020 14:03:28 +0000 [thread overview]
Message-ID: <20201123140328.GA10730@willie-the-truck> (raw)
In-Reply-To: <c75c2981-11bd-74c0-289b-c2eb198bb5ab@linux.intel.com>
On Mon, Nov 23, 2020 at 09:54:49PM +0800, Lu Baolu wrote:
> Hi Will,
>
> On 2020/11/23 21:03, Will Deacon wrote:
> > Hi Baolu,
> >
> > On Mon, Nov 23, 2020 at 08:55:17PM +0800, Lu Baolu wrote:
> > > On 2020/11/23 20:04, Will Deacon wrote:
> > > > On Sat, Nov 21, 2020 at 09:56:17PM +0800, Lu Baolu wrote:
> > > > > @@ -1645,13 +1655,10 @@ struct __group_domain_type {
> > > > > static int probe_get_default_domain_type(struct device *dev, void *data)
> > > > > {
> > > > > - const struct iommu_ops *ops = dev->bus->iommu_ops;
> > > > > struct __group_domain_type *gtype = data;
> > > > > unsigned int type = 0;
> > > > > - if (ops->def_domain_type)
> > > > > - type = ops->def_domain_type(dev);
> > > > > -
> > > > > + type = iommu_get_mandatory_def_domain_type(dev);
> > > >
> > > > afaict, this code is only called from probe_alloc_default_domain(), which
> > > > has:
> > > >
> > > > /* Ask for default domain requirements of all devices in the group */
> > > > __iommu_group_for_each_dev(group, >ype,
> > > > probe_get_default_domain_type);
> > > >
> > > > if (!gtype.type)
> > > > gtype.type = iommu_def_domain_type;
> > > >
> > > > so is there actually a need to introduce the new
> > > > iommu_get_mandatory_def_domain_type() function, given that a type of 0
> > > > always ends up resolving to the default domain type?
> > >
> > > Another consumer of this helper is in the next patch:
> > >
> > > + dev_def_dom = iommu_get_mandatory_def_domain_type(dev);
> > > +
> > > + /* Check if user requested domain is supported by the device or not */
> > > + if (!type) {
> > > + /*
> > > + * If the user hasn't requested any specific type of domain and
> > > + * if the device supports both the domains, then default to the
> > > + * domain the device was booted with
> > > + */
> > > + type = iommu_get_def_domain_type(dev);
> > > + } else if (dev_def_dom && type != dev_def_dom) {
> > > + dev_err_ratelimited(prev_dev, "Device cannot be in %s domain\n",
> > > + iommu_domain_type_str(type));
> > > + ret = -EINVAL;
> > > + goto out;
> > > + }
> > >
> > > I also added the untrusted device check in
> > > iommu_get_mandatory_def_domain_type(), so that we don't need to care
> > > about this in multiple places.
> >
> > I see, but isn't this also setting the default domain type in the case that
> > it gets back a type of 0? I think it would be nice to avoid having both
> > iommu_get_mandatory_def_domain_type() and iommu_get_def_domain_type() of we
> > can, as it's really not clear which one to use when and what is meant by
> > "mandatory" imo.
>
> Yes, agreed. I will remove iommu_get_mandatory_def_domain_type() and
> keep iommu_get_def_domain_type() as the only helper in the next version.
Great, thanks!
Will
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2020-11-23 14:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-21 13:56 [PATCH v9 0/4] iommu: Add support to change default domain of Lu Baolu
2020-11-21 13:56 ` [PATCH v9 1/4] iommu: Move def_domain type check for untrusted device into core Lu Baolu
2020-11-23 12:04 ` Will Deacon
2020-11-23 12:55 ` Lu Baolu
2020-11-23 13:03 ` Will Deacon
2020-11-23 13:54 ` Lu Baolu
2020-11-23 14:03 ` Will Deacon [this message]
2020-11-21 13:56 ` [PATCH v9 2/4] iommu: Add support to change default domain of an iommu group Lu Baolu
2020-11-21 13:56 ` [PATCH v9 3/4] iommu: Take lock before reading iommu group default domain type Lu Baolu
2020-11-21 13:56 ` [PATCH v9 4/4] iommu: Document usage of "/sys/kernel/iommu_groups/<grp_id>/type" file Lu Baolu
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=20201123140328.GA10730@willie-the-truck \
--to=will@kernel.org \
--cc=ashok.raj@intel.com \
--cc=baolu.lu@linux.intel.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox