Commit 0fc1e934 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/40x: Prepare for enabling MMU in critical exception prolog

In order the enable MMU early in exception prolog, implement
CONFIG_VMAP_STACK principles in critical exception prolog.

There is no intention to use CONFIG_VMAP_STACK on 40x,
but related code will be used to enable MMU early in exception
in a later patch.

Also address (critirq_ctx - PAGE_OFFSET) directly instead of
using tophys() in order to win one instruction.
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/3fd75ee54c48307119acdbf66cfea966c1463bbd.1615552866.git.christophe.leroy@csgroup.eu
parent 26c46886
...@@ -89,6 +89,12 @@ _ENTRY(crit_srr0) ...@@ -89,6 +89,12 @@ _ENTRY(crit_srr0)
.space 4 .space 4
_ENTRY(crit_srr1) _ENTRY(crit_srr1)
.space 4 .space 4
_ENTRY(crit_r1)
.space 4
_ENTRY(crit_dear)
.space 4
_ENTRY(crit_esr)
.space 4
_ENTRY(saved_ksp_limit) _ENTRY(saved_ksp_limit)
.space 4 .space 4
...@@ -107,32 +113,60 @@ _ENTRY(saved_ksp_limit) ...@@ -107,32 +113,60 @@ _ENTRY(saved_ksp_limit)
mfspr r11,SPRN_SRR1 mfspr r11,SPRN_SRR1
stw r10,crit_srr0@l(0) stw r10,crit_srr0@l(0)
stw r11,crit_srr1@l(0) stw r11,crit_srr1@l(0)
#ifdef CONFIG_VMAP_STACK
mfspr r10,SPRN_DEAR
mfspr r11,SPRN_ESR
stw r10,crit_dear@l(0)
stw r11,crit_esr@l(0)
#endif
mfcr r10 /* save CR in r10 for now */ mfcr r10 /* save CR in r10 for now */
mfspr r11,SPRN_SRR3 /* check whether user or kernel */ mfspr r11,SPRN_SRR3 /* check whether user or kernel */
andi. r11,r11,MSR_PR andi. r11,r11,MSR_PR
lis r11,critirq_ctx@ha lis r11,(critirq_ctx-PAGE_OFFSET)@ha
tophys(r11,r11) lwz r11,(critirq_ctx-PAGE_OFFSET)@l(r11)
lwz r11,critirq_ctx@l(r11)
beq 1f beq 1f
/* COMING FROM USER MODE */ /* COMING FROM USER MODE */
mfspr r11,SPRN_SPRG_THREAD /* if from user, start at top of */ mfspr r11,SPRN_SPRG_THREAD /* if from user, start at top of */
lwz r11,TASK_STACK-THREAD(r11) /* this thread's kernel stack */ lwz r11,TASK_STACK-THREAD(r11) /* this thread's kernel stack */
#ifdef CONFIG_VMAP_STACK
1: stw r1,crit_r1@l(0)
addi r1,r11,THREAD_SIZE-INT_FRAME_SIZE /* Alloc an excpt frm */
LOAD_REG_IMMEDIATE(r11,MSR_KERNEL & ~(MSR_IR | MSR_RI))
mtmsr r11
isync
lwz r11,crit_r1@l(0)
stw r11,GPR1(r1)
stw r11,0(r1)
mr r11,r1
#else
1: addi r11,r11,THREAD_SIZE-INT_FRAME_SIZE /* Alloc an excpt frm */ 1: addi r11,r11,THREAD_SIZE-INT_FRAME_SIZE /* Alloc an excpt frm */
tophys(r11,r11) tophys(r11,r11)
stw r1,GPR1(r11) stw r1,GPR1(r11)
stw r1,0(r11) stw r1,0(r11)
tovirt(r1,r11) tovirt(r1,r11)
#endif
stw r10,_CCR(r11) /* save various registers */ stw r10,_CCR(r11) /* save various registers */
stw r12,GPR12(r11) stw r12,GPR12(r11)
stw r9,GPR9(r11) stw r9,GPR9(r11)
mflr r10 mflr r10
stw r10,_LINK(r11) stw r10,_LINK(r11)
#ifdef CONFIG_VMAP_STACK
lis r9,PAGE_OFFSET@ha
lwz r10,crit_r10@l(r9)
lwz r12,crit_r11@l(r9)
#else
lwz r10,crit_r10@l(0) lwz r10,crit_r10@l(0)
lwz r12,crit_r11@l(0) lwz r12,crit_r11@l(0)
#endif
stw r10,GPR10(r11) stw r10,GPR10(r11)
stw r12,GPR11(r11) stw r12,GPR11(r11)
#ifdef CONFIG_VMAP_STACK
lwz r12,crit_dear@l(r9)
lwz r9,crit_esr@l(r9)
#else
mfspr r12,SPRN_DEAR /* save DEAR and ESR in the frame */ mfspr r12,SPRN_DEAR /* save DEAR and ESR in the frame */
mfspr r9,SPRN_ESR /* in them at the point where the */ mfspr r9,SPRN_ESR /* in them at the point where the */
#endif
stw r12,_DEAR(r11) /* since they may have had stuff */ stw r12,_DEAR(r11) /* since they may have had stuff */
stw r9,_ESR(r11) /* exception was taken */ stw r9,_ESR(r11) /* exception was taken */
mfspr r12,SPRN_SRR2 mfspr r12,SPRN_SRR2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment