From patchwork Sat Aug 24 04:53:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 19518 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6021C23A4E for ; Sat, 24 Aug 2013 04:54:12 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id f12sf1284208vbg.11 for ; Fri, 23 Aug 2013 21:54:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=2hKWLm0wKmbQBILr5lwP+b38bEWHVzaXGqFx9N84Qa4=; b=B11Zt6gGslYe/aWqUEeWFTCjJAcE1GTOHMd9I9tjENhn+4JP7fAoHiYsbZIEHMrED+ C4Y2PN01PjaSMG6Fiq92sWCI2J4hiZzL3b3Wm2vuBxOipbk7ZHVUQQhdtwVZSwRou9lG gfPvQUjLDiJTNi6cjbZu/z37yUbdeijV2GUPmLcxuKcE2FaGCNJKaehW0gVnm+a6Ds09 /JGnLi+sveFq2KESWAFdSKfvHm0Pn5S7y/nnDoLrgljKVPV+4Z0UaT33dH/PX+cRMyDZ FJBJjIJel2me1p92kSewws9By+1AX9sTjLGlOO6LewQ1M5BGMSwe6BD7p6YgXh0TxVeS edxw== X-Received: by 10.224.13.136 with SMTP id c8mr2690376qaa.0.1377320052111; Fri, 23 Aug 2013 21:54:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.127.99 with SMTP id nf3ls1812406qeb.83.gmail; Fri, 23 Aug 2013 21:54:12 -0700 (PDT) X-Received: by 10.220.174.200 with SMTP id u8mr2705460vcz.6.1377320052031; Fri, 23 Aug 2013 21:54:12 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id rx10si953645vdc.138.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 21:54:11 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id cy12so958751veb.4 for ; Fri, 23 Aug 2013 21:54:11 -0700 (PDT) X-Gm-Message-State: ALoCoQnmDIyjgLFoLC5qBp2w0kgiJBKwBgF6NouP/EvK1cqz1birxXtj3kvRAl9oXGJxRAEHusKX X-Received: by 10.58.246.8 with SMTP id xs8mr2748988vec.9.1377320051638; Fri, 23 Aug 2013 21:54:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp131679vcz; Fri, 23 Aug 2013 21:54:11 -0700 (PDT) X-Received: by 10.66.146.66 with SMTP id ta2mr2739659pab.11.1377320050650; Fri, 23 Aug 2013 21:54:10 -0700 (PDT) Received: from mail-pd0-f179.google.com (mail-pd0-f179.google.com [209.85.192.179]) by mx.google.com with ESMTPS id ei3si2104724pbb.37.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 21:54:10 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.179 is neither permitted nor denied by best guess record for domain of victor.kamensky@linaro.org) client-ip=209.85.192.179; Received: by mail-pd0-f179.google.com with SMTP id v10so1427561pde.24 for ; Fri, 23 Aug 2013 21:54:10 -0700 (PDT) X-Received: by 10.66.226.46 with SMTP id rp14mr2558394pac.133.1377320050058; Fri, 23 Aug 2013 21:54:10 -0700 (PDT) Received: from kamensky-w530.cisco.com.net (c-24-6-79-41.hsd1.ca.comcast.net. [24.6.79.41]) by mx.google.com with ESMTPSA id w6sm3521915pbt.32.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 23 Aug 2013 21:54:09 -0700 (PDT) From: Victor Kamensky To: boot-architecture@lists.linaro.org, linaro-enterprise@lists.linaro.org, Leif.Lindholm@linaro.org, rony.nandy@linaro.org Cc: steve.mcintyre@linaro.org, patches@linaro.org, Victor Kamensky Subject: [PATCH] UEFI-ARM: PrepareFdt need to use DescriptorSize to iterate through MemoryMap Date: Fri, 23 Aug 2013 21:53:48 -0700 Message-Id: <1377320028-14160-2-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1377320028-14160-1-git-send-email-victor.kamensky@linaro.org> References: <1377320028-14160-1-git-send-email-victor.kamensky@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: victor.kamensky@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- ArmPkg/Library/BdsLib/BdsLinuxFdt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c b/ArmPkg/Library/BdsLib/BdsLinuxFdt.c index 4ff0afe..df12607 100644 --- a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c +++ b/ArmPkg/Library/BdsLib/BdsLinuxFdt.c @@ -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); } }