From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: zhichao.gao@intel.com) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by groups.io with SMTP; Wed, 08 May 2019 20:34:16 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 May 2019 20:34:16 -0700 X-ExtLoop1: 1 Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga006.fm.intel.com with ESMTP; 08 May 2019 20:34:15 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jiewen Yao , Chasel Chiu , Ray Ni , Rangasai V Chaganty Subject: [PATCH V2] IntelSiliconPkg/IntelVTdDxe: Do global invalidation before boot Date: Thu, 9 May 2019 11:33:52 +0800 Message-Id: <20190509033352.26296-1-zhichao.gao@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1547 V2: Abandon V1. Do global invalidation of context-cache and IOTLB at ExitBootServices. V1: Only doing IOTLB invalidation would cause a BSOD 'DRIVER_VERIFIER_DMA_VIOLATION' while changing the second level page entry's attributes. So always do the global invalidation of context-cache and IOTLB. Cc: Jiewen Yao Cc: Chasel Chiu Cc: Ray Ni Cc: Rangasai V Chaganty Signed-off-by: Zhichao Gao --- .../Feature/VTd/IntelVTdDxe/DmaProtection.c | 13 +++++++- .../Feature/VTd/IntelVTdDxe/DmaProtection.h | 32 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c index f221e45938..956ebb2d3d 100644 --- a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c +++ b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -581,9 +581,20 @@ OnExitBootServices ( IN VOID *Context ) { + UINTN VtdIndex; + DEBUG ((DEBUG_INFO, "Vtd OnExitBootServices\n")); DumpVtdRegsAll (); + DEBUG ((DEBUG_INFO, "Invalidate all\n")); + for (VtdIndex = 0; VtdIndex < mVtdUnitNumber; VtdIndex++) { + FlushWriteBuffer (VtdIndex); + + InvalidateContextCache (VtdIndex); + + InvalidateIOTLB (VtdIndex); + } + if ((PcdGet8(PcdVTdPolicyPropertyMask) & BIT1) == 0) { DisableDmar (); DumpVtdRegsAll (); diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h index 72426d23c3..a3331db8f7 100644 --- a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h +++ b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -168,6 +168,36 @@ DisableDmar ( VOID ); +/** + Flush VTd engine write buffer. + + @param[in] VtdIndex The index used to identify a VTd engine. +**/ +VOID +FlushWriteBuffer ( + IN UINTN VtdIndex + ); + +/** + Invalidate VTd context cache. + + @param[in] VtdIndex The index used to identify a VTd engine. +**/ +EFI_STATUS +InvalidateContextCache ( + IN UINTN VtdIndex + ); + +/** + Invalidate VTd IOTLB. + + @param[in] VtdIndex The index used to identify a VTd engine. +**/ +EFI_STATUS +InvalidateIOTLB ( + IN UINTN VtdIndex + ); + /** Invalid VTd global IOTLB. -- 2.21.0.windows.1