From: Dmytro Maluka <dmaluka@chromium.org>
To: sashiko-reviews@lists.linux.dev
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Lu Baolu <baolu.lu@linux.intel.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Dmitry Torokhov <dtor@google.com>,
David Woodhouse <dwmw2@infradead.org>,
Bjorn Helgaas <helgaas@kernel.org>,
iommu@lists.linux.dev, Jean-Philippe Brucker <jpb@kernel.org>,
Joerg Roedel <joro@8bytes.org>,
Joshua Peraza <jperaza@google.com>,
Jesse Barnes <jsbarnes@google.com>, Len Brown <lenb@kernel.org>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Oliver O'Halloran <oohall@gmail.com>,
Pavel Machek <pavel@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Rajat Jain <rajatja@google.com>,
Rajat Jain <rajatxjain@gmail.com>, Will Deacon <will@kernel.org>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Robin Murphy <robin.murphy@arm.com>,
Vineeth Pillai <vineeth@bitbyteword.org>,
Aashish Sharma <aashish@aashishsharma.net>,
Grzegorz Jaszczyk <jaszczyk@chromium.org>,
Tomasz Nowicki <tnowicki@google.com>,
Dmytro Maluka <dmaluka@chromium.org>
Subject: Re: [PATCH v11 1/2] PCI/ACPI: Support Microsoft's "DmaProperty"
Date: Tue, 24 Nov 2026 19:58:31 +0100 [thread overview]
Message-ID: <awXeV5Jo4WTjLc8c@google.com> (raw)
In-Reply-To: <sashiko-outbox-230247@kernel.org>
On Tue, Nov 24, 2026 at 12:15:46AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issues to consider:
> - [Medium] PCI/ACPI: platform_optin_force_iommu() ignores DmaProperty
> devices
> - [Medium] PCI: SR-IOV VFs do not inherit untrusted flag from
> DmaProperty PF
> --
>
> commit 534ec8c0dc4ebcebaa88d905d9760f867ca5b38f
> Author: Rajat Jain <rajatja@google.com>
>
> PCI/ACPI: Support Microsoft's "DmaProperty"
>
> This commit adds support for the Microsoft ACPI _DSD "DmaProperty" to mark
> PCI devices as untrusted when the property is set to 1.
>
> Link: [1] https://docs.microsoft.com/en-us/windows-hardware/drivers/pci/dsd-for-pcie-root-ports#identifying-internal-pcie-ports-accessible-to-users-and-requiring-dma-protection
> Link: [2] https://docs.microsoft.com/en-us/windows/security/information-protection/kernel-dma-protection-for-thunderbolt
>
> > diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> > index 1150f2fbabf41..5971ffc2a375a 100644
> > --- a/drivers/pci/pci-acpi.c
> > +++ b/drivers/pci/pci-acpi.c
> > @@ -1427,12 +1427,34 @@ static void pci_acpi_set_external_facing(struct pci_dev *dev)
> > dev->external_facing = 1;
> > }
> >
> > +static int pci_dev_has_dma_property(struct pci_dev *dev)
> > +{
> > + struct acpi_device *adev;
> > + const union acpi_object *obj;
> > +
> > + adev = ACPI_COMPANION(&dev->dev);
> > + if (!adev)
> > + return 0;
> > +
> > + /*
> > + * Property used by Microsoft Windows to enforce IOMMU DMA
> > + * protection from any device, that the system may not fully trust;
> > + * we'll honour it the same way.
> > + */
> > + if (!acpi_dev_get_property(adev, "DmaProperty", ACPI_TYPE_INTEGER,
> > + &obj) && obj->integer.value == 1)
> > + return 1;
> > +
> > + return 0;
> > +}
> > +
> > void pci_acpi_setup(struct device *dev, struct acpi_device *adev)
> > {
> > struct pci_dev *pci_dev = to_pci_dev(dev);
> >
> > pci_acpi_optimize_delay(pci_dev, adev->handle);
> > pci_acpi_set_external_facing(pci_dev);
> > + pci_dev->untrusted |= pci_dev_has_dma_property(pci_dev);
>
> [Severity: Medium]
> Should platform_optin_force_iommu() also check for devices marked via
> DmaProperty?
>
> In drivers/iommu/intel/iommu.c, platform_optin_force_iommu() only checks
> has_external_pci(), which tests pdev->external_facing:
>
> drivers/iommu/intel/iommu.c:has_external_pci() {
> ...
> for_each_pci_dev(pdev)
> if (pdev->external_facing) {
> pci_dev_put(pdev);
> return true;
> }
> return false;
> }
>
> On systems with CONFIG_INTEL_IOMMU_DEFAULT_ON=n where firmware sets the
> DMAR platform opt-in flag and marks internal ports or devices with
> DmaProperty instead of ExternalFacingPort, has_external_pci() returns
> false. platform_optin_force_iommu() then returns early without enabling
> DMAR_FORCE_ON, and intel_iommu_init() disables the IOMMU, leaving those
> devices without DMA remapping protection.
Makes sense to me. As I understand, prior to this patch,
platform_optin_force_iommu() was technically not buggy, since
pdev->untrusted was only set for devices downstream of external-facing
ports; whereas with this patch, internal (e.g. SoC-integrated) devices
may also be marked as untrusted i.e. requiring DMA protection, thus
platform_optin_force_iommu() should check pdev->untrusted along with
checking pdev->external_facing.
Baolu, do you agree?
> [Severity: Medium]
> Do SR-IOV Virtual Functions inherit pci_dev->untrusted when DmaProperty is
> placed directly on an endpoint Physical Function?
>
> When VFs are created via pci_iov_add_virtfn() -> pci_iov_scan_device() ->
> pci_setup_device(), set_pcie_untrusted() checks pci_upstream_bridge(dev).
> Because pci_upstream_bridge() resolves pci_physfn(dev) first and returns
> the bridge upstream of the PF (or NULL on a root bus) rather than the PF
> itself, and VFs do not share the PF's ACPI companion, virtfn->untrusted
> remains 0. IOMMU and DMA paths then treat the VFs of an untrusted PF as
> trusted.
Yeah, similarly agree. Looks like pci_iov_add_virtfn() is implicitly
relying on an assumption that pdev->untrusted is *only* true for PFs
downstream of external-facing ports, which happens to be the case
without this patch, but is no longer the case with this patch.
...Although, independently of this series, looks like
set_pcie_untrusted() is completely buggy on non-x86 since v6.13, since
it solely relies on arch_pci_dev_is_removable(). I've just reported that
at https://lore.kernel.org/all/awXXSfrhLHK7TNbp@google.com/
next prev parent reply other threads:[~2026-11-24 18:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 23:58 [PATCH v11 0/2] PCI/ACPI: Support Microsoft's "DmaProperty" Dmytro Maluka
2026-11-23 23:58 ` [PATCH v11 1/2] " Dmytro Maluka
2026-11-24 0:15 ` sashiko-bot
2026-11-24 18:58 ` Dmytro Maluka [this message]
2026-11-23 23:58 ` [PATCH v11 2/2] PCI: Rename pci_dev->untrusted to pci_dev->requires_dma_protection Dmytro Maluka
2026-11-24 0:15 ` [PATCH v11 0/2] PCI/ACPI: Support Microsoft's "DmaProperty" sashiko-bot
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=awXeV5Jo4WTjLc8c@google.com \
--to=dmaluka@chromium.org \
--cc=aashish@aashishsharma.net \
--cc=baolu.lu@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=dtor@google.com \
--cc=dwmw2@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=helgaas@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=jaszczyk@chromium.org \
--cc=joro@8bytes.org \
--cc=jpb@kernel.org \
--cc=jperaza@google.com \
--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@kernel.org \
--cc=rafael@kernel.org \
--cc=rajatja@google.com \
--cc=rajatxjain@gmail.com \
--cc=robin.murphy@arm.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=suravee.suthikulpanit@amd.com \
--cc=tnowicki@google.com \
--cc=vineeth@bitbyteword.org \
--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