From patchwork Fri Apr 25 11:22:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 29053 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 89C99203AC for ; Fri, 25 Apr 2014 11:24:06 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id ij19sf651483vcb.9 for ; Fri, 25 Apr 2014 04:24:06 -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=wuGy5qyI6SQ/jVJol2U7cmGIDSXw1G/6TBzFzgQTvn8=; b=fNDgjCiD4nQCxc7G6DCSoheLudA4ZirX2FhDZQIOi1S7az5fJTCAmi2iOko9E5NhU7 jWgVI8YRqDr3aumqHUymecm+RPR2T1LKLQEIfietiaTbZzCj0X6FuAMttBnU3GL/cC5/ sCD/FhkiRUstdPkOybrG9UqMLkl8pMYyffm1+VBL5aU7yenLhywjChTkf5qpw6WgxHwD q2qF4aaHmNvs8PTV6YFIyWcyaeG+gTLa7Mww09NThaVwyH9HjfZSQ/PWI+XAZcHE49wt ZXkmMMyNC+cwsLE+C05BEDRQQIWx56Baqo0n2A9X++cGtW3Ra5uUO/VsGo4Hlt5Gv5lf 4XDA== X-Gm-Message-State: ALoCoQnh23Y8zrEdKWK0pU/+o4qVVCSv8SnuhPv8lyEncbtEMiR8eM5nK21nmJI7DAnRWuUCGNpU X-Received: by 10.236.127.35 with SMTP id c23mr2385527yhi.51.1398425046005; Fri, 25 Apr 2014 04:24:06 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.66 with SMTP id g60ls1518604qgf.40.gmail; Fri, 25 Apr 2014 04:24:05 -0700 (PDT) X-Received: by 10.58.46.207 with SMTP id x15mr6480776vem.17.1398425045881; Fri, 25 Apr 2014 04:24:05 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id vb6si1628735vec.20.2014.04.25.04.24.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Apr 2014 04:24:05 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id ik5so245034vcb.18 for ; Fri, 25 Apr 2014 04:24:05 -0700 (PDT) X-Received: by 10.221.37.1 with SMTP id tc1mr331443vcb.32.1398425045800; Fri, 25 Apr 2014 04:24:05 -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.221.72 with SMTP id ib8csp89775vcb; Fri, 25 Apr 2014 04:24:05 -0700 (PDT) X-Received: by 10.42.247.132 with SMTP id mc4mr6527912icb.44.1398425044890; Fri, 25 Apr 2014 04:24:04 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id m7si3840451igx.24.2014.04.25.04.24.04 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 25 Apr 2014 04:24:04 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) 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 1WdeDa-0004Pj-2d; Fri, 25 Apr 2014 11:22:58 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WdeDW-0004NK-TU for xen-devel@lists.xen.org; Fri, 25 Apr 2014 11:22:55 +0000 Received: from [85.158.143.35:27276] by server-1.bemta-4.messagelabs.com id B9/4B-09853-E854A535; Fri, 25 Apr 2014 11:22:54 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-16.tower-21.messagelabs.com!1398424969!1000953!3 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.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31963 invoked from network); 25 Apr 2014 11:22:53 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-16.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 25 Apr 2014 11:22:53 -0000 X-IronPort-AV: E=Sophos;i="4.97,926,1389744000"; d="scan'208";a="123461119" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 25 Apr 2014 11:22:53 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.80) with Microsoft SMTP Server id 14.3.123.3; Fri, 25 Apr 2014 07:22:52 -0400 Received: from marilith-n13-p0.uk.xensource.com ([10.80.229.115] helo=localhost.localdomain) by ukmail1.uk.xensource.com with smtp (Exim 4.69) (envelope-from ) id 1WdeDT-000764-Ek; Fri, 25 Apr 2014 12:22:52 +0100 Received: by localhost.localdomain (sSMTP sendmail emulation); Fri, 25 Apr 2014 12:22:51 +0100 From: Ian Campbell To: Date: Fri, 25 Apr 2014 12:22:44 +0100 Message-ID: <1398424967-9306-5-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1398424945.18537.424.camel@kazak.uk.xensource.com> References: <1398424945.18537.424.camel@kazak.uk.xensource.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: ian.jackson@eu.citrix.com, julien.grall@linaro.org, tim@xen.org, Ian Campbell , stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH v2 5/8] tools: arm: prepare for multiple banks of guest RAM 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: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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: Prepare for adding more banks of guest RAM by renaming a bunch of variables and defines as RAM0 etc. Also in preparation switch to using GUEST_RAM0_BASE explicitly instead of implicitly via dom->rambase_pfn (while asserting that they must be the same). This makes the multiple bank case cleaner (although it looks a bit odd for now). Lastly for now ramsize (total size) and ram0size (size of first bank) are the same, but use the appropriate one for each context. Signed-off-by: Ian Campbell Acked-by: Julien Grall --- v2: New patch --- tools/libxc/xc_dom_arm.c | 25 +++++++++++++++---------- xen/include/public/arch-arm.h | 8 ++++++-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c index 5760bb1..8775ca4 100644 --- a/tools/libxc/xc_dom_arm.c +++ b/tools/libxc/xc_dom_arm.c @@ -18,6 +18,7 @@ * Copyright (c) 2011, Citrix Systems */ #include +#include #include #include @@ -253,9 +254,11 @@ int arch_setup_meminit(struct xc_dom_image *dom) uint64_t modbase; /* Convenient */ - const uint64_t rambase = dom->rambase_pfn << XC_PAGE_SHIFT; const uint64_t ramsize = dom->total_pages << XC_PAGE_SHIFT; - const uint64_t ramend = rambase + ramsize; + + const uint64_t ram0size = ramsize; + const uint64_t ram0end = GUEST_RAM0_BASE + ram0size; + const uint64_t kernbase = dom->kernel_seg.vstart; const uint64_t kernend = ROUNDUP(dom->kernel_seg.vend, 21/*2MB*/); const uint64_t kernsize = kernend - kernbase; @@ -264,20 +267,22 @@ int arch_setup_meminit(struct xc_dom_image *dom) const uint64_t ramdisk_size = dom->ramdisk_blob ? ROUNDUP(dom->ramdisk_size, XC_PAGE_SHIFT) : 0; const uint64_t modsize = dtb_size + ramdisk_size; - const uint64_t ram128mb = rambase + (128<<20); + const uint64_t ram128mb = GUEST_RAM0_BASE + (128<<20); + + assert(dom->rambase_pfn << XC_PAGE_SHIFT == GUEST_RAM0_BASE); - if ( modsize + kernsize > ramsize ) + if ( modsize + kernsize > ram0size ) { DOMPRINTF("%s: Not enough memory for the kernel+dtb+initrd", __FUNCTION__); return -1; } - if ( ramsize > GUEST_RAM_SIZE ) + if ( ramsize > GUEST_RAM_MAX ) { DOMPRINTF("%s: ram size is too large for guest address space: " "%"PRIx64" > %"PRIx64, - __FUNCTION__, ramsize, GUEST_RAM_SIZE); + __FUNCTION__, ramsize, GUEST_RAM_MAX); return -1; } @@ -317,11 +322,11 @@ int arch_setup_meminit(struct xc_dom_image *dom) * If changing this then consider * xen/arch/arm/kernel.c:place_modules as well. */ - if ( ramend >= ram128mb + modsize && kernend < ram128mb ) + if ( ram0end >= ram128mb + modsize && kernend < ram128mb ) modbase = ram128mb; - else if ( ramend - modsize > kernend ) - modbase = ramend - modsize; - else if (kernbase - rambase > modsize ) + else if ( ram0end - modsize > kernend ) + modbase = ram0end - modsize; + else if (kernbase - GUEST_RAM0_BASE > modsize ) modbase = kernbase - modsize; else return -1; diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 4149d6f..c4f4990 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -374,8 +374,12 @@ typedef uint64_t xen_callback_t; #define GUEST_MAGIC_BASE 0x39000000ULL -#define GUEST_RAM_BASE 0x40000000ULL /* 3GB of RAM @ 1GB */ -#define GUEST_RAM_SIZE 0xc0000000ULL +#define GUEST_RAM0_BASE 0x40000000ULL /* 3GB of RAM @ 1GB */ +#define GUEST_RAM0_SIZE 0xc0000000ULL + +#define GUEST_RAM_BASE GUEST_RAM0_BASE /* Lowest RAM address */ +/* Largest amount of actual RAM, not including holes */ +#define GUEST_RAM_MAX (GUEST_RAM0_SIZE) /* Interrupts */ #define GUEST_TIMER_VIRT_PPI 27