From patchwork Mon Apr 28 13:02:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 29239 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 305B0202FE for ; Mon, 28 Apr 2014 13:04:33 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id rp18sf1871053iec.1 for ; Mon, 28 Apr 2014 06:04:32 -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=IQVramjr6aZQx08SjCY6WIWkKOmNTBOvOPPyPf+D4xM=; b=hujDPS61l7BivPxIW332IMrukpHdDKV/+qAPUNfazZoLJR4btKchql4L4p3nwt3lW9 xGr9lLeKpmSI80E6qYPkTmknPqWnwgxgMV59qZPD9TvfPF7gjsFGvqlkQV+7rUlO4rNq VDtXYFUlYWrv9NomIAfXVqCzecz/j2yOAEZhqrzfLbJ9gvW7Y00zjlfIuMDiLaFj3P0j faFByv1KD/N3RN5wXr2IUcBfEvJzZ2vnNzlkl6R3+G2BTiFgF7Jxfyzf+3ef3P5lnhOB VxlEQdYDOYElil9JWIMAtMX4gqoYv9o7T4eJihLBSQFg4njblFJIZc3RvekWda9vuizv Zelg== X-Gm-Message-State: ALoCoQkinMzXkfiQEHWomNBXThsZA2zBzGx53PZdhLDI/WyjOOvLP4cT3cE81VZTgBW1C0ADh6pN X-Received: by 10.182.95.68 with SMTP id di4mr13281802obb.4.1398690272546; Mon, 28 Apr 2014 06:04:32 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.40.209 with SMTP id x75ls2471062qgx.46.gmail; Mon, 28 Apr 2014 06:04:32 -0700 (PDT) X-Received: by 10.58.46.207 with SMTP id x15mr24371798vem.17.1398690272264; Mon, 28 Apr 2014 06:04:32 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id c6si3606995veo.0.2014.04.28.06.04.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 28 Apr 2014 06:04:32 -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.170; Received: by mail-vc0-f170.google.com with SMTP id hr9so8060167vcb.15 for ; Mon, 28 Apr 2014 06:04:32 -0700 (PDT) X-Received: by 10.221.4.66 with SMTP id ob2mr1740255vcb.28.1398690272162; Mon, 28 Apr 2014 06:04:32 -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 ib8csp115744vcb; Mon, 28 Apr 2014 06:04:31 -0700 (PDT) X-Received: by 10.50.79.226 with SMTP id m2mr23462483igx.11.1398690271416; Mon, 28 Apr 2014 06:04:31 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id av1si13084884igc.35.2014.04.28.06.04.30 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 28 Apr 2014 06:04:31 -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 1WelCc-0001mf-A4; Mon, 28 Apr 2014 13:02:34 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WelCZ-0001lo-OL for xen-devel@lists.xen.org; Mon, 28 Apr 2014 13:02:32 +0000 Received: from [85.158.139.211:3233] by server-12.bemta-5.messagelabs.com id 68/AD-03824-6615E535; Mon, 28 Apr 2014 13:02:30 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1398690147!1021950!2 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.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28162 invoked from network); 28 Apr 2014 13:02:30 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-11.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 28 Apr 2014 13:02:30 -0000 X-IronPort-AV: E=Sophos;i="4.97,944,1389744000"; d="scan'208";a="125356543" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 28 Apr 2014 13:02:20 +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:20 -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 1WelCM-0001Vk-Sl; Mon, 28 Apr 2014 14:02:19 +0100 Received: by localhost.localdomain (sSMTP sendmail emulation); Mon, 28 Apr 2014 14:02:18 +0100 From: Ian Campbell To: Date: Mon, 28 Apr 2014 14:02:11 +0100 Message-ID: <1398690132-5651-7-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: MIA1 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 7/8] tools: arm: support up to (almost) 1TB 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: This creates a second bank of RAM starting at 8GB and potentially extending to the 1TB boundary, which is the limit imposed by our current use of a 3 level p2m with 2 pages at level 0 (2^40 bits). I've deliberately left a gap between the two banks just to exercise those code paths. The second bank is 1016GB in size which plus the 3GB below 4GB is 1019GB maximum guest RAM. At the point where the fact that this is slightly less than a full TB starts to become an issue for people then we can switch to a 4 level p2m, which would be needed to support guests larger than 1TB anyhow. Tested on 32-bit with 1, 4 and 6GB guests. Anything more than ~3GB requires an LPAE enabled kernel, or a 64-bit guest. Signed-off-by: Ian Campbell Acked-by: Julien Grall --- v3: remove inadvertent whitespace change --- tools/libxc/xc_dom_arm.c | 16 +++++++++++++--- tools/libxl/libxl_arm.c | 22 +++++++++++++++++++--- xen/include/public/arch-arm.h | 7 +++++-- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c index cdb56e3..18c7adb 100644 --- a/tools/libxc/xc_dom_arm.c +++ b/tools/libxc/xc_dom_arm.c @@ -288,12 +288,18 @@ int arch_setup_meminit(struct xc_dom_image *dom) uint64_t modbase; /* Convenient */ - const uint64_t ramsize = dom->total_pages << XC_PAGE_SHIFT; + const uint64_t ramsize = (uint64_t)dom->total_pages << XC_PAGE_SHIFT; - const uint64_t ram0size = ramsize; + const uint64_t ram0size = + ramsize > GUEST_RAM0_SIZE ? GUEST_RAM0_SIZE : ramsize; const uint64_t ram0end = GUEST_RAM0_BASE + ram0size; + const uint64_t ram1size = + ramsize > ram0size ? ramsize - ram0size : 0; + const uint64_t ram1end = GUEST_RAM1_BASE + ram1size; - const xen_pfn_t p2m_size = (ram0end - GUEST_RAM0_BASE) >> XC_PAGE_SHIFT; + const xen_pfn_t p2m_size = ram1size ? + (ram1end - GUEST_RAM0_BASE) >> XC_PAGE_SHIFT : + (ram0end - GUEST_RAM0_BASE) >> XC_PAGE_SHIFT; const uint64_t kernbase = dom->kernel_seg.vstart; const uint64_t kernend = ROUNDUP(dom->kernel_seg.vend, 21/*2MB*/); @@ -339,6 +345,10 @@ int arch_setup_meminit(struct xc_dom_image *dom) GUEST_RAM0_BASE >> XC_PAGE_SHIFT, ram0size >> XC_PAGE_SHIFT))) return rc; + if ((rc = populate_guest_memory(dom, + GUEST_RAM1_BASE >> XC_PAGE_SHIFT, + ram1size >> XC_PAGE_SHIFT))) + return rc; /* * We try to place dtb+initrd at 128MB or if we have less RAM diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index 215ef9e..1af6b4a 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -255,8 +255,8 @@ static int make_psci_node(libxl__gc *gc, void *fdt) return 0; } -static int make_memory_node(libxl__gc *gc, void *fdt, - uint64_t base, uint64_t size) +static int make_one_memory_node(libxl__gc *gc, void *fdt, + uint64_t base, uint64_t size) { int res; const char *name = GCSPRINTF("memory@%"PRIx64, base); @@ -277,6 +277,23 @@ static int make_memory_node(libxl__gc *gc, void *fdt, return 0; } +static int make_memory_node(libxl__gc *gc, void *fdt, uint64_t size) +{ + int res; + /* This had better match libxc's arch_setup_meminit... */ + const uint64_t size0 = size > GUEST_RAM0_SIZE ? GUEST_RAM0_SIZE : size; + const uint64_t size1 = size > GUEST_RAM0_SIZE ? size - size0 : 0; + + res = make_one_memory_node(gc, fdt, GUEST_RAM0_BASE, size0); + if (res) return res; + if (size1) { + res = make_one_memory_node(gc, fdt, GUEST_RAM1_BASE, size1); + if (res) return res; + } + + return 0; +} + static int make_intc_node(libxl__gc *gc, void *fdt, uint64_t gicd_base, uint64_t gicd_size, uint64_t gicc_base, uint64_t gicc_size) @@ -490,7 +507,6 @@ next_resize: FDT( make_psci_node(gc, fdt) ); FDT( make_memory_node(gc, fdt, - dom->rambase_pfn << XC_PAGE_SHIFT, info->target_memkb * 1024) ); FDT( make_intc_node(gc, fdt, GUEST_GICD_BASE, GUEST_GICD_SIZE, diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 41944fe..749b7b3 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -375,12 +375,15 @@ typedef uint64_t xen_callback_t; #define GUEST_MAGIC_BASE 0x39000000ULL #define GUEST_MAGIC_SIZE 0x01000000ULL -#define GUEST_RAM0_BASE 0x40000000ULL /* 3GB of RAM @ 1GB */ +#define GUEST_RAM0_BASE 0x40000000ULL /* 3GB of low RAM @ 1GB */ #define GUEST_RAM0_SIZE 0xc0000000ULL +#define GUEST_RAM1_BASE 0x0200000000ULL /* 1016GB of RAM @ 8GB */ +#define GUEST_RAM1_SIZE 0xfe00000000ULL + #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) +#define GUEST_RAM_MAX (GUEST_RAM0_SIZE + GUEST_RAM1_SIZE) /* Interrupts */ #define GUEST_TIMER_VIRT_PPI 27