Re: [PATCH v11 1/2] PCI/ACPI: Support Microsoft's "DmaProperty"

From: Dmytro Maluka

Date: Tue Nov 24 2026 - 13:58:47 EST


On Tue, Nov 24, 2026 at 12:15:46AM +0000, sashiko-bot@xxxxxxxxxx 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@xxxxxxxxxx>
>
> 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@xxxxxxxxxx/