From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: [PATCH v2 2/2] xen/arm: If the DOM0 zImage as a DTB appended replace it Date: Thu, 30 May 2013 15:05:19 +0100 Message-ID: <1369922720-10015-3-git-send-email-julien.grall@linaro.org> References: <1369922720-10015-1-git-send-email-julien.grall@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1369922720-10015-1-git-send-email-julien.grall@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: patches@linaro.org, ian.campbell@citrix.com, Julien Grall , Stefano.Stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org If a DTB is appended to the DOM0 zImage, it's probably means that the linux decompression stage will replace the DBT register value (r2 on arm32) by the address of the appended DTB. In this case, to avoid issue with Linux, Xen needs to load the new device tree just after the kernel. Signed-off-by: Julien Grall --- xen/arch/arm/kernel.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index f8c8850..1d6c927 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -123,20 +123,6 @@ static int kernel_try_zimage_prepare(struct kernel_info *info, if ( (end - start) > size ) return -EINVAL; - /* - * Check for an appended DTB. - */ - if ( addr + end - start + sizeof(dtb_hdr) <= size ) - { - copy_from_paddr(&dtb_hdr, addr + end - start, - sizeof(dtb_hdr), DEV_SHARED); - if (be32_to_cpu(dtb_hdr.magic) == DTB_MAGIC) { - end += be32_to_cpu(dtb_hdr.total_size); - - if ( end > addr + size ) - return -EINVAL; - } - } info->zimage.kernel_addr = addr; @@ -154,6 +140,18 @@ static int kernel_try_zimage_prepare(struct kernel_info *info, info->load = kernel_zimage_load; info->type = KERNEL_ZIMAGE; + /* + * If there is an appended DTB, ask XEN to replace the DTB + * by the generate one. + */ + if ( info->zimage.len + sizeof(dtb_hdr) <= size ) + { + copy_from_paddr(&dtb_hdr, addr + end - start, + sizeof(dtb_hdr), DEV_SHARED); + if (be32_to_cpu(dtb_hdr.magic) == DTB_MAGIC) + info->dtb_paddr = info->zimage.load_addr + info->zimage.len; + } + return 0; } -- 1.7.10.4