ARM: 9011/1: centralize phys-to-virt conversion of DT/ATAGS address
authorArd Biesheuvel <ardb@kernel.org>
Mon, 10 May 2021 13:21:08 +0000 (06:21 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 May 2021 08:13:18 +0000 (10:13 +0200)
commit e9a2f8b599d0bc22a1b13e69527246ac39c697b4 upstream

Before moving the DT mapping out of the linear region, let's prepare
for this change by removing all the phys-to-virt translations of the
__atags_pointer variable, and perform this translation only once at
setup time.

Tested-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm/include/asm/prom.h
arch/arm/kernel/atags.h
arch/arm/kernel/atags_parse.c
arch/arm/kernel/devtree.c
arch/arm/kernel/setup.c
arch/arm/mm/mmu.c

index 1e36c40533c161aa759a61b6d23b2f09475d7b60..402e3f34c7ed886dda7f8b2fc7d398ef755f0a2d 100644 (file)
@@ -9,12 +9,12 @@
 
 #ifdef CONFIG_OF
 
-extern const struct machine_desc *setup_machine_fdt(unsigned int dt_phys);
+extern const struct machine_desc *setup_machine_fdt(void *dt_virt);
 extern void __init arm_dt_init_cpu_maps(void);
 
 #else /* CONFIG_OF */
 
-static inline const struct machine_desc *setup_machine_fdt(unsigned int dt_phys)
+static inline const struct machine_desc *setup_machine_fdt(void *dt_virt)
 {
        return NULL;
 }
index 067e12edc34199edbb77617654b5ef5bb0b49e48..f2819c25b602994b1f104bd8798625902189a6c4 100644 (file)
@@ -2,11 +2,11 @@
 void convert_to_tag_list(struct tag *tags);
 
 #ifdef CONFIG_ATAGS
-const struct machine_desc *setup_machine_tags(phys_addr_t __atags_pointer,
+const struct machine_desc *setup_machine_tags(void *__atags_vaddr,
        unsigned int machine_nr);
 #else
 static inline const struct machine_desc * __init __noreturn
-setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
+setup_machine_tags(void *__atags_vaddr, unsigned int machine_nr)
 {
        early_print("no ATAGS support: can't continue\n");
        while (true);
index 6c12d9fe694e3eaa1da4008dcf6cd9db2f4d0f24..373b61f9a4f01c17fba7a5d4398034129a43f3d1 100644 (file)
@@ -174,7 +174,7 @@ static void __init squash_mem_tags(struct tag *tag)
 }
 
 const struct machine_desc * __init
-setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
+setup_machine_tags(void *atags_vaddr, unsigned int machine_nr)
 {
        struct tag *tags = (struct tag *)&default_tags;
        const struct machine_desc *mdesc = NULL, *p;
@@ -195,8 +195,8 @@ setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
        if (!mdesc)
                return NULL;
 
-       if (__atags_pointer)
-               tags = phys_to_virt(__atags_pointer);
+       if (atags_vaddr)
+               tags = atags_vaddr;
        else if (mdesc->atag_offset)
                tags = (void *)(PAGE_OFFSET + mdesc->atag_offset);
 
index 7f0745a97e20f21f67483d91484939bc1bd6c198..28311dd0fee686fde3d78cdbaecc628667059047 100644 (file)
@@ -203,12 +203,12 @@ static const void * __init arch_get_next_mach(const char *const **match)
 
 /**
  * setup_machine_fdt - Machine setup when an dtb was passed to the kernel
- * @dt_phys: physical address of dt blob
+ * @dt_virt: virtual address of dt blob
  *
  * If a dtb was passed to the kernel in r2, then use it to choose the
  * correct machine_desc and to setup the system.
  */
-const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
+const struct machine_desc * __init setup_machine_fdt(void *dt_virt)
 {
        const struct machine_desc *mdesc, *mdesc_best = NULL;
 
@@ -221,7 +221,7 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
        mdesc_best = &__mach_desc_GENERIC_DT;
 #endif
 
-       if (!dt_phys || !early_init_dt_verify(phys_to_virt(dt_phys)))
+       if (!dt_virt || !early_init_dt_verify(dt_virt))
                return NULL;
 
        mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach);
index 3f65d0ac9f632b4c37fbc214379de71eb5a5875a..306bcd9844be75c362c872e917f848180ce74ab4 100644 (file)
@@ -89,6 +89,7 @@ unsigned int cacheid __read_mostly;
 EXPORT_SYMBOL(cacheid);
 
 unsigned int __atags_pointer __initdata;
+void *atags_vaddr __initdata;
 
 unsigned int system_rev;
 EXPORT_SYMBOL(system_rev);
@@ -1081,19 +1082,22 @@ void __init hyp_mode_check(void)
 
 void __init setup_arch(char **cmdline_p)
 {
-       const struct machine_desc *mdesc;
+       const struct machine_desc *mdesc = NULL;
+
+       if (__atags_pointer)
+               atags_vaddr = phys_to_virt(__atags_pointer);
 
        setup_processor();
-       mdesc = setup_machine_fdt(__atags_pointer);
+       if (atags_vaddr)
+               mdesc = setup_machine_fdt(atags_vaddr);
        if (!mdesc)
-               mdesc = setup_machine_tags(__atags_pointer, __machine_arch_type);
+               mdesc = setup_machine_tags(atags_vaddr, __machine_arch_type);
        if (!mdesc) {
                early_print("\nError: invalid dtb and unrecognized/unsupported machine ID\n");
                early_print("  r1=0x%08x, r2=0x%08x\n", __machine_arch_type,
                            __atags_pointer);
                if (__atags_pointer)
-                       early_print("  r2[]=%*ph\n", 16,
-                                   phys_to_virt(__atags_pointer));
+                       early_print("  r2[]=%*ph\n", 16, atags_vaddr);
                dump_machine_table();
        }
 
index ab69250a86bc34a5976d9622cf6d25091f203f2d..55991fe60054e6767c100f074fb66b3a029475a8 100644 (file)
@@ -1489,7 +1489,7 @@ static void __init map_lowmem(void)
 }
 
 #ifdef CONFIG_ARM_PV_FIXUP
-extern unsigned long __atags_pointer;
+extern void *atags_vaddr;
 typedef void pgtables_remap(long long offset, unsigned long pgd, void *bdata);
 pgtables_remap lpae_pgtables_remap_asm;
 
@@ -1520,7 +1520,7 @@ static void __init early_paging_init(const struct machine_desc *mdesc)
         */
        lpae_pgtables_remap = (pgtables_remap *)(unsigned long)__pa(lpae_pgtables_remap_asm);
        pa_pgd = __pa(swapper_pg_dir);
-       boot_data = __va(__atags_pointer);
+       boot_data = atags_vaddr;
        barrier();
 
        pr_info("Switching physical address space to 0x%08llx\n",