From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C6CA020945BFA for ; Wed, 13 Sep 2017 23:07:30 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Sep 2017 23:10:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,391,1500966000"; d="scan'208";a="1172089409" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga001.jf.intel.com with ESMTP; 13 Sep 2017 23:10:28 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 13 Sep 2017 23:10:28 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 13 Sep 2017 23:10:28 -0700 Received: from shsmsx151.ccr.corp.intel.com ([169.254.3.98]) by shsmsx102.ccr.corp.intel.com ([169.254.2.39]) with mapi id 14.03.0319.002; Thu, 14 Sep 2017 14:10:24 +0800 From: "Zeng, Star" To: "Yao, Jiewen" , "edk2-devel@lists.01.org" CC: "Zeng, Star" Thread-Topic: [PATCH 04/11] IntelSiliconPkg/VTdDxe: Disable PMR Thread-Index: AQHTKLPCe8Cw2FMzPkmKHFIp22ODcaKz5OFw//+BxACAAIc7AA== Date: Thu, 14 Sep 2017 06:10:24 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9527F3@SHSMSX151.ccr.corp.intel.com> References: <1504883034-22060-1-git-send-email-jiewen.yao@intel.com> <1504883034-22060-5-git-send-email-jiewen.yao@intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B952715@SHSMSX151.ccr.corp.intel.com> <74D8A39837DF1E4DA445A8C0B3885C503A9B245E@SHSMSX151.ccr.corp.intel.com> In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503A9B245E@SHSMSX151.ccr.corp.intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 04/11] IntelSiliconPkg/VTdDxe: Disable PMR X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Sep 2017 06:07:31 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Then, if there is a driver wants to do DMA at early DXE, it must need a PEI= M to allocate the DMA buffers in PEI and transfer them to DXE by HOB. Is that what we want? I want to confirm that. Thanks, Star -----Original Message----- From: Yao, Jiewen=20 Sent: Thursday, September 14, 2017 2:03 PM To: Zeng, Star ; edk2-devel@lists.01.org Subject: RE: [PATCH 04/11] IntelSiliconPkg/VTdDxe: Disable PMR I did consider that before. I do not disable at EndOfPei purposely that because I want to make sure tha= t the DMA protect is still available in early DXE phase, just in case there= is bug in other module which forgets disabling BME. Later it is VTdDxe driver that disable PME, *after* it sets up translation = table. As such, the DMA protection is always there. Thank you Yao Jiewen > -----Original Message----- > From: Zeng, Star > Sent: Thursday, September 14, 2017 1:36 PM > To: Yao, Jiewen ; edk2-devel@lists.01.org > Cc: Zeng, Star > Subject: RE: [PATCH 04/11] IntelSiliconPkg/VTdDxe: Disable PMR >=20 > A minor comment. >=20 > Should or need IntelVTdPmrPei disable PMR at endofpei? >=20 >=20 > Thanks, > Star > -----Original Message----- > From: Yao, Jiewen > Sent: Friday, September 8, 2017 11:04 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star > Subject: [PATCH 04/11] IntelSiliconPkg/VTdDxe: Disable PMR >=20 > When VTd translation is enabled, PMR can be disable. > Or the DMA will be blocked by PMR. >=20 > Cc: Star Zeng > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jiewen Yao > --- > IntelSiliconPkg/IntelVTdDxe/VtdReg.c | 51 +++++++++++++++++++- > 1 file changed, 50 insertions(+), 1 deletion(-) >=20 > diff --git a/IntelSiliconPkg/IntelVTdDxe/VtdReg.c > b/IntelSiliconPkg/IntelVTdDxe/VtdReg.c > index 7402d81..1404af7 100644 > --- a/IntelSiliconPkg/IntelVTdDxe/VtdReg.c > +++ b/IntelSiliconPkg/IntelVTdDxe/VtdReg.c > @@ -196,6 +196,39 @@ PrepareVtdConfig ( } >=20 > /** > + Disable PMR in all VTd engine. > +**/ > +VOID > +DisablePmr ( > + VOID > + ) > +{ > + UINT32 Reg32; > + VTD_CAP_REG CapReg; > + UINTN Index; > + > + DEBUG ((DEBUG_INFO,"DisablePmr\n")); for (Index =3D 0; Index <=20 > + mVtdUnitNumber; Index++) { > + CapReg.Uint64 =3D MmioRead64 > (mVtdUnitInformation[Index].VtdUnitBaseAddress + R_CAP_REG); > + if (CapReg.Bits.PLMR =3D=3D 0 || CapReg.Bits.PHMR =3D=3D 0) { > + continue ; > + } > + > + Reg32 =3D MmioRead32 (mVtdUnitInformation[Index].VtdUnitBaseAddress= =20 > + + > R_PMEN_ENABLE_REG); > + if ((Reg32 & BIT0) !=3D 0) { > + MmioWrite32 (mVtdUnitInformation[Index].VtdUnitBaseAddress + > R_PMEN_ENABLE_REG, 0x0); > + do { > + Reg32 =3D MmioRead32 > (mVtdUnitInformation[Index].VtdUnitBaseAddress + R_PMEN_ENABLE_REG); > + } while((Reg32 & BIT0) !=3D 0); > + DEBUG ((DEBUG_INFO,"Pmr(%d) disabled\n", Index)); > + } else { > + DEBUG ((DEBUG_INFO,"Pmr(%d) not enabled\n", Index)); > + } > + } > + return ; > +} > + > +/** > Enable DMAR translation. >=20 > @retval EFI_SUCCESS DMAR translation is enabled. > @@ -259,6 +292,11 @@ EnableDmar ( > DEBUG ((DEBUG_INFO,"VTD (%d) enabled!<<<<<<\n",Index)); > } >=20 > + // > + // Need disable PMR, since we already setup translation table. > + // > + DisablePmr (); > + > mVtdEnabled =3D TRUE; >=20 > return EFI_SUCCESS; > @@ -502,7 +540,7 @@ DumpVtdIfError ( > for (Index =3D 0; Index < (UINTN)CapReg.Bits.NFR + 1; Index++) { > FrcdReg.Uint64[0] =3D MmioRead64 > (mVtdUnitInformation[Num].VtdUnitBaseAddress + ((CapReg.Bits.FRO * 16)=20 > + (Index * 16) + R_FRCD_REG)); > FrcdReg.Uint64[1] =3D MmioRead64 > (mVtdUnitInformation[Num].VtdUnitBaseAddress + ((CapReg.Bits.FRO * 16)=20 > + (Index * 16) + R_FRCD_REG + sizeof(UINT64))); > - if ((FrcdReg.Uint64[0] !=3D 0) || (FrcdReg.Uint64[1] !=3D 0)) { > + if (FrcdReg.Bits.F !=3D 0) { > HasError =3D TRUE; > } > } > @@ -511,6 +549,17 @@ DumpVtdIfError ( > DEBUG((DEBUG_INFO, "\n#### ERROR ####\n")); > DumpVtdRegs (Num); > DEBUG((DEBUG_INFO, "#### ERROR ####\n\n")); > + // > + // Clear > + // > + for (Index =3D 0; Index < (UINTN)CapReg.Bits.NFR + 1; Index++) { > + FrcdReg.Uint64[1] =3D MmioRead64 > (mVtdUnitInformation[Num].VtdUnitBaseAddress + ((CapReg.Bits.FRO * 16)=20 > + (Index * 16) + R_FRCD_REG + sizeof(UINT64))); > + if (FrcdReg.Bits.F !=3D 0) { > + FrcdReg.Bits.F =3D 0; > + MmioWrite64 (mVtdUnitInformation[Num].VtdUnitBaseAddress + > ((CapReg.Bits.FRO * 16) + (Index * 16) + R_FRCD_REG + sizeof(UINT64)),=20 > FrcdReg.Uint64[1]); > + } > + MmioWrite32 (mVtdUnitInformation[Num].VtdUnitBaseAddress + > R_FSTS_REG, MmioRead32 (mVtdUnitInformation[Num].VtdUnitBaseAddress +=20 > R_FSTS_REG)); > + } > } > } > } > -- > 2.7.4.windows.1