From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0618.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe46::618]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5A738820DB for ; Wed, 8 Feb 2017 09:12:02 -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=CJlLD8VggndnJ7Pub2x0wOvUbdbmDV4ycXwztRLsC2A=; b=Y/v2fDZZZOj1mq5Zz1X2EGdw21LZhdPCJ82kCSdUHESQ3JJcP/Lx8YxtZ3pU+Bi1O71uPC5dRkdzegs8lyz8VxJwyCMgVjwo6R7EQgVB10mLLEabB1X4gQo0L1vn07XD7oUnCzX7ky7atOy5kJFhQujq8qj1DHa8BBHyF3FC/D4= Received: from DM5PR12MB1243.namprd12.prod.outlook.com (10.168.237.22) by DM5PR12MB1611.namprd12.prod.outlook.com (10.172.40.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Wed, 8 Feb 2017 17:12:00 +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.026; Wed, 8 Feb 2017 17:11:54 +0000 From: "Duran, Leo" To: "'Gao, Liming'" , "edk2-devel@ml01.01.org" CC: Laszlo Ersek , "Tian, Feng" , "Singh, Brijesh" , "Zeng, Star" Thread-Topic: [edk2] [PATCH] MdeModulePkg: Add dynamic PCD PcdPteMemoryEncryptionAddressOrMask Thread-Index: AQHSgXvpPu5JgE3+Q0eFw1PUQsHrO6FfOmMAgAAcOoA= Date: Wed, 8 Feb 2017 17:11:53 +0000 Message-ID: References: <1486497223-22694-1-git-send-email-leo.duran@amd.com> <1486497223-22694-2-git-send-email-leo.duran@amd.com> <4A89E2EF3DFEDB4C8BFDE51014F606A14D6D8590@shsmsx102.ccr.corp.intel.com> In-Reply-To: <4A89E2EF3DFEDB4C8BFDE51014F606A14D6D8590@shsmsx102.ccr.corp.intel.com> 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; DM5PR12MB1611; 7:bLC+yX8aFWUZYs3zX951rv6ddZJBkazSkKC1iQejw11iMGDRF3v5m6gUVqeJDCS2fDS7DrkGLs9IFK2XSUgT3gtRPJcGORoFg8Ip6z43DWfXH8Ch/dP717Wuj1cz4H1Lmm+QpQz7EAQYB8263mXF+xKAHD2VD+KXWET+mL0BUK0hcRDuXSd4lJqWKsRT/8X8B1DEJ87mx6u8++B7WnBlPSgg+Y07+RqBTACLib92UHxqBP7AAJ0GjCizW9M7/9mkNEDdgZ9xAF/C5o4r6aa4Ugp+JNKmPcpsKrOuwY99tg1IkD+DSnKsv+MUXF7tUHOHIdij5dwV//HltQBlSDNd0RYZzF4Kj55EP9S9VQhCHL3V9PiSaO4jn2So3QycOlUKK1XAkyD9QvCxaRS/rqnJKMJgvXU7Rs/0awXhkIm1aPQXxrpPNhwcYndHtf/y0W+0FdeGxWy4/nsrYvZtiFnAp603FpO7YPz7WVpHp8suYDwFIQ+YCxLPWNhJIwsr4n6WfoKgC+b3LPMZ4Htr7qefbA==; 20:+WWd04TJk1xGUCdyB5vDYo+SRV4XmOayh86/yQYei2LYgOmvGvaIhpRS3F+2gs5lOFIc2+NkVTTV2UHFQ5J7bBMQ4bKMu07rPjNxrMsStzhONF6EAFRZame9l2yRb5ET2RnFLdfctIQpNN7UcBUnzMYdZah3c1bIl1AxSIE+q6VXfhZ4AHnNOsd7scukLDBGDqqHTjSshjCRLorUGNjvfnMJ6TuREtPa6Mq2DWkttq9mLaEDDmsb7IChjApz/kam x-forefront-antispam-report: SFV:SKI; SCL:-1SFV:NSPM; SFS:(10009020)(6029001)(6009001)(7916002)(39450400003)(39840400002)(39410400002)(39860400002)(39850400002)(199003)(189002)(377454003)(13464003)(54356999)(76176999)(305945005)(6246003)(102836003)(122556002)(74316002)(6506006)(92566002)(97736004)(6436002)(25786008)(6116002)(66066001)(4326007)(5660300001)(7736002)(2501003)(50986999)(3846002)(38730400002)(2906002)(189998001)(229853002)(81156014)(8936002)(86362001)(3280700002)(106356001)(105586002)(106116001)(81166006)(8676002)(68736007)(9686003)(55016002)(54906002)(99286003)(33656002)(77096006)(2900100001)(101416001)(6306002)(7696004)(3660700001)(2950100002)(53936002)(213903007)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1611; H:DM5PR12MB1243.namprd12.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; x-ms-office365-filtering-correlation-id: 015da052-b18c-4a21-c499-08d450459483 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:DM5PR12MB1611; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(767451399110)(162533806227266)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(2017020702029)(5005006)(20170203043)(8121501046)(10201501046)(3002001)(6055026)(6041248)(20161123558025)(20161123562025)(20161123560025)(20161123555025)(20161123564025)(6072148); SRVR:DM5PR12MB1611; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1611; x-forefront-prvs: 0212BDE3BE 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: 08 Feb 2017 17:11:53.9690 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1611 Subject: Re: [PATCH] MdeModulePkg: Add dynamic PCD PcdPteMemoryEncryptionAddressOrMask 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: Wed, 08 Feb 2017 17:12:02 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Please see replies below. Thanks, Leo > -----Original Message----- > From: Gao, Liming [mailto:liming.gao@intel.com] > Sent: Wednesday, February 08, 2017 9:19 AM > To: Duran, Leo ; edk2-devel@ml01.01.org > Cc: Laszlo Ersek ; Tian, Feng ; > Singh, Brijesh ; Zeng, Star > Subject: RE: [edk2] [PATCH] MdeModulePkg: Add dynamic PCD > PcdPteMemoryEncryptionAddressOrMask >=20 > Leo: > MdeModulePkg CapsulePei and UefiCpuPkg S3Resume2 also create > PageTable to run X64 code. Do they require this change? >=20 > Thanks > Liming [Duran, Leo]=20 1) MedModelePkg/Universal/CapsulePei: Does not seem applicable for MDE_XPU_X64 compile-time option, which is requ= ired for SEV. - ModeSwitch() calls Thunk32To64(), which in turn may call Create4GPageTabl= es() - However, ModeSwitch() is called only under #ifdef MDE_CPU_IA32 2) UefiCpuPkg/Universal/Acpi/S3Resume2Pei: Agreed. Will incorporate changes in 'v2' of the patch. > -----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 > Cc: Laszlo Ersek ; Tian, Feng ; > Brijesh Singh ; Zeng, Star ; > Leo Duran > Subject: [edk2] [PATCH] MdeModulePkg: Add dynamic PCD > PcdPteMemoryEncryptionAddressOrMask >=20 > From: Brijesh Singh >=20 > 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. >=20 > Cc: Feng Tian > Cc: Star Zeng > Cc: Laszlo Ersek > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Leo Duran > --- > MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf | 5 ++++- > MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 18 ++++++++++-- > ------ > MdeModulePkg/MdeModulePkg.dec | 8 ++++++++ > 3 files changed, 22 insertions(+), 9 deletions(-) >=20 > 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 >=20 > [Pcd.IA32,Pcd.X64] > - gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## > SOMETIMES_CONSUMES > + gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable = ## > SOMETIMES_CONSUMES > + > gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrM > ask ## CONSUMES >=20 > [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 >=20 > 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; >=20 > 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 < Stack= Base + > 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; >=20 > PhysicalAddress2M =3D PhysicalAddress; > for (IndexOfPageDirectoryEntries =3D 0; IndexOfPageDirectoryEntries < = 512; > IndexOfPageDirectoryEntries++, PageDirectoryEntry++, 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; >=20 > @@ -262,7 +264,7 @@ CreateIdentityMappingPageTables ( > // > // Fill in the Page Directory entries > // > - PageDirectory1GEntry->Uint64 =3D (UINT64)PageAddress; > + PageDirectory1GEntry->Uint64 =3D (UINT64)PageAddress | PcdGet6= 4 > + (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; >=20 > @@ -294,7 +296,7 @@ CreateIdentityMappingPageTables ( > // > // Fill in the Page Directory entries > // > - PageDirectoryEntry->Uint64 =3D (UINT64)PageAddress; > + PageDirectoryEntry->Uint64 =3D (UINT64)PageAddress | PcdGet6= 4 > + (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. >=20 > gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed|FALSE|BOOLEAN|0x0 > 0030003 >=20 > + ## 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 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel