@@ -395,15 +395,29 @@ SYM_FUNC_START_LOCAL(__create_page_tables)
395395SYM_FUNC_END(__create_page_tables)
396396
397397 / *
398+ * Initialize CPU registers with task - specific and cpu - specific context.
399+ *
398400 * Create a final frame record at task_pt_regs(current) - >stackframe , so
399401 * th at the unwinder can identify the final frame record of any task by
400402 * its location in the task stack. We reserve the entire pt_regs space
401403 * for consistency with user tasks and kthreads.
402404 * /
403- .macro setup_final_frame
405+ .macro init_cpu_task tsk , tmp1 , tmp2
406+ msr sp_el0 , \tsk
407+
408+ ldr \tmp1 , [ \tsk , #TSK_STACK ]
409+ add sp , \tmp1 , #THREAD_SIZE
404410 sub sp , sp , #PT_REGS_SIZE
411+
405412 stp xzr , xzr , [ sp , #S_STACKFRAME ]
406413 add x29 , sp , #S_STACKFRAME
414+
415+ scs_load \tsk
416+
417+ adr_l \tmp1 , __per_cpu_offset
418+ ldr w\tmp2 , [ \tsk , #TSK_ CPU ]
419+ ldr \tmp1 , [ \tmp1 , \tmp2 , lsl # 3 ]
420+ set_this_cpu_offset \tmp1
407421 .endm
408422
409423/ *
@@ -412,22 +426,16 @@ SYM_FUNC_END(__create_page_tables)
412426 * x0 = __PHYS_OFFSET
413427 * /
414428SYM_FUNC_START_LOCAL(__primary_switched)
415- adrp x4 , init_thread_union
416- add sp , x4 , #THREAD_SIZE
417- adr_l x5 , init_task
418- msr sp_el0 , x5 // Save thread_info
429+ adr_l x4 , init_task
430+ init_cpu_task x4 , x5 , x6
419431
420432 adr_l x8 , vectors // load VBAR_EL1 with virtual
421433 msr vbar_el1 , x8 // vector table address
422434 isb
423435
424- stp xzr , x30 , [ sp , # - 16 ] !
436+ stp x29 , x30 , [ sp , # - 16 ] !
425437 mov x29 , sp
426438
427- #ifdef CONFIG_SHADOW_CALL_STACK
428- adr_l scs_sp , init_shadow_call_stack // Set shadow call stack
429- #endif
430-
431439 str_l x21 , __fdt_pointer , x5 // Save FDT pointer
432440
433441 ldr_l x4 , kimage_vaddr // Save the offset between
@@ -459,8 +467,7 @@ SYM_FUNC_START_LOCAL(__primary_switched)
4594670 :
460468#endif
461469 bl switch_to_vhe // Prefer VHE if possible
462- add sp , sp , # 16
463- setup_final_frame
470+ ldp x29 , x30 , [ sp ], # 16
464471 bl start_kernel
465472 ASM_BUG()
466473SYM_FUNC_END(__primary_switched)
@@ -645,14 +652,10 @@ SYM_FUNC_START_LOCAL(__secondary_switched)
645652 isb
646653
647654 adr_l x0 , secondary_data
648- ldr x1 , [ x0 , #CPU_BOOT_STACK ] // get secondary_data.stack
649- cbz x1 , __secondary_too_slow
650- mov sp , x1
651655 ldr x2 , [ x0 , #CPU_BOOT_TASK ]
652656 cbz x2 , __secondary_too_slow
653- msr sp_el0 , x2
654- scs_load x2 , x3
655- setup_final_frame
657+
658+ init_cpu_task x2 , x1 , x3
656659
657660#ifdef CONFIG_ARM64_PTR_AUTH
658661 ptrauth_keys_init_ cpu x2 , x3 , x4 , x5
0 commit comments