From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-x230.google.com (mail-io0-x230.google.com [IPv6:2607:f8b0:4001:c06::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E12A621E945F3 for ; Tue, 19 Sep 2017 23:29:04 -0700 (PDT) Received: by mail-io0-x230.google.com with SMTP id d16so3163970ioj.3 for ; Tue, 19 Sep 2017 23:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=qHS2WgzXNG3Wr/RnAe0anolrZ/M004fUHStuW7dOXmc=; b=d5J/sK1C0n9GPDWV9cXT9xbiz89Lpj1TzxeqTxu5iHkb8gCjRlMiW6/WIAbhJ9F9iX leTR5Ujsv3MkRcC/Rdonl18Z9J1LSsc1JKqbOXiDL93aAD71Qzak6sJ0CO12j3TQsIRx pAxxV7wQPHclKPHNY+dugUHrqgFP5fZEprJqc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=qHS2WgzXNG3Wr/RnAe0anolrZ/M004fUHStuW7dOXmc=; b=ZLMDbZQpO6O2MHgkF5lAS2JanA47T2oErJRAu+EvxM94vZzcoMk/iAmN9UwDDfGCV3 6nyY69kEMg6XH6p7tvahRBvMHjCzF23J/KIzfyc8TqJfLKz0GAZ0I1v7PtyDRPIfTUWF 5lVhS1HjUuIYH2228H+PJxtDuUGaVs2z/sAVtUqDzhxMGV4eGUYUXvgh3XBiSDJXfhMh ehGaih+MqBa9HTfz7VS0y84gifpqnDbBI6oBAD+qm7Rg6XxdMoNupdzkqXcbO4dCqopM GFyd32AQl5npjPQiLdtQj8bqPIqg2oQqugaPiB7Q/yFQ6rWUqPGOvFxkadv00GyBVjjU N0aA== X-Gm-Message-State: AHPjjUi4D8QeskPHX+V6fSXUSg1EjiY0ukZvHrFhtljpIv7ktXDC4Dn9 m5WR2wm0hVk5pM77cUuo297VfHREj7ZEVpOXJK5nbQ== X-Google-Smtp-Source: AOwi7QAQJZV5nt7fiDPkyZ2NZmAVSF4MfPv3oKCK2j+nODvLhfU8d5MncyNc3uArVF52CA9919elyWFsBZKrcLvkOrU= X-Received: by 10.107.53.213 with SMTP id k82mr5922629ioo.179.1505889129674; Tue, 19 Sep 2017 23:32:09 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.152.18 with HTTP; Tue, 19 Sep 2017 23:32:08 -0700 (PDT) In-Reply-To: References: <1505485954-24345-1-git-send-email-meenakshi.aggarwal@nxp.com> <1505824329-32532-1-git-send-email-meenakshi.aggarwal@nxp.com> From: Ard Biesheuvel Date: Tue, 19 Sep 2017 23:32:08 -0700 Message-ID: To: Sakar Arora Cc: Meenakshi Aggarwal , "edk2-devel@lists.01.org" , "leif.lindholm@linaro.org" 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: Wed, 20 Sep 2017 06:29:05 -0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 19 September 2017 at 22:32, Sakar Arora wrote: > The DXE core dispatcher relies on the available memory to allocate space = for loading the rest of the modules from the UEFI image. If we declare the = UEFI image memory space (from which DXE dispatcher reads the efi modules) o= pen to allocation, it might lead to data corruption, depending on the locat= ion of UEFI image and cumulative size of uncompressed EFI modules. > > Also, since UEFI allows unloading and loading of drivers at runtime, IMO,= there is a need to preserve the UEFI image even after all the modules have= been decompressed and loaded in the boot sequence. > 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, and not reserve the memory so we don't lose it. If you still think this may break anything, could you please elaborate? > -----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 UEF= I 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 decompres= sed into memory already? > > >> 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_DESCRIPTO= R, 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 + NextH= ob.ResourceDescriptor->ResourceLength)) >> - { >> - ResourceAttributes =3D NextHob.ResourceDescriptor->ResourceAttr= ibute; >> - ResourceLength =3D NextHob.ResourceDescriptor->ResourceLength; >> - ResourceTop =3D NextHob.ResourceDescriptor->PhysicalStart + Res= ourceLength; >> - >> - if (PcdGet64 (PcdFdBaseAddress) =3D=3D NextHob.ResourceDescript= or->PhysicalStart) { >> - if (SystemMemoryTop =3D=3D FdTop) { >> - NextHob.ResourceDescriptor->ResourceAttribute =3D ResourceA= ttributes & ~EFI_RESOURCE_ATTRIBUTE_PRESENT; >> - } else { >> - // Create the System Memory HOB for the firmware with the n= on-present attribute >> - BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY, >> - ResourceAttributes & ~EFI_RESOU= RCE_ATTRIBUTE_PRESENT, >> - PcdGet64 (PcdFdBaseAddress), >> - PcdGet32 (PcdFdSize)); >> - >> - // Top of the FD is system memory available for UEFI >> - NextHob.ResourceDescriptor->PhysicalStart +=3D PcdGet32(Pcd= FdSize); >> - NextHob.ResourceDescriptor->ResourceLength -=3D PcdGet32(Pc= dFdSize); >> - } >> - } else { >> - // Create the System Memory HOB for the firmware with the non= -present attribute >> - BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY, >> - ResourceAttributes & ~EFI_RESOURC= E_ATTRIBUTE_PRESENT, >> - PcdGet64 (PcdFdBaseAddress), >> - PcdGet32 (PcdFdSize)); >> - >> - // Update the HOB >> - NextHob.ResourceDescriptor->ResourceLength =3D PcdGet64 (PcdF= dBaseAddress) - NextHob.ResourceDescriptor->PhysicalStart; >> - >> - // If there is some memory available on the top of the FD the= n create a HOB >> - if (FdTop < NextHob.ResourceDescriptor->PhysicalStart + Resou= rceLength) { >> - // Create the System Memory HOB for the remaining region (t= op 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 con= fidential 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. > IMPORTANT NOTICE: The contents of this email and any attachments are conf= idential and may also be privileged. If you are not the intended recipient,= please notify the sender immediately and do not disclose the contents to a= ny other person, use it for any purpose, or store or copy the information i= n any medium. Thank you.