From: Baolu Lu <baolu.lu@linux.intel.com>
To: Michal Camacho Romero <michal.camacho.romero@linux.intel.com>
Cc: baolu.lu@linux.intel.com, Ning Sun <ning.sun@intel.com>,
Thomas Gleixner <tglx@kernel.org>, Borislav Petkov <bp@alien8.de>,
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>
Subject: Re: [PATCH v8 2/2] iommu/vt-d: Disable TXT TPRs before enabling queued invalidation
Date: Wed, 2 Dec 2026 13:58:10 +0800 [thread overview]
Message-ID: <5c1bbc21-d148-4d56-b540-28ff32d67035@linux.intel.com> (raw)
In-Reply-To: <c7c6a9e88e0ce6ef0e4bf868b87e1f388b04bc9e.1793357321.git.michal.camacho.romero@linux.intel.com>
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@linux.intel.com>
> Signed-off-by: Michal Camacho Romero <michal.camacho.romero@linux.intel.com>
> ---
> 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
prev parent reply other threads:[~2026-12-02 5:58 UTC|newest]
Thread overview: 32+ 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-10-30 11:18 ` [PATCH v8 " Michal Camacho Romero
2026-10-30 14:32 ` [PATCH v9] " Michal Camacho Romero
2026-12-02 3:52 ` Sun, Ning
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 ` [PATCH v7 2/2] iommu/vt-d: Disable TXT TPRs before enabling queued invalidation Michal Camacho Romero
2026-10-30 11:20 ` [PATCH v8 " Michal Camacho Romero
2026-12-02 5:58 ` Baolu Lu [this message]
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=5c1bbc21-d148-4d56-b540-28ff32d67035@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=adamx.pawlicki@intel.com \
--cc=bp@alien8.de \
--cc=iommu@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mateusz.mowka@intel.com \
--cc=michal.camacho.romero@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.