From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.107.5.52; helo=eur03-ve1-obe.outbound.protection.outlook.com; envelope-from=udit.kumar@nxp.com; receiver=edk2-devel@lists.01.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50052.outbound.protection.outlook.com [40.107.5.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B84CE21A1099A for ; Thu, 30 Nov 2017 02:02:41 -0800 (PST) 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=uvE56WlH1tI4pTmY7EwkeSvf+Q3taDmoAjZu9eMA+Yw=; b=iEilwb9bcn5oo0e8x1qU09mrq7WOH011FTcmVwpOGK0vS97grXN8OT1gmyXPdOj2CoCgAFdLI2JrQyFNGY9N85ia8gBGK9sPHqDIe3Y6RGrEpGXLQwBaGU7J+3SJq7npeh4ddbwv72WXhg10XGpZHh+LYYPWhcVC1QBZMv1uZSw= Received: from AM6PR0402MB3334.eurprd04.prod.outlook.com (52.133.18.151) by AM6PR0402MB3333.eurprd04.prod.outlook.com (52.133.18.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.282.5; Thu, 30 Nov 2017 10:07:04 +0000 Received: from AM6PR0402MB3334.eurprd04.prod.outlook.com ([fe80::51eb:bed3:cf67:f4be]) by AM6PR0402MB3334.eurprd04.prod.outlook.com ([fe80::51eb:bed3:cf67:f4be%13]) with mapi id 15.20.0282.006; Thu, 30 Nov 2017 10:07:04 +0000 From: Udit Kumar To: Sakar Arora , Ard Biesheuvel CC: "edk2-devel@lists.01.org" , "leif.lindholm@linaro.org" Thread-Topic: [edk2] [PATCH v2] PeiLib : Inform UEFI memory to Linux Thread-Index: AQHTMRKizTdBt8YK50CCBP5JRh+41aK7185wgABRKICAARD5AIAAGEkAgAAc6QCAb7RjoA== Date: Thu, 30 Nov 2017 10:07:04 +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; AM6PR0402MB3333; 6:Iw4G1m6qI3lnAtA18HxTrKoI3R2ozzbKKPnO5uHySlprcUDScayiV555Mx3evoVB3t+urgUMxSwg7rHAiJ48mUVRR6seRtjCo9lVhgBBTasOk1/hTIemsYkiMyDZu6DqoRpoOmkUgmMh4oBzMENdo3yXtpwmWT8dCf0x0xKNfLSCRZVdNQ5CarcLBEL9rEdhijRbUsL4M2yFIoCd9iFeHlGDrrtI2lmTVhPbu3A4DuO6tRE5TSulRqkGK5lNzklfaOJ2rgarqmvtfgonWgZWnXlX3cHjSMgmePN9G4Ug0Eoy0phiAzmM2RP98SD8/ub56Y2uqL813Dx8/JZbPZCZx5l5ajtr/iRlNtb0n5ulr2s=; 5:mNTIjcq62iTs91z+MTPnbJuWPLXPtin4FpIShmDh3Tco8JNO2UZpZzq79NPMQ9CehEMMjRb5yM2kU/FlcnhCBg/eW3PMiB1pLqY/BeI26F/3s25vKhBTD5dn8y9rL8XKv6zHqmBMcDgxyKlvJ4CykziEybOVeICEiub2sqh9Ad8=; 24:1P0AvqfJ9Oc2eqGuXVzYoB0WX1d1wQSCPLmGIqo6mUGXNc3K1RaCjhrpT8PEDpGcjOM1E4wpiZWaNyRTpju4/e8nJQvEE65heKI1KDQSjWM=; 7:3I9eUEqpAGQDA1AAIevzmcp/sonhJUwmOBVlhA1xa6+Q8rqmPkRDBb8tQ4B8TukJKfET3+NXVUC1sGK0W/atH61fUYFRKCfNbVkQocrPUJVvInll/Wdg1+zFUTqjVPzZNX3G0xXfEvUIjS6LSYcQYliQ/d0sRG2/Z7I/ttRbWNffkhu4FPCg62m/hW7Q3NfmnXmBW1JU7IeYXMQpViR3M/yQgV2Q57bQb+6uQMLZNCryiHs0Sls7HMx0qsrojlKv x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: a89f73c0-8ee5-44f3-9bfb-08d537da1bb0 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603284); SRVR:AM6PR0402MB3333; x-ms-traffictypediagnostic: AM6PR0402MB3333: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(185117386973197)(162533806227266); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231022)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123555025)(20161123560025)(20161123564025)(20161123558100)(6072148)(201708071742011); SRVR:AM6PR0402MB3333; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:AM6PR0402MB3333; x-forefront-prvs: 05079D8470 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(346002)(366004)(39860400002)(51914003)(13464003)(24454002)(199003)(189002)(6116002)(66066001)(5250100002)(4326008)(316002)(33656002)(76176010)(2906002)(305945005)(25786009)(8936002)(7696005)(54356010)(50986010)(6436002)(53546010)(99286004)(2950100002)(6506006)(3280700002)(7736002)(189998001)(5890100001)(229853002)(110136005)(55016002)(3846002)(53936002)(966005)(5660300001)(106356001)(9686003)(3660700001)(93886005)(105586002)(6306002)(54906003)(6246003)(86362001)(101416001)(68736007)(478600001)(102836003)(97736004)(14454004)(74316002)(8676002)(81156014)(81166006)(2900100001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR0402MB3333; H:AM6PR0402MB3334.eurprd04.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; 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-Network-Message-Id: a89f73c0-8ee5-44f3-9bfb-08d537da1bb0 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2017 10:07:04.8500 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0402MB3333 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: Thu, 30 Nov 2017 10:02:43 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Ard,=20 Sorry for coming back late on this=20 Are you ok to apply this patch in edk2 Thx Udit > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Sa= kar > Arora > Sent: Wednesday, September 20, 2017 1:50 PM > To: Ard Biesheuvel > Cc: edk2-devel@lists.01.org; leif.lindholm@linaro.org > Subject: Re: [edk2] [PATCH v2] PeiLib : Inform UEFI memory to Linux >=20 > Thanks for the information. Seems my understanding was not correct in thi= s > context. I have no other doubts on this change. >=20 > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: Wednesday, September 20, 2017 12:02 PM > To: Sakar Arora > Cc: Meenakshi Aggarwal ; edk2- > devel@lists.01.org; leif.lindholm@linaro.org > Subject: Re: [edk2] [PATCH v2] PeiLib : Inform UEFI memory to Linux >=20 > On 19 September 2017 at 22:32, Sakar Arora wrote: > > The DXE core dispatcher relies on the available memory to allocate spac= e for > loading the rest of the modules from the UEFI image. If we declare the UE= FI > image memory space (from which DXE dispatcher reads the efi modules) open= to > allocation, it might lead to data corruption, depending on the location o= f UEFI > image and cumulative size of uncompressed EFI modules. > > > > Also, since UEFI allows unloading and loading of drivers at runtime, IM= O, there > is a need to preserve the UEFI image even after all the modules have been > decompressed and loaded in the boot sequence. > > >=20 > None of this is relevant. The uncompressed firmware volume containing DXE > core and everything else is preserved as before. The only thing that gets > discarded is the outer FV, which only contains the PrePi SEC module, and = the > compressed FV, neither of which is ever touched again after DXE core has > started executing. So we should not register the FV in the first place, a= nd not > reserve the memory so we don't lose it. >=20 > If you still think this may break anything, could you please elaborate? >=20 >=20 >=20 > > -----Original Message----- > > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > > Sent: Tuesday, September 19, 2017 6:18 PM > > To: Sakar Arora > > Cc: Meenakshi Aggarwal ; > > edk2-devel@lists.01.org; leif.lindholm@linaro.org > > Subject: Re: [edk2] [PATCH v2] PeiLib : Inform UEFI memory to Linux > > > > On 19 September 2017 at 01:07, Sakar Arora wrote: > >> This change will create the possibility for memory space holding the U= EFI > image to be over-written by the DXE core code, since this space will then= be > available for allocation. > > > > Yes. But why does this matter after the entire payload has been decompr= essed > into memory already? > > > > > >> Any such change, if required, should be done just before booting the O= S. > >> > >> -----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.ResourceDescripto= r- > >PhysicalStart) && > >> - (FdTop <=3D NextHob.ResourceDescriptor->PhysicalStart + > NextHob.ResourceDescriptor->ResourceLength)) > >> - { > >> - ResourceAttributes =3D NextHob.ResourceDescriptor->ResourceAt= tribute; > >> - ResourceLength =3D NextHob.ResourceDescriptor->ResourceLength= ; > >> - ResourceTop =3D NextHob.ResourceDescriptor->PhysicalStart + > ResourceLength; > >> - > >> - if (PcdGet64 (PcdFdBaseAddress) =3D=3D NextHob.ResourceDescri= ptor- > >PhysicalStart) { > >> - if (SystemMemoryTop =3D=3D FdTop) { > >> - NextHob.ResourceDescriptor->ResourceAttribute =3D > ResourceAttributes & ~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(P= cdFdSize); > >> - NextHob.ResourceDescriptor->ResourceLength -=3D > PcdGet32(PcdFdSize); > >> - } > >> - } else { > >> - // Create the System Memory HOB for the firmware with the n= on- > 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 t= hen 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 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. > > 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. > 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. > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel