From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0062.outbound.protection.outlook.com [104.47.0.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 052DA21D046AB for ; Tue, 19 Sep 2017 05:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=lqLCO4WL06zksUGhHtZe3dABxrVxIACWcgllZPSMH1k=; b=Pt9K9UlmP8FoR0fNicuuKhTgJ6roJfeoQeIfn6j98Xv7ZPmv8qM3+1YDVge0vbrzyqrPTufssN1PKquKFuD1Dd2eV6ClWqfG2A1A0bLU5A8QEJ9SDphaHLyusUSdQhz/22CQts8vNaB3PDxHbOu2b/1Rs5iuMK6a5g9LBCwKI/s= Received: from AM6PR0402MB3334.eurprd04.prod.outlook.com (52.133.18.151) by AM6PR0402MB3477.eurprd04.prod.outlook.com (52.133.19.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11; Tue, 19 Sep 2017 12:46:14 +0000 Received: from AM6PR0402MB3334.eurprd04.prod.outlook.com ([fe80::4d05:6a0c:bcca:93be]) by AM6PR0402MB3334.eurprd04.prod.outlook.com ([fe80::4d05:6a0c:bcca:93be%13]) with mapi id 15.20.0056.016; Tue, 19 Sep 2017 12:46:14 +0000 From: Udit Kumar To: Sakar Arora , Meenakshi Aggarwal , "edk2-devel@lists.01.org" , "leif.lindholm@linaro.org" , "ard.biesheuvel@linaro.org" Thread-Topic: [edk2] [PATCH v2] PeiLib : Inform UEFI memory to Linux Thread-Index: AQHTMRKizTdBt8YK50CCBP5JRh+41aK72m+AgAAhYGCAABS7AIAAF2bw Date: Tue, 19 Sep 2017 12:46:14 +0000 Message-ID: References: <1505485954-24345-1-git-send-email-meenakshi.aggarwal@nxp.com> <1505824329-32532-1-git-send-email-meenakshi.aggarwal@nxp.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=udit.kumar@nxp.com; x-originating-ip: [192.88.169.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM6PR0402MB3477; 6:p+B78rAZvvcSZHKZOMtV8AAm9Pu5udOOycDDplbAj/NDQKkRH/Pzyz4UUBdnZkcCA8PoVD3JtxJgsNofHUlCOGsUwLMnOJ2L7MHuMzUOt/2N6ii7bX8qax552huKH0RCUx5g0ni/rf7mOzulK0Cguvc4Stpm/grFCYk+tuI+gJSB59BuaD4/e1bUjz7726xG8UsQej2Va8sqDjNj3eZNx0AW7RE7G3puqkWctWhQYRzflPElFUsY4MfPlLBoHJjzGN1jdt/akH3Xru1boE+YoJ78ypa3lYcgZfAVwy2WeIO2eYNSZIrkcMOpFbyvyrH7G/PXPUG7BPweO30SVh/iVw==; 5:9MJ9/n8U3/ww3iZvBs2XbVGWNBagRD9yxI6qq6JrD+cUjXZMxY02GWqEgEDw83717xubdkKegtzcd3gSfyq4+ACxuiXkxuCKEsEy0/vnAB49txSXkv2DFv/3i3i9VOD+V54joGezmGFztvC5JCDGXw==; 24:3d5VOv7l3c9I6e2VGl1BH3NH7LzTFffKBqkdqQNYL6g5fPQ5nNXp3ID22ijtTlrMa9D0C6zmm166TCl51Ef4U51OEfKNIg9SMYiOa/bUohI=; 7:TvCraEFlOGBsM3MDQGzi78+jfwF5UHgjD1v1c/KGJRp3ZEqD0rw3vfyYk6YYCnCWJ7wbmZls70SVTvNwaoGTrR2TruL43U1FBbwuJckZrpuMwEgbMNIKoQW61vX6Cal8Iz/6hlNDoUyp2yL354omB97XeS1rdz3QPFFNCYqh6gfinWfXsVowNZbPrNejWdNFdvd9CrjK4K9TUH9B1UJSqxqvGGhYB8L4sQUnfuIoEhU= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI; SCL:-1; SFV:NSPM; SFS:(10009020)(6009001)(376002)(346002)(39860400002)(199003)(377454003)(189002)(13464003)(7736002)(66066001)(105586002)(106356001)(305945005)(68736007)(8676002)(8936002)(81166006)(33656002)(81156014)(53936002)(55016002)(99286003)(6306002)(9686003)(478600001)(6246003)(93886005)(966005)(14454004)(110136005)(74316002)(316002)(3280700002)(229853002)(5890100001)(5250100002)(2501003)(6116002)(102836003)(3846002)(97736004)(25786009)(2906002)(7696004)(101416001)(5660300001)(54356999)(189998001)(2900100001)(2950100002)(6506006)(6436002)(3660700001)(76176999)(50986999)(2201001)(86362001)(53546010); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR0402MB3477; H:AM6PR0402MB3334.eurprd04.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; x-ms-office365-filtering-correlation-id: aa7d51ce-24fe-400b-245d-08d4ff5c69d0 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:AM6PR0402MB3477; x-ms-traffictypediagnostic: AM6PR0402MB3477: x-exchange-antispam-report-test: UriScan:(180628864354917)(185117386973197)(162533806227266); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123562025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM6PR0402MB3477; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM6PR0402MB3477; x-forefront-prvs: 04359FAD81 received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Sep 2017 12:46:14.2467 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0402MB3477 Subject: Re: [PATCH v2] PeiLib : Inform UEFI memory to Linux 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: Tue, 19 Sep 2017 12:43:13 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks for this,=20 If memory is marked as reserved by HobList then gDS->AddMemorySpace will re= turn error 15. No ?=20 Regards Udit > -----Original Message----- > From: Sakar Arora [mailto:Sakar.Arora@arm.com] > Sent: Tuesday, September 19, 2017 4:51 PM > To: Udit Kumar ; Meenakshi Aggarwal > ; edk2-devel@lists.01.org; > leif.lindholm@linaro.org; ard.biesheuvel@linaro.org > Subject: RE: [edk2] [PATCH v2] PeiLib : Inform UEFI memory to Linux >=20 > You could use the DXE services method gDS->AddMemorySpace to add this > memory space to the global gMemoryMap. This is the memory map linux efi > stub reads to get information about all the available system memory. >=20 > Thanks, > Sakar >=20 > -----Original Message----- > From: Udit Kumar [mailto:udit.kumar@nxp.com] > Sent: Tuesday, September 19, 2017 3:41 PM > To: Sakar Arora ; Meenakshi Aggarwal > ; edk2-devel@lists.01.org; > leif.lindholm@linaro.org; ard.biesheuvel@linaro.org > Subject: RE: [edk2] [PATCH v2] PeiLib : Inform UEFI memory to Linux >=20 > Thanks Sakar, > I am wondering, how we can add this memory before OS, please suggest. > I guess, we cannot add in HobList when we are in DXE or BDS. >=20 > Regards > Udit >=20 > > -----Original Message----- > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > > Sakar Arora > > Sent: Tuesday, September 19, 2017 1:37 PM > > To: Meenakshi Aggarwal ; edk2- > > devel@lists.01.org; leif.lindholm@linaro.org; > > ard.biesheuvel@linaro.org > > Subject: Re: [edk2] [PATCH v2] PeiLib : Inform UEFI memory to Linux > > > > This change will create the possibility for memory space holding the > > UEFI image to be over-written by the DXE core code, since this space > > will then be available for allocation. Any such change, if required, > > should be done just before booting the OS. > > > > -----Original Message----- > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > > Meenakshi Aggarwal > > Sent: Tuesday, September 19, 2017 6:02 PM > > To: edk2-devel@lists.01.org; leif.lindholm@linaro.org; > > ard.biesheuvel@linaro.org > > Subject: [edk2] [PATCH v2] PeiLib : Inform UEFI memory to Linux > > > > While creating Hob list, ArmPlatformPkg is hiding UEFI memory. > > whereas this memory can be used by OS. > > > > This patch, allows OS to use UEFI code area. > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Udit Kumar > > Signed-off-by: Meenakshi Aggarwal > > --- > > ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c | 69 > > ------------------------- > > 1 file changed, 69 deletions(-) > > > > diff --git a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c > > b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c > > index 2feb11f..d03214b 100644 > > --- a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c > > +++ b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c > > @@ -70,11 +70,7 @@ MemoryPeim ( > > { > > ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable; > > EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes; > > - UINT64 ResourceLength; > > EFI_PEI_HOB_POINTERS NextHob; > > - EFI_PHYSICAL_ADDRESS FdTop; > > - EFI_PHYSICAL_ADDRESS SystemMemoryTop; > > - EFI_PHYSICAL_ADDRESS ResourceTop; > > BOOLEAN Found; > > > > // Get Virtual Memory Map from the Platform Library @@ -121,71 > > +117,6 @@ MemoryPeim ( > > ); > > } > > > > - // > > - // Reserved the memory space occupied by the firmware volume > > - // > > - > > - SystemMemoryTop =3D (EFI_PHYSICAL_ADDRESS)PcdGet64 > > (PcdSystemMemoryBase) + (EFI_PHYSICAL_ADDRESS)PcdGet64 > > (PcdSystemMemorySize); > > - FdTop =3D (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFdBaseAddress) + > > (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFdSize); > > - > > - // EDK2 does not have the concept of boot firmware copied into > > DRAM. To avoid the DXE > > - // core to overwrite this area we must mark the region with the > > attribute non- present > > - if ((PcdGet64 (PcdFdBaseAddress) >=3D PcdGet64 (PcdSystemMemoryBase)= ) > > && (FdTop <=3D SystemMemoryTop)) { > > - Found =3D FALSE; > > - > > - // Search for System Memory Hob that contains the firmware > > - NextHob.Raw =3D GetHobList (); > > - while ((NextHob.Raw =3D GetNextHob > > (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, NextHob.Raw)) !=3D NULL) { > > - if ((NextHob.ResourceDescriptor->ResourceType =3D=3D > > EFI_RESOURCE_SYSTEM_MEMORY) && > > - (PcdGet64 (PcdFdBaseAddress) >=3D NextHob.ResourceDescriptor= - > > >PhysicalStart) && > > - (FdTop <=3D NextHob.ResourceDescriptor->PhysicalStart + > > NextHob.ResourceDescriptor->ResourceLength)) > > - { > > - ResourceAttributes =3D NextHob.ResourceDescriptor->ResourceAtt= ribute; > > - ResourceLength =3D NextHob.ResourceDescriptor->ResourceLength; > > - ResourceTop =3D NextHob.ResourceDescriptor->PhysicalStart + > > ResourceLength; > > - > > - if (PcdGet64 (PcdFdBaseAddress) =3D=3D NextHob.ResourceDescrip= tor- > > >PhysicalStart) { > > - if (SystemMemoryTop =3D=3D FdTop) { > > - NextHob.ResourceDescriptor->ResourceAttribute =3D Resource= Attributes > > & ~EFI_RESOURCE_ATTRIBUTE_PRESENT; > > - } else { > > - // Create the System Memory HOB for the firmware with the = non- > > present attribute > > - BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY, > > - ResourceAttributes & > > ~EFI_RESOURCE_ATTRIBUTE_PRESENT, > > - PcdGet64 (PcdFdBaseAddress), > > - PcdGet32 (PcdFdSize)); > > - > > - // Top of the FD is system memory available for UEFI > > - NextHob.ResourceDescriptor->PhysicalStart +=3D PcdGet32(Pc= dFdSize); > > - NextHob.ResourceDescriptor->ResourceLength -=3D > PcdGet32(PcdFdSize); > > - } > > - } else { > > - // Create the System Memory HOB for the firmware with the no= n- > present > > attribute > > - BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY, > > - ResourceAttributes & > > ~EFI_RESOURCE_ATTRIBUTE_PRESENT, > > - PcdGet64 (PcdFdBaseAddress), > > - PcdGet32 (PcdFdSize)); > > - > > - // Update the HOB > > - NextHob.ResourceDescriptor->ResourceLength =3D PcdGet64 > > (PcdFdBaseAddress) - NextHob.ResourceDescriptor->PhysicalStart; > > - > > - // If there is some memory available on the top of the FD th= en create a > > HOB > > - if (FdTop < NextHob.ResourceDescriptor->PhysicalStart + > > ResourceLength) { > > - // Create the System Memory HOB for the remaining region (= top of the > > FD) > > - BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY, > > - ResourceAttributes, > > - FdTop, > > - ResourceTop - FdTop); > > - } > > - } > > - Found =3D TRUE; > > - break; > > - } > > - NextHob.Raw =3D GET_NEXT_HOB (NextHob); > > - } > > - > > - ASSERT(Found); > > - } > > - > > // Build Memory Allocation Hob > > InitMmu (MemoryTable); > > > > -- > > 1.9.1 > > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel > > IMPORTANT NOTICE: The contents of this email and any attachments are > > confidential and may also be privileged. If you are not the intended > > recipient, please notify the sender immediately and do not disclose > > the contents to any other person, use it for any purpose, or store or > > copy the information in any medium. Thank you. > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel > IMPORTANT NOTICE: The contents of this email and any attachments are > confidential and may also be privileged. If you are not the intended reci= pient, > please notify the sender immediately and do not disclose the contents to = any > other person, use it for any purpose, or store or copy the information in= any > medium. Thank you.