82
82
* primary lowlevel boot path:
83
83
*
84
84
* Register Scope Purpose
85
+ * x20 primary_entry() .. __primary_switch() CPU boot mode
85
86
* x21 primary_entry() .. start_kernel() FDT pointer passed at boot in x0
86
87
* x22 create_idmap() .. start_kernel() ID map VA of the DT blob
87
88
* x23 primary_entry() .. start_kernel() physical misalignment/KASLR offset
91
92
SYM_CODE_START(primary_entry)
92
93
bl preserve_boot_args
93
94
bl init_kernel_el // w0=cpu_boot_mode
95
+ mov x20 , x0
94
96
adrp x23 , __PHYS_OFFSET
95
97
and x23 , x23 , MIN_KIMG_ALIGN - 1 // KASLR offset , defaults to 0
96
- bl set_cpu_boot_mode_flag
97
98
bl create_idmap
98
99
99
100
/ *
@@ -429,6 +430,9 @@ SYM_FUNC_START_LOCAL(__primary_switched)
429
430
sub x4 , x4 , x0 // the kernel virtual and
430
431
str_l x4 , kimage_voffset , x5 // physical mappings
431
432
433
+ mov x0 , x20
434
+ bl set_cpu_boot_mode_flag
435
+
432
436
// Clear BSS
433
437
adr_l x0 , __bss_start
434
438
mov x1 , xzr
@@ -454,6 +458,7 @@ SYM_FUNC_START_LOCAL(__primary_switched)
454
458
ret // to __primary_switch()
455
459
0 :
456
460
#endif
461
+ mov x0 , x20
457
462
bl switch_to_vhe // Prefer VHE if possible
458
463
ldp x29 , x30 , [ sp ], # 16
459
464
bl start_kernel
@@ -553,52 +558,21 @@ SYM_FUNC_START_LOCAL(set_cpu_boot_mode_flag)
553
558
b.ne 1f
554
559
add x1 , x1 , # 4
555
560
1 : str w0 , [ x1 ] // Save CPU boot mode
556
- dmb sy
557
- dc ivac , x1 // Invalidate potentially stale cache line
558
561
ret
559
562
SYM_FUNC_END(set_cpu_boot_mode_flag)
560
563
561
- / *
562
- * These values are written with the MMU off , but read with the MMU on.
563
- * Writers will invalidate the corresponding address , discarding up to a
564
- * 'Cache Writeback Granule' (CWG) worth of data. The linker script ensures
565
- * sufficient alignment th at the CWG doesn't overlap another section.
566
- * /
567
- .pushsection ".mmuoff.data.write" , "aw"
568
- / *
569
- * We need to find out the CPU boot mode long after boot , so we need to
570
- * store it in a writable variable.
571
- *
572
- * This is not in .bss , because we set it sufficiently early th at the boot - time
573
- * zeroing of .bss would clobber it.
574
- * /
575
- SYM_DATA_START(__boot_cpu_mode)
576
- .long BOOT_CPU_MODE_EL2
577
- .long BOOT_CPU_MODE_EL1
578
- SYM_DATA_END(__boot_cpu_mode)
579
- / *
580
- * The booting CPU updates the failed status @__early_cpu_boot_status ,
581
- * with MMU turned off.
582
- * /
583
- SYM_DATA_START(__early_cpu_boot_status)
584
- .quad 0
585
- SYM_DATA_END(__early_cpu_boot_status)
586
-
587
- .popsection
588
-
589
564
/ *
590
565
* This provides a "holding pen" for platforms to hold all secondary
591
566
* cores are held until we're ready for them to initialise.
592
567
* /
593
568
SYM_FUNC_START(secondary_holding_pen)
594
569
bl init_kernel_el // w0=cpu_boot_mode
595
- bl set_cpu_boot_mode_flag
596
- mrs x0 , mpidr_el1
570
+ mrs x2 , mpidr_el1
597
571
mov_q x1 , MPIDR_HWID_BITMASK
598
- and x0 , x0 , x1
572
+ and x2 , x2 , x1
599
573
adr_l x3 , secondary_holding_pen_release
600
574
pen: ldr x4 , [ x3 ]
601
- cmp x4 , x0
575
+ cmp x4 , x2
602
576
b.eq secondary_startup
603
577
wfe
604
578
b pen
@@ -610,14 +584,14 @@ SYM_FUNC_END(secondary_holding_pen)
610
584
* /
611
585
SYM_FUNC_START(secondary_entry)
612
586
bl init_kernel_el // w0=cpu_boot_mode
613
- bl set_cpu_boot_mode_flag
614
587
b secondary_startup
615
588
SYM_FUNC_END(secondary_entry)
616
589
617
590
SYM_FUNC_START_LOCAL(secondary_startup)
618
591
/ *
619
592
* Common entry point for secondary CPUs.
620
593
* /
594
+ mov x20 , x0 // preserve boot mode
621
595
bl switch_to_vhe
622
596
bl __cpu_secondary_check52bitva
623
597
bl __cpu_setup // initialise processor
@@ -629,6 +603,9 @@ SYM_FUNC_START_LOCAL(secondary_startup)
629
603
SYM_FUNC_END(secondary_startup)
630
604
631
605
SYM_FUNC_START_LOCAL(__secondary_switched)
606
+ mov x0 , x20
607
+ bl set_cpu_boot_mode_flag
608
+ str_l xzr , __early_cpu_boot_status , x3
632
609
adr_l x5 , vectors
633
610
msr vbar_el1 , x5
634
611
isb
@@ -691,7 +668,6 @@ SYM_FUNC_START(__enable_mmu)
691
668
b.lt __no_granule_support
692
669
cmp x3 , #ID_AA64MMFR0_TGRAN_SUPPORTED_MAX
693
670
b.gt __no_granule_support
694
- update_early_cpu_boot_status 0 , x3 , x4
695
671
phys_to_ttbr x2 , x2
696
672
msr ttbr0_el1 , x2 // load TTBR0
697
673
load_ttbr1 x1 , x1 , x3
0 commit comments