Skip to content

Commit

Permalink
powerpc/64: Simplify __secondary_start paca->kstack handling
Browse files Browse the repository at this point in the history
In __secondary_start() we load the thread_info of the idle task of the
secondary CPU from current_set[cpu], and then convert it into a stack
pointer before storing that back to paca->kstack.

As pointed out in commit f761622 ("powerpc: Initialise
paca->kstack before early_setup_secondary") it's important that we
initialise paca->kstack before calling the MMU setup code, in
particular slb_initialize(), because it will bolt the SLB entry for
the kstack into the SLB.

However we have already setup paca->kstack in cpu_idle_thread_init(),
since commit 3b57506 ("[POWERPC] Bolt in SLB entry for kernel
stack on secondary cpus") (May 2008).

It's also in cpu_idle_thread_init() that we initialise current_set[cpu]
with the thread_info pointer, so there is no issue of the timing being
different between the two.

Therefore the initialisation of paca->kstack in __setup_secondary() is
completely redundant, so remove it.

This has the added benefit of removing code that runs in real mode,
and is therefore restricted by the RMO, and so opens the way for us to
enable THREAD_INFO_IN_TASK.

Signed-off-by: Michael Ellerman <[email protected]>
  • Loading branch information
mpe committed Feb 23, 2019
1 parent e7fda7e commit eafd825
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions arch/powerpc/kernel/head_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -801,21 +801,19 @@ __secondary_start:
/* Set thread priority to MEDIUM */
HMT_MEDIUM

/* Initialize the kernel stack */
LOAD_REG_ADDR(r3, current_set)
sldi r28,r24,3 /* get current_set[cpu#] */
ldx r14,r3,r28
addi r14,r14,THREAD_SIZE-STACK_FRAME_OVERHEAD
std r14,PACAKSAVE(r13)

/* Do early setup for that CPU (SLB and hash table pointer) */
/*
* Do early setup for this CPU, in particular initialising the MMU so we
* can turn it on below. This is a call to C, which is OK, we're still
* running on the emergency stack.
*/
bl early_setup_secondary

/*
* setup the new stack pointer, but *don't* use this until
* translation is on.
* The primary has initialized our kernel stack for us in the paca, grab
* it and put it in r1. We must *not* use it until we turn on the MMU
* below, because it may not be inside the RMO.
*/
mr r1, r14
ld r1, PACAKSAVE(r13)

/* Clear backchain so we get nice backtraces */
li r7,0
Expand Down

0 comments on commit eafd825

Please sign in to comment.