linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Rajat Jain <rajatja@google.com>
Cc: Jean-Philippe Brucker <jean-philippe@linaro.org>,
	Rajat Jain <rajatxjain@gmail.com>, Will Deacon <will@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	linux-pci@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Pavel Machek <pavel@denx.de>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	iommu@lists.linux-foundation.org,
	Oliver O'Halloran <oohall@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Jesse Barnes <jsbarnes@google.com>,
	Dmitry Torokhov <dtor@google.com>, Len Brown <lenb@kernel.org>
Subject: Re: [PATCH v5 1/2] PCI: ACPI: Support Microsoft's "DmaProperty"
Date: Fri, 15 Apr 2022 17:15:06 -0500	[thread overview]
Message-ID: <20220415221506.GA851834@bhelgaas> (raw)
In-Reply-To: <CACK8Z6Fy3L7vijVn4w+6HwRuuTtW5ePrWc04rUc8U8TPT0Re0w@mail.gmail.com>

On Thu, Apr 14, 2022 at 04:15:47PM -0700, Rajat Jain via iommu wrote:
> On Thu, Apr 7, 2022 at 12:17 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
> > On Fri, Mar 25, 2022 at 11:46:08AM -0700, Rajat Jain wrote:

> > > Support the "DmaProperty" with the same semantics. This is useful for
> > > internal PCI devices that do not hang off a PCIe rootport, but offer
> > > an attack surface for DMA attacks (e.g. internal network devices).
> >
> > Same semantics as what?
> 
> Er, I meant the same semantics as the "DmaProperty". Please also see below.

"Support the 'DmaProperty' with the same semantics as 'DmaProperty'"
doesn't help much, so there must be a little more to the story :)

> > The MS description of "ExternalFacingPort" says:
> >
> >   This ACPI object enables the operating system to identify externally
> >   exposed PCIe hierarchies, such as Thunderbolt.
> 
> No, my patch doesn't have to do with this one.

I know, but it's similar, and I'm just hoping we can deal with them
consistently.

> > and "DmaProperty" says:
> >
> >   This ACPI object enables the operating system to identify internal
> >   PCIe hierarchies that are easily accessible by users (such as,
> >   Laptop M.2 PCIe slots accessible by way of a latch) and require
> >   protection by the OS Kernel DMA Protection mechanism.
> 
> Yes, this is the property that my patch uses. Microsoft has agreed to
> update this documentation (in a sideband thread that I also copied you
> on), with the updated semantics that this property can be used to
> identify any PCI devices that require Kernel DMA protection. i.e. the
> property is not restricted to identify "internal PCIe hierarchies"
> (starting at root port), but to "any PCI device".
> 
> > I don't really understand why they called out "laptop M.2 PCIe slots"
> > here.  Is the idea that those are more accessible than a standard
> > internal PCIe slot?  Seems like a pretty small distinction to me.
> >
> > I can understand your example of internal network devices adding an
> > attack surface.  But I don't see how "DmaProperty" helps identify
> > those.  Wouldn't a NIC in a standard internal PCIe slot add the same
> > attack surface?
> 
> Yes it would. The attack surface is the same. They probably only
> thought of devices external to the SoC (starting from a root port)
> when designing this property and thus called out internal M.2 PCI
> slots. But nowhave realized that this could be opened to any PCI
> device.

> > > +      * Property also used by Microsoft Windows for same purpose,
> > > +      * (to implement DMA protection from a device, using the IOMMU).
> > > +      */
> > > +     if (device_property_read_u8(&dev->dev, "DmaProperty", &val))
> >
> > The MS web page says a _DSD with this property must be implemented in
> > the Root Port device scope, but we don't enforce that here.  We *do*
> > enforce it in pci_acpi_set_untrusted().  Shouldn't we do the same
> > here?
> 
> No, the whole point of doing this (please refer to the discussion on
> the previous versions of this patch) was that we want to have a
> property that is NOT limited to the root ports only. And we have
> reached an agreement with Microsoft about that.

We need to either mention the fact that we're going beyond what the MS
web page says or (ideally, as you are doing) get the page updated with
the semantics you need.

> > But IIUC, device_property_read_u8() works for either ACPI or DT
> > properties, and maybe there is interest in using this for DT systems.
> > None of these appear in any in-tree DTs, but maybe it is important to
> > handle these in DTs?
> >
> > If that's the case, this code would no longer be specific to ACPI and
> > should be moved to somewhere that's compiled even when CONFIG_ACPI
> > isn't set.
> 
> I think unifying ACPI and GPIO systems to use the same code / function
> to read the properties might be more work/investigation, because
> reading the properties for ACPI system happens much later than DT
> systems (For acpi systems, it happens in pci_acpi_setup() which is
> called much later). Given that no one wants to use this for DT
> systems, I'd prefer for this to be ACPI specific for now, and then we
> can solve it for DT once someone needs it.

I think it's OK to make it ACPI-specific for now.

Bjorn

      reply	other threads:[~2022-04-15 22:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-25 18:46 [PATCH v5 1/2] PCI: ACPI: Support Microsoft's "DmaProperty" Rajat Jain
2022-03-25 18:46 ` [PATCH v5 2/2] PCI: Rename pci_dev->untrusted to pci_dev->untrusted_dma Rajat Jain
2022-04-05 13:26   ` Rafael J. Wysocki
2022-04-05 13:25 ` [PATCH v5 1/2] PCI: ACPI: Support Microsoft's "DmaProperty" Rafael J. Wysocki
2022-04-07 19:17 ` Bjorn Helgaas
2022-04-14 23:15   ` Rajat Jain
2022-04-15 22:15     ` Bjorn Helgaas [this message]

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=20220415221506.GA851834@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=dtor@google.com \
    --cc=dwmw2@infradead.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jean-philippe@linaro.org \
    --cc=jsbarnes@google.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=oohall@gmail.com \
    --cc=pavel@denx.de \
    --cc=rafael@kernel.org \
    --cc=rajatja@google.com \
    --cc=rajatxjain@gmail.com \
    --cc=will@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).