From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B59974457B7; Mon, 14 Sep 2026 11:23:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789384990; cv=none; b=uv1WJiGR/LiKPxKuX28ff3QSChVPl1Rtmx4UAfh0HH75MvVSMz00133069GhggmsS8g/s9MaTdmTjyfRW8TxFab6dfMofXZZ5VGs+K9PKKiMZZOC9wAbFDIAYYc6mEEIyNQYADwmTnPKyAvJz3x0KLkNaAhKABSa+nJPNFY3iOQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789384990; c=relaxed/simple; bh=YHMSGoWo12kqHH/9jpnEItTIAqyqxLhgK1rYGVpBOuQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RDMWImT6f8WPTBYcSPULjSc/2xp2ltOWt3BUt0HcDnW6ca8pE8T/EukqOUMfZeAa9YjLnr3hC6DvQHC30njOghK51crekMUDR1iBoi4Yy+nnJJN7GDXAWDISNzAFJ50Va2MfpZhkmqae9MC7Z6ie3lJojkcDMvq5+xR3uHcEmtI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=it0WCzje; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="it0WCzje" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73E941F00898; Mon, 14 Sep 2026 11:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789384988; bh=EQ+G8TpB9QqK14VWN1C6DtN6XM6oOCSfCS60D48WQ4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=it0WCzjeir7wCO4A8EYEv8KlIeycs7/8P6qDKTP9dUZ7grucBNcGIMIKCj57vxWdl 3S6mastH0CnylSImNg0rWfxkJSPOmpZkX0ccRxnubY3mi2NZcAzPl+0Y7+N3DGtG9o 9ePRDKD03maUAHyvncqkuu6RXxCG7PNObIVVlYzauJzNyzzQppMrdzepCY6Isj3YEq c+EXXcqnbuQMxKcZnqXFPUHEgkHDSsdTe+v8iOAya69syzRIl7+jPy6hmfWv7aNtNV TC+AtHMw8GnZQtWGxvBQ2e1AK97ewFMH/48u7zettehcISZr6s1NyUQSE9hMc23VJZ SPnkB/3EUUOfg== From: Leon Romanovsky To: Bjorn Helgaas , Logan Gunthorpe , Chaitanya Kulkarni , Greg Kroah-Hartman , Jens Axboe , Alex Williamson , Leon Romanovsky , Ankit Agrawal , Jason Gunthorpe , Jonathan Corbet , Shuah Khan , "Joerg Roedel (AMD)" , Will Deacon , Robin Murphy , Randy Dunlap , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, iommu@lists.linux.dev, Tushar Dave , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-rdma@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH v6 04/18] PCI: Reject unreadable ACS controls in isolation checks Date: Mon, 14 Sep 2026 14:22:37 +0300 Message-ID: <20260914-fix-p2p-acs-v4-0-v6-4-5ef07ec9ef06@nvidia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260914-fix-p2p-acs-v4-0-v6-0-5ef07ec9ef06@nvidia.com> References: <20260914-fix-p2p-acs-v4-0-v6-0-5ef07ec9ef06@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15-dev-18f8f Content-Transfer-Encoding: 8bit From: Leon Romanovsky pci_acs_flags_enabled() and the Intel SPT PCH quirk use ACS registers without checking config-space read errors. A failed read may leave control state indeterminate yet allow the device to satisfy requested isolation controls. Return false when either ACS capability or control state cannot be read. An unknown state cannot prove isolation. Signed-off-by: Leon Romanovsky --- drivers/pci/pci.c | 3 ++- drivers/pci/quirks.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b2879a6be5f8..f7d94ecf9157 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3594,7 +3594,8 @@ static bool pci_acs_flags_enabled(struct pci_dev *pdev, u16 acs_flags) */ acs_flags &= (pdev->acs_capabilities | PCI_ACS_EC); - pci_read_config_word(pdev, pos + PCI_ACS_CTRL, &ctrl); + if (pci_read_config_word(pdev, pos + PCI_ACS_CTRL, &ctrl)) + return false; return (ctrl & acs_flags) == acs_flags; } diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index de9bbccda21f..d5c3e6802840 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -4992,10 +4992,12 @@ static int pci_quirk_intel_spt_pch_acs(struct pci_dev *dev, u16 acs_flags) return -ENOTTY; /* see pci_acs_flags_enabled() */ - pci_read_config_dword(dev, pos + PCI_ACS_CAP, &cap); + if (pci_read_config_dword(dev, pos + PCI_ACS_CAP, &cap)) + return 0; acs_flags &= (cap | PCI_ACS_EC); - pci_read_config_dword(dev, pos + INTEL_SPT_ACS_CTRL, &ctrl); + if (pci_read_config_dword(dev, pos + INTEL_SPT_ACS_CTRL, &ctrl)) + return 0; return pci_acs_ctrl_enabled(acs_flags, ctrl); } -- 2.55.0