From patchwork Wed Jul 6 13:01:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 71455 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp854111qgy; Wed, 6 Jul 2016 06:04:09 -0700 (PDT) X-Received: by 10.36.29.20 with SMTP id 20mr17251662itj.99.1467810249284; Wed, 06 Jul 2016 06:04:09 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id k202si3550852itb.86.2016.07.06.06.04.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jul 2016 06:04:09 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKmSP-0000EE-Ca; Wed, 06 Jul 2016 13:01:37 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKmSN-0000CK-KZ for xen-devel@lists.xen.org; Wed, 06 Jul 2016 13:01:35 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id 5E/78-07949-E210D775; Wed, 06 Jul 2016 13:01:34 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPLMWRWlGSWpSXmKPExsVysyfVTVePsTb c4MEUKYslHxezODB6HN39mymAMYo1My8pvyKBNePk/Ea2gmmyFavv1TUwvhTtYuTkEBLYxCjR 1eUBYZ9mlLg4TxHEZhPQlLjz+RMTiC0iIC1x7fNlRhCbWcBB4s3HeywgtrBAkMSMf/OZQWwWA VWJt3s2gtXwCrhIXO7vBrMlBOQkTh6bzApicwq4Sky/9pgdYpeLxPbFk5gnMHIvYGRYxahenF pUllqka6qXVJSZnlGSm5iZo2toYKyXm1pcnJiempOYVKyXnJ+7iRHo2XoGBsYdjJe/Oh1ilOR gUhLlZflWHS7El5SfUpmRWJwRX1Sak1p8iFGGg0NJgrfhf024kGBRanpqRVpmDjDEYNISHDxK IryPQNK8xQWJucWZ6RCpU4y6HFsW3FjLJMSSl5+XKiXO2wlSJABSlFGaBzcCFu6XGGWlhHkZG RgYhHgKUotyM0tQ5V8xinMwKgnz3vwHNIUnM68EbtMroCOYgI746VINckRJIkJKqoFxf/CV3E +XTqt/zL64ruD/QV0fthtz5mycHl7I5q04RbPnVN7skPdN3ikPbjyYPX++q0rS+bvCz6b8CvV 7vetV05rDvOwz3msumVk1VdZWePvdg7LPEiqNnzeV1n9/u+bNnDuLito+7fz85dZNFuPNUya8 LXazMTj6iJ/1q4LObQ3/HwtiouWq7iuxFGckGmoxFxUnAgDpG5lPcgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1467810093!32456182!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 8697 invoked from network); 6 Jul 2016 13:01:34 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-31.messagelabs.com with SMTP; 6 Jul 2016 13:01:34 -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 65DADBB4; Wed, 6 Jul 2016 06:02:32 -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 DD98D3F21A; Wed, 6 Jul 2016 06:01:32 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 6 Jul 2016 14:01:07 +0100 Message-Id: <1467810073-27971-9-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467810073-27971-1-git-send-email-julien.grall@arm.com> References: <1467810073-27971-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v6 08/14] 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" 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 Acked-by: Stefano Stabellini --- Changes in v6: - Add Stefano's acked-by 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) {