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.136, mailfrom: jiewen.yao@intel.com) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by groups.io with SMTP; Wed, 08 May 2019 20:37:15 -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 fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 May 2019 20:37:15 -0700 X-ExtLoop1: 1 Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga006.fm.intel.com with ESMTP; 08 May 2019 20:37:15 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 8 May 2019 20:37:15 -0700 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 8 May 2019 20:37:15 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.249]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.213]) with mapi id 14.03.0415.000; Thu, 9 May 2019 11:37:13 +0800 From: "Yao, Jiewen" To: "Gao, Zhichao" , "devel@edk2.groups.io" CC: "Chiu, Chasel" , "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: AQHVBhgWfRK6xzej/kCPqWjYZNq8k6ZiJLvg Date: Thu, 9 May 2019 03:37:12 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503F63575E@shsmsx102.ccr.corp.intel.com> References: <20190509033352.26296-1-zhichao.gao@intel.com> In-Reply-To: <20190509033352.26296-1-zhichao.gao@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZWJkOGZkNzItNTU0Ny00ZDFhLTk2MDMtZGRlN2FjZjc5YmNjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiVGsxNVlZN2hyc2lvMDVRM1hLTThYSEtsMGVCMjdZSjZGYjNKMm9MNXpSa1VoZ2MxRDEzRlNzYXg4ZFBiOFcxbCJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: jiewen.yao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Gao, Zhichao > Sent: Wednesday, May 8, 2019 8:34 PM > To: devel@edk2.groups.io > Cc: Yao, Jiewen ; Chiu, Chasel > ; Ni, Ray ; Chaganty, Rangasai V > > Subject: [PATCH V2] IntelSiliconPkg/IntelVTdDxe: Do global invalidation > before 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