From patchwork Mon Apr 28 13:02:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 29241 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 02D42202FE for ; Mon, 28 Apr 2014 13:04:43 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id ih12sf11225091qab.6 for ; Mon, 28 Apr 2014 06:04:43 -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=Cbpy+mQZfObkRCNSyVu15DL6xNxkamn/1tm86hGWttE=; b=ivKp/BkMWpo+KCLC/LYPuZ88say94LSV1J2jFW+sgXAbbtByje7TdA/WinyfECbvTD k6WIaLiRJSPUxVe1oMVoXG4Z5YP0XKZhY0bmDFoojNTbYl2VRBFqbm7aA2Ep+SW62/4w Wh9Kg2H1/NY5KEKM8L7f1T00xYp1QgqqQ6f5iInXrWNYr52Fj3TFtQvKYrnONRzx4v6n u7EZ72/JIu5G3x1ykv2IxdR+qhWJin50tNzBX/YBdn7Fsk1s0YbCt5yO980bP13XMZA1 vC83nQwGog55NXK5YV6aYJBZWdeg4HNpapYod9xagyUDYdI5HNTlL0vIFFP0sEjs/Mkn SQQg== X-Gm-Message-State: ALoCoQnNTanDU4IBxN7UUA9chqYsml5GwrncxuGcSq1rSvF8pGnc3GFuKizIzZ932KN8p8LIa3b0 X-Received: by 10.236.87.73 with SMTP id x49mr10490550yhe.30.1398690283697; Mon, 28 Apr 2014 06:04:43 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.72 with SMTP id i66ls2647011qgf.78.gmail; Mon, 28 Apr 2014 06:04:43 -0700 (PDT) X-Received: by 10.221.37.1 with SMTP id tc1mr805492vcb.32.1398690283543; Mon, 28 Apr 2014 06:04:43 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id z14si3594750vcf.208.2014.04.28.06.04.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 28 Apr 2014 06:04:43 -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.179; Received: by mail-vc0-f179.google.com with SMTP id ij19so7934203vcb.24 for ; Mon, 28 Apr 2014 06:04:43 -0700 (PDT) X-Received: by 10.58.187.78 with SMTP id fq14mr23321491vec.9.1398690283442; Mon, 28 Apr 2014 06:04:43 -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 ib8csp115762vcb; Mon, 28 Apr 2014 06:04:43 -0700 (PDT) X-Received: by 10.140.86.71 with SMTP id o65mr30805947qgd.67.1398690282891; Mon, 28 Apr 2014 06:04:42 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id g93si3810842qgf.43.2014.04.28.06.04.42 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 28 Apr 2014 06:04:42 -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 1WelCx-0001vj-FP; Mon, 28 Apr 2014 13:02:55 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WelCv-0001tK-4g for xen-devel@lists.xen.org; Mon, 28 Apr 2014 13:02:53 +0000 Received: from [85.158.143.35:62800] by server-2.bemta-4.messagelabs.com id CE/4D-06539-C715E535; Mon, 28 Apr 2014 13:02:52 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1398690167!1480237!4 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 21176 invoked from network); 28 Apr 2014 13:02:51 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-9.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 28 Apr 2014 13:02:51 -0000 X-IronPort-AV: E=Sophos;i="4.97,944,1389744000"; d="scan'208";a="124330247" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 28 Apr 2014 13:02:19 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.3.181.6; Mon, 28 Apr 2014 09:02:18 -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 1WelCK-0001Ve-Po; Mon, 28 Apr 2014 14:02:17 +0100 Received: by localhost.localdomain (sSMTP sendmail emulation); Mon, 28 Apr 2014 14:02:16 +0100 From: Ian Campbell To: Date: Mon, 28 Apr 2014 14:02:09 +0100 Message-ID: <1398690132-5651-5-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1398690109.29700.82.camel@kazak.uk.xensource.com> References: <1398690109.29700.82.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 v3 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). GUEST_RAM_BASE is defined as the address of the lowest RAM bank, it is used in tools/libxl/libxl_dom.c to call xc_dom_rambase_init(). 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 Acked-by: Ian Jackson --- v3: Mention why GUEST_RAM_BASE is still defined. 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 74917c3..b218e0f 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 @@ -255,9 +256,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; @@ -266,20 +269,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; } @@ -319,11 +324,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 d5090fb..41944fe 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -375,8 +375,12 @@ typedef uint64_t xen_callback_t; #define GUEST_MAGIC_BASE 0x39000000ULL #define GUEST_MAGIC_SIZE 0x01000000ULL -#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