[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ImageBuilder PATCH] uboot-script-gen: use size from arm64 Image header


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Thu, 24 Aug 2023 14:22:31 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QMltQQhGGtk4wnzy42Xehvg/dyQWAzbgc6rFZmJF9GM=; b=JpVVbJHxnFfALXnJb2CyYr0MpvD98qjfVok8WV++WmfRDfZ1qzsb7JkvE+eo3HONqf9qsz/qT4MGAJlvxuDPn9MzgK/Rsr+0gq4ubaSyWMmbIZ2ZxNGJfUQG5EZZ1YhHVZSQuiCt/c5II4kyox+PBWTTC/ppkWqxS/MHcBT7P6rb0VptUQwMtNm2CH1BM8Rqy4vy2grqrNzojYg3mekl6xLRuaP8bPXQxwZzxqqxaeAD+8V7C+g94BWv6M0lydu6/XrhCI/6JKCc+6ahQfzhOuTaWYzJmoN0Ua9qX2I26rNwMbTYvl56IMwPy1gL9OtcmSqntv3V+2cx8fjKqSNhyA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W570YnU6gvugyC/OGQi4plieGtQcmUd6886fACPxc21BojWfkUSGzTZ2hiDZUdaz6PRe+N6I3P2qkXcxOVEGigmuYVn2ljdMRJ8d3tIUYTqBI3kIiebuExRCatwVlZbOU1xOWMG+/nFvNHYfU0OYj1cTGLiFlQPmzSOwCS6v5MA/Np8ftC+la+q9hLz+XJID0A8oU7mGaQq/d782AwLnhz+2YSz7hKgs1i5ZaGGpl3wQqb1ezfKI0B5LIdkByDQC6NfmJBIfz6sCkdv1konzblssybAyJxmCSeuecRn+XhX0P7iJSLYQwAWVGgWr2JTIHorc7ON9hcHyT2ZbFTwq3Q==
  • Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Thu, 24 Aug 2023 18:23:14 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

There is a corner case where the filesizes of the xen and Linux kernel images
are not sufficient. These binaries likely contain .NOLOAD sections, which are
not accounted in the filesize.

Check for the presence of an arm64 kernel image header, and get the effective
image size from the header. Use the effective image size for calculating the
next load address and for populating the size in the /chosen/dom*/reg property.

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
---
 scripts/uboot-script-gen | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
index 9656a458ac00..50fe525e7145 100755
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -2,7 +2,7 @@
 
 offset=$((2*1024*1024))
 filesize=0
-prog_req=(mkimage file fdtput mktemp awk)
+prog_req=(mkimage file fdtput mktemp awk od)
 
 function cleanup_and_return_err()
 {
@@ -435,6 +435,17 @@ function add_size()
 {
     local filename=$1
     local size=`stat -L --printf="%s" $filename`
+
+    if [ "$(od -j 56 -N 4 -t x4 ${filename} | head -n 1 | awk -F' ' '{ print 
$2 }')" = "644d5241" ]
+    then
+        local size_header=$(od -j 16 -N 8 -t u8 ${filename} | head -n 1 | awk 
-F' ' '{ print $2 }')
+
+        if [ "${size_header}" -gt "${size}" ]
+        then
+            size=${size_header}
+        fi
+    fi
+
     memaddr=$(( $memaddr + $size + $offset - 1))
     memaddr=$(( $memaddr & ~($offset - 1) ))
     memaddr=`printf "0x%X\n" $memaddr`
-- 
2.42.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.