From: Michal Camacho Romero <michal.camacho.romero@linux.intel.com>
To: Lu Baolu <baolu.lu@linux.intel.com>,
Thomas Gleixner <tglx@kernel.org>, Ning Sun <ning.sun@intel.com>
Cc: Michal Camacho Romero <michal.camacho.romero@intel.com>,
x86@kernel.org, iommu@lists.linux.dev,
tboot-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org,
Mateusz Mowka <mateusz.mowka@intel.com>,
Adam Pawlicki <adamx.pawlicki@intel.com>,
Pawel Randzio <pawel.randzio@intel.com>,
Michal Camacho Romero <michal.camacho.romero@linux.intel.com>
Subject: [PATCH v7 2/2] iommu/vt-d: Disable TXT TPRs before enabling queued invalidation
Date: Thu, 29 Oct 2026 12:57:27 +0100 [thread overview]
Message-ID: <fa4cf46c2f7613806c47f7c39bd05980b7b0024e.1793273244.git.michal.camacho.romero@linux.intel.com> (raw)
In-Reply-To: <cover.1793273244.git.michal.camacho.romero@linux.intel.com>
When the SINIT ACM establishes TXT Protection Regions (TPRs), they block
all inbound DMA to their protected range, including the IOMMU's own
queued invalidation (QI) ring. If the TPRs are still active when QI is
first enabled, the first invalidation faults with an Invalidation Queue
Error and the boot hangs. On systems with interrupt remapping enabled
this happens very early, in intel_setup_irq_remapping() ->
dmar_enable_qi(), well before init_dmars().
Link: https://uefi.org/sites/default/files/resources/633933_Intel_TXT_DMA_Protection_Ranges_rev_0p73.pdf
Link: https://cdrdv2-public.intel.com/315168/315168_TXT_MLE_DG_rev_017_7.pdf
Tested-by: Michal Camacho Romero <michal.camacho.romero@linux.intel.com>
Signed-off-by: Michal Camacho Romero <michal.camacho.romero@linux.intel.com>
---
drivers/iommu/intel/dmar.c | 19 +++++++++++++++++++
drivers/iommu/intel/iommu.c | 18 ++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
index ba675b08cd208..5e59aa46721e6 100644
--- a/drivers/iommu/intel/dmar.c
+++ b/drivers/iommu/intel/dmar.c
@@ -675,6 +675,25 @@ parse_dmar_table(void)
if (ret == 0 && drhd_count == 0)
pr_warn(FW_BUG "No DRHD structure found in DMAR table\n");
+ /*
+ * Only on a successful DMAR parse: if SINIT programmed TXT TPRs for DMA
+ * protection, disable them here, before any queued invalidation (QI) is
+ * enabled. TPRs block all inbound DMA to their protected range, including
+ * the IOMMU's own QI ring, so leaving them active makes the first queued
+ * invalidation fault (Invalidation Queue Error) and hangs the boot on any
+ * system with interrupt remapping enabled.
+ *
+ * If parsing failed, dmar_table_init() propagates the error and both the
+ * IOMMU and IRQ remmaping preparation will be aborted, before QI will
+ * be enabled, so the TPRs are left in place and SINIT's DMA protection
+ * will be retained.
+ */
+ if (ret == 0 && tboot_enabled()) {
+ tboot_check_tprs();
+ if (tboot_teardown_tprs() != 0)
+ pr_warn("tboot: Failed to disable TPRs. DMA is still blocked.\n");
+ }
+
return ret;
}
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 2e3b3ab216f8f..8cb9096b8d732 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -2648,6 +2648,15 @@ int __init intel_iommu_init(void)
init_no_remapping_devices();
+ /*
+ * SINIT TPRs (if any were active) should be already torn down during DMAR
+ * Table parsing process. If the teardown failed, DMA (including the IOMMU's
+ * own QI ring) is still blocked, so refuse to continue a forced launch
+ * rather than hang mid-init.
+ */
+ if (tboot_is_tpr_protection_enabled() && !intel_iommu_tboot_noforce)
+ panic("tboot: Failed to disable TPRs. DMA is still blocked.\n");
+
ret = init_dmars();
if (ret) {
if (dmar_policy_force_on())
@@ -2698,6 +2707,14 @@ int __init intel_iommu_init(void)
iommu_disable_protect_mem_regions(iommu);
}
+
+ /*
+ * Release the TXT heap mapping if it is still held. TPRs (and the
+ * heap) are normally torn down in parse_dmar_table(); this is a
+ * safety net for paths where no TPRs were active.
+ */
+ tboot_free_txt_heap_mem();
+
up_read(&dmar_global_lock);
pr_info("Intel(R) Virtualization Technology for Directed I/O\n");
@@ -2707,6 +2724,7 @@ int __init intel_iommu_init(void)
return 0;
out_free_dmar:
+ tboot_free_txt_heap_mem();
intel_iommu_free_dmars();
up_write(&dmar_global_lock);
return ret;
--
2.43.0
next prev parent reply other threads:[~2026-10-29 11:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 11:57 [PATCH v7 0/2] x86/tboot: Add Intel TXT Protection Regions (TPR) support Michal Camacho Romero
2026-10-29 11:57 ` [PATCH v7 1/2] x86/tboot: Add support for parsing DTPR table and disabling TPRs Michal Camacho Romero
2026-10-29 11:57 ` Michal Camacho Romero [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-10-19 1:30 [PATCH v5 2/2] iommu/vt-d: Disable PMRs and skip force-IOMMU when TXT TPRs are active Baolu Lu
2026-10-29 13:41 ` [PATCH v7 2/2] iommu/vt-d: Disable TXT TPRs before enabling queued invalidation Michal Camacho Romero
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=fa4cf46c2f7613806c47f7c39bd05980b7b0024e.1793273244.git.michal.camacho.romero@linux.intel.com \
--to=michal.camacho.romero@linux.intel.com \
--cc=adamx.pawlicki@intel.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mateusz.mowka@intel.com \
--cc=michal.camacho.romero@intel.com \
--cc=ning.sun@intel.com \
--cc=pawel.randzio@intel.com \
--cc=tboot-devel@lists.sourceforge.net \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®