From patchwork Wed Sep 14 05:12:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 9330337 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 491AF60231 for ; Wed, 14 Sep 2016 05:15:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 366702901E for ; Wed, 14 Sep 2016 05:15:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B0FB29807; Wed, 14 Sep 2016 05:15:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8A47A2901E for ; Wed, 14 Sep 2016 05:15:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bk2V3-000784-A9; Wed, 14 Sep 2016 05:12:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bk2V1-00077y-Vb for xen-devel@lists.xen.org; Wed, 14 Sep 2016 05:12:44 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id E6/FD-05361-B4CD8D75; Wed, 14 Sep 2016 05:12:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOIsWRWlGSWpSXmKPExsVyMfSOk67XnRv hBqdmSVos+biYxYHR4+ju30wBjFGsmXlJ+RUJrBk9a36xFrSqVPzedIupgXGqbBcjF4eQQD+j xJoNy5hAHBaBSywS3+YdYu5i5OSQEHjHIrF9mzqEHSPxc1kbaxcjB5BdKXHvXxRIWEhARWLup h5GiEHTmCR27LzNApJgE1CTOPJ+JiNEvbHE85s5IGERAUOJyav+soLYzAKWEuc3fGQHsYUFPC Va//4Gi7MIqErs7pwOdgKvgIPEnI5lUOfISVyfOZ1pAiP/AkaGVYzqxalFZalFukZ6SUWZ6Rk luYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiBwcMABDsYl/11OsQoycGkJMrb638jXIgvKT+l MiOxOCO+qDQntfgQowwHh5IEL+dtoJxgUWp6akVaZg4wjGHSEhw8SiK86iBp3uKCxNzizHSI1 ClGY44tv6+tZeLYNvXeWiYhlrz8vFQpcV4NkFIBkNKM0jy4QbD4usQoKyXMywh0mhBPQWpRbm YJqvwrRnEORiVh3miQKTyZeSVw+14BncIEdMqWNddBTilJREhJNTAGTLFJO1aVan1sz9PA1nt zA4TdZXWVlq/ZYVl9fMe5uTfSzsW8+PCfudnRcR5HSuSsvqYW3Z87z+9L55tfE7Oq22DOTsFZ k2fEeScuuN+nVF+yWvgda9tjC/Hthkt2rUgT/5SSI2vsP7eh7cCkY4tbZx45u1RVIaV6u82Om L+Scx9/CxGbdvOQEktxRqKhFnNRcSIAn6cMb6oCAAA= X-Env-Sender: van.freenix@gmail.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1473829961!32546583!1 X-Originating-IP: [209.85.220.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3105 invoked from network); 14 Sep 2016 05:12:42 -0000 Received: from mail-pa0-f66.google.com (HELO mail-pa0-f66.google.com) (209.85.220.66) by server-3.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 14 Sep 2016 05:12:42 -0000 Received: by mail-pa0-f66.google.com with SMTP id vz6so204610pab.1 for ; Tue, 13 Sep 2016 22:12:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=hsjHABLrvJvQOYgs5uEbTlIizQOPwB9hsifV2vfkugA=; b=WioX3eakGPyStwqP3Cmsd3GhRNjhM7HXRPbVjcZoNGH9uVTu0odqYAkAYqqNT/E9Qz 03sivFvrIzCl5rjJ+rBgjpaK/0DcC47sRiNNAfBvfHRtUNoE7S2sxHDKtoE++2d1SQjA i66Gfw65LgpvlLA1/bN/4tF1poYERH6uC0BG9NoHMplse9SYXivT6iMNoKeqcoJFKKf4 77wnFbM04EILiKf0gV+mz4wS41QH/8xGQxZAMZ8cOVflR1rgOL1ur4XPhR7T2gJN7+6a WNuES1bLBN08Jvmjdo40wTaoPVRSCkzv5twIbZCj47Z5px6MCUbX5UrDtRinwVE6gMdl 8xqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=hsjHABLrvJvQOYgs5uEbTlIizQOPwB9hsifV2vfkugA=; b=K5iL2MvAJZeS74Vi1V3mmzUW6sywFKUtTKECCyreYq9b+EZ27/wccIz1o2LUISA9BA 3+IZTxsOWGb3pQrZHNahJYzdKr7la9kBy/zkIypALS8wFZJlCtDcL9+5dSV/Rcbx6sKS 5aBiVlxuZPsgKYKYY8ohhWkWDbH5ZkntYX/WU+m3YWFWorwz7TXfFIWp7LPXPNPISmR/ RJ1nF0KRnupTipqzRfdDY4t33Jx9rLgdP0d5dRC8IofytGmosnXHgRD6+tAJX/2MW+mS 5oFS/VqQfG5aJUhLfoyYS2L+gdMRSoSdFTcZndmfAP3XqoWSG0OPIx/OkFYHW41O70Bq B5Kg== X-Gm-Message-State: AE9vXwM+Ii5kun+WgtS2opMoGgkPpxFWGdr990aUNoGOKRVBfaxQRmR0vorbpQTpNWZ66w== X-Received: by 10.67.7.170 with SMTP id dd10mr1134915pad.152.1473829960665; Tue, 13 Sep 2016 22:12:40 -0700 (PDT) Received: from linux-u7w5.ap.freescale.net (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id bm8sm1936100pac.16.2016.09.13.22.12.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Sep 2016 22:12:40 -0700 (PDT) From: Peng Fan X-Google-Original-From: Peng Fan To: sstabellini@kernel.org, julien.grall@arm.com Date: Wed, 14 Sep 2016 13:12:29 +0800 Message-Id: <1473829949-21481-1-git-send-email-peng.fan@nxp.com> X-Mailer: git-send-email 2.6.6 Cc: Peng Fan , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH V1] xen/arm: domain_build: introduce dom0_lowmem bootargs X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On AArch64 SoCs, some IPs may only have the capability to access 32bits address space. The physical memory assigned for Dom0 maybe not in 4GB address space, then the IPs will not work properly. Introduce dom0_lowmem bootargs, user could pass "dom0_lowmem=xx" to xen. It means how much memory user would like to be allocated in lower 4GB memory space. If there is not enough memory for dom0_lowmem, higher memory will be allocated. Thinking such a memory layout on an AArch64 SoC: Region 0: 2GB(0x80000000 - 0xffffffff) Region 1: 4GB(0x880000000 - 0x97fffffff) If user would like to assign 2GB for Dom0 and 1GB of the 2GB memory in Region 0, user could pass "dom0=2048M dom0_lowmem=1024M" to xen. Signed-off-by: Peng Fan Cc: Stefano Stabellini Cc: Julien Grall --- RFC->V1: This patch is to resolve the issue in https://lists.xen.org/archives/html/xen-devel/2016-09/msg00235.html No code change since RFC. Tested on xen-4.8 unstable with AArch64. See partial log: "dom0_mem = 2048M dom0_lowmem=128M" (XEN) Allocated 0x00000088000000-0x00000090000000 (128MB/2048MB, order 15) (XEN) Allocated 0x00000880000000-0x000008c0000000 (1024MB/1920MB, order 18) (XEN) Allocated 0x000009c0000000-0x000009e0000000 (512MB/896MB, order 17) (XEN) Allocated 0x000009e0000000-0x000009f0000000 (256MB/384MB, order 16) (XEN) Allocated 0x000008f8000000-0x00000900000000 (128MB/128MB, order 15) "dom0_mem = 2048M dom0_lowmem=1024M" (XEN) Allocated 0x000000a0000000-0x000000c0000000 (512MB/2048MB, order 17) (XEN) Allocated 0x000000c0000000-0x000000e0000000 (512MB/1536MB, order 17) (XEN) Allocated 0x00000880000000-0x000008c0000000 (1024MB/1024MB, order 18) "dom0_mem = 1024M dom0_lowmem=1024M" (XEN) Allocated 0x000000a0000000-0x000000c0000000 (512MB/1024MB, order 17) (XEN) Allocated 0x000000c0000000-0x000000e0000000 (512MB/512MB, order 17) xen/arch/arm/domain_build.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 35ab08d..0f53bba 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -33,6 +33,8 @@ int dom0_11_mapping = 1; #define DOM0_MEM_DEFAULT 0x8000000 /* 128 MiB */ static u64 __initdata dom0_mem = DOM0_MEM_DEFAULT; +/* Only for AArch64 */ +static u64 __initdata dom0_lowmem; static void __init parse_dom0_mem(const char *s) { @@ -42,6 +44,12 @@ static void __init parse_dom0_mem(const char *s) } custom_param("dom0_mem", parse_dom0_mem); +static void __init parse_dom0_lowmem(const char *s) +{ + dom0_lowmem = parse_size_and_unit(s, &s); +} +custom_param("dom0_lowmem", parse_dom0_lowmem); + //#define DEBUG_11_ALLOCATION #ifdef DEBUG_11_ALLOCATION # define D11PRINT(fmt, args...) printk(XENLOG_DEBUG fmt, ##args) @@ -244,7 +252,7 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo) unsigned int order = get_11_allocation_size(kinfo->unassigned_mem); int i; - bool_t lowmem = is_32bit_domain(d); + bool_t lowmem = is_32bit_domain(d) || !!dom0_lowmem; unsigned int bits; /* @@ -263,6 +271,9 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo) * First try and allocate the largest thing we can as low as * possible to be bank 0. */ + if ( dom0_lowmem ) + order = get_order_from_bytes(dom0_lowmem); + while ( order >= min_low_order ) { for ( bits = order ; bits <= (lowmem ? 32 : PADDR_BITS); bits++ ) @@ -278,6 +289,11 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo) got_bank0: + if ( dom0_lowmem ) { + dom0_lowmem -= pfn_to_paddr((1 << order)); + lowmem = is_32bit_domain(d) || !!dom0_lowmem; + } + if ( !insert_11_bank(d, kinfo, pg, order) ) BUG(); /* Cannot fail for first bank */ @@ -325,6 +341,16 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo) } } + if ( dom0_lowmem && lowmem ) + { + dom0_lowmem -= pfn_to_paddr((1 << order)); + lowmem = is_32bit_domain(d) || !!dom0_lowmem; + } + else + { + lowmem = false; + } + /* * Success, next time around try again to get the largest order * allocation possible. @@ -2098,6 +2124,8 @@ int construct_dom0(struct domain *d) d->max_pages = ~0U; + BUG_ON(dom0_mem < dom0_lowmem); + kinfo.unassigned_mem = dom0_mem; rc = kernel_probe(&kinfo);