Skip to content

Commit 6cdbafc

Browse files
ardbiesheuvelgregkh
authored andcommitted
ARM: 9011/1: centralize phys-to-virt conversion of DT/ATAGS address
commit e9a2f8b 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>
1 parent 6d5fda4 commit 6cdbafc

6 files changed

Lines changed: 21 additions & 17 deletions

File tree

‎arch/arm/include/asm/prom.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
#ifdef CONFIG_OF
1111

12-
extern const struct machine_desc *setup_machine_fdt(unsigned int dt_phys);
12+
extern const struct machine_desc *setup_machine_fdt(void *dt_virt);
1313
extern void __init arm_dt_init_cpu_maps(void);
1414

1515
#else /* CONFIG_OF */
1616

17-
static inline const struct machine_desc *setup_machine_fdt(unsigned int dt_phys)
17+
static inline const struct machine_desc *setup_machine_fdt(void *dt_virt)
1818
{
1919
return NULL;
2020
}

‎arch/arm/kernel/atags.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
void convert_to_tag_list(struct tag *tags);
33

44
#ifdef CONFIG_ATAGS
5-
const struct machine_desc *setup_machine_tags(phys_addr_t __atags_pointer,
5+
const struct machine_desc *setup_machine_tags(void *__atags_vaddr,
66
unsigned int machine_nr);
77
#else
88
static inline const struct machine_desc * __init __noreturn
9-
setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
9+
setup_machine_tags(void *__atags_vaddr, unsigned int machine_nr)
1010
{
1111
early_print("no ATAGS support: can't continue\n");
1212
while (true);

‎arch/arm/kernel/atags_parse.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static void __init squash_mem_tags(struct tag *tag)
174174
}
175175

176176
const struct machine_desc * __init
177-
setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
177+
setup_machine_tags(void *atags_vaddr, unsigned int machine_nr)
178178
{
179179
struct tag *tags = (struct tag *)&default_tags;
180180
const struct machine_desc *mdesc = NULL, *p;
@@ -195,8 +195,8 @@ setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
195195
if (!mdesc)
196196
return NULL;
197197

198-
if (__atags_pointer)
199-
tags = phys_to_virt(__atags_pointer);
198+
if (atags_vaddr)
199+
tags = atags_vaddr;
200200
else if (mdesc->atag_offset)
201201
tags = (void *)(PAGE_OFFSET + mdesc->atag_offset);
202202

‎arch/arm/kernel/devtree.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,12 @@ static const void * __init arch_get_next_mach(const char *const **match)
203203

204204
/**
205205
* setup_machine_fdt - Machine setup when an dtb was passed to the kernel
206-
* @dt_phys: physical address of dt blob
206+
* @dt_virt: virtual address of dt blob
207207
*
208208
* If a dtb was passed to the kernel in r2, then use it to choose the
209209
* correct machine_desc and to setup the system.
210210
*/
211-
const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
211+
const struct machine_desc * __init setup_machine_fdt(void *dt_virt)
212212
{
213213
const struct machine_desc *mdesc, *mdesc_best = NULL;
214214

@@ -221,7 +221,7 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
221221
mdesc_best = &__mach_desc_GENERIC_DT;
222222
#endif
223223

224-
if (!dt_phys || !early_init_dt_verify(phys_to_virt(dt_phys)))
224+
if (!dt_virt || !early_init_dt_verify(dt_virt))
225225
return NULL;
226226

227227
mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach);

‎arch/arm/kernel/setup.c‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ unsigned int cacheid __read_mostly;
8989
EXPORT_SYMBOL(cacheid);
9090

9191
unsigned int __atags_pointer __initdata;
92+
void *atags_vaddr __initdata;
9293

9394
unsigned int system_rev;
9495
EXPORT_SYMBOL(system_rev);
@@ -1081,19 +1082,22 @@ void __init hyp_mode_check(void)
10811082

10821083
void __init setup_arch(char **cmdline_p)
10831084
{
1084-
const struct machine_desc *mdesc;
1085+
const struct machine_desc *mdesc = NULL;
1086+
1087+
if (__atags_pointer)
1088+
atags_vaddr = phys_to_virt(__atags_pointer);
10851089

10861090
setup_processor();
1087-
mdesc = setup_machine_fdt(__atags_pointer);
1091+
if (atags_vaddr)
1092+
mdesc = setup_machine_fdt(atags_vaddr);
10881093
if (!mdesc)
1089-
mdesc = setup_machine_tags(__atags_pointer, __machine_arch_type);
1094+
mdesc = setup_machine_tags(atags_vaddr, __machine_arch_type);
10901095
if (!mdesc) {
10911096
early_print("\nError: invalid dtb and unrecognized/unsupported machine ID\n");
10921097
early_print(" r1=0x%08x, r2=0x%08x\n", __machine_arch_type,
10931098
__atags_pointer);
10941099
if (__atags_pointer)
1095-
early_print(" r2[]=%*ph\n", 16,
1096-
phys_to_virt(__atags_pointer));
1100+
early_print(" r2[]=%*ph\n", 16, atags_vaddr);
10971101
dump_machine_table();
10981102
}
10991103

‎arch/arm/mm/mmu.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ static void __init map_lowmem(void)
14891489
}
14901490

14911491
#ifdef CONFIG_ARM_PV_FIXUP
1492-
extern unsigned long __atags_pointer;
1492+
extern void *atags_vaddr;
14931493
typedef void pgtables_remap(long long offset, unsigned long pgd, void *bdata);
14941494
pgtables_remap lpae_pgtables_remap_asm;
14951495

@@ -1520,7 +1520,7 @@ static void __init early_paging_init(const struct machine_desc *mdesc)
15201520
*/
15211521
lpae_pgtables_remap = (pgtables_remap *)(unsigned long)__pa(lpae_pgtables_remap_asm);
15221522
pa_pgd = __pa(swapper_pg_dir);
1523-
boot_data = __va(__atags_pointer);
1523+
boot_data = atags_vaddr;
15241524
barrier();
15251525

15261526
pr_info("Switching physical address space to 0x%08llx\n",

0 commit comments

Comments
 (0)