From patchwork Wed Apr 9 11:51:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 28084 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 56AED202DD for ; Wed, 9 Apr 2014 11:53:30 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id j7sf5907323qaq.6 for ; Wed, 09 Apr 2014 04:53:29 -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=n5zbsb79nlDI8+dvZnoQzfdsEm5SlBJePmEiW65RQu0=; b=RKWJq1kj3k+O6knx4DdpttDzEW67BKOaWeKOYWrhEq42zWqqOs32UkeZ/kMLmCPG03 DT1HCVcX4ZkLxbXp3XS9AWhfO3DoatuB3MiRQBMN/C/ohx+mVhomcrEx78mbcVwY8/v4 jmnRabgP7olXOUIw5fthcdEFPPwyOL6QI6Dho0pFpWA4gHYh5Tumkj3rYQ5hR8tie64g tl4F6HKNYuu8BgTYHYVipourCVPyx5nwfwJkSXZJ8ds9gnKk/KDO+CvUJzJ52i9d7JV2 lJqWh3cjr1DEHXOc8cUD6KtveszfKlacWAA7gvm7JafOutToTb+fiB8pTeuKrmz8fNIk qhUw== X-Gm-Message-State: ALoCoQkKE+yn3lwx4qGMPrzeHSjjE/QYY35GkjlM8kU/9x0GZ/NRpkoqOj2cHiTi1VI33X0keSZQ X-Received: by 10.236.92.15 with SMTP id i15mr4188122yhf.8.1397044409880; Wed, 09 Apr 2014 04:53:29 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.104.116 with SMTP id z107ls668084qge.37.gmail; Wed, 09 Apr 2014 04:53:29 -0700 (PDT) X-Received: by 10.52.99.168 with SMTP id er8mr974253vdb.26.1397044409763; Wed, 09 Apr 2014 04:53:29 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id tz5si96157vdc.115.2014.04.09.04.53.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Apr 2014 04:53:29 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.169 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.169; Received: by mail-vc0-f169.google.com with SMTP id ik5so2021052vcb.0 for ; Wed, 09 Apr 2014 04:53:29 -0700 (PDT) X-Received: by 10.58.107.65 with SMTP id ha1mr8509202veb.1.1397044409680; Wed, 09 Apr 2014 04:53:29 -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 v8csp323201vcv; Wed, 9 Apr 2014 04:53:29 -0700 (PDT) X-Received: by 10.224.36.194 with SMTP id u2mr11391382qad.73.1397044408528; Wed, 09 Apr 2014 04:53:28 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id v10si278253qat.70.2014.04.09.04.53.28 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 09 Apr 2014 04:53:28 -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 1WXr2J-00026Q-OR; Wed, 09 Apr 2014 11:51:23 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WXr2H-00026B-O0 for xen-devel@lists.xen.org; Wed, 09 Apr 2014 11:51:21 +0000 Received: from [193.109.254.147:56438] by server-6.bemta-14.messagelabs.com id 75/61-13066-83435435; Wed, 09 Apr 2014 11:51:20 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1397044278!7204744!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n X-StarScan-Received: X-StarScan-Version: 6.11.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16660 invoked from network); 9 Apr 2014 11:51:19 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-15.tower-27.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="118265012" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO02.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 1WXr2D-00034e-1w; Wed, 09 Apr 2014 11:51:17 +0000 From: Ian Campbell To: Date: Wed, 9 Apr 2014 12:51:16 +0100 Message-ID: <1397044276-30185-3-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: MIA1 Cc: julien.grall@linaro.org, tim@xen.org, Ian Campbell , stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH 3/3] xen: arm: rework dom0 initrd and dtb placement 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.169 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: This now uses the same decision tree as libxc (which is much easier to test). The main change is to explictly handle the placement at 128MB or end of RAM as two cases, rather than combining with MIN. The effect is the same but the code is clearer. Secondly the attempt to place the mopules right after the kernel is removed, since it is redundant with the case where placing them at the end of RAM ends up abutting the kernel. Also round the kernel size up to a 2MB boundary. Signed-off-by: Ian Campbell Acked-by: Julien Grall --- I'm sure to regret playing with this yet again... --- xen/arch/arm/kernel.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index bc625a4..1102392 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -77,7 +77,7 @@ static void place_modules(struct kernel_info *info, 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 kernsize = ROUNDUP(kernend, MB(2)) - kernbase; const paddr_t ram128mb = rambase + MB(128); paddr_t modbase; @@ -95,16 +95,18 @@ static void place_modules(struct kernel_info *info, * If the bootloader provides an initrd, it will be loaded just * after the DTB. * - * We try to place dtb+initrd at 128MB, (or, if we have less RAM, - * as high as possible). If there is no space then fallback to - * just after the kernel, if there is room, otherwise just before. + * We try to place dtb+initrd at 128MB or if we have less RAM + * as high as possible. If there is no space then fallback to + * just before the kernel. + * + * If changing this then consider + * tools/libxc/xc_dom_arm.c:arch_setup_meminit as well. */ - - 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 ) + if ( ramend >= ram128mb + modsize && kernend < ram128mb ) + modbase = ram128mb; + else if ( ramend - modsize > ROUNDUP(kernend, MB(2)) ) + modbase = ramend - modsize; + else if ( kernbase - rambase > modsize ) modbase = kernbase - modsize; else {