From patchwork Thu Apr 20 15:12:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 97831 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp846271qgf; Thu, 20 Apr 2017 08:14:51 -0700 (PDT) X-Received: by 10.202.54.87 with SMTP id d84mr2958542oia.129.1492701290954; Thu, 20 Apr 2017 08:14:50 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id l32si2826059otd.116.2017.04.20.08.14.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Apr 2017 08:14:50 -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 1d1DlC-000535-ED; Thu, 20 Apr 2017 15:12:42 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d1DlB-00052K-7q for xen-devel@lists.xen.org; Thu, 20 Apr 2017 15:12:41 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id E7/57-03696-8EFC8F85; Thu, 20 Apr 2017 15:12:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTff5+R8 RBstnW1ss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBndffYFG9QqOr7uYmxg3CbbxcjFISSwiVHi Qu9eZgjnNKPE22U3GLsYOTnYBDQl7nz+xARiiwhIS1z7fBkszizgIPHm4z0WEFtYIF3i+4xtz CA2i4CqxKn/3awgNq+ApcT5zc1gNRIC8hK72i6CxTkFrCR67kDMFAKq6Zu2mWkCI/cCRoZVjO rFqUVlqUW6xnpJRZnpGSW5iZk5uoYGZnq5qcXFiempOYlJxXrJ+bmbGIHeZQCCHYwd/5wOMUp yMCmJ8qrN/REhxJeUn1KZkVicEV9UmpNafIhRhoNDSYL3xTmgnGBRanpqRVpmDjDMYNISHDxK IrynQdK8xQWJucWZ6RCpU4y6HIee/3zPJMSSl5+XKiXO+wSkSACkKKM0D24ELOQvMcpKCfMyA h0lxFOQWpSbWYIq/4pRnINRSZj3IcgUnsy8ErhNr4COYAI64qwf2BEliQgpKWAcMXHZGGp3N/ r88M5Qjb4mKFkScXpfwSah96tndWga1c1cpM31+tcPhe9/Tn3yaoj5p7k56Owig7Uuacmz+Ts +1b713aXCuCNskcKCzeGdQjcvrN5ZvuBMSubV9SEJu4x1oq8ca5dSknt8KLzCT8XuhJfgtw+b /WexxvPybN5dGNMutv/ZrR9KLMUZiYZazEXFiQDZDbt6dAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-21.messagelabs.com!1492701159!64545712!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 971 invoked from network); 20 Apr 2017 15:12:39 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-21.messagelabs.com with SMTP; 20 Apr 2017 15:12:39 -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 F37F0CFC; Thu, 20 Apr 2017 08:12:38 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 610603F4FF; Thu, 20 Apr 2017 08:12:38 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 20 Apr 2017 16:12:26 +0100 Message-Id: <20170420151228.19158-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170420151228.19158-1-julien.grall@arm.com> References: <20170420151228.19158-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 for-4.9 3/5] xen/arm: Move the code to map FDT in the boot tables from assembly to C 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 FDT will not be accessed before start_xen (begining of C code) is called and it will be easier to maintain as the code could be common between AArch32 and AArch64. A new function early_fdt_map is introduced to map the FDT in the boot page table. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Remove the forward declaration for create_mappins as it has been moved earlier. - Remove spurious newline. - Add Stefano's reviewed. I keep it because the change is minor. --- xen/arch/arm/arm32/head.S | 14 -------------- xen/arch/arm/arm64/head.S | 13 ------------- xen/arch/arm/mm.c | 13 +++++++++++++ xen/arch/arm/setup.c | 4 +--- xen/include/asm-arm/mm.h | 2 ++ 5 files changed, 16 insertions(+), 30 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index ec63ba4c04..4090f4a744 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -389,20 +389,6 @@ paging: /* Use a virtual address to access the UART. */ ldr r11, =EARLY_UART_VIRTUAL_ADDRESS #endif - /* Map the DTB in the boot misc slot */ - teq r12, #0 /* Only on boot CPU */ - bne 1f - - ldr r1, =boot_second - mov r3, #0x0 - lsr r2, r8, #SECOND_SHIFT - lsl r2, r2, #SECOND_SHIFT /* r2: 2MB-aligned paddr of DTB */ - orr r2, r2, #PT_UPPER(MEM) - orr r2, r2, #PT_LOWER(MEM) /* r2:r3 := 2MB RAM incl. DTB */ - ldr r4, =BOOT_FDT_VIRT_START - mov r4, r4, lsr #(SECOND_SHIFT - 3) /* Slot for BOOT_FDT_VIRT_START */ - strd r2, r3, [r1, r4] /* Map it in the early fdt slot */ -1: /* * Flush the TLB in case the 1:1 mapping happens to clash with diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 72ea4e0233..78292f4396 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -550,19 +550,6 @@ paging: ldr x23, =EARLY_UART_VIRTUAL_ADDRESS #endif - /* Map the DTB in the boot misc slot */ - cbnz x22, 1f /* Only on boot CPU */ - - ldr x4, =boot_second /* x4 := vaddr (boot_second) */ - lsr x2, x21, #SECOND_SHIFT - lsl x2, x2, #SECOND_SHIFT /* x2 := 2MB-aligned paddr of DTB */ - mov x3, #PT_MEM /* x2 := 2MB RAM incl. DTB */ - orr x2, x2, x3 - ldr x1, =BOOT_FDT_VIRT_START - lsr x1, x1, #(SECOND_SHIFT - 3) /* x4 := Slot for BOOT_FDT_VIRT_START */ - str x2, [x4, x1] /* Map it in the early fdt slot */ -1: - /* * Flush the TLB in case the 1:1 mapping happens to clash with * the virtual addresses used by the fixmap or DTB. diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index bc65c0e432..97b3209286 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -38,6 +38,7 @@ #include #include #include +#include struct domain *dom_xen, *dom_io, *dom_cow; @@ -468,6 +469,18 @@ static inline lpae_t pte_of_xenaddr(vaddr_t va) return mfn_to_xen_entry(mfn, WRITEALLOC); } +/* Map the FDT in the early boot page table */ +void * __init early_fdt_map(paddr_t fdt_paddr) +{ + /* We are using 2MB superpage for mapping the FDT */ + paddr_t base_paddr = fdt_paddr & SECOND_MASK; + + create_mappings(boot_second, BOOT_FDT_VIRT_START, paddr_to_pfn(base_paddr), + SZ_2M >> PAGE_SHIFT, SZ_2M); + + return (void *)BOOT_FDT_VIRT_START + (fdt_paddr % SECOND_SIZE); +} + void __init remove_early_mappings(void) { lpae_t pte = {0}; diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 92a2de6b70..986398970f 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -724,9 +724,7 @@ void __init start_xen(unsigned long boot_phys_offset, smp_clear_cpu_maps(); - /* This is mapped by head.S */ - device_tree_flattened = (void *)BOOT_FDT_VIRT_START - + (fdt_paddr & ((1 << SECOND_SHIFT) - 1)); + device_tree_flattened = early_fdt_map(fdt_paddr); fdt_size = boot_fdt_info(device_tree_flattened, fdt_paddr); cmdline = boot_fdt_cmdline(device_tree_flattened); diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index 0fef612f42..f6915ad882 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -160,6 +160,8 @@ extern unsigned long total_pages; /* Boot-time pagetable setup */ extern void setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr); +/* Map FDT in boot pagetable */ +extern void *early_fdt_map(paddr_t fdt_paddr); /* Remove early mappings */ extern void remove_early_mappings(void); /* Allocate and initialise pagetables for a secondary CPU. Sets init_ttbr to the