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=nCQhn091y//khQwgCNCgc67M68uCG5g/e1MoSoJgiLnmOVLFq3CIPHasCgsBrn1xWxnd nq93M+aH4VxSVhEyfHwyqceoeMa8LH6Zg8TV943YXeyobrpCbA8ee1IK7iLkiegQZkDrC RZokLtHv4mIgMfIAy6LjZ8YHDHwwqsE7Ynj7nG7A2hKPtAr1aAu+8l2nEWgvEPk9YOKcC 4Hllma8YN4aph8mIOV1Bkbocq8FCJP0/0diSdiCwmNQ3IsJX9sWtiMB15cF3kgwJ1H3d3 RDuNXEKSbB7SLURc2Ov2xa2+sia1RVhONBtoRmXAGZK73VM0pTCeNk7CnHMHbNFtK0g== 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=oodKbeZbTIC6wbBPlecMseGejWD/VqEwUiAoAAMyt2d44JA5yfhvM0d7GUED7K612Co8 5P3TvUR69eIhl8ai2zRW1/xa27vkCvE7AigoVVtpwKJAHEu0DpIwOrcuY+uyl8IH7pC2i LUqX6Blvc6RUXAJ7GMGNHdKKNTyMazEzoeIME4md85WbbRz/Wd0RjBTMDe7ONpITmxZ98 3TIzUvOZIojU48BolnAiH3srCNEJR93HA4ssRujFIsZJIZGuMiVeURblaQWgnFTx0USvc EeCXvjKLvSS6ubH4GAbffzsKVj07hgz3z/4S8bCB66yF3P/83eHc/KLC5xFhhFoJjxQ== 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 ECD75606A322 for ; Wed, 2 Dec 2026 05:58:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ECD75606A322 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) 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: r7WMmKJuRaqm8/QjDHNZ+Q== X-CSE-MsgGUID: GSWnM22kSXqPhBciQ/9DoA== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5035871" X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="5035871" 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: iommu@lists.linux.dev 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