Re: [PATCH v8 2/2] iommu/vt-d: Disable TXT TPRs before enabling queued invalidation

From: Baolu Lu

Date: Wed Dec 02 2026 - 00:58:24 EST


On 10/30/2026 7:20 PM, Michal Camacho Romero wrote:
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().

This commit message is not complete. Please add some words explaining
how this change addresses the issue and why it is safe to drop the TPRs
at that point.


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@xxxxxxxxxxxxxxx>
Signed-off-by: Michal Camacho Romero <michal.camacho.romero@xxxxxxxxxxxxxxx>
---
Changes since v7:
- Renamed tboot_free_txt_heap_mem() to tboot_unmap_txt_heap() to match
the rename in patch 1.

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");
+ }

This disables the TPRs during the first dmar_table_init(), which can be
pretty early from the irq remapping setup, while DMA remapping is
enabled only at the end of intel_iommu_init(). In between, nothing
protects memory from inbound DMA. Doesn't that defeat the DMA protection
that the measured launch relies on?

The existing PMR handling avoids this gap by disabling protected memory
regions only after the DMA translation has been enabled.

+
return ret;
}
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 2e3b3ab216f8f..3ad6542f83e41 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");

If the TPR teardown failed, the system has already hung on the first qi
submission, this panic is never reached.

+
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_unmap_txt_heap();

Why does the iommu driver need to care about the txt heap mapping? The
mapping is created inside tboot code, so it should also be released
there. Please keep the txt internals out of the iommu driver; ideally,
it only needs a single tboot hook to drop the TPRs at the right time.

+
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_unmap_txt_heap();
intel_iommu_free_dmars();
up_write(&dmar_global_lock);
return ret;

Thanks,
baolu