Skip to content

Commit c730564

Browse files
npigginmpe
authored andcommitted
powerpc/64s: Convert slb_miss_common to use RFI_TO_USER/KERNEL
In the SLB miss handler we may be returning to user or kernel. We need to add a check early on and save the result in the cr4 register, and then we bifurcate the return path based on that. Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent a08f828 commit c730564

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

arch/powerpc/kernel/exceptions-64s.S

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,9 @@ EXC_COMMON_BEGIN(slb_miss_common)
598598
stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
599599
std r10,PACA_EXSLB+EX_LR(r13) /* save LR */
600600

601+
andi. r9,r11,MSR_PR // Check for exception from userspace
602+
cmpdi cr4,r9,MSR_PR // And save the result in CR4 for later
603+
601604
/*
602605
* Test MSR_RI before calling slb_allocate_realmode, because the
603606
* MSR in r11 gets clobbered. However we still want to allocate
@@ -624,9 +627,32 @@ END_MMU_FTR_SECTION_IFCLR(MMU_FTR_TYPE_RADIX)
624627

625628
/* All done -- return from exception. */
626629

630+
bne cr4,1f /* returning to kernel */
631+
632+
.machine push
633+
.machine "power4"
634+
mtcrf 0x80,r9
635+
mtcrf 0x08,r9 /* MSR[PR] indication is in cr4 */
636+
mtcrf 0x04,r9 /* MSR[RI] indication is in cr5 */
637+
mtcrf 0x02,r9 /* I/D indication is in cr6 */
638+
mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */
639+
.machine pop
640+
641+
RESTORE_CTR(r9, PACA_EXSLB)
642+
RESTORE_PPR_PACA(PACA_EXSLB, r9)
643+
mr r3,r12
644+
ld r9,PACA_EXSLB+EX_R9(r13)
645+
ld r10,PACA_EXSLB+EX_R10(r13)
646+
ld r11,PACA_EXSLB+EX_R11(r13)
647+
ld r12,PACA_EXSLB+EX_R12(r13)
648+
ld r13,PACA_EXSLB+EX_R13(r13)
649+
RFI_TO_USER
650+
b . /* prevent speculative execution */
651+
1:
627652
.machine push
628653
.machine "power4"
629654
mtcrf 0x80,r9
655+
mtcrf 0x08,r9 /* MSR[PR] indication is in cr4 */
630656
mtcrf 0x04,r9 /* MSR[RI] indication is in cr5 */
631657
mtcrf 0x02,r9 /* I/D indication is in cr6 */
632658
mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */
@@ -640,9 +666,10 @@ END_MMU_FTR_SECTION_IFCLR(MMU_FTR_TYPE_RADIX)
640666
ld r11,PACA_EXSLB+EX_R11(r13)
641667
ld r12,PACA_EXSLB+EX_R12(r13)
642668
ld r13,PACA_EXSLB+EX_R13(r13)
643-
rfid
669+
RFI_TO_KERNEL
644670
b . /* prevent speculative execution */
645671

672+
646673
2: std r3,PACA_EXSLB+EX_DAR(r13)
647674
mr r3,r12
648675
mfspr r11,SPRN_SRR0

0 commit comments

Comments
 (0)