From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: chasel.chiu@intel.com) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by groups.io with SMTP; Wed, 08 May 2019 21:59:53 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 May 2019 21:59:52 -0700 X-ExtLoop1: 1 Received: from pgsmsx107.gar.corp.intel.com ([10.221.44.105]) by orsmga006.jf.intel.com with ESMTP; 08 May 2019 21:59:51 -0700 Received: from pgsmsx109.gar.corp.intel.com (10.221.44.109) by PGSMSX107.gar.corp.intel.com (10.221.44.105) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 9 May 2019 12:59:50 +0800 Received: from pgsmsx111.gar.corp.intel.com ([169.254.2.74]) by PGSMSX109.gar.corp.intel.com ([169.254.14.210]) with mapi id 14.03.0415.000; Thu, 9 May 2019 12:59:50 +0800 From: "Chiu, Chasel" To: "Gao, Zhichao" , "devel@edk2.groups.io" CC: "Yao, Jiewen" , "Ni, Ray" , "Chaganty, Rangasai V" Subject: Re: [PATCH V2] IntelSiliconPkg/IntelVTdDxe: Do global invalidation before boot Thread-Topic: [PATCH V2] IntelSiliconPkg/IntelVTdDxe: Do global invalidation before boot Thread-Index: AQHVBhgXTPnuzFX6nE6YHjxkgThRZKZiO7Dg Date: Thu, 9 May 2019 04:59:49 +0000 Message-ID: <3C3EFB470A303B4AB093197B6777CCEC5030A352@PGSMSX111.gar.corp.intel.com> References: <20190509033352.26296-1-zhichao.gao@intel.com> In-Reply-To: <20190509033352.26296-1-zhichao.gao@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTBmNmM2OGYtYjRhNi00MzhhLWI1MjEtZTA1ZTIwYWEyYjFjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoieFkyYkxLbllTS0l1bGc2OFdmUGV5RWNUZFc0bG4wcG5ySDBPc0dxaTI1anVub2d4V1V2dk9XTGpkT1VuaGRDeSJ9 x-ctpclassification: CTP_NT x-originating-ip: [172.30.20.206] MIME-Version: 1.0 Return-Path: chasel.chiu@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Chasel Chiu > -----Original Message----- > From: Gao, Zhichao > Sent: Thursday, May 9, 2019 11:34 AM > To: devel@edk2.groups.io > Cc: Yao, Jiewen ; Chiu, Chasel ; > Ni, Ray ; Chaganty, Rangasai V > > Subject: [PATCH V2] IntelSiliconPkg/IntelVTdDxe: Do global invalidation b= efore > boot >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1547 >=20 > V2: > Abandon V1. > Do global invalidation of context-cache and IOTLB at ExitBootServices. >=20 > 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. >=20 > 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(-) >=20 > 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 >=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/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 >=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 > -- > 2.21.0.windows.1