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

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


  • To: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Wed, 13 Sep 2023 09:27:33 +0200
  • 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=u5uJOSoVS/xon+Tz/yEuR9AFjMT+k3rKxF/c2hyQWPo=; b=aXZ9DOYN1JOJX98FzCIdErhrf17H16/xbu64/Te1VTipFOTLLRcM1HOx2zanQUfMOTlGevMt1zEEvyGvNmUjbXYTd5qVa+MQWu0PEjdSd77zVarYsQLFyrsW3Xw9Kou3plO5BM6KwrTu01nKBviMSAfWYJ9JmWS0nJrJBh/gf+j0XrD+tD7a8Ug5O+4+BrmZd3SRFa7aIXgfzgWgDFM4GPKNfJqd6heyYTtnBSb3La35SGJoAhQlR9OGCAjzqw3lGY2eNqIB4bv4FTKudLQ+JS4kd/yrCRTACsF1B23evoxXyCRm40FmImagJLQkUtvVEzKH973pPU2B8Q5A3YC/5w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jIX6iKc6Qj4kzpziFzcsE8RDaOAmv7ZKAAb6pgaTtCLSzP/LyZvs+F3eygFST6kIPVnvb0QqdH1qVn35zvYgrVzb9G1CwjzCF3f9rRRq9ObwOzLZVYw0nsxYvCAO6eZ4uyZtSsN9Ky38zq+K/ioQJwqSIzSY9m+mmSPezDzccwzzZ7BBVNdkLkwFrkWPKE62Ok1Oje6k5rFysu363TYh+pKC30Lr5bSCXj5MCJMeQ3Odq9NoZaWZGHk+BYHdpCMJYd+kVG6KmObZ1LrlJupLwxasw+B5lCONc9L/Zt/KZggOuy/U7jydaHypMGLjg1g4JJXFnC4g9n9LRyHFoj4JGw==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Wed, 13 Sep 2023 07:28:08 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Stewart,

On 12/09/2023 22:43, Stewart Hildebrand wrote:
> There is a corner case where the filesizes of the xen and Linux kernel images
> are not sufficient. These binaries likely contain NOLOAD sections (e.g. bss),
> 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>
The patch works, thanks!
Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>

with one little suggestion...

> ---
> v1->v2:
> * add in-code comments
> * use variables more
> ---
>  scripts/uboot-script-gen | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
> index 9656a458ac00..f0972d983017 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,21 @@ function add_size()
>  {
>      local filename=$1
>      local size=`stat -L --printf="%s" $filename`
> +    # Read arm64 header magic 
> (https://www.kernel.org/doc/Documentation/arm64/booting.txt)
> +    local arm64_header_magic=$(od -j 56 -N 4 -t x4 ${filename} | head -n 1 | 
> awk -F' ' '{ print $2 }')
can we simplify:
head -n 1 | awk -F' ' '{ print $2 }'
by just doing:
awk 'NR==1 {print $2}'

~Michal



 


Rackspace

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