Ben: I agree this is an issue. PI spec has no limitation to create memory allocation hob. Memory may be allocated in either the HOB producer phase memory area or other areas of present and initialized system memory. DxeCore shouldn't assume the memory allocation hob are all created by PEI AllocatePages() service. I attach my patch to add the check in CoreInitializeMemoryServices(). Could you help review and try first?
Thanks Liming -----Original Message----- From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Benjamin Herrenschmidt Sent: Saturday, August 22, 2015 12:35 PM To: Tian, Feng Cc: Kinney, Michael D; edk2-devel@lists.01.org; Laszlo Ersek; Andrew Fish Subject: Re: [edk2] Question about memory reservation from PrePi to DXE On Mon, 2015-08-10 at 16:18 -0700, Andrew Fish wrote: > Laszlo and I are not the maintainers for this code. > https://github.com/tianocore/edk2/blob/master/Maintainers.txt < > https://github.com/tianocore/edk2/blob/master/Maintainers.txt> > > But it does feel like the assumption in the DXE Core is not implied by > the PI Specifications. Hi Feng ! You never replied to that thread ... my problem is that the code in CoreInitializeMemoryServices() will essentially pickup a piece of memory out of *any* memory descriptor HOB completely ignoring the memory allocation HOBs. That means that if Sec or Peim (or in my case, a special PrePei that transfers controls to DXE from a different firmware layer) has marked some memory as reserved via some memory allocation HOBs, there is still a chance that this memory gets overwriten early during DXE initialization, because CoreInitializeMemoryServices() ignores those allocations completely to pick up the initial core memory, which it then makes available to the allocator with CoreAddMemoryDescriptor(). It appears that the Gcd code is generally trying to honor the existing allocation HOBs since later on, CoreInitializeGcdServices() will iterate them and allocates them, but this happens after the above initialization and some allocations do happen in between. Is there a non-documented (or maybe I missed the documentation) requirement that all the Memory resource descriptor HOBs passed to DXE have been modified to *remove* all allocated space from them to avoid that problem or is this mainly a bug ? It does make the transition from a Flat Device Tree to DXE tricky, since in the FDT world, we have on one hand the "memory" modes that give us the regions of physical memory in the system, which would nicely translate to memory resource descriptors, and separately we have a reserve map which describes ranges of addresses that are reserved, either by some firmware layer or in some cases by the HW itself. Unless I missed something, while the spec allows us to match this to memory resource descriptors and memory allocation HOBs respectively, the DXE implementation will fail to honor such overlap properly. Am I correct ? Cheers, Ben. _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel