From patchwork Thu Sep 22 09:16:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 9344835 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 21A1A6077A for ; Thu, 22 Sep 2016 09:19:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 108A72A8FB for ; Thu, 22 Sep 2016 09:19:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 051642A8FD; Thu, 22 Sep 2016 09:19:03 +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=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, 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 EDFEE2A8FB for ; Thu, 22 Sep 2016 09:19:01 +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 1bn07S-0000fB-Ix; Thu, 22 Sep 2016 09:16:38 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bn07Q-0000f5-VQ for xen-devel@lists.xen.org; Thu, 22 Sep 2016 09:16:37 +0000 Received: from [193.109.254.147] by server-1.bemta-6.messagelabs.com id AF/E1-21406-471A3E75; Thu, 22 Sep 2016 09:16:36 +0000 X-Bright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Msg-Ref: server-14.tower-27.messagelabs.com!1474535795!48174512!1 X-Originating-IP: [104.47.1.58] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6641 invoked from network); 22 Sep 2016 09:16:35 -0000 Received: from mail-ve1eur01on0058.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (104.47.1.58) by server-14.tower-27.messagelabs.com with AES256-SHA256 encrypted SMTP; 22 Sep 2016 09:16:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=SfMBnzKnkoTycKjYql2bRcUzxMhjDvRk8/kmnLiOCGI=; b=bKhgKtDKRVujjbilRz04W/6f4feocPEFFdcfH7QQIOvByhwSXps2n6+GuDVNx+Xn6t8qVJQjfYKauA6NSfxCeYm1W0op3Pa+bgowwIXR+aX9DN/iVthn/Zr8TFwmNRueSuTd23tvfcBOkHfMxJAXDqKRYtMyhEaHLfzfaYTpznY= Received: from linux-u7w5.ap.freescale.net (123.151.195.53) by VI1PR0401MB1805.eurprd04.prod.outlook.com (10.165.234.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.2; Thu, 22 Sep 2016 09:16:28 +0000 From: Peng Fan To: , Date: Thu, 22 Sep 2016 17:16:01 +0800 Message-ID: <1474535761-22079-1-git-send-email-peng.fan@nxp.com> X-Mailer: git-send-email 2.6.6 MIME-Version: 1.0 X-Originating-IP: [123.151.195.53] X-ClientProxiedBy: SIXPR0301CA0007.apcprd03.prod.outlook.com (10.162.171.145) To VI1PR0401MB1805.eurprd04.prod.outlook.com (10.165.234.155) X-MS-Office365-Filtering-Correlation-Id: 88bce367-fc91-4048-0a1a-08d3e2c924ee X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB1805; 2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864354917)(185117386973197)(114974198459425); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:VI1PR0401MB1805; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0401MB1805; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB1805; 4:wPNrOru2tAJejyqKJewyQPjiUKHFhs3YDHNCsa51XL3joA1Mq5lGFcgmTUxDq9O84aOvjwsYv/xbPkR2G5/hvSuPmxQnCUe+i2wn5z/pKDQpDBSPvfRW+vbYI46QpXwAhyR6dv8iD8jpy/K6ROTUgcLzsW3hzhRsVl7vFXegOqCPo/Kj2R8haZD6rB6+R/4kDhHcfkFeCnTV68NVHe2NtMnLdRpKjbg4t80tr+zuEDugYynvQp7ZPVJG4Bpz7ilyrPuZpM2e4lwStBlGfbfAcsEk4lT+u6lXDtArhpoyIHvSR4BqCISWHxMnvTlPlDdQHIpQ0uv2H5rZlqW7aaw5eBrh3qGp9uX2vyguoMu1bIzifAFXzdhVbuPf0KWEAaxnwc892P3PfZwEeANmOp2j8ouAk41rgjEw2iJL22OoOiJcQgvSFleaEQn99JMP+/ZBfvnwMP/vbZLLAjaVcVm6QB3P0hx017BvvmlkgyhfMmp92g5l0pLrSXAGjSj/dJGadx6TBXMJq+7mIHEsP0aR7A== X-Forefront-PRVS: 0073BFEF03 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(979002)(6009001)(7916002)(199003)(189002)(6116002)(97736004)(2906002)(50226002)(8676002)(81156014)(92566002)(81166006)(7846002)(50466002)(42186005)(7736002)(305945005)(48376002)(5003940100001)(3846002)(586003)(189998001)(68736007)(66066001)(19580395003)(4326007)(105586002)(229853001)(47776003)(5001770100001)(77096005)(33646002)(15975445007)(36756003)(106356001)(5660300001)(86362001)(50986999)(19580405001)(101416001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0401MB1805; H:linux-u7w5.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0401MB1805; 23:i1RCIkFIx/oZYYq1jLCKc4gisELU6yePQge9BZL?= =?us-ascii?Q?NDfjWfoX11GoZ6kQs9uOiAb7bnQoPnTF18GGCiVsrex6EU87O4a4kuF2+w5V?= =?us-ascii?Q?ZPyykEpQIbxRU7QV3+7HOUvrtFRmIhVyF0wjusrPqDPkthuB38yL5dD+CaWg?= =?us-ascii?Q?GixnYeduK2+blCRMYkis3kZqMGZ5QY5Jj1D7WjQvLgebT2UxoBwxFQg64uMe?= =?us-ascii?Q?aK1uIWcN2OJxRVWNSD2FMF/cEnhgHf0WNNaxsLvIjTktIRQMrzi4Nsad1e9I?= =?us-ascii?Q?2ze2rCoQTQbpHz7HbStYaAQwNT5ESYXOxw8GKDHyQPOsPUkplGgFLAgQ3Rst?= =?us-ascii?Q?rH9DCYvgb5LHbadfNoe91RqE/hxPATOoVt07G9m1Ulawe5wLsrQBuT2q0KCX?= =?us-ascii?Q?jEE3LYpE7M7JTIYaLrknurAYVjw5ydmI041/lPwxGsZuUp3Pn8XIp+aYxREb?= =?us-ascii?Q?+hZrRvxJ0KquxxhON70W25j477FrQpKQJfHpDG9uvEG35ZrYSU1br3BOLhY1?= =?us-ascii?Q?/F/kw30sciN0rXf2w9j1Whz1uAf5AN8jiiDtdxj+gyaUnvu9zbav/hkPVF8/?= =?us-ascii?Q?ujJMeGIjX0/21ZHs58eJ/CaEGLuCXiI7MNZw7VZopPRR+atlvIFtaxlbSJ4s?= =?us-ascii?Q?7dKBZt/7zXaGQow040oSAtBwmXXRjm27TKgntQMkRUTCpPe/Z0R6LJmXGLzh?= =?us-ascii?Q?5nsBCRA9F+lC9fWsVrt1CL3aVHxcv2CbXWWQZwnOYsqaxBJxwf4r6HgC+4uA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290PCr9TL7hi/KhUaT6w7TyFHHb6+yHDQgNSocLAU8tWKwssT7NNLj3dIU4+3dLKg4hoO8tAntKFSeV3AuHAJofjnXoq7NEnZyirairoU=; 7:MSh49TJWgn/KTYKfFuxNI2fmqLQjgqNlFwGLdG+sw/KbGL/9tSL76B+j/6pbdjy6g+Xnpjh6cDUwXreYmyzooBCgG9rjSnMABCxfdJUVwF5y250XAdTGXdEZXvIwprclhtrXZZyB87pXt7EDsE1fkBdSp4XCc7cG6JmJFIYiDrLZIWdyxsUIkT5CsWh1ZYrNhhEDGmriArVk0izrSUbdFASOGeXbUZ4lty/jTA3TGRSETVeTUUFWUEy3HruYDnw86kFJKxLqQwBtWZE9jhve5rLx7sH5aXAO9udlc3EBTO/KxnEtFiop61gqEl1XG9Ms SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2016 09:16:28.1360 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB1805 Cc: van.freenix@gmail.com, Peng Fan , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH V3] 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: , 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 32 bits 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. This patch does not affect 32-bit domain, because Variable "lowmem" is set to true at the beginning. If failed to allocate bank0 under 4GB, need to panic for 32-bit domain, because 32-bit domain requires bank0 be allocated under 4GB. For 64-bit domain, set "lowmem" to false, and continue allocating memory from higher memory space. 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 V3: Add more commit log Add more comments Add back panic if failed to allocate bank0 under 4GB for 32-bit domain. 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 | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 35ab08d..a9c37c4 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -195,9 +195,10 @@ fail: * bank. Partly this is just easier for us to deal with, but also * the ramdisk and DTB must be placed within a certain proximity of * the kernel within RAM. - * 3. For 32-bit dom0 we want to place as much of the RAM as we - * reasonably can below 4GB, so that it can be used by non-LPAE - * enabled kernels. + * 3. For dom0 we want to place as much of the RAM as we reasonably can + * below 4GB, so that the devices have the limitation to access 64 bits + * address space and work properly and it can be used by non-LPAE enabled + * kernels. * 4. For 32-bit dom0 the kernel must be located below 4GB. * 5. We want to have a few largers banks rather than many smaller ones. * @@ -230,7 +231,8 @@ fail: * we give up. * * For 32-bit domain we require that the initial allocation for the - * first bank is under 4G. Then for the subsequent allocations we + * first bank is under 4G. For 64-bit domain, the first bank is preferred + * to be allocated under 4G. Then for the subsequent allocations we * initially allocate memory only from below 4GB. Once that runs out * (as described above) we allow higher allocations and continue until * that runs out (or we have allocated sufficient dom0 memory). @@ -240,11 +242,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,24 +267,40 @@ 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"); - - got_bank0: + /* Failed to allocate bank0 under 4GB */ + if ( pg == NULL ) + { + if ( is_32bit_domain(d) ) + panic("Unable to allocate first memory bank."); - if ( !insert_11_bank(d, kinfo, pg, order) ) - BUG(); /* Cannot fail for first bank */ + /* Try allocating higher memory */ + printk(XENLOG_INFO "No bank has been allocated below 4GB.\n"); + lowmem = false; + } - /* Now allocate more memory and fill in additional banks */ + got_bank0: + /* + * If failed to allocate bank0 under 4GB, continue allocating + * memory from higher memory space and fill in banks. + * Otherwise allocate more memory under 4GB and fill in additional + * banks. If there is not enough memory under 4GB, use higher + * memory. + */ order = get_11_allocation_size(kinfo->unassigned_mem); while ( kinfo->unassigned_mem && kinfo->mem.nr_banks < NR_MEM_BANKS ) {