Skip to content

Commit aea73ab

Browse files
Ard Biesheuvelwildea01
authored andcommitted
arm64: head.S: get rid of x25 and x26 with 'global' scope
Currently, x25 and x26 hold the physical addresses of idmap_pg_dir and swapper_pg_dir, respectively, when running early boot code. But having registers with 'global' scope in files that contain different sections with different lifetimes, and that are called by different CPUs at different times is a bit messy, especially since stashing the values does not buy us anything in terms of code size or clarity. So simply replace each reference to x25 or x26 with an adrp instruction referring to idmap_pg_dir or swapper_pg_dir directly. Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 5a9e3e1 commit aea73ab

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

arch/arm64/kernel/head.S

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ ENTRY(stext)
214214
adrp x24, __PHYS_OFFSET
215215
and x23, x24, MIN_KIMG_ALIGN - 1 // KASLR offset, defaults to 0
216216
bl set_cpu_boot_mode_flag
217-
bl __create_page_tables // x25=TTBR0, x26=TTBR1
217+
bl __create_page_tables
218218
/*
219219
* The following calls CPU setup code, see arch/arm64/mm/proc.S for
220220
* details.
@@ -311,23 +311,21 @@ ENDPROC(preserve_boot_args)
311311
* been enabled
312312
*/
313313
__create_page_tables:
314-
adrp x25, idmap_pg_dir
315-
adrp x26, swapper_pg_dir
316314
mov x28, lr
317315

318316
/*
319317
* Invalidate the idmap and swapper page tables to avoid potential
320318
* dirty cache lines being evicted.
321319
*/
322-
mov x0, x25
323-
add x1, x26, #SWAPPER_DIR_SIZE
320+
adrp x0, idmap_pg_dir
321+
adrp x1, swapper_pg_dir + SWAPPER_DIR_SIZE
324322
bl __inval_cache_range
325323

326324
/*
327325
* Clear the idmap and swapper page tables.
328326
*/
329-
mov x0, x25
330-
add x6, x26, #SWAPPER_DIR_SIZE
327+
adrp x0, idmap_pg_dir
328+
adrp x6, swapper_pg_dir + SWAPPER_DIR_SIZE
331329
1: stp xzr, xzr, [x0], #16
332330
stp xzr, xzr, [x0], #16
333331
stp xzr, xzr, [x0], #16
@@ -340,7 +338,7 @@ __create_page_tables:
340338
/*
341339
* Create the identity mapping.
342340
*/
343-
mov x0, x25 // idmap_pg_dir
341+
adrp x0, idmap_pg_dir
344342
adrp x3, __idmap_text_start // __pa(__idmap_text_start)
345343

346344
#ifndef CONFIG_ARM64_VA_BITS_48
@@ -390,7 +388,7 @@ __create_page_tables:
390388
/*
391389
* Map the kernel image (starting with PHYS_OFFSET).
392390
*/
393-
mov x0, x26 // swapper_pg_dir
391+
adrp x0, swapper_pg_dir
394392
mov_q x5, KIMAGE_VADDR + TEXT_OFFSET // compile time __va(_text)
395393
add x5, x5, x23 // add KASLR displacement
396394
create_pgd_entry x0, x5, x3, x6
@@ -405,8 +403,8 @@ __create_page_tables:
405403
* accesses (MMU disabled), invalidate the idmap and swapper page
406404
* tables again to remove any speculatively loaded cache lines.
407405
*/
408-
mov x0, x25
409-
add x1, x26, #SWAPPER_DIR_SIZE
406+
adrp x0, idmap_pg_dir
407+
adrp x1, swapper_pg_dir + SWAPPER_DIR_SIZE
410408
dmb sy
411409
bl __inval_cache_range
412410

@@ -666,8 +664,6 @@ secondary_startup:
666664
/*
667665
* Common entry point for secondary CPUs.
668666
*/
669-
adrp x25, idmap_pg_dir
670-
adrp x26, swapper_pg_dir
671667
bl __cpu_setup // initialise processor
672668

673669
adr_l x27, __secondary_switch // address to jump to after enabling the MMU
@@ -731,8 +727,10 @@ ENTRY(__enable_mmu)
731727
cmp x2, #ID_AA64MMFR0_TGRAN_SUPPORTED
732728
b.ne __no_granule_support
733729
update_early_cpu_boot_status 0, x1, x2
734-
msr ttbr0_el1, x25 // load TTBR0
735-
msr ttbr1_el1, x26 // load TTBR1
730+
adrp x1, idmap_pg_dir
731+
adrp x2, swapper_pg_dir
732+
msr ttbr0_el1, x1 // load TTBR0
733+
msr ttbr1_el1, x2 // load TTBR1
736734
isb
737735
msr sctlr_el1, x0
738736
isb

arch/arm64/kernel/sleep.S

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ ENTRY(cpu_resume)
102102
/* enable the MMU early - so we can access sleep_save_stash by va */
103103
adr_l lr, __enable_mmu /* __cpu_setup will return here */
104104
adr_l x27, _resume_switched /* __enable_mmu will branch here */
105-
adrp x25, idmap_pg_dir
106-
adrp x26, swapper_pg_dir
107105
b __cpu_setup
108106
ENDPROC(cpu_resume)
109107

0 commit comments

Comments
 (0)