From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.10 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796191099; b=kdi0AbBi4+KwuWavh2I9rqpEbwy78t1PWNjcBKKm4qRpB6EnBUyE3FydBSZATv+lVgf1 nGBYRvBpG4llK7Pt2RGbweMElynUtU+km5vJh7J5BUrriYRYVJ2+YSoxQirQQf8UvdrvW TcZkomE3xoYD3ZEgMP4Z5MJ8Wxy4wYDBKnaPOfvhbcyoBaHmhJ8opcEzvJHPDiDvku1y0 tPIrfSDpGNvJk4WQsQ8mRAtdRLPymgR/I4oJgyVvWeMzm6/M+Tm7opl0vPID73V3UDs3s qdGf0g8WSGlO6kmXPEzxQp1RyEAz1Bb6zGr7tkpJB+OzzWqJrd7nl0lZuz920RG9lMg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796191099; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Message-ID:Date: MIME-Version:User-Agent:Cc:Subject:To:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=vrWfYm9RgLJpWVG/KoDdZYksM0zPFf7/SzsHq6rEQx8=; b=jE6s1kXAMSwBHzQOc+AZds17T/fIC3fD519C87dGJRs6tAOAuhcRJC+DDaZrh8mWpCXu uySMBg7EEPoQO8xQ0RT9aX2YvvbjP4UJxVIUbRydrYA8Kj5s/sajaF3f7v0oVhfUP540U IRoxVlcW7yypqIzEzMAHZug31TExx32XK2uHoosk2S0HK/JGYhlhxb1TRsVXaIDxbwELn 7uUmVkZV8jJqcCmiLnUK/kOafpjE4Lidok07Ccn79FEfcxZBNabvuYHrMGeQTnofQEy8z lozvvvynQW2RMF6zoof5PO3sq2tUw1gdjKJt30alaPOA9DGh207QiG6p1Hjwp4628fw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=AIVqAPZ8; arc=none smtp.remote-ip=198.175.65.10 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA070606A31A for ; Wed, 2 Dec 2026 05:58:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EA070606A31A 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, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=AIVqAPZ8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796191099; x=1827727099; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=vrWfYm9RgLJpWVG/KoDdZYksM0zPFf7/SzsHq6rEQx8=; b=AIVqAPZ8QmoMblzGt9DcCq/9R5tA7xYpoIIpCwGtlGdwUGhbzE5dEcZY PmhZvBVBhoqzGJSyoWOeUD+Wyryi9+nBShtP7whj2YklOxYz4rshLFUB4 LF8PTqQkJ+SUXkUmS8DBTF+bXiK0K5oEAkG6ZCXoueGPX/Z9AUtMZNxpe inE7+R5QOGeaOn6SZMK33pdZYwnCEyEymySSp8X2UAwEmVttRJuI5oCiy hP31JUK/SfvEDpxHCgWX3X/wWJnIXsTYjyjSkomqs8emGEoW8biHNE3IA v+GztAMursc4I0seU2LPV/aBH2rN0wAYdz1rB1i8HfNtQ9HR5fPyNsvxL Q==; X-CSE-ConnectionGUID: M7A+OlmFRjGz9xP4dzFXgw== X-CSE-MsgGUID: +GsudMTtQxignaShkb3/mQ== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5035869" X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="5035869" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 21:58:18 -0800 X-CSE-ConnectionGUID: FjB3pk28T+ST88EClcL/9g== X-CSE-MsgGUID: r3J+/YGSTJWp/FZHb7O7pg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="13927609" Received: from unknown (HELO [10.238.1.144]) ([10.238.1.144]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 21:58:13 -0800 Message-ID: <5c1bbc21-d148-4d56-b540-28ff32d67035@linux.intel.com> Date: Wed, 2 Dec 2026 13:58:10 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, Ning Sun , Thomas Gleixner , Borislav Petkov , Michal Camacho Romero , x86@kernel.org, iommu@lists.linux.dev, tboot-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Mateusz Mowka , Adam Pawlicki , Pawel Randzio Subject: Re: [PATCH v8 2/2] iommu/vt-d: Disable TXT TPRs before enabling queued invalidation To: Michal Camacho Romero References: <20261029134149.3498677-1-michal.camacho.romero@intel.com> Content-Language: en-US From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 > Signed-off-by: Michal Camacho Romero > --- > 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