Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmytro Maluka" <dmaluka@chromium.org>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v11 1/2] PCI/ACPI: Support Microsoft's "DmaProperty"
Date: Tue, 24 Nov 2026 00:15:46 +0000	[thread overview]
Message-ID: <sashiko-outbox-230247@kernel.org> (raw)
In-Reply-To: <20261123235845.564027-2-dmaluka@chromium.org>

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.

[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.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123235845.564027-1-dmaluka@chromium.org?part=1

  reply	other threads:[~2026-11-24  0:15 UTC|newest]

Thread overview: 5+ 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 [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=sashiko-outbox-230247@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmaluka@chromium.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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