From patchwork Tue Sep 20 05:52:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 9341045 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 8D79A601C2 for ; Tue, 20 Sep 2016 05:55:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79A74285BD for ; Tue, 20 Sep 2016 05:55:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D7CA29C0D; Tue, 20 Sep 2016 05:55:13 +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 A1FC2285BD for ; Tue, 20 Sep 2016 05:55:12 +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 1bmDz6-00082v-Gk; Tue, 20 Sep 2016 05:52:48 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmDz5-00082o-2H for xen-devel@lists.xen.org; Tue, 20 Sep 2016 05:52:47 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id 5B/CF-30284-EAEC0E75; Tue, 20 Sep 2016 05:52:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsVyMfSOo+7acw/ CDVYuMrRY8nExiwOjx9Hdv5kCGKNYM/OS8isSWDOWzO1nKjgiXnHy/DeWBsbFQl2MnBxCAhMY JWZfqgKxWQQusUis32oGYksIvGORWPHBGcKOkXgx/Ro7hF0u8fb0dFaIXhWJuZt6GLsYuYDs6 UwSOzeuZQJJsAlIS+y5sJQRokFDYunR+2ANIgKGErtPLwKzmQUsJc5v+Ag2VFggXKL78VVmiC NUJR6v2QxWwytgL3Hs234WiDlyEtdnTmeawMi/gJFhFaNGcWpRWWqRrrGBXlJRZnpGSW5iZo6 uoYGpXm5qcXFiempOYlKxXnJ+7iZGYPjUMzAw7mCcsMrvEKMkB5OSKK8c34NwIb6k/JTKjMTi jPii0pzU4kOMGhwcApvXrr7AKMWSl5+XqiTBO/ssUJ1gUWp6akVaZg4wwGFKJTh4lER494Cke YsLEnOLM9MhUqcYjTm2/L62lolj29R7a5mEwCZJifM2gpQKgJRmlObBDYJF3iVGWSlhXkYGBg YhnoLUotzMElT5V4ziHIxKwrwGIFN4MvNK4Pa9AjqFCegUxp77IKeUJCKkpBoYF0x8sK8jvmX jE0v9KyHs73VuzPx5y2yZw4ldN3gibzafYOvf6CbZmLI280SexJYTGzR7BFcL2WXv8P6cuM6G qUDQM+un2JvgVVrdQol1b9Iy/Oa82+jw7V5RLzv75WmZns7HndcXiGcpxbAzybaUnPqqxndP+ 4vkHKYVF3Xrbos7lMhYeOsrsRRnJBpqMRcVJwIAFPdzuLcCAAA= X-Env-Sender: van.freenix@gmail.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1474350764!58763007!1 X-Originating-IP: [209.85.220.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14077 invoked from network); 20 Sep 2016 05:52:45 -0000 Received: from mail-pa0-f65.google.com (HELO mail-pa0-f65.google.com) (209.85.220.65) by server-5.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 20 Sep 2016 05:52:45 -0000 Received: by mail-pa0-f65.google.com with SMTP id hi10so409660pac.2 for ; Mon, 19 Sep 2016 22:52:45 -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=8pwH+7/cJLBFCXV6taJDf7tsB8QkWPRI9uJGFvdnz+Q=; b=EJNelR7ry5F+w/jxnfH9r1MQKds93k5emijtMGE50ZQsquluoCxcvqMaYM9l4/Z3qc KOzXwWfq1rLkCIu/svDfyhwnmq5xTThzsAJcNM3Z+MAr4pSd/M+Ondur4BDQrULmafXy w3LdyYDS4V+DKXGuPBB8wBgdwqP85r+WIblYxPlgBg7bS48/WBuXwRpix8k2nZ5e+Edx vpwU0LXceWaU9F5BterTncekAjaoYijhVQP9vK3VKDn7vs4bZittU8zokkeNnSrKxW0b aUJ5T2bmxwZBF+nkiaDgQxq3cahIZDc6NJHOTA2d4uUcoinC8GkDpX4u26bG/7TU3I4D MNEQ== 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=8pwH+7/cJLBFCXV6taJDf7tsB8QkWPRI9uJGFvdnz+Q=; b=ehwN5t2f52R+CZEPW5YGJ6Z9JHcn+hWOlYNjFJqgeHv4QtkKK2IIculJStBw72bABb Zd97CQJ5iZxy2hhhmjD58ZMurM20TzfE5yN27HzjAVKUU8J7h9ENBR5NLqp34DGGBhyu e01PdXN4aG5ORF7b3siz3jsPG89gr78wx2va0RX6pJb7Cwsy+Qy9ymSeXXB+b753j0jx AIy0i0Fy4DPqKHl0v5LrG6jqYpXaBlWSPLnf1UspBlUCOrL57aYvfpY6mDwoWxfQ1YAb LP6A2p88ikXQsmoyBj5vcndjfpwAld+DWOyliV5QuUosf56kitGCr2AQzH1gfFUqBHb7 ptZQ== X-Gm-Message-State: AE9vXwOuJb9M9cGALQUNhIZjGv8uPNyF+vO2S2Bpg2ba4VXBH+RBsUtIf0f23xfb6w/FbA== X-Received: by 10.66.76.65 with SMTP id i1mr52901869paw.51.1474350764044; Mon, 19 Sep 2016 22:52:44 -0700 (PDT) Received: from linux-u7w5.ap.freescale.net (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id 184sm75588379pfg.20.2016.09.19.22.52.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Sep 2016 22:52:43 -0700 (PDT) From: van.freenix@gmail.com X-Google-Original-From: peng.fan@nxp.com To: julien.grall@arm.com, sstabellini@kernel.org Date: Tue, 20 Sep 2016 13:52:31 +0800 Message-Id: <1474350751-5650-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 V2] xen/arm: domain_build: allocate lowmem for dom0 as much as possible 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 From: Peng Fan 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. So need to allocate memory under 4GB for Dom0. There is no restriction that how much lowmem needs to be allocated for Dom0. Dom0 now use 1:1 mapping, but DomU does not use 1:1 mapping, there is no need to reserve lowmem for DomU, so allocate lowmem as much as possible for Dom0. Signed-off-by: Peng Fan Cc: Stefano Stabellini Cc: Julien Grall --- This patch is to resolve the issue mentioned in https://lists.xen.org/archives/html/xen-devel/2016-09/msg00235.html V2: Remove the bootargs dom0_lowmem introduced in V1. Following "https://lists.xenproject.org/archives/html/xen-devel/2016-09/msg01459.html" to allocate as much as possible lowmem. Tested results: (XEN) Allocating 1:1 mappings totalling 2048MB for dom0: (XEN) BANK[0] 0x00000088000000-0x000000f8000000 (1792MB) (XEN) BANK[1] 0x000009e0000000-0x000009f0000000 (256MB) 1792M allocated in 4GB address space. xen/arch/arm/domain_build.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 35ab08d..0b9b85c 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -240,11 +240,11 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo) const unsigned int min_low_order = get_order_from_bytes(min_t(paddr_t, dom0_mem, MB(128))); const unsigned int min_order = get_order_from_bytes(MB(4)); - struct page_info *pg; + struct page_info *pg = NULL; unsigned int order = get_11_allocation_size(kinfo->unassigned_mem); int i; - bool_t lowmem = is_32bit_domain(d); + bool_t lowmem = true; unsigned int bits; /* @@ -265,22 +265,28 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo) */ while ( order >= min_low_order ) { - for ( bits = order ; bits <= (lowmem ? 32 : PADDR_BITS); bits++ ) + for ( bits = order ; bits <= 32 ; bits++ ) { pg = alloc_domheap_pages(d, order, MEMF_bits(bits)); if ( pg != NULL ) + { + if ( !insert_11_bank(d, kinfo, pg, order) ) + BUG(); /* Cannot fail for first bank */ + goto got_bank0; + } } order--; } - panic("Unable to allocate first memory bank"); + if ( pg == NULL ) + { + printk(XENLOG_INFO "No bank has been allocated below 4GB.\n"); + lowmem = false; + } got_bank0: - if ( !insert_11_bank(d, kinfo, pg, order) ) - BUG(); /* Cannot fail for first bank */ - /* Now allocate more memory and fill in additional banks */ order = get_11_allocation_size(kinfo->unassigned_mem);