From patchwork Tue Jun 28 16:17:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 71108 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1681603qgy; Tue, 28 Jun 2016 09:19:42 -0700 (PDT) X-Received: by 10.36.67.145 with SMTP id s139mr15198334itb.78.1467130781041; Tue, 28 Jun 2016 09:19:41 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id i14si14108370ioe.65.2016.06.28.09.19.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jun 2016 09:19:41 -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 1bHvhy-0007Cp-56; Tue, 28 Jun 2016 16:17:54 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHvhx-00079z-8m for xen-devel@lists.xen.org; Tue, 28 Jun 2016 16:17:53 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 92/20-18304-033A2775; Tue, 28 Jun 2016 16:17:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTVd/cVG 4wf9uU4slHxezODB6HN39mymAMYo1My8pvyKBNWP9De+C1TIVJ9edZ2pgnCbaxcjFISSwkVFi 088pbBDOaUaJm//uMHcxcnKwCWhK3Pn8iQnEFhGQlrj2+TIjiM0s4CDx5uM9FhBbWCBIYvLxM 6wgNouAqsT/5uVgNq+Aq8TkGW/AeiUE5CROHpsMFucEim+Z8pMNxBYScJG4cOIGywRG7gWMDK sYNYpTi8pSi3QNzfWSijLTM0pyEzNzdA0NjPVyU4uLE9NTcxKTivWS83M3MQL9ywAEOxhfnvY 8xCjJwaQkyvuttyhciC8pP6UyI7E4I76oNCe1+BCjDAeHkgSv7CKgnGBRanpqRVpmDjDQYNIS HDxKIryuIGne4oLE3OLMdIjUKUZdji0LbqxlEmLJy89LlRLn3b0QqEgApCijNA9uBCzoLzHKS gnzMgIdJcRTkFqUm1mCKv+KUZyDUUmY1w9kFU9mXgncpldARzABHcFanQ9yREkiQkqqgfGSoe 6nuRdP2R5tblVXzuQ81ZHDO0Hx3PRdhaf5qi7WHS/8Yn50v1xWIu8F7m97WLc6/580UV1IJ+5 Pm+HJjieHsp0mbqr559X41Hsbg5eHw6l60covVRKPD+yW/Nz0W0Q+Y13GhPiZktxX737O1zFh Lgh/eWe64/Z4/oLk91WzV0e089etvabEUpyRaKjFXFScCABOJrWodQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1467130669!47102581!2 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 55257 invoked from network); 28 Jun 2016 16:17:51 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-31.messagelabs.com with SMTP; 28 Jun 2016 16:17:51 -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 7ECFB2F; Tue, 28 Jun 2016 09:18:43 -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 9DAB33F21A; Tue, 28 Jun 2016 09:17:50 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 28 Jun 2016 17:17:17 +0100 Message-Id: <1467130643-23868-12-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467130643-23868-1-git-send-email-julien.grall@arm.com> References: <1467130643-23868-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v5 11/17] 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 --- 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) {