Skip to content

Commit 19f29ae

Browse files
Keith Packardardbiesheuvel
authored andcommitted
ARM: smp: Pass task to secondary_start_kernel
This avoids needing to compute the task pointer in this function, which will no longer be possible once we move thread_info off the stack. Signed-off-by: Keith Packard <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Tested-by: Amit Daniel Kachhap <[email protected]>
1 parent dfbdcda commit 19f29ae

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

arch/arm/include/asm/smp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extern void set_smp_ipi_range(int ipi_base, int nr_ipi);
4848
* Called from platform specific assembly code, this is the
4949
* secondary CPU entry point.
5050
*/
51-
asmlinkage void secondary_start_kernel(void);
51+
asmlinkage void secondary_start_kernel(struct task_struct *task);
5252

5353

5454
/*
@@ -61,6 +61,7 @@ struct secondary_data {
6161
};
6262
unsigned long swapper_pg_dir;
6363
void *stack;
64+
struct task_struct *task;
6465
};
6566
extern struct secondary_data secondary_data;
6667
extern void secondary_startup(void);

arch/arm/kernel/head-nommu.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ ENTRY(secondary_startup)
115115
ret r12
116116
1: bl __after_proc_init
117117
ldr sp, [r7, #12] @ set up the stack pointer
118+
ldr r0, [r7, #16] @ set up task pointer
118119
mov fp, #0
119120
b secondary_start_kernel
120121
ENDPROC(secondary_startup)

arch/arm/kernel/head.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,9 @@ ENDPROC(secondary_startup)
424424
ENDPROC(secondary_startup_arm)
425425

426426
ENTRY(__secondary_switched)
427-
ldr_l r7, secondary_data + 12 @ get secondary_data.stack
428-
mov sp, r7
427+
adr_l r7, secondary_data + 12 @ get secondary_data.stack
428+
ldr sp, [r7]
429+
ldr r0, [r7, #4] @ get secondary_data.task
429430
mov fp, #0
430431
b secondary_start_kernel
431432
ENDPROC(__secondary_switched)

arch/arm/kernel/smp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
153153
secondary_data.pgdir = virt_to_phys(idmap_pgd);
154154
secondary_data.swapper_pg_dir = get_arch_pgd(swapper_pg_dir);
155155
#endif
156+
secondary_data.task = idle;
156157
sync_cache_w(&secondary_data);
157158

158159
/*
@@ -375,9 +376,12 @@ void arch_cpu_idle_dead(void)
375376
*/
376377
__asm__("mov sp, %0\n"
377378
" mov fp, #0\n"
379+
" mov r0, %1\n"
378380
" b secondary_start_kernel"
379381
:
380-
: "r" (task_stack_page(current) + THREAD_SIZE - 8));
382+
: "r" (task_stack_page(current) + THREAD_SIZE - 8),
383+
"r" (current)
384+
: "r0");
381385
}
382386
#endif /* CONFIG_HOTPLUG_CPU */
383387

@@ -400,7 +404,7 @@ static void smp_store_cpu_info(unsigned int cpuid)
400404
* This is the secondary CPU boot entry. We're using this CPUs
401405
* idle thread stack, but a set of temporary page tables.
402406
*/
403-
asmlinkage void secondary_start_kernel(void)
407+
asmlinkage void secondary_start_kernel(struct task_struct *task)
404408
{
405409
struct mm_struct *mm = &init_mm;
406410
unsigned int cpu;

0 commit comments

Comments
 (0)