@@ -490,17 +490,18 @@ PrepareFdt (
// Go through the list and add the reserved region to the Device Tree
if (!EFI_ERROR(Status)) {
- for (Index = 0; Index < (MemoryMapSize / sizeof(EFI_MEMORY_DESCRIPTOR)); Index++) {
+ for (Index = 0; Index < (MemoryMapSize / DescriptorSize); Index++) {
if (IsLinuxReservedRegion ((EFI_MEMORY_TYPE)MemoryMap[Index].Type)) {
DEBUG((DEBUG_VERBOSE, "Reserved region of type %d [0x%X, 0x%X]\n",
- MemoryMap[Index].Type,
- (UINTN)MemoryMap[Index].PhysicalStart,
- (UINTN)(MemoryMap[Index].PhysicalStart + MemoryMap[Index].NumberOfPages * EFI_PAGE_SIZE)));
- err = fdt_add_mem_rsv(fdt, MemoryMap[Index].PhysicalStart, MemoryMap[Index].NumberOfPages * EFI_PAGE_SIZE);
+ MemoryMap->Type,
+ (UINTN)MemoryMap->PhysicalStart,
+ (UINTN)(MemoryMap->PhysicalStart + MemoryMap->NumberOfPages * EFI_PAGE_SIZE)));
+ err = fdt_add_mem_rsv(fdt, MemoryMap->PhysicalStart, MemoryMap->NumberOfPages * EFI_PAGE_SIZE);
if (err != 0) {
Print(L"Warning: Fail to add 'memreserve' (err:%d)\n", err);
}
}
+ MemoryMap = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryMap + DescriptorSize);
}
}
Fix PrepareFdt function to use DescriptorSize returned by gBS->GetMemoryMap (CoreGetMemoryMap) to iterate through MemoryMap area returned by the same function. Existing code that assumes that MemoryMap is array of EFI_MEMORY_DESCRIPTOR structures which is incorrect. Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org> --- ArmPkg/Library/BdsLib/BdsLinuxFdt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)