From patchwork Tue Jul 12 13:59:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 71839 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp492782qga; Tue, 12 Jul 2016 07:03:27 -0700 (PDT) X-Received: by 10.107.191.195 with SMTP id p186mr3373430iof.115.1468332207799; Tue, 12 Jul 2016 07:03:27 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id f184si2500533ith.102.2016.07.12.07.03.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jul 2016 07:03:27 -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 1bMyED-0007II-UA; Tue, 12 Jul 2016 14:00:01 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMyEC-00079h-Nu for xen-devel@lists.xen.org; Tue, 12 Jul 2016 14:00:00 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id 4D/BF-04210-FD7F4875; Tue, 12 Jul 2016 13:59:59 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRWlGSWpSXmKPExsVysyfVTff+95Z wgxcnFSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oyT8xvZCqbJVqy+V9fA+FK0i5GTQ0hgE6PE 7Fd8XYxcQPZpRonnq2axgCTYBDQl7nz+xARiiwhIS1z7fJkRxGYWcJB48/EeWI2wQJDEhp2Hw OIsAqoSjS/72EFsXgEXif5D69lAbAkBOYmTxyazgticAq4SX6efZIRY7CJxYdlX1gmM3AsYGV YxqhenFpWlFuma6yUVZaZnlOQmZuboGhqY6uWmFhcnpqfmJCYV6yXn525iBPqWAQh2MB6b7Hy IUZKDSUmUt5m5JVyILyk/pTIjsTgjvqg0J7X4EKMMB4eSBG/4N6CcYFFqempFWmYOMMhg0hIc PEoivEYgad7igsTc4sx0iNQpRl2OLQturGUSYsnLz0uVEucVAykSACnKKM2DGwEL+EuMslLCv IxARwnxFKQW5WaWoMq/YhTnYFQS5m0GmcKTmVcCt+kV0BFMQEfUOjSDHFGSiJCSamA0+3l99c RbT3JVLXoFGCcUSJtqis+5Wbjl2AExn+3zk8ty7ncYbn9gHbFWRPHd091qoVNCMvbO5hWam+j 79s6d7W9WCb/YMe379D951vqFS5fZntP8OJWjSWCFIivnn5QrTO+SjGtYup/ffRvtsiP+7QFD juUrVPx5vyZ+49ct/dSi/vFdL8clJZbijERDLeai4kQAg56/qnMCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1468331995!49521094!3 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.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6721 invoked from network); 12 Jul 2016 13:59:59 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-206.messagelabs.com with SMTP; 12 Jul 2016 13:59:59 -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 D00F1BAD; Tue, 12 Jul 2016 07:01:02 -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 53C3E3F213; Tue, 12 Jul 2016 06:59:58 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 12 Jul 2016 14:59:29 +0100 Message-Id: <1468331975-27331-9-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468331975-27331-1-git-send-email-julien.grall@arm.com> References: <1468331975-27331-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v7 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) {