From patchwork Mon Jun 27 16:54:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9200941 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 E8ACF607D3 for ; Mon, 27 Jun 2016 16:56:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9ADD285A3 for ; Mon, 27 Jun 2016 16:56:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEA02285A5; Mon, 27 Jun 2016 16:56:23 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 7392D285A3 for ; Mon, 27 Jun 2016 16:56:23 +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 1bHZny-0005hz-UK; Mon, 27 Jun 2016 16:54:38 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHZnx-0005eY-2Q for xen-devel@lists.xen.org; Mon, 27 Jun 2016 16:54:37 +0000 Received: from [193.109.254.147] by server-15.bemta-14.messagelabs.com id 3F/0B-07069-C4A51775; Mon, 27 Jun 2016 16:54:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTdc7qjD c4NsfU4slHxezODB6HN39mymAMYo1My8pvyKBNWP9De+C1TIVJ9edZ2pgnCbaxcjFISSwiVFi 1fWn7BDOaUaJ1VP3MXcxcnKwCWhK3Pn8iQnEFhGQlrj2+TIjiM0sECZx+80uMFtYIEhi4dmfr CA2i4CqxKeZT9lAbF4BF4mfV3aygNgSAnISJ49NBqvhBIrvvbAUbL6QgLPEwWnf2Scwci9gZF jFqFGcWlSWWqRraKaXVJSZnlGSm5iZo2toaKKXm1pcnJiempOYVKyXnJ+7iRHo33oGBsYdjF9 Pex5ilORgUhLl3fYoN1yILyk/pTIjsTgjvqg0J7X4EKMMB4eSBG9SZGG4kGBRanpqRVpmDjDQ YNISHDxKIrxrQdK8xQWJucWZ6RCpU4y6HFsW3FjLJMSSl5+XKiXOqwRSJABSlFGaBzcCFvSXG GWlhHkZGRgYhHgKUotyM0tQ5V8xinMwKgnztoNM4cnMK4Hb9AroCCagI1ir80GOKElESEk1MK 5U7SjmD5++MG+ei8vXgqVN64wXlxrfqPvwIGPLtOb2dMuYuMnW7zJa/+qxuiWFSq0qmfaa/2W eoaD+srdLI8Uqa3XVwuLU3gYfnx9hVPSO/8C/UOb1r83Kv9rOOXoqeRK/z4zqMD+hpCkFGx9G R9+aaNoZufJUla1K/5Z7LxjKfK9uuMTLoMRSnJFoqMVcVJwIAGGYS2t1AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1467046475!50430405!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30652 invoked from network); 27 Jun 2016 16:54:35 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-27.messagelabs.com with SMTP; 27 Jun 2016 16:54:35 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 60ABE523; Mon, 27 Jun 2016 09:55:26 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.215.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3280B3F246; Mon, 27 Jun 2016 09:54:34 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 27 Jun 2016 17:54:06 +0100 Message-Id: <1467046452-1261-11-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467046452-1261-1-git-send-email-julien.grall@arm.com> References: <1467046452-1261-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, wei.chen@linaro.org Subject: [Xen-devel] [PATCH v4 10/16] xen/arm: dom0_build: Remove dead code in allocate_memory 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 The code to allocate memory when dom0 does not use direct mapping is relying on the presence of memory node in the DT. However, they are not present when booting using UEFI or when using ACPI. Rather than fixing the code, remove it because dom0 is always direct memory mapped and therefore the code is never tested. Also add a check to avoid disabling direct memory mapped and not implementing the associated RAM bank allocation. Signed-off-by: Julien Grall --- Changes in v4: - Patch added --- xen/arch/arm/domain_build.c | 58 ++++++--------------------------------------- 1 file changed, 7 insertions(+), 51 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 49185f0..923f48a 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -235,7 +235,7 @@ fail: * (as described above) we allow higher allocations and continue until * that runs out (or we have allocated sufficient dom0 memory). */ -static void allocate_memory_11(struct domain *d, struct kernel_info *kinfo) +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))); @@ -247,6 +247,12 @@ static void allocate_memory_11(struct domain *d, struct kernel_info *kinfo) bool_t lowmem = is_32bit_domain(d); unsigned int bits; + /* + * TODO: Implement memory bank allocation when DOM0 is not direct + * mapped + */ + BUG_ON(!dom0_11_mapping); + printk("Allocating 1:1 mappings totalling %ldMB for dom0:\n", /* Don't want format this as PRIpaddr (16 digit hex) */ (unsigned long)(kinfo->unassigned_mem >> 20)); @@ -343,56 +349,6 @@ static void allocate_memory_11(struct domain *d, struct kernel_info *kinfo) } } -static void allocate_memory(struct domain *d, struct kernel_info *kinfo) -{ - - struct dt_device_node *memory = NULL; - const void *reg; - u32 reg_len, reg_size; - unsigned int bank = 0; - - if ( dom0_11_mapping ) - return allocate_memory_11(d, kinfo); - - while ( (memory = dt_find_node_by_type(memory, "memory")) ) - { - int l; - - dt_dprintk("memory node\n"); - - reg_size = dt_cells_to_size(dt_n_addr_cells(memory) + dt_n_size_cells(memory)); - - reg = dt_get_property(memory, "reg", ®_len); - if ( reg == NULL ) - panic("Memory node has no reg property"); - - for ( l = 0; - kinfo->unassigned_mem > 0 && l + reg_size <= reg_len - && kinfo->mem.nr_banks < NR_MEM_BANKS; - l += reg_size ) - { - paddr_t start, size; - - if ( dt_device_get_address(memory, bank, &start, &size) ) - panic("Unable to retrieve the bank %u for %s", - bank, dt_node_full_name(memory)); - - if ( size > kinfo->unassigned_mem ) - size = kinfo->unassigned_mem; - - printk("Populate P2M %#"PRIx64"->%#"PRIx64"\n", - start, start + size); - if ( p2m_populate_ram(d, start, start + size) < 0 ) - panic("Failed to populate P2M"); - kinfo->mem.bank[kinfo->mem.nr_banks].start = start; - kinfo->mem.bank[kinfo->mem.nr_banks].size = size; - kinfo->mem.nr_banks++; - - kinfo->unassigned_mem -= size; - } - } -} - static int write_properties(struct domain *d, struct kernel_info *kinfo, const struct dt_device_node *node) {