From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795546718; b=AoQyNcA34oz9m3TEBg5GHBNKqruioAqMVahPmkaGd1E9Jk+Hh5Wt7T8qK1uv/MybFEnK li2F4AMC4xPQamdmMQVfgxzEJLg/NYxNM4anOSVCpuPEZMpYgs3r9oce639PqR4StJ8DB bqpQdO/vKFTsVFgKX6cAGAzMO97DsZ6kWWVjEQI6TtMqQvoeabK0LseI1mpllJgbpcKJ/ VB8NzRSVlFMMaVc0ol85lSGfB62UGzYd4KoRhfrgKwWxXKZ7PbgOHo2D3fGqJxRzJclYk +z0mUgK3sFshQ1/Ih130ukP0Cp2EraO7OOFFsAAo4+ihM8pO5yfYd6zxwxrQnW/tgYA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795546718; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=rKVd0WB9GKER5oLiGhqXKhoz1U/fSQCfKOepi4KUjiM=; b=mWWc/29Y7auUvpDJdFxvPyerS/bo2qkV2SaeL0pWo2bkRupq2wZJIWEcflovCNXLoLd4 LutGXfIv2f8xSKqeoneRUcd17PC7os8yvbiVVuJILyrmPB6hd9JJDDIWnl/fcHjAtXKiA QIW6fIZcBa3JbSPcrr99QxQcO/RY2WpRpEyfBFd/HuoeO7QXL26tc36tMzWJis6jQhTE2 absttOaNDko86ng+fvR4OGchWrf1UlJm/xLUYmnV8Ee3ZzPykdgkGwHadfKc/oR+xPGDL gSK0OARTtsnGm/b3mr5kI7Or7j10r+byciEG2C+nDDGlJNyby0vFRGJARKL3GH/Y5sQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=bDP7tg7r; arc=none smtp.remote-ip=209.85.221.46 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17922606A31E for ; Tue, 24 Nov 2026 18:58:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 17922606A31E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=bDP7tg7r Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-4a5024b3c28so3476582f8f.0 for ; Tue, 24 Nov 2026 10:58:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1795546716; x=1796151516; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=rKVd0WB9GKER5oLiGhqXKhoz1U/fSQCfKOepi4KUjiM=; b=bDP7tg7rXIWgB+hAPfjr5hkfXqq3/feAOEYjiTHuNZrQlhTtTN46nfDNyfwQbJPZFF 9dIgjYOemEri6j3ST+69bdA6wEwAor2eTWvN7U35JZAsxdhhRIUlxX9rIE9vYUa4xshh me3UKBz9ojnotyqPz1jk4D5mb5c58YTf5H6Ys= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795546716; x=1796151516; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=rKVd0WB9GKER5oLiGhqXKhoz1U/fSQCfKOepi4KUjiM=; b=CrAGfi5onD+KRXzUCuaDuNznAiYeXnYY3m+ocsvKHZWxIbvOZxWYtmy/PV9uAdJPVx 4j4jOs9b5OvtH1wtyYDtLe+4M4bZaJgbcDVLPujlQXXkhyztZZ+pgNBtHjNeNwO7Jyq6 2j62tAPJBoqr0DztEFWb7RqRo+SdJ56IMbkgIEPS3KTZS0NveSj96ewEBDO76A+tovc0 rVRl0FiUiWXX+KbPceflpuH5cNf9lt9e46FOnzMmMf495u+Qnvvg8LFBOeK6uhwhel23 NAr5STeRq8iHaMor9NtnnKU5BPeRGHqeiM1zfM5zfjRQSqO5Wz2yPA8OrNMAmXmuKn9A rCDA== X-Forwarded-Encrypted: i=1; AL+hErGWiit/LalXSZVSX+ofuf24aAC40pUrwhJdfi/bNvJQr41SzXjJDZAOJywULFqe4BVGhiDNQDPok8FdiOY=@vger.kernel.org X-Gm-Message-State: APuU4Z8adLa3JqfS6+Wj9vDhNsIHUrdLSWrx0tHFogMQvt7gye552GVU ARLYRyZe7UHRbhRoclu+9H+AjN9D+4Yds9d79umbbQVTO+yU7sUmmkBEx0vkDXjbHg== X-Gm-Gg: AZFdTZe6t2fe1jvxE8yeOl59B/Fp3cwsFWVPCTXpqhPLW7RD62VRA9BY+zIX4G9/hRp N2oxw01jV4XqmHk6vzWHXdcSoWeB8HqIoWbypfy9Ry3PA+/qxFctoIIdBsIvfivl0ZcfryQf07g SsewwNF1XXl4sQxCCIo8CBzfEcNO/5V05aNEEMGOixuVe8WzWwdopG/IN0oBnT2i7vE6iafwCbX /SXakNd0qBB1lHraYZZu5ZhMgG01T1wbtFetOYoH/N6De/YhHknZzdfIhPIpPPtkPTU14gkaLMv tn/ADE1H/dwqjLPIj6h2MJvvg4qe2XhHzyN0Lrhsn77Bmg9QHKTlFFlwRlMgTPwZm02HIE3uH95 R3yO0IO1n7hKSvgYLMF6fUWszzbvdQnyF8XyhlDPyxS8FFZYyzMV5YmyUpOBQ3tIOBYQcq9Ij7l Iht/tXXbzNtYaWyiVrhKjErZ2E6Oqn0lYYg0aCayUgB1FqRfmz0Oml2MJcsjQQH+WtfhTJyOJJj d6dn4hEdEGISnYrCxGlk9lIzYWoEERRhr6DICnP5zDa76uOm2I+bPM3wwkc9Y9nwhQkqEFhXJBA WJJG4i6GZEyO691OpvllpatL0IMyqY7/1Xhhj+Fd0b+tZlUUnbhrppyPEwR10e/q X-Received: by 2002:a05:600c:4585:b0:4a1:c6f5:2450 with SMTP id 5b1f17b1804b1-4bb8881b8e4mr321879025e9.17.1795546716413; Tue, 24 Nov 2026 10:58:36 -0800 (PST) Received: from google.com ([2a00:79e0:285b:8:af0c:c5f1:ee8a:b81f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853ca452sm445870355e9.15.2026.11.24.10.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2026 10:58:35 -0800 (PST) Date: Tue, 24 Nov 2026 19:58:31 +0100 From: Dmytro Maluka To: sashiko-reviews@lists.linux.dev Cc: Greg Kroah-Hartman , Lu Baolu , Bjorn Helgaas , Dmitry Torokhov , David Woodhouse , Bjorn Helgaas , iommu@lists.linux.dev, Jean-Philippe Brucker , Joerg Roedel , Joshua Peraza , Jesse Barnes , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Mika Westerberg , Oliver O'Halloran , Pavel Machek , "Rafael J. Wysocki" , Rajat Jain , Rajat Jain , Will Deacon , Suravee Suthikulpanit , Robin Murphy , Vineeth Pillai , Aashish Sharma , Grzegorz Jaszczyk , Tomasz Nowicki , Dmytro Maluka Subject: Re: [PATCH v11 1/2] PCI/ACPI: Support Microsoft's "DmaProperty" Message-ID: References: <20261123235845.564027-1-dmaluka@chromium.org> <20261123235845.564027-2-dmaluka@chromium.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 > > 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/