From nobody Sat Feb 7 08:43:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+85776+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+85776+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1642493701; cv=none; d=zohomail.com; s=zohoarc; b=KP14M/KVpkUmWmSBsb2RqIKDl3111fDg/Hf2A0PAbVeMJjXgYjWA58YsoNE82YCQM6Yk845YXRkW4VHWg8t+Nil6W3Dhnm+fQ2Pi7RTqlpVygxI2OU1Fb2AAcyWIXdLaiMTUc4Ps++9xKAXt+WHpVMcFpQ1/GiQj6irmdh4G9Ms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642493701; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=tofyCg73srhtIJsWXjYAJZ4AxJHBsmax5JZOwyA3kqU=; b=hoMn6m4Rjlv21X568c9QevxWSu2A9yf9Qkw2QStoKHGxpXlf2rOoxFzoDkw/1yZitCO2DRXEvkwYImHSJPChuTNXCFBELdwtI/0L3yBnW9VrYSErwoMm7l3HfGplOlYLyyacaVpL5ZvMj2I5hP9csQFE1gG5h2qZlwf6FT0/UX4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+85776+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1642493701671583.1169899294039; Tue, 18 Jan 2022 00:15:01 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id uJZvYY1788612xDreZd8b5do; Tue, 18 Jan 2022 00:15:01 -0800 X-Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web08.10054.1642493700408524031 for ; Tue, 18 Jan 2022 00:15:00 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10230"; a="244721679" X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="244721679" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2022 00:14:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="517674512" X-Received: from unknown (HELO shwdeSSSDDPDWEI.ccr.corp.intel.com) ([10.239.157.43]) by orsmga007.jf.intel.com with ESMTP; 18 Jan 2022 00:14:43 -0800 From: "Sheng Wei" To: devel@edk2.groups.io Cc: Ray Ni , Rangasai V Chaganty , Jenny Huang , Robert Kowalewski Subject: [edk2-devel] [PATCH v5 3/4] IntelSiliconPkg/VTd: Support VTd Abort DMA Mode Date: Tue, 18 Jan 2022 16:14:32 +0800 Message-Id: <20220118081433.15620-4-w.sheng@intel.com> In-Reply-To: <20220118081433.15620-1-w.sheng@intel.com> References: <20220118081433.15620-1-w.sheng@intel.com> Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,w.sheng@intel.com X-Gm-Message-State: Gd0JWkqnNBf2xNB57uf4RdcRx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1642493701; bh=jsq+by25vDYHv3E9NElpvMRjibhRD06azkp/rWyjs2A=; h=Cc:Date:From:Reply-To:Subject:To; b=S+ItfoCClOHbXDTUh7k1rUMA2tBISAjIDtQhDRi/dPjjEbc7mb1pCoMS0CUAXhoTY7E l2jjP7djHnk9Lw69La5NCxcBoRWSg6ne7l0bzOMnaKCNH84B8g05I82Ts71UJ1t59kJBh 7zWl+hzGpOedjtMu/TM8Oes8ud9EBc35QVQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1642493702787100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If VTd ECAP_REG.ADMS bit is set, abort DMA mode is supported. When VTd Abort DMA Mode is enabled, hardware will abort all DMA operations without the need to set up a root-table with each entry marked as not-present. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3766 Cc: Ray Ni Cc: Rangasai V Chaganty Cc: Jenny Huang Cc: Robert Kowalewski Reviewed-by: Jenny Huang Signed-off-by: Sheng Wei --- .../Feature/VTd/IntelVTdDmarPei/IntelVTdDmar.c | 43 +++++++++++++-----= ---- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDmarPei/Inte= lVTdDmar.c b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDmarPei/Inte= lVTdDmar.c index 87ce9716..63397a1a 100644 --- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDmarPei/IntelVTdDma= r.c +++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDmarPei/IntelVTdDma= r.c @@ -384,7 +384,7 @@ InvalidateIOTLB ( Enable DMAR translation inpre-mem phase. =20 @param[in] VtdUnitBaseAddress The base address of the VTd engine. - @param[in] RootEntryTable The address of the VTd RootEntryTable. + @param[in] RtaddrRegValue The value of RTADDR_REG. =20 @retval EFI_SUCCESS DMAR translation is enabled. @retval EFI_DEVICE_ERROR DMAR translation is not enabled. @@ -392,15 +392,15 @@ InvalidateIOTLB ( EFI_STATUS EnableDmarPreMem ( IN UINTN VtdUnitBaseAddress, - IN UINTN RootEntryTable + IN UINTN RtaddrRegValue ) { UINT32 Reg32; =20 DEBUG ((DEBUG_INFO, ">>>>>>EnableDmarPreMem() for engine [%x] \n", VtdUn= itBaseAddress)); =20 - DEBUG ((DEBUG_INFO, "RootEntryTable 0x%x \n", RootEntryTable)); - MmioWrite64 (VtdUnitBaseAddress + R_RTADDR_REG, (UINT64) (UINTN) RootEnt= ryTable); + DEBUG ((DEBUG_INFO, "RTADDR_REG : 0x%x \n", RtaddrRegValue)); + MmioWrite64 (VtdUnitBaseAddress + R_RTADDR_REG, (UINT64) RtaddrRegValue); =20 Reg32 =3D MmioRead32 (VtdUnitBaseAddress + R_GSTS_REG); MmioWrite32 (VtdUnitBaseAddress + R_GCMD_REG, Reg32 | B_GMCD_REG_SRTP); @@ -662,18 +662,6 @@ EnableVTdTranslationProtectionAll ( =20 DEBUG ((DEBUG_INFO, "EnableVTdTranslationProtectionAll - 0x%lx\n", Engin= eMask)); =20 - Status =3D PeiServicesLocatePpi ( - &gEdkiiVTdNullRootEntryTableGuid, - 0, - NULL, - (VOID **)&RootEntryTable - ); - if (EFI_ERROR(Status)) { - DEBUG ((DEBUG_ERROR, "Locate Null Root Entry Table Ppi Failed : %r\n",= Status)); - ASSERT (FALSE); - return; - } - for (Index =3D 0; Index < VTdInfo->VTdEngineCount; Index++) { if ((EngineMask & LShiftU64(1, Index)) =3D=3D 0) { continue; @@ -686,7 +674,28 @@ EnableVTdTranslationProtectionAll ( VTdInfo->VtdUnitInfo[Index].ECapReg.Uint64 =3D MmioRead64 (VTdInfo->Vt= dUnitInfo[Index].VtdUnitBaseAddress + R_ECAP_REG); DumpVtdECapRegs (&VTdInfo->VtdUnitInfo[Index].ECapReg); =20 - EnableDmarPreMem (VTdInfo->VtdUnitInfo[Index].VtdUnitBaseAddress, (UIN= TN) *RootEntryTable); + if (VTdInfo->VtdUnitInfo[Index].ECapReg.Bits.ADMS =3D=3D 1) { + // + // Use Abort DMA Mode + // + Status =3D EnableDmarPreMem (VTdInfo->VtdUnitInfo[Index].VtdUnitBase= Address, V_RTADDR_REG_TTM_ADM); + } else { + // + // Use Null Root Entry Table + // + Status =3D PeiServicesLocatePpi ( + &gEdkiiVTdNullRootEntryTableGuid, + 0, + NULL, + (VOID **)&RootEntryTable + ); + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_ERROR, "Locate Null Root Entry Table Ppi Failed : %r= \n", Status)); + ASSERT (FALSE); + return; + } + EnableDmarPreMem (VTdInfo->VtdUnitInfo[Index].VtdUnitBaseAddress, (U= INTN) *RootEntryTable); + } } =20 return; --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#85776): https://edk2.groups.io/g/devel/message/85776 Mute This Topic: https://groups.io/mt/88505120/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-