From patchwork Mon May 27 13:50:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 17221 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 93923238E8 for ; Mon, 27 May 2013 13:51:48 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id bs12sf2891736qab.3 for ; Mon, 27 May 2013 06:50:44 -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 :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=pplGpFxdlid1KGDZtGNtoZtEGaNt7yMclC7rgXTyomc=; b=Pgh7sk8DlFrGFcre0Lv6NrqeFj8XlzMWtz72Rjokzq8VzNns6ygVZYyWnHL7yHRYSC ioFP/RHKTx5Oxazpw+lxOpQqwebBI0zlXMCtC2ChON2QFnzi7OUreHXUAfs97uyEfKus lmYPFyeZ8ApO9bt30WVMEKMKjkVTayKWzDYHHJU6EWbRcXmnHPsBxV4LrbZDrFPZLHrc 53vq47ouFZmZAFxCZS2Ls3SxdIPcKk32oneptBFynPkyQiRz3hkcOVLiom5WqmFT5K+H XuuvSKO1XA89uRTsEzW8+huRhhwRD7YfTPvHLfg7U+aUS/y4iLh4BHU+JvjL5chyX/Jv 8HKA== X-Received: by 10.236.146.201 with SMTP id r49mr13938642yhj.27.1369662644024; Mon, 27 May 2013 06:50:44 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.58.172 with SMTP id s12ls2791043qeq.18.gmail; Mon, 27 May 2013 06:50:43 -0700 (PDT) X-Received: by 10.58.172.67 with SMTP id ba3mr15055006vec.58.1369662643821; Mon, 27 May 2013 06:50:43 -0700 (PDT) Received: from mail-ve0-x22d.google.com (mail-ve0-x22d.google.com [2607:f8b0:400c:c01::22d]) by mx.google.com with ESMTPS id sc6si16785695vdc.99.2013.05.27.06.50.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 May 2013 06:50:43 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22d 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::22d; Received: by mail-ve0-f173.google.com with SMTP id cy12so5060891veb.4 for ; Mon, 27 May 2013 06:50:43 -0700 (PDT) X-Received: by 10.52.69.200 with SMTP id g8mr12948475vdu.4.1369662643452; Mon, 27 May 2013 06:50:43 -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 jj7csp788vcb; Mon, 27 May 2013 06:50:42 -0700 (PDT) X-Received: by 10.180.90.164 with SMTP id bx4mr8710979wib.13.1369662642251; Mon, 27 May 2013 06:50:42 -0700 (PDT) Received: from mail-we0-x230.google.com (mail-we0-x230.google.com [2a00:1450:400c:c03::230]) by mx.google.com with ESMTPS id h6si4246952wiz.33.2013.05.27.06.50.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 May 2013 06:50:42 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::230 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=2a00:1450:400c:c03::230; Received: by mail-we0-f176.google.com with SMTP id p58so4514344wes.35 for ; Mon, 27 May 2013 06:50:41 -0700 (PDT) X-Received: by 10.180.72.195 with SMTP id f3mr8671882wiv.32.1369662641730; Mon, 27 May 2013 06:50:41 -0700 (PDT) Received: from belegaer.uk.xensource.com. (firewall.ctxuk.citrix.com. [46.33.159.2]) by mx.google.com with ESMTPSA id d5sm17632656wic.1.2013.05.27.06.50.40 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 May 2013 06:50:40 -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] xen/arm: Rework the way to compute dom0 DTB base address Date: Mon, 27 May 2013 14:50:37 +0100 Message-Id: <1369662637-21449-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQmFRqFwWS6UvjqDdCv5UIIYwxFDajzh9zwc3ffy7w0Pkx72XF4skDxBOHDLfWTge3PdOi1D X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22d 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 the DTB is loading right the after the kernel, on some setup, Linux will overwrite the DTB during the decompression step. To be sure the DTB won't be overwritten by the decrompression stage, load the DTB near the end of the first memory bank and below 4Gib (if memory range is greater). Signed-off-by: Julien Grall --- xen/arch/arm/domain_build.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index f857e40..ca086a3 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -519,6 +519,7 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) void *fdt; int new_size; int ret; + paddr_t end; kinfo->unassigned_mem = dom0_mem; @@ -543,11 +544,6 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) if ( ret < 0 ) goto err; - /* - * Put the device tree at the beginning of the first bank. It - * must be below 4 GiB. - */ - kinfo->dtb_paddr = kinfo->mem.bank[0].start + 0x100; if ( kinfo->dtb_paddr + fdt_totalsize(kinfo->fdt) > (1ull << 32) ) { printk("Not enough memory below 4 GiB for the device tree."); @@ -555,6 +551,16 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) goto err; } + /* + * DTB must be load below 4GiB and far enough to linux (Linux use + * the space after it to decompress) + * Load the DTB at the end of the first bank or below 4Gib + */ + end = kinfo->mem.bank[0].start + kinfo->mem.bank[0].size; + kinfo->dtb_paddr = (MIN(1ull << 32, end) - fdt_totalsize(kinfo->fdt)); + /* Linux requires the address to be a multiple of 4 */ + kinfo->dtb_paddr &= ~3; + return 0; err: @@ -566,6 +572,8 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo) static void dtb_load(struct kernel_info *kinfo) { void * __user dtb_virt = (void * __user)(register_t)kinfo->dtb_paddr; + printk("Loading dom0 DTB to 0x%"PRIpaddr"-0x%"PRIpaddr"\n", + kinfo->dtb_paddr, kinfo->dtb_paddr + fdt_totalsize(kinfo->fdt)); raw_copy_to_guest(dtb_virt, kinfo->fdt, fdt_totalsize(kinfo->fdt)); xfree(kinfo->fdt); @@ -604,7 +612,6 @@ int construct_dom0(struct domain *d) /* The following loads use the domain's p2m */ p2m_load_VTTBR(d); - kinfo.dtb_paddr = kinfo.zimage.load_addr + kinfo.zimage.len; kernel_load(&kinfo); dtb_load(&kinfo);