From: Michal Camacho Romero <michal.camacho.romero@intel.com>
To: Lu Baolu <baolu.lu@linux.intel.com>
Cc: Ning Sun <ning.sun@intel.com>, Thomas Gleixner <tglx@kernel.org>,
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 14:41:49 +0100 [thread overview]
Message-ID: <20261029134149.3498677-1-michal.camacho.romero@intel.com> (raw)
In-Reply-To: <3a78df93-845a-4432-8aa1-fc4939f4f400@linux.intel.com>
From: Michal Camacho Romero <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>
---
Changes since v6:
- Retitled from "iommu/vt-d: Disable PMRs and skip force-IOMMU when TXT
TPRs are active", reflecting a substantially reworked approach:
* TPRs are now torn down early in parse_dmar_table(), before any
dmar_enable_qi() (the real fix for the IQE boot hang on IR/x2apic
systems), instead of in intel_iommu_init() after translation is
enabled.
* tboot_force_iommu() is no longer modified. The IOMMU is forced on
exactly as before, so booting intel_iommu=off on a TPR-capable
platform behaves as upstream.
* All TPR/DTPR/txt_heap states are kept internal to tboot.c. The IOMMU
driver now uses only parameterless helpers (tboot_check_tprs(),
tboot_teardown_tprs(), tboot_is_tpr_protection_enabled(),
tboot_free_txt_heap_mem()). All TBOOT state leaks into the driver
have been eliminated.
* TPR teardown runs only on a successful DMAR table parse.
* Using intel_iommu=tboot_noforce now suppresses the TPR-related panic.
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
---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach handlowych.
Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.
next prev parent reply other threads:[~2026-10-29 13:43 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 11:44 [PATCH v1 0/2] x86/tboot: Add Intel TXT Protection Regions (TPR) support Michal Camacho Romero
2026-06-03 11:44 ` [PATCH v1 1/2] x86/tboot: Add support for parsing DTPR table and disabling TPRs Michal Camacho Romero
2026-09-14 13:19 ` [PATCH v2 " Michal Camacho Romero
2026-09-15 23:23 ` Sun, Ning
2026-09-17 9:41 ` [PATCH 1/1] " Michal Camacho Romero
2026-09-18 6:45 ` kernel test robot
2026-09-18 7:35 ` kernel test robot
2026-09-17 9:43 ` [PATCH v3 1/2] " Michal Camacho Romero
2026-09-22 10:00 ` [PATCH v4 " michal.camacho.romero
2026-09-23 22:21 ` Sun, Ning
2026-09-30 12:30 ` [PATCH v5 " Michal Camacho Romero
2026-10-05 18:37 ` Sun, Ning
2026-10-12 9:35 ` [PATCH v6 " Michal Camacho Romero
2026-10-27 16:13 ` Sun, Ning
2026-10-29 13:40 ` [PATCH v7 " Michal Camacho Romero
2026-06-03 11:45 ` [PATCH v1 2/2] iommu/vt-d: Disable PMRs and skip force-IOMMU when TXT TPRs are active Michal Camacho Romero
2026-06-11 8:49 ` Baolu Lu
2026-08-07 9:16 ` [PATCH v2 " Michal Camacho Romero
2026-08-07 10:14 ` Michal Camacho Romero
2026-08-20 3:28 ` Baolu Lu
2026-09-03 9:33 ` [PATCH v3 " Michal Camacho Romero
2026-09-04 2:19 ` Baolu Lu
2026-10-01 12:12 ` [PATCH v4 " michal.camacho.romero
2026-10-07 7:11 ` Baolu Lu
2026-10-12 10:22 ` [PATCH v5 " Michal Camacho Romero
2026-10-19 1:30 ` Baolu Lu
2026-10-29 13:41 ` Michal Camacho Romero [this message]
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 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=20261029134149.3498677-1-michal.camacho.romero@intel.com \
--to=michal.camacho.romero@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@linux.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®