From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0611.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe46::611]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7E3BF821BD for ; Wed, 22 Feb 2017 07:07:10 -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=mhekYyT6Tufvw+JueKzobk0SbRDV5JTGxjJA+IFoIeE=; b=zRbXoMtoofz8e+lscawglGbuEc7Gp7p3qmvXsCFtlFKdECd7i2YO8f6ADYjB3uGqzS8w4fX3wulQW9ft0pSBcanmG6O7aCiLTwnkQAI1c5etAL1hbqHgZfPp79ZaTg8mWUuKFb9l/sGDo6v84RtjdTv6XTzbEcdfdlzqe6+0N9s= Received: from DM5PR12MB1243.namprd12.prod.outlook.com (10.168.237.22) by DM5PR12MB1609.namprd12.prod.outlook.com (10.172.40.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.13; Wed, 22 Feb 2017 15:07:07 +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.0919.018; Wed, 22 Feb 2017 15:07:06 +0000 From: "Duran, Leo" To: "'Zeng, Star'" , "edk2-devel@ml01.01.org" CC: "Singh, Brijesh" , "Tian, Feng" , Laszlo Ersek Thread-Topic: [edk2] [PATCH v3 2/4] MdeModulePkg/Universal/CapsulePei: Add support for PCD PcdPteMemoryEncryptionAddressOrMask Thread-Index: AQHSiJf7APITXEb0fkm/yPXbz8aYs6FxbVAAgAJBBjCAAJQNgIAA5o+w Date: Wed, 22 Feb 2017 15:07:06 +0000 Message-ID: References: <1487278926-14303-1-git-send-email-leo.duran@amd.com> <1487278926-14303-3-git-send-email-leo.duran@amd.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B829F55@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B829F55@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; DM5PR12MB1609; 7:UErh4nc5aOBaK2KSlC6vK9LexdMPqkkdmk10HrJcCVdean+Tnw6IZ8dhNZ4gQqKzm8bCdS2vHiIq4LUalalvewRy0WTh72TyRK+irzwO/EgTp/BpE9eCgZ2+QARR/w63f6Sb5GhGTNmOuhHqHOI1QOrU6MiTzNDd4X5wTZSaTc0xFuHJ6F2I5qMob9zIiEsILa0+efTyWhhWU5HJ5UnNYO6QSlUV5hYcJ/md2fy8GnWYwciasku9/xnNsD3HTN4kDpw75v35vhhsQdnjSIsEe/QmuZnomFgLi2u/MfGvsWLQn5X2YveOx1SBBkHiXaLhwCbV0OJQqOF4zUk8CmcBbw==; 20:mxScRkrTu+lxedhXbhsffqK0rsb02T59tGAh896YQ9OxH+FswgsokgWFuZZqd+S3iB6Dh2/hVR0kYm+nijfYak9iohuITIV5CoUau1CVOQrp1jWvMkEQtX3Za/akn3/38C798NVoxSLJyLS4Vjlm7ivf+ee0qk7Cc/07696aux58+7zadg6QDCyvrFBVgKcuOvQYwYSVSTZwgYH/0YmNqMuJW14JbqDdmNTlyoAo6sdHVduJZ7wQp5VULJvrxXpW x-forefront-antispam-report: SFV:SKI; SCL:-1SFV:NSPM; SFS:(10009020)(6009001)(6029001)(7916002)(39450400003)(39850400002)(39840400002)(39860400002)(39410400002)(43544003)(199003)(377454003)(189002)(24454002)(13464003)(3280700002)(2501003)(97736004)(77096006)(93886004)(8676002)(5660300001)(2950100002)(101416001)(54356999)(6246003)(76176999)(6506006)(92566002)(106356001)(3846002)(7696004)(229853002)(81156014)(6116002)(189998001)(81166006)(3660700001)(53546006)(50986999)(102836003)(53936002)(38730400002)(4326007)(68736007)(122556002)(86362001)(25786008)(33656002)(66066001)(105586002)(305945005)(6436002)(8936002)(9686003)(74316002)(7736002)(99286003)(55016002)(2906002)(106116001)(6306002)(54906002)(2900100001)(213903007)(44824005)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1609; H:DM5PR12MB1243.namprd12.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; x-ms-office365-filtering-correlation-id: 5b180659-312c-477b-3f29-08d45b3477a3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:DM5PR12MB1609; 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)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123558025)(20161123562025)(20161123564025)(20161123555025)(6072148); SRVR:DM5PR12MB1609; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1609; x-forefront-prvs: 022649CC2C 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: 22 Feb 2017 15:07:06.7474 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1609 Subject: Re: [PATCH v3 2/4] MdeModulePkg/Universal/CapsulePei: Add support for 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, 22 Feb 2017 15:07:10 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Star, Please see my reply below. Thanks, Leo. > -----Original Message----- > From: Zeng, Star [mailto:star.zeng@intel.com] > Sent: Tuesday, February 21, 2017 7:20 PM > To: Duran, Leo ; edk2-devel@ml01.01.org > Cc: Singh, Brijesh ; Tian, Feng > ; Laszlo Ersek ; Zeng, Star > > Subject: RE: [edk2] [PATCH v3 2/4] MdeModulePkg/Universal/CapsulePei: > Add support for PCD PcdPteMemoryEncryptionAddressOrMask >=20 > Shouldn't >=20 > ((*PageFaultContext->PageFaultUplink[PageFaultContext->PageFaultIndex] > & PageFaultContext->PhyMask) =3D=3D Address) >=20 > be >=20 > (((*PageFaultContext->PageFaultUplink[PageFaultContext- > >PageFaultIndex] & ~(AddressSetMask & > PAGING_4K_ADDRESS_MASK_64)) & PageFaultContext->PhyMask) =3D=3D > Address) >=20 > like you did at other place? [Duran, Leo]=20 Yes, I agree... I will take care of that in v4 of the set. >=20 > Thanks, > Star >=20 > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Duran, Leo > Sent: Wednesday, February 22, 2017 12:43 AM > To: Zeng, Star ; edk2-devel@ml01.01.org > Cc: Singh, Brijesh ; Tian, Feng > ; Laszlo Ersek > Subject: Re: [edk2] [PATCH v3 2/4] MdeModulePkg/Universal/CapsulePei: > Add support for PCD PcdPteMemoryEncryptionAddressOrMask >=20 > Hi Star, >=20 > Please double-check the complete [PATCH v3 2/4]. >=20 > Yes, there is a non-functional change where I did break a 'very long' lin= e into > 2 lines as you noted (I can put that back as it was before if so required= ). > However the intended functional changes are applied in the rest of the pa= tch > in lines where I reference 'AddressSetMask'. >=20 > As for [PATCH v3 4/4] > The intended functional changes are applied... please confirm, or please = let > me know what seems to be missing. >=20 > Thanks, > Leo. >=20 > > -----Original Message----- > > From: Zeng, Star [mailto:star.zeng@intel.com] > > Sent: Monday, February 20, 2017 12:05 AM > > To: Duran, Leo ; edk2-devel@ml01.01.org > > Cc: Laszlo Ersek ; Feng Tian ; > > Singh, Brijesh ; star.zeng@intel.com > > Subject: Re: [edk2] [PATCH v3 2/4] MdeModulePkg/Universal/CapsulePei: > > Add support for PCD PcdPteMemoryEncryptionAddressOrMask > > > > Leo, > > > > Comments added inline. > > > > On 2017/2/17 5:02, Leo Duran wrote: > > > This PCD holds the address mask for page table entries when memory > > > encryption is enabled on AMD processors supporting the Secure > > > Encrypted Virtualization (SEV) feature. > > > > > > The mask is applied when 4GB tables are created (UefiCapsule.c), and > > > when the tables are expanded on-demand by page-faults above 4GB's > > (X64Entry.c). > > > > > > Cc: Feng Tian > > > Cc: Star Zeng > > > Cc: Laszlo Ersek > > > Cc: Brijesh Singh > > > Contributed-under: TianoCore Contribution Agreement 1.0 > > > Signed-off-by: Leo Duran > > > Reviewed-by: Star Zeng > > > --- > > > MdeModulePkg/Universal/CapsulePei/CapsulePei.inf | 2 ++ > > > .../Universal/CapsulePei/Common/CommonHeader.h | 7 +++++++ > > > MdeModulePkg/Universal/CapsulePei/UefiCapsule.c | 13 ++++++++--- > - > > > MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c | 23 > > +++++++++++++++------- > > > 4 files changed, 34 insertions(+), 11 deletions(-) > > > > > > > [snipped] > > > > > diff --git a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c > > > b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c > > > index 5ad95d2..2197502 100644 > > > --- a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c > > > +++ b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c > > > @@ -2,6 +2,8 @@ > > > The X64 entrypoint is used to process capsule in long mode. > > > > > > Copyright (c) 2011 - 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 @@ -29,6 +31,7 @@ typedef struct _PAGE_FAULT_CONTEXT { > > > UINT64 PhyMask; > > > UINTN PageFaultBuffer; > > > UINTN PageFaultIndex; > > > + UINT64 PteMemoryEncryptionAddressOrMask; > > > // > > > // Store the uplink information for each page being used. > > > // > > > @@ -114,6 +117,7 @@ AcquirePage ( > > > ) > > > { > > > UINTN Address; > > > + UINT64 AddressSetMask; > > > > > > Address =3D PageFaultContext->PageFaultBuffer + EFI_PAGES_TO_SIZE > > (PageFaultContext->PageFaultIndex); > > > ZeroMem ((VOID *) Address, EFI_PAGES_TO_SIZE (1)); @@ -121,14 > > > +125,16 @@ AcquirePage ( > > > // > > > // Cut the previous uplink if it exists and wasn't overwritten. > > > // > > > - if > > > > > >((PageFaultContext->PageFaultUplink[PageFaultContext- > >PageFaultIndex] > > > !=3D NULL) && > > > ((*PageFaultContext->PageFaultUplink[PageFaultContext- > > >PageFaultIndex] > > > & PageFaultContext->PhyMask) =3D=3D Address)) { > > > + if ((PageFaultContext->PageFaultUplink[PageFaultContext- > > >PageFaultIndex] !=3D NULL) && > > > + > > > + ((*PageFaultContext->PageFaultUplink[PageFaultContext- > > >PageFaultInde > > > + x] & PageFaultContext->PhyMask) =3D=3D Address)) { > > > > No real change at here except the line feed added. > > You were going to update code at here, but forgot to do the real change= ? > > > > Will you do similar change for [PATCH v3 4/4] > > > > Thanks, > > Star > > > > > *PageFaultContext->PageFaultUplink[PageFaultContext- > > >PageFaultIndex] =3D 0; > > > } > > > > > > // > > > // Link & Record the current uplink. > > > // > > > - *Uplink =3D Address | IA32_PG_P | IA32_PG_RW; > > > + AddressSetMask =3D > > > + PageFaultContext->PteMemoryEncryptionAddressOrMask; > > > + *Uplink =3D Address | (AddressSetMask & > > PAGING_4K_ADDRESS_MASK_64) | > > > + IA32_PG_P | IA32_PG_RW; > > > > > > PageFaultContext->PageFaultUplink[PageFaultContext->PageFaultIndex] > > > =3D Uplink; > > > > > > PageFaultContext->PageFaultIndex =3D > > > (PageFaultContext->PageFaultIndex + 1) % EXTRA_PAGE_TABLE_PAGES; > > @@ -153,6 +159,7 @@ PageFaultHandler ( > > > UINT64 *PageTable; > > > UINT64 PFAddress; > > > UINTN PTIndex; > > > + UINT64 AddressSetMask; > > > > > > // > > > // Get the IDT Descriptor. > > > @@ -163,6 +170,7 @@ PageFaultHandler ( > > > // > > > PageFaultContext =3D (PAGE_FAULT_CONTEXT *) (UINTN) (Idtr.Base - > > sizeof (PAGE_FAULT_CONTEXT)); > > > PhyMask =3D PageFaultContext->PhyMask; > > > + AddressSetMask =3D > > > + PageFaultContext->PteMemoryEncryptionAddressOrMask; > > > > > > PFAddress =3D AsmReadCr2 (); > > > DEBUG ((EFI_D_ERROR, "CapsuleX64 - PageFaultHandler: Cr2 - > > > %lx\n", PFAddress)); @@ -179,19 +187,19 @@ PageFaultHandler ( > > > if ((PageTable[PTIndex] & IA32_PG_P) =3D=3D 0) { > > > AcquirePage (PageFaultContext, &PageTable[PTIndex]); > > > } > > > - PageTable =3D (UINT64*)(UINTN)(PageTable[PTIndex] & PhyMask); > > > + PageTable =3D (UINT64*)(UINTN)((PageTable[PTIndex] & > > ~(AddressSetMask > > > + & PAGING_4K_ADDRESS_MASK_64)) & PhyMask); > > > PTIndex =3D BitFieldRead64 (PFAddress, 30, 38); > > > // PDPTE > > > if (PageFaultContext->Page1GSupport) { > > > - PageTable[PTIndex] =3D (PFAddress & ~((1ull << 30) - 1)) | IA32_= PG_P | > > IA32_PG_RW | IA32_PG_PS; > > > + PageTable[PTIndex] =3D ((PFAddress | (AddressSetMask & > > > + PAGING_1G_ADDRESS_MASK_64)) & ~((1ull << 30) - 1)) | IA32_PG_P | > > > + IA32_PG_RW | IA32_PG_PS; > > > } else { > > > if ((PageTable[PTIndex] & IA32_PG_P) =3D=3D 0) { > > > AcquirePage (PageFaultContext, &PageTable[PTIndex]); > > > } > > > - PageTable =3D (UINT64*)(UINTN)(PageTable[PTIndex] & PhyMask); > > > + PageTable =3D (UINT64*)(UINTN)((PageTable[PTIndex] & > > > + ~(AddressSetMask & PAGING_4K_ADDRESS_MASK_64)) & PhyMask); > > > PTIndex =3D BitFieldRead64 (PFAddress, 21, 29); > > > // PD > > > - PageTable[PTIndex] =3D (PFAddress & ~((1ull << 21) - 1)) | IA32_= PG_P | > > IA32_PG_RW | IA32_PG_PS; > > > + PageTable[PTIndex] =3D ((PFAddress | (AddressSetMask & > > > + PAGING_2M_ADDRESS_MASK_64)) & ~((1ull << 21) - 1)) | IA32_PG_P | > > > + IA32_PG_RW | IA32_PG_PS; > > > } > > > > > > return NULL; > > > @@ -244,6 +252,7 @@ _ModuleEntryPoint ( > > > // Hook page fault handler to handle >4G request. > > > // > > > PageFaultIdtTable.PageFaultContext.Page1GSupport =3D > > > EntrypointContext->Page1GSupport; > > > + > > > PageFaultIdtTable.PageFaultContext.PteMemoryEncryptionAddressOrMask > > > + =3D EntrypointContext->PteMemoryEncryptionAddressOrMask; > > > IdtEntry =3D (IA32_IDT_GATE_DESCRIPTOR *) (X64Idtr.Base + (14 * > > > sizeof > > (IA32_IDT_GATE_DESCRIPTOR))); > > > HookPageFaultHandler (IdtEntry, > > > &(PageFaultIdtTable.PageFaultContext)); > > > > > > @@ -298,4 +307,4 @@ _ModuleEntryPoint ( > > > // > > > ASSERT (FALSE); > > > return EFI_SUCCESS; > > > -} > > > \ No newline at end of file > > > +} > > > >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel