From patchwork Wed Apr 9 11:51:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 28086 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 850B4202DD for ; Wed, 9 Apr 2014 11:53:34 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id lh14sf6666364vcb.2 for ; Wed, 09 Apr 2014 04:53:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=dWeN7bg+oBSEyI4nfdndXtsGvN89xLK1Cqu6XQNRjfA=; b=hMa4OfSKcj5ExxdHa0DG4uWtrhFD3xuGmoYXZSH/fBKB/NH4vh2bzrJDwbgcYVAi5S TMbvez9veNaZ5SQ7pK/Q1xqixrQutJSjjKY8R8CaqHcdg8qIZSD+ll8Z4l9nJ19t6p+d T9yxzF4xSeLUp8MltR849fJtQ1dhnqo7waJq0hps1ogxxS/Y6qfCKKCaMv913sDEf8a+ krdtq+2V9HsM2kvlDaz6K27DVfYcxnvNd7uqlrHPpeofwrbSYVcUr8sXPuJ6YqwEpFCz B+cP4P6qBRsK1ewkFExRwk1eQZrPqpBsI8NEiOeOcdjKDertV1zSDr9PjCow0FyiQJ6/ 7Uhw== X-Gm-Message-State: ALoCoQlT51rdzgL/PQf7zyUESad/E+ND5Dmvb8EtfNTSUEYapeCM8WLBy91qrhy7PwqTsaItHult X-Received: by 10.58.95.98 with SMTP id dj2mr4411466veb.30.1397044414260; Wed, 09 Apr 2014 04:53:34 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.145 with SMTP id c17ls621239qgd.60.gmail; Wed, 09 Apr 2014 04:53:34 -0700 (PDT) X-Received: by 10.220.105.4 with SMTP id r4mr216162vco.27.1397044414115; Wed, 09 Apr 2014 04:53:34 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id u5si98539vdo.58.2014.04.09.04.53.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Apr 2014 04:53:34 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id lf12so1995390vcb.11 for ; Wed, 09 Apr 2014 04:53:34 -0700 (PDT) X-Received: by 10.220.162.6 with SMTP id t6mr8592806vcx.12.1397044414017; Wed, 09 Apr 2014 04:53:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp323204vcv; Wed, 9 Apr 2014 04:53:33 -0700 (PDT) X-Received: by 10.140.30.71 with SMTP id c65mr10309366qgc.16.1397044413476; Wed, 09 Apr 2014 04:53:33 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id u10si276401qcz.58.2014.04.09.04.53.32 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 09 Apr 2014 04:53:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WXr2K-00026b-3y; Wed, 09 Apr 2014 11:51:24 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WXr2H-00026C-Tq for xen-devel@lists.xen.org; Wed, 09 Apr 2014 11:51:22 +0000 Received: from [85.158.137.68:43125] by server-8.bemta-3.messagelabs.com id BF/F4-21547-93435435; Wed, 09 Apr 2014 11:51:21 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-8.tower-31.messagelabs.com!1397044277!879209!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.11.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11019 invoked from network); 9 Apr 2014 11:51:19 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-8.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 9 Apr 2014 11:51:19 -0000 X-IronPort-AV: E=Sophos;i="4.97,826,1389744000"; d="scan'208";a="119455029" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 09 Apr 2014 11:51:17 +0000 Received: from norwich.cam.xci-test.com (10.80.248.129) by smtprelay.citrix.com (10.13.107.80) with Microsoft SMTP Server id 14.2.342.4; Wed, 9 Apr 2014 07:51:17 -0400 Received: from marilith-n13-p0.uk.xensource.com ([10.80.229.115] helo=marilith-n13.uk.xensource.com.) by norwich.cam.xci-test.com with esmtp (Exim 4.72) (envelope-from ) id 1WXr2C-00034e-UV; Wed, 09 Apr 2014 11:51:17 +0000 From: Ian Campbell To: Date: Wed, 9 Apr 2014 12:51:15 +0100 Message-ID: <1397044276-30185-2-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1397044259.6275.15.camel@kazak.uk.xensource.com> References: <1397044259.6275.15.camel@kazak.uk.xensource.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: julien.grall@linaro.org, tim@xen.org, Ian Campbell , stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH 2/3] xen: arm: use same variables as userspace in dom0 builder place_modules() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ian.campbell@citrix.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.180 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 Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: The placement algorithm should be effectively the same and using different variable names makes my head hurt when I try to compare. Signed-off-by: Ian Campbell Acked-by: Julien Grall --- xen/arch/arm/kernel.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index ae86772..bc625a4 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -65,25 +65,25 @@ void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len) } static void place_modules(struct kernel_info *info, - paddr_t kernel_start, - paddr_t kernel_end) + paddr_t kernbase, paddr_t kernend) { /* Align DTB and initrd size to 2Mb. Linux only requires 4 byte alignment */ const paddr_t initrd_len = ROUNDUP(early_info.modules.module[MOD_INITRD].size, MB(2)); const paddr_t dtb_len = ROUNDUP(fdt_totalsize(info->fdt), MB(2)); - const paddr_t total = initrd_len + dtb_len; + const paddr_t modsize = initrd_len + dtb_len; /* Convenient */ - const paddr_t mem_start = info->mem.bank[0].start; - const paddr_t mem_size = info->mem.bank[0].size; - const paddr_t mem_end = mem_start + mem_size; - const paddr_t kernel_size = kernel_end - kernel_start; + const paddr_t rambase = info->mem.bank[0].start; + const paddr_t ramsize = info->mem.bank[0].size; + const paddr_t ramend = rambase + ramsize; + const paddr_t kernsize = kernend - kernbase; + const paddr_t ram128mb = rambase + MB(128); - paddr_t addr; + paddr_t modbase; - if ( total + kernel_size > mem_size ) - panic("Not enough memory in the first bank for the dtb+initrd"); + if ( modsize + kernsize > ramsize ) + panic("Not enough memory in the first bank for the kernel+dtb+initrd"); /* * DTB must be loaded such that it does not conflict with the @@ -100,19 +100,19 @@ static void place_modules(struct kernel_info *info, * just after the kernel, if there is room, otherwise just before. */ - if ( kernel_end < MIN(mem_start + MB(128), mem_end - total) ) - addr = MIN(mem_start + MB(128), mem_end - total); - else if ( mem_end - ROUNDUP(kernel_end, MB(2)) >= total ) - addr = ROUNDUP(kernel_end, MB(2)); - else if ( kernel_start - mem_start >= total ) - addr = kernel_start - total; + if ( kernend < MIN(ram128mb, ramend - modsize) ) + modbase = MIN(ram128mb, ramend - modsize); + else if ( ramend - ROUNDUP(kernend, MB(2)) >= modsize ) + modbase = ROUNDUP(kernend, MB(2)); + else if ( kernbase - rambase >= modsize ) + modbase = kernbase - modsize; else { panic("Unable to find suitable location for dtb+initrd"); return; } - info->dtb_paddr = addr; + info->dtb_paddr = modbase; info->initrd_paddr = info->dtb_paddr + dtb_len; }