From nobody Tue May 7 17:56:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+40236+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40236+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1557372857; cv=none; d=zoho.com; s=zohoarc; b=UhCKXbUOs38xJUvOVxb4UrksZafzULyvUhost2+rbk92PYPcWSGOEwpgFUq0/3ToWk03L4Qpurf7R1eMgPJZuHfDA/OgH/1w5TwY6vrLIfDVfhbeYNoMoOgUDL/cxfW2IsOBJD/dUBFIpiccDhYEHFRxpqRQue9VdIGx6WqV6O4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557372857; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=fasYHposXuZE8n95wgVImn95CAJdFBqnAIZDky79fwo=; b=ZE5JAQvsLlUFxfBau4W/8W3c8qacU5ebEjo+lkPeuAsZjkEXCq2lGkPyPG1z9OMEOC+VLPB+84vKmj7h3SDJkzzEbMuneSp369MjafxjqnSHv8gJvWinUMFV1ND870KOoLPxg66SKbj5juM6fH4GuEhOVBOWHas/uroU8fd1nE8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+40236+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1557372857300330.9058693934493; Wed, 8 May 2019 20:34:17 -0700 (PDT) Return-Path: X-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 X-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 X-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: [edk2-devel] [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> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,zhichao.gao@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1557372856; bh=SnDmogmc3euAHL0Nkth0w0k/OLtbJASFYX7q3HgD7DE=; h=Cc:Date:From:Reply-To:Subject:To; b=t4ohcRhcHbomjzJ+6L5B+uXsGZZPhXjonkkRdtt2JE+9q02WdNlD+V+2clHQef7LMZH Rm0xsJpdpNhycCcGQXWPC5Q12q8QiOt5hBodC2Lqe4cUC+UChu1f2S/tcKAGxkjbGxVhW O7+D50VZbsdhJ0mnkHzN8ihaKqBJlq2uJNc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1547 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 Reviewed-by: Chasel Chiu Reviewed-by: Jiewen.yao@intel.com --- .../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/Inte= lSiliconPkg/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 =20 - 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 =20 **/ @@ -581,9 +581,20 @@ OnExitBootServices ( IN VOID *Context ) { + UINTN VtdIndex; + DEBUG ((DEBUG_INFO, "Vtd OnExitBootServices\n")); DumpVtdRegsAll (); =20 + DEBUG ((DEBUG_INFO, "Invalidate all\n")); + for (VtdIndex =3D 0; VtdIndex < mVtdUnitNumber; VtdIndex++) { + FlushWriteBuffer (VtdIndex); + + InvalidateContextCache (VtdIndex); + + InvalidateIOTLB (VtdIndex); + } + if ((PcdGet8(PcdVTdPolicyPropertyMask) & BIT1) =3D=3D 0) { DisableDmar (); DumpVtdRegsAll (); diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.h b/Inte= lSiliconPkg/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 =20 - 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 =20 **/ @@ -168,6 +168,36 @@ DisableDmar ( VOID ); =20 +/** + 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. =20 --=20 2.21.0.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 (#40236): https://edk2.groups.io/g/devel/message/40236 Mute This Topic: https://groups.io/mt/31551351/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-