From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on061f.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe49::61f]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B380F81F6D for ; Thu, 9 Feb 2017 07:11:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=D2AMOPXZ53hE5bXipUFbZA8DVlKCHXT7N4u6VDMKtkY=; b=h4h2YUKV8j5KXwCM3yFoU7cLT5IHK+/EJAcxPJJ85APub7rLanAyF+YWicgP33N57mci9q2VleFiMG2lTGEHjDDs/zPt7nTxIvuMDBinl2GZI1UPk2qLKKfkScg/TbsatjwybRfgNLQPycO1O+zwI1p7wdjuhncShLA5eOgqOcw= Received: from DM5PR12MB1243.namprd12.prod.outlook.com (10.168.237.22) by DM5PR12MB1610.namprd12.prod.outlook.com (10.172.40.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Thu, 9 Feb 2017 15:11:25 +0000 Received: from DM5PR12MB1243.namprd12.prod.outlook.com ([10.168.237.22]) by DM5PR12MB1243.namprd12.prod.outlook.com ([10.168.237.22]) with mapi id 15.01.0888.028; Thu, 9 Feb 2017 15:11:24 +0000 From: "Duran, Leo" To: 'Laszlo Ersek' , "Zeng, Star" , "Yao, Jiewen" , "edk2-devel@ml01.01.org" CC: "Tian, Feng" , "Singh, Brijesh" , "Justen, Jordan L" Thread-Topic: [edk2] [PATCH] Discussion about PcdDxeIplSwitchToLongMode Thread-Index: AdKC5sbQJHXT0wXxTDe5QxD6o1ENLA== Date: Thu, 9 Feb 2017 15:11:24 +0000 Message-ID: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=leo.duran@amd.com; x-originating-ip: [165.204.77.1] x-microsoft-exchange-diagnostics: 1; DM5PR12MB1610; 7:uJg1XX1lUc04OA49m8DPfIYDLMJmhpLsKoNLg/fHA4r0hZHm5QVqNlunLKDKDTGPLIosEOBFGWSdaISFYYKLfrFwNVZuRQ4v3VQRs7k57YLv8j7RyLjmuCS2Fx/PNwux5O/49ty0EaSagvnnLIlWzzAD/1Nk+993joopfTBUmBKryeudq8+IlblDlzBf3HHW5MD5XiMpcnqT6KuoJSTT/5r9+Dj0CV8rYw6Q3qWARBrSdG0ak4FggjKVcd2ZEMw2qqbqJtCRi4zWTJNgg/59BJF5iqAqAseMQ8cuL7/VK1aJcSD294iretj4swWq/PHdFbz8A8jpefmpv8TRsKSiud+YXHjwq9dA9rlt3MsqSWY3cKiLfmqJUYs8kyGtIG64YUGbwWuSbpkPRss35rmYrk5W83WoEmL4RjpCKzeyQhK6w8k6Cg3GA1zokEVAhMorwRRxOicJneob4MqitHgJiafQVy5n2+QEfwEe0ZJci4XLwoQMrUjl7zi9LuD790pJW5xX8n1AdSh6dX3s5Uvt8w==; 20:rJqlVVcGM9BoVKwAJjbfIhTSxPFIlpGVbVv4afcd9CNYr9h5IY/DPzxPW8u4K0aumtD08MzBd3bFoNixy3gWhm2hczYaX292FxihU1rfm4KDs2d+0CuDVHglZeK7v9pL92tCvyNxBH4poda0bPywR4mK0H/JV+FDwbnKGR+cXpD/wXdpykMDHrP5cu+UWZQvoe69G3pDFeDQ+/sRsz5qtjxT1vEQTjbMNtutsLSyZl+w9K/W+bn5bUuKHvouF95X x-forefront-antispam-report: SFV:SKI; SCL:-1SFV:NSPM; SFS:(10009020)(6029001)(6009001)(7916002)(39450400003)(39840400002)(39410400002)(39850400002)(39860400002)(199003)(189002)(377454003)(24454002)(13464003)(2501003)(2906002)(86362001)(4326007)(2900100001)(54356999)(66066001)(122556002)(3660700001)(68736007)(3280700002)(50986999)(189998001)(81156014)(8936002)(305945005)(7736002)(74316002)(8676002)(81166006)(105586002)(106356001)(6246003)(53546003)(38730400002)(92566002)(7696004)(3846002)(77096006)(229853002)(5660300001)(33656002)(55016002)(99286003)(53946003)(16200700003)(9686003)(97736004)(54906002)(101416001)(53936002)(102836003)(25786008)(6116002)(6306002)(6506006)(6436002)(579004)(569005); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1610; H:DM5PR12MB1243.namprd12.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; x-ms-office365-filtering-correlation-id: 69609761-0f1e-40cd-3187-08d450fde9f2 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:DM5PR12MB1610; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(158342451672863)(767451399110)(42262312472803)(162533806227266)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(20161123558025)(6072148); SRVR:DM5PR12MB1610; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1610; x-forefront-prvs: 02135EB356 received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Feb 2017 15:11:24.6553 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1610 Subject: Re: [PATCH] Discussion about PcdDxeIplSwitchToLongMode X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Feb 2017 15:11:28 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable All, I've changed the 'Subject' line to avoid confusion. Thanks, Leo. > -----Original Message----- > From: Laszlo Ersek [mailto:lersek@redhat.com] > Sent: Thursday, February 09, 2017 3:46 AM > To: Zeng, Star ; Yao, Jiewen ; > Duran, Leo ; edk2-devel@ml01.01.org > Cc: Tian, Feng ; Singh, Brijesh > ; Justen, Jordan L > Subject: Re: [edk2] [PATCH] MdeModulePkg: Add dynamic PCD > PcdPteMemoryEncryptionAddressOrMask >=20 > On 02/09/17 10:17, Zeng, Star wrote: > > EFI_HOB_CPU? > > Is there discussion in PIWG for it? >=20 > None that I'm aware of. >=20 > Thanks > Laszlo >=20 > > > > Thanks, > > Star > > -----Original Message----- > > From: Laszlo Ersek [mailto:lersek@redhat.com] > > Sent: Thursday, February 9, 2017 5:13 PM > > To: Zeng, Star ; Yao, Jiewen > > ; Duran, Leo ; > > edk2-devel@ml01.01.org > > Cc: Tian, Feng ; Singh, Brijesh > > ; Justen, Jordan L > > Subject: Re: [edk2] [PATCH] MdeModulePkg: Add dynamic PCD > > PcdPteMemoryEncryptionAddressOrMask > > > > On 02/09/17 06:26, Zeng, Star wrote: > >> Correct typo in below email. > >> > >> "about how to determine DXE is 32BITs or 64BITs" should be "about how > >> to determine PEI is 32BITs or 64BITs". > >> > >> At that time, we were discussing if the code needs to allocate <4G > >> ACPI table for PEI phase at S3 resume. > > > > Indeed. Although OVMF X64 has a 64-bit PEI phase, that PEI phase can > access only <4G RAM. IIRC one suggestion was to introduce a new HOB for > this, so that PEI can advertise such a limitation to DXE. > > > > Thanks > > Laszlo > > > > > >> > >> Thanks, > >> Star > >> -----Original Message----- > >> From: Zeng, Star > >> Sent: Thursday, February 9, 2017 1:12 PM > >> To: Laszlo Ersek ; Yao, Jiewen > >> ; Duran, Leo ; > >> edk2-devel@ml01.01.org > >> Cc: Tian, Feng ; Singh, Brijesh > >> ; Justen, Jordan L > >> ; Zeng, Star > >> Subject: RE: [edk2] [PATCH] MdeModulePkg: Add dynamic PCD > >> PcdPteMemoryEncryptionAddressOrMask > >> > >> In fact, X64 DxeIplPeim does not refer PcdDxeIplSwitchToLongMode at al= l. > >> > >> DxeIpl.inf: > >> [FeaturePcd.IA32] > >> gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## > CONSUMES > >> > >> As I remember, I did a draft patch below before for the discussion abo= ut > how to determine DXE is 32BITs or 64BITs in title "[edk2] [PATCH v3 2/4] > IntelFrameworkModulePkg: BdsDxe: only allocate below 4 GB if needed", I > can't find the archive link any more. > >> > >> --- > >> MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c | 5 +++++ > >> MdeModulePkg/MdeModulePkg.dec | 4 +++- > >> 2 files changed, 8 insertions(+), 1 deletion(-) > >> > >> diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c > >> b/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c > >> index 6488880..348e084 100644 > >> --- a/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c > >> +++ b/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c > >> @@ -43,6 +43,11 @@ HandOffToDxeCore ( > >> EFI_PEI_VECTOR_HANDOFF_INFO_PPI *VectorHandoffInfoPpi; > >> > >> // > >> + // It should be FALSE for both PEI and DXE are 64-bit. > >> + // > >> + ASSERT (PcdGetBool (PcdDxeIplSwitchToLongMode) =3D=3D FALSE); > >> + > >> + // > >> // Get Vector Hand-off Info PPI and build Guided HOB > >> // > >> Status =3D PeiServicesLocatePpi ( > >> diff --git a/MdeModulePkg/MdeModulePkg.dec > >> b/MdeModulePkg/MdeModulePkg.dec index af7bcab..4a73f7b 100644 > >> --- a/MdeModulePkg/MdeModulePkg.dec > >> +++ b/MdeModulePkg/MdeModulePkg.dec > >> @@ -712,8 +712,10 @@ > >> ## Indicates if DxeIpl should switch to long mode to enter DXE phas= e. > >> # It is assumed that 64-bit DxeCore is built in firmware if it is = true; > otherwise 32-bit DxeCore > >> # is built in firmware.

> >> + # And it should be FALSE for both PEI and DXE are 64-bit. > >> # TRUE - DxeIpl will load a 64-bit DxeCore and switch to long mo= de to > hand over to DxeCore.
> >> - # FALSE - DxeIpl will load a 32-bit DxeCore and perform stack swi= tch to > hand over to DxeCore.
> >> + # FALSE - DxeIpl will load a 32-bit DxeCore and perform stack swi= tch to > hand over to DxeCore,
> >> + # or both PEI and DXE are 64-bit.
> >> # @Prompt DxeIpl switch to long mode. > >> > >> > gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE|B > OOLEAN > >> | > >> 0x0001003b > >> > >> -- > >> > >> > >> Thanks, > >> Star > >> -----Original Message----- > >> From: Laszlo Ersek [mailto:lersek@redhat.com] > >> Sent: Thursday, February 9, 2017 3:48 AM > >> To: Yao, Jiewen ; Duran, Leo > >> ; Zeng, Star ; > >> edk2-devel@ml01.01.org > >> Cc: Tian, Feng ; Singh, Brijesh > >> ; Justen, Jordan L > >> Subject: Re: [edk2] [PATCH] MdeModulePkg: Add dynamic PCD > >> PcdPteMemoryEncryptionAddressOrMask > >> > >> On 02/08/17 19:20, Yao, Jiewen wrote: > >>> Got it. > >>> > >>> > >>> > >>> If the means of PcdDxeIplSwitchtoLongMode is unclear, we may add > >>> more description to make it clear. > >>> > >>> > >>> > >>> If we believe "PcdDxeIplSwitchtoLongMode =3D=3D DXE is Long mode" as > >>> final conclusion, can we treat that as a bug and fix OVMF X64? > >> > >> I don't know how to "fix" that. What is there to fix? > >> > >> Flipping the PCD to TRUE in OVMF X64 would break OVMF X64, and likely > OVMF Ia32X64 too. For two reasons: > >> > >> > >> (1) Toggling the PCD would alter the behavior of the DXE IPL PEIM and/= or > the DXE Core, and that behavior has never ever been tested with OVMF X64. > >> > >> The PcdDxeIplSwitchToLongMode=3DFALSE setting in the X64 DSC dates > back to: > >> > >> commit 8fa729a8b1401f01c6fd8ddbcab45e4a4904fa9a > >> Author: lgao4 > >> Date: Mon Mar 15 01:40:59 2010 +0000 > >> > >> Merge the same type PCD section. > >> > >> git-svn-id: > >> https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10243 > >> 6f19259b-4bc3-4df7-8a09-765794883524 > >> > >> and before that, to: > >> > >> commit 49ba9447c92d6fca214476381107a180d08e59d1 > >> Author: jljusten > >> Date: Wed May 27 21:10:18 2009 +0000 > >> > >> Add initial version of Open Virtual Machine Firmware (OVMF) plat= form. > >> > >> git-svn-id: > >> https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8398 > >> 6f19259b-4bc3-4df7-8a09-765794883524 > >> > >> In other words, OVMF X64 has always worked like this, since its incept= ion. > >> > >> > >> (2) PEI code under OvmfPkg itself uses this PCD to identify a 32-bit D= XE > phase. > >> > >> // > >> // If DXE is 32-bit, then we're done; PciBusDxe will degrade 64-bi= t MMIO > >> // resources to 32-bit anyway. See DegradeResource() in > >> // "PciResourceSupport.c". > >> // > >> #ifdef MDE_CPU_IA32 > >> if (!FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { > >> return FirstNonAddress; > >> } > >> #endif > >> > >> and > >> > >> // > >> // If DXE is 32-bit, then just return the traditional 64 MB cap. > >> // > >> #ifdef MDE_CPU_IA32 > >> if (!FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { > >> return SIZE_64MB; > >> } > >> #endif > >> > >> Thanks > >> Laszlo > >> > >>> > >>> > >>> > >>> Thank you > >>> > >>> Yao Jiewen > >>> > >>> > >>> > >>> > >>> > >>> *From:*Laszlo Ersek [mailto:lersek@redhat.com] > >>> *Sent:* Wednesday, February 8, 2017 9:52 AM > >>> *To:* Yao, Jiewen ; Duran, Leo > >>> ; Zeng, Star ; > >>> edk2-devel@ml01.01.org > >>> *Cc:* Tian, Feng ; Singh, Brijesh > >>> ; Justen, Jordan L > >>> > >>> *Subject:* Re: [edk2] [PATCH] MdeModulePkg: Add dynamic PCD > >>> PcdPteMemoryEncryptionAddressOrMask > >>> > >>> > >>> > >>> On 02/08/17 18:27, Yao, Jiewen wrote: > >>>> I believe PcdDxeIplSwitchtoLongMode =3D=3D DXE is Long mode. > >>>> > >>>> > >>>> > >>>> See DEC description: > >>>> > >>>> # It is assumed that 64-bit DxeCore is built in firmware if it > >>>> is true; otherwise 32-bit DxeCore > >>>> > >>>> # is built in firmware.

> >>> > >>> Unfortunately, I have no historical context or background for this > >>> PCD; all I can say is that the X64 OVMF platform does not set the PCD= . > >>> > >>> It enters long mode, and sets up page tables for the first 4GB of > >>> RAM, in SEC. Then SEC decompresses the flash contents to RAM, which > >>> covers both PEIFV and DXEFV. PEI runs from RAM. > >>> > >>> This is possible because on QEMU/KVM, there's no need to initialize > >>> RAM, thus only SEC runs from flash, in-place. > >>> > >>> Perhaps Jordan can provide more insight. > >>> > >>> If Brijesh and Leo would like to run the X64 OVMF platform as a SEV > >>> guest too, then this should be considered, in my opinion. > >>> > >>> One more comment below: > >>> > >>>> > >>>> > >>>> > >>>> And the code > MdeModulePkg\Universal\Acpi\S3SaveStateDxe\AcpiS3ContextSave.c: > >>>> > >>>> > >>>> > >>>> BOOLEAN > >>>> > >>>> IsLongModeWakingVectorSupport ( > >>>> > >>>> IN EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE*Facs > >>>> > >>>> ) > >>>> > >>>> { > >>>> > >>>> if((Facs =3D=3D NULL) || > >>>> > >>>> (Facs->Signature !=3D > >>>> EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) > ) { > >>>> > >>>> // > >>>> > >>>> // Something wrong with FACS. > >>>> > >>>> // > >>>> > >>>> returnFALSE; > >>>> > >>>> } > >>>> > >>>> if((Facs->Version =3D=3D > >>>> EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION) > && > >>>> > >>>> ((Facs->Flags & EFI_ACPI_4_0_64BIT_WAKE_SUPPORTED_F) !=3D 0)) = { > >>>> > >>>> // > >>>> > >>>> // BIOS supports 64bit waking vector. > >>>> > >>>> // > >>>> > >>>> if(FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { > >>>> > >>>> returnTRUE; > >>>> > >>>> } > >>>> > >>>> } > >>>> > >>>> returnFALSE; > >>>> > >>>> } > >>> > >>> In practice, it's okay if the OVMF X64 platform is recognized as > >>> "not supporting a 64-bit waking vector for S3 resume". All the > >>> 64-bit guest OSes that I've tested with OVMF X64 (Linux, and the > >>> Windows 7 / > >>> 8 / 10 families, both client and server) use a real mode (16-bit) > >>> waking vector, in practice. > >>> > >>> ... Actually, upon reviewing the above code more carefully, we don't > >>> even reach the FeaturePcdGet() call: the FACS that QEMU generates > >>> (and OVMF downloads and installs) corresponds to ACPI 1.0, that is, > >>> EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION. > >>> > >>> Thanks > >>> Laszlo > >>> > >>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> Thank you > >>>> > >>>> Yao Jiewen > >>>> > >>>> > >>>> > >>>> *From:*edk2-devel [mailto:edk2-devel-bounces@lists.01.org] *On > >>>> Behalf Of *Yao, Jiewen > >>>> *Sent:* Wednesday, February 8, 2017 9:18 AM > >>>> *To:* Laszlo Ersek >>> >; Duran, Leo >>> >; > >>>> Zeng, Star >>> >; edk2-devel@ml01.01.org > >>> > >>>> *Cc:* Tian, Feng >>>> >; Singh, Brijesh > >>>> > > >>>> *Subject:* Re: [edk2] [PATCH] MdeModulePkg: Add dynamic PCD > >>>> PcdPteMemoryEncryptionAddressOrMask > >>>> > >>>> > >>>> > >>>> Good reminder. I take back my word. > >>>> > >>>> In this case, we need consume > PcdPteMemoryEncryptionAddressOrMask in IA32 mode to build X64 paging. > >>>> > >>>> We need > >>>> > >>>> From: Laszlo Ersek [mailto:lersek@redhat.com] > >>>> Sent: Wednesday, February 8, 2017 9:11 AM > >>>> To: Yao, Jiewen >>> > >; > >>> Duran, Leo > > >>> >; Zeng, Star >>> > >; > >>> edk2-devel@ml01.01.org > >>>> > >>>> Cc: Tian, Feng >>> > >; > >>> Singh, Brijesh >>> > > >>> > > >>>> Subject: Re: [edk2] [PATCH] MdeModulePkg: Add dynamic PCD > >>>> PcdPteMemoryEncryptionAddressOrMask > >>>> > >>>> On 02/08/17 18:05, Yao, Jiewen wrote: > >>>>> HI Leo > >>>>> > >>>>> Thanks to clarify that. > >>>>> > >>>>> > >>>>> > >>>>> If that is the case, do you think it will be better to limit this > >>>>> PCD to > >>>>> X64 only in DEC file. Such as [PcdsDynamic.X64, PcdsDynamicEx.X64] > >>>> > >>>> Not sure if this is the best place to raise the following > >>>> observation, but it should do: > >>>> > >>>> please everyone remember that PcdDxeIplSwitchToLongMode is only > >>>> TRUE if PEI is 32-bit and DXE is 64-bit. It is FALSE in *two* cases: > >>>> - both PEI and DXE are 32-bit, and > >>>> - both PEI and DXE are 64-bit. > >>>> > >>>> This doesn't necessarily invalidate anything said thus fair in the > >>>> thread, but the following statement from Leo: > >>>> > >>>> The SEV feature requires 64-bit LongMode, so the > >>>> PcdDxeIplSwitchtoLongMode *must* set to TRUE at build-time > >>>> > >>>> does not follow. The PCD is FALSE in OvmfPkgX64.dsc. > >>>> > >>>> Thanks, > >>>> Laszlo > >>>> > >>>>> > >>>>> > >>>>> > >>>>> Thank you > >>>>> > >>>>> Yao Jiewen > >>>>> > >>>>> > >>>>> > >>>>> *From:*Duran, Leo [mailto:leo.duran@amd.com] > >>>>> *Sent:* Wednesday, February 8, 2017 9:00 AM > >>>>> *To:* Zeng, Star >>> > > >>> >>; > >>> edk2-devel@ml01.01.org >>> > >>>> devel@ml01.01.org>> > >>>>> *Cc:* Laszlo Ersek >>> > > >>> >>; Tian, > Feng > >>>>> >>> > > >>> >>; Singh, > >>> Brijesh >>> > > > >>> >>; > >>> Yao, > >>>>> Jiewen >>> > > >>> >> > >>>>> *Subject:* RE: [edk2] [PATCH] MdeModulePkg: Add dynamic PCD > >>>>> PcdPteMemoryEncryptionAddressOrMask > >>>>> > >>>>> > >>>>> > >>>>> Pease see reply below. > >>>>> Leo > >>>>> > >>>>>> -----Original Message----- > >>>>>> From: Zeng, Star [mailto:star.zeng@intel.com] > >>>>>> Sent: Tuesday, February 07, 2017 8:27 PM > >>>>>> To: Duran, Leo >>>>>> >>>>>> %3cmailto:leo.duran@amd.com > >>> >>> %3cmailto:leo.duran@amd.com%3cmailto:leo.duran@amd.com > >>> %3cmailto:leo.duran@amd.com%0b>> >>> %3cmailto:leo.duran@amd.com%3cmailto:leo.duran@amd.com > >>> %3cmailto:leo.duran@amd.com>>>>; > >>> edk2-devel@ml01.01.org >>> > >>>> devel@ml01.01.org>> > >>>>> > >>>>>> Cc: Laszlo Ersek >>> > >>> > > >>> >> > >>> >; Tian, Feng >>> > >>> > > >>> >> > >>> >; > >>>>>> Singh, Brijesh >>> > > >>> > > >>> > >> > >>> > >; Zeng, Star >>> > >>> > > >>> > >> > >>> >; > >>>>>> Yao, Jiewen >>>>>> >>>>>> %3cmailto:jiewen.yao@intel.com > >>> >>> %3cmailto:jiewen.yao@intel.com%3cmailto:jiewen.yao@intel.com > >>> %3cmailto:jiewen.yao@intel.com%0b>> >>> %3cmailto:jiewen.yao@intel.com%3cmailto:jiewen.yao@intel.com > >>> %3cmailto:jiewen.yao@intel.com>>>> > >>>>>> Subject: RE: [edk2] [PATCH] MdeModulePkg: Add dynamic PCD > >>>>>> PcdPteMemoryEncryptionAddressOrMask > >>>>>> > >>>>>> Does Create4GPageTablesIa32Pae() also need to be updated? > >>>>>> > >>>>>> Thanks, > >>>>>> Star > >>>>> [Duran, Leo] > >>>>> Hi Star, > >>>>> No, I do not think Create4GPageTablesIa32Pae() is in the execution > path. > >>>>> > >>>>> The SEV feature requires 64-bit LongMode, so the > >>>>> PcdDxeIplSwitchtoLongMode *must* set to TRUE at build-time, in > which case Create4GPageTablesIa32Pae() would *not* be called by > HandOffToDxeCore(). > >>>>> > >>>>>> -----Original Message----- > >>>>>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On > >>>>>> Behalf Of Leo Duran > >>>>>> Sent: Wednesday, February 8, 2017 3:54 AM > >>>>>> To: edk2-devel@ml01.01.org >>> > >>>> devel@ml01.01.org>> > >>>> > >>>>>> Cc: Laszlo Ersek >>> > >>> > > >>> >> > >>> >; Tian, Feng >>> > >>> > > >>> >> > >>> >; > >>>>>> Brijesh Singh >>> > > >>> > > >>> > >> > >>> > >; Zeng, Star >>> > >>> > > >>> > >> > >>> >; > >>>>>> Leo Duran >>>>>> >>>>>> %3cmailto:leo.duran@amd.com > >>> >>> %3cmailto:leo.duran@amd.com%3cmailto:leo.duran@amd.com > >>> %3cmailto:leo.duran@amd.com%0b>> >>> %3cmailto:leo.duran@amd.com%3cmailto:leo.duran@amd.com > >>> %3cmailto:leo.duran@amd.com>>>> > >>>>>> Subject: [edk2] [PATCH] MdeModulePkg: Add dynamic PCD > >>>>>> PcdPteMemoryEncryptionAddressOrMask > >>>>>> > >>>>>> From: Brijesh Singh >>>>>> >>>>>> %3cmailto:brijesh.singh@amd.com > >>> >>> %3cmailto:brijesh.singh@amd.com%3cmailto:brijesh.singh@amd.com > >>> %3cmailto:brijesh.singh@amd.com%0b>> > >>> %3cmailto:brijesh.singh@amd.com%3cmailto:brijesh.singh@amd.com > >>> %3cmailto:brijesh.singh@amd.com>>>> > >>>>>> > >>>>>> This dynamic PCD holds the address mask for page table entries > >>>>>> when memory encryption is enabled on AMD processors supporting > >>>>>> the Secure Encrypted Virtualization (SEV) feature. > >>>>>> > >>>>>> Cc: Feng Tian >>>>>> >>>>>> %3cmailto:feng.tian@intel.com > >>> >>> %3cmailto:feng.tian@intel.com%3cmailto:feng.tian@intel.com > >>> %3cmailto:feng.tian@intel.com%0b>> >>> %3cmailto:feng.tian@intel.com%3cmailto:feng.tian@intel.com > >>> %3cmailto:feng.tian@intel.com>>>> > >>>>>> Cc: Star Zeng >>>>>> >>>>>> %3cmailto:star.zeng@intel.com > >>> >>> %3cmailto:star.zeng@intel.com%3cmailto:star.zeng@intel.com > >>> %3cmailto:star.zeng@intel.com%0b>> >>> %3cmailto:star.zeng@intel.com%3cmailto:star.zeng@intel.com > >>> %3cmailto:star.zeng@intel.com>>>> > >>>>>> Cc: Laszlo Ersek >>>>>> >>>>>> %3cmailto:lersek@redhat.com > >>> >>> %3cmailto:lersek@redhat.com%3cmailto:lersek@redhat.com > >>> %3cmailto:lersek@redhat.com%0b>> >>> %3cmailto:lersek@redhat.com%3cmailto:lersek@redhat.com > >>> %3cmailto:lersek@redhat.com>>>> > >>>>>> Contributed-under: TianoCore Contribution Agreement 1.0 > >>>>>> Signed-off-by: Leo Duran >>>>>> >>>>>> %3cmailto:leo.duran@amd.com > >>> >>> %3cmailto:leo.duran@amd.com%3cmailto:leo.duran@amd.com > >>> %3cmailto:leo.duran@amd.com%0b>> >>> %3cmailto:leo.duran@amd.com%3cmailto:leo.duran@amd.com > >>> %3cmailto:leo.duran@amd.com>>>> > >>>>>> --- > >>>>>> MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf | 5 ++++- > >>>>>> MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 18 > >>>>>> ++++++++++-- > >>>>>> ------ > >>>>>> MdeModulePkg/MdeModulePkg.dec | 8 ++++++++ > >>>>>> 3 files changed, 22 insertions(+), 9 deletions(-) > >>>>>> > >>>>>> diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf > >>>>>> b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf > >>>>>> index 2bc41be..d62bd9b 100644 > >>>>>> --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf > >>>>>> +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf > >>>>>> @@ -6,6 +6,8 @@ > >>>>>> # needed to run the DXE Foundation. > >>>>>> # > >>>>>> # Copyright (c) 2006 - 2016, Intel Corporation. All rights > >>>>>> reserved.
> >>>>>> +# Copyright (c) 2017, AMD Incorporated. All rights > >>>>>> +reserved.
# > >>>>>> # This program and the accompanying materials # are licensed > >>>>>> and made available under the terms and conditions of the BSD > >>>>>> License # which accompanies this distribution. The full text > >>>>>> of the license may be found at @@ -111,7 +113,8 @@ [FeaturePcd] > >>>>>> > gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportUefiDecompress > >>>>>> ## CONSUMES > >>>>>> > >>>>>> [Pcd.IA32,Pcd.X64] > >>>>>> - gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable > ## > >>>>>> SOMETIMES_CONSUMES > >>>>>> + gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable > ## > >>>>>> SOMETIMES_CONSUMES > >>>>>> + > >>>>>> > gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrM > >>>>>> ask ## CONSUMES > >>>>>> > >>>>>> [Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64] > >>>>>> gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack #= # > >>>>>> SOMETIMES_CONSUMES > >>>>>> diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > >>>>>> b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > >>>>>> index 790f6ab..2c52389 100644 > >>>>>> --- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > >>>>>> +++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > >>>>>> @@ -16,6 +16,8 @@ > >>>>>> 3) IA-32 Intel(R) Architecture Software Developer's Manual > >>>>>> Volume 3:System Programmer's Guide, Intel > >>>>>> > >>>>>> Copyright (c) 2006 - 2016, Intel Corporation. All rights > >>>>>> reserved.
> >>>>>> +Copyright (c) 2017, AMD Incorporated. All rights reserved.
> >>>>>> + > >>>>>> This program and the accompanying materials are licensed and > >>>>>> made available under the terms and conditions of the BSD License > >>>>>> which accompanies this distribution. The full text of the > >>>>>> license may be found at @@ -71,14 +73,14 @@ Split2MPageTo4K ( > >>>>>> // > >>>>>> // Fill in 2M page entry. > >>>>>> // > >>>>>> - *PageEntry2M =3D (UINT64) (UINTN) PageTableEntry | IA32_PG_P | > >>>>>> IA32_PG_RW; > >>>>>> + *PageEntry2M =3D (UINT64) (UINTN) PageTableEntry | PcdGet64 > >>>>>> + (PcdPteMemoryEncryptionAddressOrMask) | IA32_PG_P | > IA32_PG_RW; > >>>>>> > >>>>>> PhysicalAddress4K =3D PhysicalAddress; > >>>>>> for (IndexOfPageTableEntries =3D 0; IndexOfPageTableEntries < > >>>>>> 512; > >>>>>> IndexOfPageTableEntries++, PageTableEntry++, PhysicalAddress4K > +=3D > >>>>>> SIZE_4KB) { > >>>>>> // > >>>>>> // Fill in the Page Table entries > >>>>>> // > >>>>>> - PageTableEntry->Uint64 =3D (UINT64) PhysicalAddress4K; > >>>>>> + PageTableEntry->Uint64 =3D (UINT64) PhysicalAddress4K | > >>>>>> + PcdGet64 (PcdPteMemoryEncryptionAddressOrMask); > >>>>>> PageTableEntry->Bits.ReadWrite =3D 1; > >>>>>> PageTableEntry->Bits.Present =3D 1; > >>>>>> if ((PhysicalAddress4K >=3D StackBase) && (PhysicalAddress4K = < > >>>>>> StackBase + > >>>>>> StackSize)) { @@ -116,7 +118,7 @@ Split1GPageTo2M ( > >>>>>> // > >>>>>> // Fill in 1G page entry. > >>>>>> // > >>>>>> - *PageEntry1G =3D (UINT64) (UINTN) PageDirectoryEntry | > IA32_PG_P > >>>>>> | IA32_PG_RW; > >>>>>> + *PageEntry1G =3D (UINT64) (UINTN) PageDirectoryEntry | PcdGet64 > >>>>>> + (PcdPteMemoryEncryptionAddressOrMask) | IA32_PG_P | > IA32_PG_RW; > >>>>>> > >>>>>> PhysicalAddress2M =3D PhysicalAddress; > >>>>>> for (IndexOfPageDirectoryEntries =3D 0; > >>>>>> IndexOfPageDirectoryEntries < 512; > >>>>>> IndexOfPageDirectoryEntries++, PageDirectoryEntry++, > >>>>>> IndexOfPageDirectoryEntries++PhysicalAddress2M > >>>>>> +=3D SIZE_2MB) { @@ -129,7 +131,7 @@ Split1GPageTo2M ( > >>>>>> // > >>>>>> // Fill in the Page Directory entries > >>>>>> // > >>>>>> - PageDirectoryEntry->Uint64 =3D (UINT64) PhysicalAddress2M; > >>>>>> + PageDirectoryEntry->Uint64 =3D (UINT64) PhysicalAddress2M | > >>>>>> + PcdGet64 (PcdPteMemoryEncryptionAddressOrMask); > >>>>>> PageDirectoryEntry->Bits.ReadWrite =3D 1; > >>>>>> PageDirectoryEntry->Bits.Present =3D 1; > >>>>>> PageDirectoryEntry->Bits.MustBe1 =3D 1; @@ -248,7 +250,7 @@ > >>>>>> CreateIdentityMappingPageTables ( > >>>>>> // > >>>>>> // Make a PML4 Entry > >>>>>> // > >>>>>> - PageMapLevel4Entry->Uint64 =3D > >>>>>> (UINT64)(UINTN)PageDirectoryPointerEntry; > >>>>>> + PageMapLevel4Entry->Uint64 =3D > >>>>>> + (UINT64)(UINTN)PageDirectoryPointerEntry | PcdGet64 > >>>>>> + (PcdPteMemoryEncryptionAddressOrMask); > >>>>>> PageMapLevel4Entry->Bits.ReadWrite =3D 1; > >>>>>> PageMapLevel4Entry->Bits.Present =3D 1; > >>>>>> > >>>>>> @@ -262,7 +264,7 @@ CreateIdentityMappingPageTables ( > >>>>>> // > >>>>>> // Fill in the Page Directory entries > >>>>>> // > >>>>>> - PageDirectory1GEntry->Uint64 =3D (UINT64)PageAddress; > >>>>>> + PageDirectory1GEntry->Uint64 =3D (UINT64)PageAddress | > >>>>>> + PcdGet64 (PcdPteMemoryEncryptionAddressOrMask); > >>>>>> PageDirectory1GEntry->Bits.ReadWrite =3D 1; > >>>>>> PageDirectory1GEntry->Bits.Present =3D 1; > >>>>>> PageDirectory1GEntry->Bits.MustBe1 =3D 1; @@ -280,7 > >>>>>> +282,7 @@ CreateIdentityMappingPageTables ( > >>>>>> // > >>>>>> // Fill in a Page Directory Pointer Entries > >>>>>> // > >>>>>> - PageDirectoryPointerEntry->Uint64 =3D > >>>>>> (UINT64)(UINTN)PageDirectoryEntry; > >>>>>> + PageDirectoryPointerEntry->Uint64 =3D > >>>>>> + (UINT64)(UINTN)PageDirectoryEntry | PcdGet64 > >>>>>> + (PcdPteMemoryEncryptionAddressOrMask); > >>>>>> PageDirectoryPointerEntry->Bits.ReadWrite =3D 1; > >>>>>> PageDirectoryPointerEntry->Bits.Present =3D 1; > >>>>>> > >>>>>> @@ -294,7 +296,7 @@ CreateIdentityMappingPageTables ( > >>>>>> // > >>>>>> // Fill in the Page Directory entries > >>>>>> // > >>>>>> - PageDirectoryEntry->Uint64 =3D (UINT64)PageAddress; > >>>>>> + PageDirectoryEntry->Uint64 =3D (UINT64)PageAddress | > >>>>>> + PcdGet64 (PcdPteMemoryEncryptionAddressOrMask); > >>>>>> PageDirectoryEntry->Bits.ReadWrite =3D 1; > >>>>>> PageDirectoryEntry->Bits.Present =3D 1; > >>>>>> PageDirectoryEntry->Bits.MustBe1 =3D 1; diff --git > >>>>>> a/MdeModulePkg/MdeModulePkg.dec > b/MdeModulePkg/MdeModulePkg.dec > >>>>>> index 273cd7e..207384f 100644 > >>>>>> --- a/MdeModulePkg/MdeModulePkg.dec > >>>>>> +++ b/MdeModulePkg/MdeModulePkg.dec > >>>>>> @@ -6,6 +6,8 @@ > >>>>>> # Copyright (c) 2007 - 2017, Intel Corporation. All rights > >>>>>> reserved.
# Copyright (c) 2016, Linaro Ltd. All rights > >>>>>> reserved.
# (C) Copyright 2016 Hewlett Packard Enterprise > >>>>>> Development LP
> >>>>>> +# Copyright (c) 2017, AMD Incorporated. All rights reserved.
> >>>>>> +# > >>>>>> # This program and the accompanying materials are licensed and > >>>>>> made available under # the terms and conditions of the BSD > >>>>>> License that accompanies this distribution. > >>>>>> # The full text of the license may be found at @@ -1738,5 > >>>>>> +1740,11 @@ [PcdsDynamic, PcdsDynamicEx] > >>>>>> # @Prompt If there is any test key used by the platform. > >>>>>> > >>>>>> > gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed|FALSE|BOOLEAN|0x0 > >>>>>> 0030003 > >>>>>> > >>>>>> + ## This dynamic PCD holds the address mask for page table > >>>>>> + entries when memory encryption is # enabled on AMD > processors > >>>>>> + supporting the > >>>>>> Secure Encrypted Virtualization (SEV) feature. > >>>>>> + # This mask should be applied when creating 1:1 virtual to > >>>>>> + physical > >>>>>> mapping tables. > >>>>>> + # > >>>>>> + > >>>>>> + > >>>>>> > gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrM > >>>>>> ask|0x0 > >>>>>> + |UINT64|0x00030004 > >>>>>> + > >>>>>> [UserExtensions.TianoCore."ExtraFiles"] > >>>>>> MdeModulePkgExtra.uni > >>>>>> -- > >>>>>> 1.9.1 > >>>>>> > >>>>>> _______________________________________________ > >>>>>> edk2-devel mailing list > >>>>>> edk2-devel@lists.01.org >>> > >>>> > > >>>> > >>>>>> https://lists.01.org/mailman/listinfo/edk2-devel > >>>>> > >>>> _______________________________________________ > >>>> edk2-devel mailing list > >>>> edk2-devel@lists.01.org > >>> > >>>> https://lists.01.org/mailman/listinfo/edk2-devel > >>>> > >>> > >> > >