From nobody Mon Jun 8 05:24:55 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 9E7103D47B7 for ; Thu, 4 Jun 2026 06:05:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780553133; cv=none; b=bRBQPrceWOxwDZCIuc2QF5VbOwqC0T0xO+f8Q3ndOfWS8srWKcN8CptbUmD89y/wDLMtv69bBGjFIWRW2infHsrSA1x7NbsQICYq5EnyCJpVIm2v5aQNAODroLrxXQpOeh4IMnHlqyixQuQlbNh887OEgzH4bYw35swFoufHMhg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780553133; c=relaxed/simple; bh=xm53TpFRrN5dL4C2+v5j9/m5g0/qjhftnOUG7WU1TT0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LLzxraQfzZ+4h/nXEaRoj1A2yOa2w8WABr3oRtEGmQZoi1JSYMOTY8ej87Y0us9fzMB4AgKb86znyhJczMVZix5f83+IjIKEVmRn+oLuxYgFWiVeyCB2PXNrEeDqnRYh1p/k2tmTt22K/X8eHnjWQKZw0IH1Y/8Gbh7/mj9mNEw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fS03G2si; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fS03G2si" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780553133; x=1812089133; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xm53TpFRrN5dL4C2+v5j9/m5g0/qjhftnOUG7WU1TT0=; b=fS03G2siZgLsyc7656MI6LqMxeiyJQAp3UsumPmkVy4ADjJWOxKnFEfh NcywFl6E369NH34OAJ5yQPjdKiUBsIQ0tFXplgrVoS1q3twI4H1BL4BmO 4vIG6ybICQi6TeTNRPX5uPPIQCixT7BXkuwCrSNHJzn2lmdJ6zoHwiSvV 938KQBziW9gXvBLhLA2hr4noQqCV2TGcqJBWRb2iFGvU7MkdKHvE2jwkP PCbpt+WQhCEtlgWVLnVv7WSp4w7oiFYSqV2UuxRdD2H/GxebgF8FAZbzt e3LQzCplrGKhIopexgL1D7yaZ7qZgoYUSW5hK9qvSZ+pDa9fCXslS9uCD w==; X-CSE-ConnectionGUID: rc/WGyZ1TI6OgWXpSVAt9A== X-CSE-MsgGUID: cyS0U4/tSc68T9vFSjpnHg== X-IronPort-AV: E=McAfee;i="6800,10657,11806"; a="81554234" X-IronPort-AV: E=Sophos;i="6.24,186,1774335600"; d="scan'208";a="81554234" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2026 23:05:33 -0700 X-CSE-ConnectionGUID: Ku4LxLOlS2CqEfM8umyqIA== X-CSE-MsgGUID: IKkWEaOhRt2uftN5QLxqWA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,186,1774335600"; d="scan'208";a="268112151" Received: from allen-box.sh.intel.com ([10.239.159.52]) by fmviesa002.fm.intel.com with ESMTP; 03 Jun 2026 23:05:30 -0700 From: Lu Baolu To: Joerg Roedel Cc: Pranjal Shrivastava , Guanghui Feng , =?UTF-8?q?Micha=C5=82=20Grzelak?= , Michael Bommarito , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/5] iommu/vt-d: Avoid WARNING in sva unbind path Date: Thu, 4 Jun 2026 14:03:06 +0800 Message-ID: <20260604060311.365074-2-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604060311.365074-1-baolu.lu@linux.intel.com> References: <20260604060311.365074-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Intel IOMMU driver allows SVA on devices even if they do not support PCI/PRI. Commit 39c20c4e83b9 ("iommu/vt-d: Only handle IOPF for SVA when PRI is supported") modified the SVA bind path to allow this configuration by skipping IOPF enablement when PRI is missing. However, it failed to update the unbind path. This creates an imbalance: the unbind path attempts to disable IOPF for a device that never had it enabled, triggering a WARNING in intel_iommu_disable_iopf(): WARNING: drivers/iommu/intel/iommu.c:3475 at intel_iommu_disable_iopf+0x4f= /0x90d Call Trace: blocking_domain_set_dev_pasid+0x50/0x70 iommu_detach_device_pasid+0x89/0xc0 iommu_sva_unbind_device+0x73/0x150 xe_vm_close_and_put+0x4d2/0x1200 [xe] Fix this by bypassing IOPF operations for SVA domains on non-PRI hardware in both the bind and unbind paths. Fixes: 39c20c4e83b9 ("iommu/vt-d: Only handle IOPF for SVA when PRI is supp= orted") Cc: stable@vger.kernel.org Reported-by: Nareshkumar Gollakoti Signed-off-by: Lu Baolu Reviewed-by: Kevin Tian Link: https://lore.kernel.org/r/20260519052917.3729796-1-baolu.lu@linux.int= el.com --- drivers/iommu/intel/iommu.h | 11 +++++++++++ drivers/iommu/intel/svm.c | 12 ++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h index ef145560aa98..775f1c4ae346 100644 --- a/drivers/iommu/intel/iommu.h +++ b/drivers/iommu/intel/iommu.h @@ -1254,18 +1254,29 @@ void intel_iommu_disable_iopf(struct device *dev); static inline int iopf_for_domain_set(struct iommu_domain *domain, struct device *dev) { + struct device_domain_info *info =3D dev_iommu_priv_get(dev); + if (!domain || !domain->iopf_handler) return 0; =20 + /* SVA with non-IOMMU/PRI IOPF handling is allowed. */ + if (domain->type =3D=3D IOMMU_DOMAIN_SVA && !info->pri_supported) + return 0; + return intel_iommu_enable_iopf(dev); } =20 static inline void iopf_for_domain_remove(struct iommu_domain *domain, struct device *dev) { + struct device_domain_info *info =3D dev_iommu_priv_get(dev); + if (!domain || !domain->iopf_handler) return; =20 + if (domain->type =3D=3D IOMMU_DOMAIN_SVA && !info->pri_supported) + return; + intel_iommu_disable_iopf(dev); } =20 diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index 57cd1db7207a..fea10acd4f02 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -164,12 +164,9 @@ static int intel_svm_set_dev_pasid(struct iommu_domain= *domain, if (IS_ERR(dev_pasid)) return PTR_ERR(dev_pasid); =20 - /* SVA with non-IOMMU/PRI IOPF handling is allowed. */ - if (info->pri_supported) { - ret =3D iopf_for_domain_replace(domain, old, dev); - if (ret) - goto out_remove_dev_pasid; - } + ret =3D iopf_for_domain_replace(domain, old, dev); + if (ret) + goto out_remove_dev_pasid; =20 /* Setup the pasid table: */ sflags =3D cpu_feature_enabled(X86_FEATURE_LA57) ? PASID_FLAG_FL5LP : 0; @@ -184,8 +181,7 @@ static int intel_svm_set_dev_pasid(struct iommu_domain = *domain, =20 return 0; out_unwind_iopf: - if (info->pri_supported) - iopf_for_domain_replace(old, domain, dev); + iopf_for_domain_replace(old, domain, dev); out_remove_dev_pasid: domain_remove_dev_pasid(domain, dev, pasid); return ret; --=20 2.43.0 From nobody Mon Jun 8 05:24:55 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 9B6823D47CE for ; Thu, 4 Jun 2026 06:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780553135; cv=none; b=e3G6wqJLeNRMKx5AXYhsbBsl7nOBV8RAO7JbZdhYjRh3IQWcgidVsD/0CA9JGD7dfr3ftJ3X3nRD48Dc2z9vgYpfamRwgF3eut9nJBRZPzVQ7o1ZdFjX8KAvu3RDAs1pQvAQHCLGYuUMlbRypx/OoZkUaJL6hLVDqrmNWhL8aqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780553135; c=relaxed/simple; bh=ZNuUnQtm2QZ2JMwplBFeCc5TjvOkVGByw+irME/PHDE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NIIDsRFrUOqCgRBlASJlj64dUGxzHU6uWKRZt+aT6hF8exmXwIozm41fif1k7iZIE3a9NubgkUpcq5rFQfJ4LEiCjvKsKHmm+x4XNeCKmonY6K+5RpP4Os2cnZ1Xuac0V2/1WAsGAffVUeXzYE5MDLTPOCCJmNf6qieochUxt0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Eu5o/8oD; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Eu5o/8oD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780553135; x=1812089135; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZNuUnQtm2QZ2JMwplBFeCc5TjvOkVGByw+irME/PHDE=; b=Eu5o/8oDvzIr569IFXsDGBgbWu0faROx2NENNxpnF7GjMtWef9/4NqMl idT3wlxSIyBPeicuU0EtoeTeGMmBFd1XbBO3nFLxFSt1HZvQuiKe+Wu1i 0wxUE1Gp4BAhOBop99y4VHhbPvh4LWGvGvY8/lVPDx6tjhojIaqq4V43m cMZLn9E3KKlHpIvc5apbPNimM5ikXOt61yJj1f+/tU5pItnOT57ps5LlC BkPPElZXMTuiGm9dbnZOntxJLQHXcafRhhb0VgYJVRUeHSyTfgiYj6H7t Uih2BUYQHYnmv5m/uxlGjFayBDfn6a6KfSxdqqEwvC+W6HPjlAO4ma2O4 g==; X-CSE-ConnectionGUID: FRhdvGd3TBKeCUZ98Fc0vg== X-CSE-MsgGUID: P8ewvIfVR7qiUXPcrLjCUQ== X-IronPort-AV: E=McAfee;i="6800,10657,11806"; a="81554241" X-IronPort-AV: E=Sophos;i="6.24,186,1774335600"; d="scan'208";a="81554241" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2026 23:05:35 -0700 X-CSE-ConnectionGUID: fFARWh9CSsyHr6vzFbJjVg== X-CSE-MsgGUID: gOU0XIbgT8iOclobibFcwg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,186,1774335600"; d="scan'208";a="268112158" Received: from allen-box.sh.intel.com ([10.239.159.52]) by fmviesa002.fm.intel.com with ESMTP; 03 Jun 2026 23:05:32 -0700 From: Lu Baolu To: Joerg Roedel Cc: Pranjal Shrivastava , Guanghui Feng , =?UTF-8?q?Micha=C5=82=20Grzelak?= , Michael Bommarito , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/5] iommu/vt-d: Clear Present bit before tearing down scalable-mode context entry Date: Thu, 4 Jun 2026 14:03:07 +0800 Message-ID: <20260604060311.365074-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604060311.365074-1-baolu.lu@linux.intel.com> References: <20260604060311.365074-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Michael Bommarito device_pasid_table_teardown() zeroes the 128-bit scalable-mode context entry with context_clear_entry() while the Present bit is still set. This creates a window where the hardware can fetch a torn entry, with some fields already zeroed while Present is still set, leading to unpredictable behavior or spurious faults. The context-cache invalidation is issued only after the entry has been zeroed, and intel_pasid_free_table() then frees the PASID directory pages, so the IOMMU can keep walking a stale Present=3D1 entry that points at freed memory. While x86 provides strong write ordering, the compiler may reorder the two 64-bit writes to the entry, and the hardware fetch is not guaranteed to be atomic with respect to multiple CPU writes. Commit c1e4f1dccbe9d ("iommu/vt-d: Clear Present bit before tearing down context entry") fixed this exact pattern in domain_context_clear_one() and the copied-context path, but device_pasid_table_teardown() was not converted. Align it with the "Guidance to Software for Invalidations" in the VT-d spec, Section 6.5.3.3, using the same ownership handshake as the sibling fix: clear only the Present bit, flush it to the IOMMU, perform the context-cache invalidation, and only then zero the rest of the entry. Fixes: 81e921fd32161 ("iommu/vt-d: Fix NULL domain on device release") Signed-off-by: Michael Bommarito Assisted-by: Claude:claude-opus-4-7 Link: https://lore.kernel.org/r/20260528025557.3209367-1-michael.bommarito@= gmail.com Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index 89541b74ab8c..40910dc7363b 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -748,10 +748,12 @@ static void device_pasid_table_teardown(struct device= *dev, u8 bus, u8 devfn) } =20 did =3D context_domain_id(context); - context_clear_entry(context); + context_clear_present(context); __iommu_flush_cache(iommu, context, sizeof(*context)); spin_unlock(&iommu->lock); intel_context_flush_no_pasid(info, context, did); + context_clear_entry(context); + __iommu_flush_cache(iommu, context, sizeof(*context)); } =20 static int pci_pasid_table_teardown(struct pci_dev *pdev, u16 alias, void = *data) --=20 2.43.0 From nobody Mon Jun 8 05:24:55 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 289003D565A for ; Thu, 4 Jun 2026 06:05:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780553137; cv=none; b=fI/otvJAdOq0wrOM8cP1cu1VJeU6oRRv90St7XenppqFtkcTU476tGO17YHYkY4ebFKQnRqCx68VHkG1L0snpujR+uy5pj+vW/dl4dr7WiHzsh9+oQTIO5/5e1DTcafH2Js4Yeot4JteTO49wu9kBb7bwL72gipcXZqOjPc+9Ig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780553137; c=relaxed/simple; bh=lk+QXBIHW2Uv+ZVyv3jxFQlkkLl5igDptN3oRqoYpls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=klc1+mQRs6EFsV7F1zoCF+KQPlxj6PTRcK5vMbmpZJN7U64LSHV2B01qTKSwmJS0U7jH9KM4za+dm7CL9oqdnWOVOoAJlh4Zgn6BP4FRy+iamET7Jq/PeRUs/rqKF6WR7NmzBLPvPx9JzbPHziAeMF5cU0HBjRk+85nj/yoTWRg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=UxH4j3hf; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UxH4j3hf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780553137; x=1812089137; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lk+QXBIHW2Uv+ZVyv3jxFQlkkLl5igDptN3oRqoYpls=; b=UxH4j3hfRbTJsDQ+B56/iOBwNloA7MHEGI2v6Tr7u97WcXoI1HBkRHPK mduKmJYTqlDKS+nGJArjtbOnJdkmgJVNqhLYrzWtsWOsMFmwYIWJ+I87T 4u7TRC0+gEZ9uTfhmI0NJH95eeEOWGZFX+TQZ2xq6cVT2OYtuNmA1zSjr jvOntW/ZXQR6mWIFhw2UqYaMjNITSd2NRkxv/6M0GGzL1t2tzfBT+JyJe A72YExl49BSUIRw5mvFxZ+THfHnHgcfQagxxaMcV5gFRf1cQJLcseIsnz 8I+lIFfh3DMSPwzRdn+aNAc4xDxuHLw5wdjMsiOg8HxPPJjA2pRt/zOUx w==; X-CSE-ConnectionGUID: /uoy0jbJT0ueDzA7TFKUCQ== X-CSE-MsgGUID: KjVu1oaZRI60kTUdAp8osQ== X-IronPort-AV: E=McAfee;i="6800,10657,11806"; a="81554249" X-IronPort-AV: E=Sophos;i="6.24,186,1774335600"; d="scan'208";a="81554249" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2026 23:05:36 -0700 X-CSE-ConnectionGUID: ZU41HM9bS/OMStdCOuNrPQ== X-CSE-MsgGUID: JY+tLDYbRXiurXHSdjwUug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,186,1774335600"; d="scan'208";a="268112164" Received: from allen-box.sh.intel.com ([10.239.159.52]) by fmviesa002.fm.intel.com with ESMTP; 03 Jun 2026 23:05:34 -0700 From: Lu Baolu To: Joerg Roedel Cc: Pranjal Shrivastava , Guanghui Feng , =?UTF-8?q?Micha=C5=82=20Grzelak?= , Michael Bommarito , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/5] iommu/vt-d: Remove typo from pasid_pte_config_nested() Date: Thu, 4 Jun 2026 14:03:08 +0800 Message-ID: <20260604060311.365074-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604060311.365074-1-baolu.lu@linux.intel.com> References: <20260604060311.365074-1-baolu.lu@linux.intel.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" Content-Transfer-Encoding: quoted-printable From: Micha=C5=82 Grzelak Rename pasid_pte_config_nestd() into pasid_pte_config_nested(). Do it to match other function names ending with _nested(). Signed-off-by: Micha=C5=82 Grzelak Link: https://lore.kernel.org/r/20260509174503.831134-1-michal.grzelak@inte= l.com Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index 40910dc7363b..81353fd46b37 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -618,11 +618,11 @@ void intel_pasid_setup_page_snoop_control(struct inte= l_iommu *iommu, intel_pasid_flush_present(iommu, dev, pasid, did, pte); } =20 -static void pasid_pte_config_nestd(struct intel_iommu *iommu, - struct pasid_entry *pte, - struct iommu_hwpt_vtd_s1 *s1_cfg, - struct dmar_domain *s2_domain, - u16 did) +static void pasid_pte_config_nested(struct intel_iommu *iommu, + struct pasid_entry *pte, + struct iommu_hwpt_vtd_s1 *s1_cfg, + struct dmar_domain *s2_domain, + u16 did) { struct pt_iommu_vtdss_hw_info pt_info; =20 @@ -720,7 +720,7 @@ int intel_pasid_setup_nested(struct intel_iommu *iommu,= struct device *dev, return -EBUSY; } =20 - pasid_pte_config_nestd(iommu, pte, s1_cfg, s2_domain, did); + pasid_pte_config_nested(iommu, pte, s1_cfg, s2_domain, did); spin_unlock(&iommu->lock); =20 pasid_flush_caches(iommu, pte, pasid, did); --=20 2.43.0 From nobody Mon Jun 8 05:24:55 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 EEF373D646B for ; Thu, 4 Jun 2026 06:05:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780553139; cv=none; b=MQacYBZ5OSlOFHHovXpLss5WQCEBmVjDfW28EDBHm5V3uCDQBi4mDM5pftSjXGr9pAknYpBpB0fZ6F3iB1c4uNPPm58ZWcCZe8y9z59drTnHQYqYIf0JGSFRk7o1NZl95K89AlH05mX/Id/j1mpaloIZIrzClpHW+Z6JnrtFPtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780553139; c=relaxed/simple; bh=bg9a90q7vThLPozRo1SItoJxz5cp3kq3hBfy/kU+5jg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jvSCas8y59/PwFtBnTQKyu0I5p2axWRHEATJcdMbC759FL3JMrycl3OcUdIYL0Tru/oSBWbmjQ3xuPTnv6RTYCIoz/jreZ16Ej3cnIu9kp/JOY+dO5eZ5V3pc5quxS5/F91t2Ivv3U6WqtB2jENVO8toIKcE3ajDz+zAB71PhT4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WSto4Hft; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WSto4Hft" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780553139; x=1812089139; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bg9a90q7vThLPozRo1SItoJxz5cp3kq3hBfy/kU+5jg=; b=WSto4HftKvlxfvWuc5b6vQFl4g3qfHil0G+g+qkFsUwfvenoA03rW2Cd esdjheKOkHcWA5QG1MgyC07nPfq8ylz08sLOfyPkBdTrohrnJH0Vb3W/w jJzmGTcREUH1vTiUoI5pkTgTawDJ8IvXxEEz3kHfDOhpIyXIRq0ryGa4x vgOL9jtGUyZvQDqYjbmr1I7vSa8jhGZvoAh0uoQRnnFXa9cOb+kYo3/WA 72A+gmfPBkK91NRcvYO4kaREYrJb0XM92QvrdiWbAK8v72YYUAM1RpWLn 7IXX4fPaTAvVdHnOzSKkXGKKQMl0ouvACadbmjNflNsKo7Y5dIL5U9s4J A==; X-CSE-ConnectionGUID: 8w3WHVPHRTGGlmSOVHx1Ng== X-CSE-MsgGUID: wuimNDFdT1eJkLdVb0dYdg== X-IronPort-AV: E=McAfee;i="6800,10657,11806"; a="81554256" X-IronPort-AV: E=Sophos;i="6.24,186,1774335600"; d="scan'208";a="81554256" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2026 23:05:38 -0700 X-CSE-ConnectionGUID: RIQLWxasTaKcl+ll8cuhyg== X-CSE-MsgGUID: 7hC163kSRXaU+8geGzIDrQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,186,1774335600"; d="scan'208";a="268112167" Received: from allen-box.sh.intel.com ([10.239.159.52]) by fmviesa002.fm.intel.com with ESMTP; 03 Jun 2026 23:05:36 -0700 From: Lu Baolu To: Joerg Roedel Cc: Pranjal Shrivastava , Guanghui Feng , =?UTF-8?q?Micha=C5=82=20Grzelak?= , Michael Bommarito , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/5] iommu/vt-d: Improve IOMMU fault information Date: Thu, 4 Jun 2026 14:03:09 +0800 Message-ID: <20260604060311.365074-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604060311.365074-1-baolu.lu@linux.intel.com> References: <20260604060311.365074-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Guanghui Feng In some environments, multiple PCIe segments exist, and PCIe device information needs to be differentiated and identified based on the segment. When an IOMMU fault event occurs, the IOMMU and device segment information should be output in detail in dmar_fault_do_one. Signed-off-by: Guanghui Feng Link: https://lore.kernel.org/r/20260528022943.1697564-1-guanghuifeng@linux= .alibaba.com Signed-off-by: Lu Baolu --- drivers/iommu/intel/dmar.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c index d33c119a935e..767ec092accd 100644 --- a/drivers/iommu/intel/dmar.c +++ b/drivers/iommu/intel/dmar.c @@ -1894,7 +1894,8 @@ static int dmar_fault_do_one(struct intel_iommu *iomm= u, int type, reason =3D dmar_get_fault_reason(fault_reason, &fault_type); =20 if (fault_type =3D=3D INTR_REMAP) { - pr_err("[INTR-REMAP] Request device [%02x:%02x.%d] fault index 0x%llx [f= ault reason 0x%02x] %s\n", + pr_err("[INTR-REMAP] Request device [%04x:%02x:%02x.%d] fault index 0x%l= lx [fault reason 0x%02x] %s\n", + iommu->segment, source_id >> 8, PCI_SLOT(source_id & 0xFF), PCI_FUNC(source_id & 0xFF), addr >> 48, fault_reason, reason); @@ -1903,14 +1904,16 @@ static int dmar_fault_do_one(struct intel_iommu *io= mmu, int type, } =20 if (pasid =3D=3D IOMMU_PASID_INVALID) - pr_err("[%s NO_PASID] Request device [%02x:%02x.%d] fault addr 0x%llx [f= ault reason 0x%02x] %s\n", + pr_err("[%s NO_PASID] Request device [%04x:%02x:%02x.%d] fault addr 0x%l= lx [fault reason 0x%02x] %s\n", type ? "DMA Read" : "DMA Write", + iommu->segment, source_id >> 8, PCI_SLOT(source_id & 0xFF), PCI_FUNC(source_id & 0xFF), addr, fault_reason, reason); else - pr_err("[%s PASID 0x%x] Request device [%02x:%02x.%d] fault addr 0x%llx = [fault reason 0x%02x] %s\n", + pr_err("[%s PASID 0x%x] Request device [%04x:%02x:%02x.%d] fault addr 0x= %llx [fault reason 0x%02x] %s\n", type ? "DMA Read" : "DMA Write", pasid, + iommu->segment, source_id >> 8, PCI_SLOT(source_id & 0xFF), PCI_FUNC(source_id & 0xFF), addr, fault_reason, reason); --=20 2.43.0 From nobody Mon Jun 8 05:24:55 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 C09693D6CBB for ; Thu, 4 Jun 2026 06:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780553141; cv=none; b=PfO0UKbUCjgbcuU0t2XDfeBsQtxbUCWu/geRJVgnU8H+nVsxmJiMSL7Wp7hvmkttsiG3J+9i6xu0hTp2mgyzn1UGxLFvENBfNHkJNIGtPy62ALIHKDVd9j1lzfTJGOOtc6UNT4XTKx3GY9IgjdYp7676xdMuHp12EWp2gb+UtpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780553141; c=relaxed/simple; bh=D3dEDDoT3aHbpPxK4hEFaV8P3ei5CFxGflWpK+in12E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kOTYuiX6cJmVOAMr9aRg20XoHgHuqr9KGoYMKY8lzQpHciGdVOhR1OV9Gqy8pLkT3uRGWqIfOp1qy/87umWeB/YfbMmY1upjq4VEo94wfTblQ7iTNeOwhCW1BUM1QyvaLshX9WfA52+xD6G8K7q1iF4rcLB9p2l/r6akkOiyT3o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HoUvFCmv; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HoUvFCmv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1780553140; x=1812089140; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D3dEDDoT3aHbpPxK4hEFaV8P3ei5CFxGflWpK+in12E=; b=HoUvFCmvE50iCc0L1p2WDmkxuBnoPBXuGG1U5W9Nv1VKiaxRx0WSlQiK zz2uHBCTRZjqeW6gRoQU1CyrcOwEpKb5roalhfWp5VfxCKIo86MAPTu25 gWJbflWKqt9YBfYOx3BkJHzuAvjIR/7zCtdvb+83e1kCYw6uDP6fypHn5 BhQVijEsuKQKr0cEG8z8f1Vqrz47XqZmJsQz+xWSpz/8oPXyNT8z1FUwY vctvD5LqsBT2FTX+kf0JkOgxrUCmzJ9Ly7axphTlE9SMUVufvLvIUXFuy RgSDy02HuoG69MHQwbmlzZGmBjpYXk0OK/AqVCqCEzeCnHfY2JMg8Sshi A==; X-CSE-ConnectionGUID: rn8Np8lARE6BFF5I8FgEFA== X-CSE-MsgGUID: AeT7Bx6OS9SbhIpqnDl5WA== X-IronPort-AV: E=McAfee;i="6800,10657,11806"; a="81554262" X-IronPort-AV: E=Sophos;i="6.24,186,1774335600"; d="scan'208";a="81554262" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2026 23:05:40 -0700 X-CSE-ConnectionGUID: gT6dt4HMTXqG3sEObwqJjw== X-CSE-MsgGUID: wb79acpnQP+XGRs1KBH2ZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,186,1774335600"; d="scan'208";a="268112170" Received: from allen-box.sh.intel.com ([10.239.159.52]) by fmviesa002.fm.intel.com with ESMTP; 03 Jun 2026 23:05:38 -0700 From: Lu Baolu To: Joerg Roedel Cc: Pranjal Shrivastava , Guanghui Feng , =?UTF-8?q?Micha=C5=82=20Grzelak?= , Michael Bommarito , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/5] iommu/vt-d: Fix RB-tree corruption in probe error path Date: Thu, 4 Jun 2026 14:03:10 +0800 Message-ID: <20260604060311.365074-6-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604060311.365074-1-baolu.lu@linux.intel.com> References: <20260604060311.365074-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Pranjal Shrivastava The info->node RB-tree member is zero-initialized via kzalloc. If a device does not support ATS, the device_rbtree_insert() call is skipped. If a subsequent probe step fails, the error path jumps to device_rbtree_remove(), which misinterprets the zeroed node as a tree root and corrupts the device RB-tree. Fix this by explicitly initializing the RB-node as empty using RB_CLEAR_NODE() during initialization and guarding the removal with RB_EMPTY_NODE(). Fixes: 4f1492efb495 ("iommu/vt-d: Revert ATS timing change to fix boot fail= ure") Reported-by: sashiko-bot@kernel.org Closes: https://lore.kernel.org/all/20260525205628.CD4431F000E9@smtp.kernel= .org/ Suggested-by: Baolu Lu Signed-off-by: Pranjal Shrivastava Link: https://lore.kernel.org/r/20260531170254.60493-2-praan@google.com Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 4d0e65bc131d..849d06dfe1ae 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -157,7 +157,10 @@ static void device_rbtree_remove(struct device_domain_= info *info) unsigned long flags; =20 spin_lock_irqsave(&iommu->device_rbtree_lock, flags); - rb_erase(&info->node, &iommu->device_rbtree); + if (!RB_EMPTY_NODE(&info->node)) { + rb_erase(&info->node, &iommu->device_rbtree); + RB_CLEAR_NODE(&info->node); + } spin_unlock_irqrestore(&iommu->device_rbtree_lock, flags); } =20 @@ -3254,6 +3257,7 @@ static struct iommu_device *intel_iommu_probe_device(= struct device *dev) =20 info->dev =3D dev; info->iommu =3D iommu; + RB_CLEAR_NODE(&info->node); if (dev_is_pci(dev)) { if (ecap_dev_iotlb_support(iommu->ecap) && pci_ats_supported(pdev) && --=20 2.43.0