xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xen.org
Cc: ian.jackson@eu.citrix.com, julien.grall@linaro.org, tim@xen.org,
	Ian Campbell <ian.campbell@citrix.com>,
	stefano.stabellini@eu.citrix.com
Subject: [PATCH v3 5/8] tools: arm: prepare for multiple banks of guest RAM
Date: Mon, 28 Apr 2014 14:02:09 +0100	[thread overview]
Message-ID: <1398690132-5651-5-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1398690109.29700.82.camel@kazak.uk.xensource.com>

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 <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
---
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 <inttypes.h>
+#include <assert.h>
 
 #include <xen/xen.h>
 #include <xen/io/protocols.h>
@@ -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
-- 
1.7.10.4

  parent reply	other threads:[~2014-04-28 13:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-28 13:01 [PATCH v3 0/8] xen: arm: support up to (almost) 1TB of guest RAM Ian Campbell
2014-04-28 13:02 ` [PATCH v3 1/8] tools: libxl: use uint64_t not unsigned long long for addresses Ian Campbell
2014-05-02 14:34   ` Ian Jackson
2014-04-28 13:02 ` [PATCH v3 2/8] tools: arm: report an error if the guest RAM is too large Ian Campbell
2014-05-02 14:35   ` Ian Jackson
2014-04-28 13:02 ` [PATCH v3 3/8] tools: arm: move magic pfns out of guest RAM region Ian Campbell
2014-05-02 14:36   ` Ian Jackson
2014-04-28 13:02 ` [PATCH v3 4/8] tools: arm: rearrange guest physical address space to increase max RAM Ian Campbell
2014-05-02 14:36   ` Ian Jackson
2014-04-28 13:02 ` Ian Campbell [this message]
2014-05-02 14:37   ` [PATCH v3 5/8] tools: arm: prepare for multiple banks of guest RAM Ian Jackson
2014-05-02 15:32     ` Ian Campbell
2014-04-28 13:02 ` [PATCH v3 6/8] tools: arm: refactor code to setup guest p2m and fill it with RAM Ian Campbell
2014-05-02 14:42   ` Ian Jackson
2014-05-02 15:34     ` Ian Campbell
2014-05-02 15:46       ` Ian Jackson
2014-04-28 13:02 ` [PATCH v3 7/8] tools: arm: support up to (almost) 1TB of guest RAM Ian Campbell
2014-05-02 14:50   ` Ian Jackson
2014-05-02 15:35     ` Ian Campbell
2014-04-28 13:02 ` [PATCH v3 8/8] tools: arm: increase size of region set aside for guest grant table Ian Campbell
2014-05-02 14:57   ` Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1398690132-5651-5-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=julien.grall@linaro.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).