From patchwork Thu May 30 14:05:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 17302 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2060725C6D for ; Thu, 30 May 2013 14:05:34 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id fs12sf306550lab.4 for ; Thu, 30 May 2013 07:05:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=zeBQvQQ2aHEuvgy7OZx7pqyPdJ6b5VFGsXVHVAi29y8=; b=oAhVW3jBovx4SQk++5C0DuWa0vGgP1f6Bzud4fHiLr8chsqnMbBIvyNsxS0up8jo/6 RSlLpDusN2uTDUOVkOKKpNQK3N70xNJ3/U8iOV/RmQccph27Crq3uaB2gxR/vi8SF7VH m14023CbtmMal0ku5/aJ+76ENmllGn0m8J2z3Cnmo+TnEBv+ccupan9heuHjScBIdX0l JssvFFrNQPlYGaUdmZX7IGaqHTMs2cKoB3y6XIU9LsHBTP3YgV3qNTomXJAH7D5qasFX 9ZEnOO+aD/mYbjjD1s0fRO/liX2951oaokr+gEnj42GnscvW8nf2IrrxZUWiNBZth5+x 6NbA== X-Received: by 10.180.185.115 with SMTP id fb19mr9485256wic.0.1369922732240; Thu, 30 May 2013 07:05:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.8.134 with SMTP id r6ls1907352wia.48.canary; Thu, 30 May 2013 07:05:32 -0700 (PDT) X-Received: by 10.180.109.48 with SMTP id hp16mr4857869wib.24.1369922732134; Thu, 30 May 2013 07:05:32 -0700 (PDT) Received: from mail-ve0-x22f.google.com (mail-ve0-x22f.google.com [2607:f8b0:400c:c01::22f]) by mx.google.com with ESMTPS id bf3si8391043wjb.33.2013.05.30.07.05.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 May 2013 07:05:32 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22f is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22f; Received: by mail-ve0-f175.google.com with SMTP id da11so198794veb.6 for ; Thu, 30 May 2013 07:05:31 -0700 (PDT) X-Received: by 10.52.163.207 with SMTP id yk15mr4736434vdb.42.1369922731028; Thu, 30 May 2013 07:05:31 -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.229.199 with SMTP id jj7csp9432vcb; Thu, 30 May 2013 07:05:30 -0700 (PDT) X-Received: by 10.194.61.140 with SMTP id p12mr4890741wjr.51.1369922730057; Thu, 30 May 2013 07:05:30 -0700 (PDT) Received: from mail-wi0-x22a.google.com (mail-wi0-x22a.google.com [2a00:1450:400c:c05::22a]) by mx.google.com with ESMTPS id o10si8238702wiy.32.2013.05.30.07.05.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 May 2013 07:05:30 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c05::22a is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=2a00:1450:400c:c05::22a; Received: by mail-wi0-f170.google.com with SMTP id hr14so5327182wib.3 for ; Thu, 30 May 2013 07:05:29 -0700 (PDT) X-Received: by 10.180.109.195 with SMTP id hu3mr4931115wib.13.1369922729485; Thu, 30 May 2013 07:05:29 -0700 (PDT) Received: from belegaer.uk.xensource.com. (firewall.ctxuk.citrix.com. [46.33.159.2]) by mx.google.com with ESMTPSA id f2sm38153571wiv.11.2013.05.30.07.05.28 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 May 2013 07:05:28 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Cc: Stefano.Stabellini@eu.citrix.com, ian.campbell@citrix.com, patches@linaro.org, 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> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1369922720-10015-1-git-send-email-julien.grall@linaro.org> References: <1369922720-10015-1-git-send-email-julien.grall@linaro.org> X-Gm-Message-State: ALoCoQnZfsJpMjg63qe6jaa8ojBHpT6K/OxdeJuXHxAUw02XLbTxppT9ypDChY/spnzY/FpZ3W3I X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22f 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: , 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; }