Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/booke64: Use SPRG_TLB_EXFRAME on bolted handlers

While bolted handlers (including e6500) do not need to deal with a TLB
miss recursively causing another TLB miss, nested TLB misses can still
happen with crit/mc/debug exceptions -- so we still need to honor
SPRG_TLB_EXFRAME.

We don't need to spend time modifying it in the TLB miss fastpath,
though -- the special level exception will handle that.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Cc: Mihai Caraman <mihai.caraman@freescale.com>
Cc: kvm-ppc@vger.kernel.org

+42 -31
-10
arch/powerpc/include/asm/exception-64e.h
··· 172 172 ld r9,EX_TLB_R9(r12); \ 173 173 ld r8,EX_TLB_R8(r12); \ 174 174 mtlr r16; 175 - #define TLB_MISS_PROLOG_STATS_BOLTED \ 176 - mflr r10; \ 177 - std r8,PACA_EXTLB+EX_TLB_R8(r13); \ 178 - std r9,PACA_EXTLB+EX_TLB_R9(r13); \ 179 - std r10,PACA_EXTLB+EX_TLB_LR(r13); 180 - #define TLB_MISS_RESTORE_STATS_BOLTED \ 181 - ld r16,PACA_EXTLB+EX_TLB_LR(r13); \ 182 - ld r9,PACA_EXTLB+EX_TLB_R9(r13); \ 183 - ld r8,PACA_EXTLB+EX_TLB_R8(r13); \ 184 - mtlr r16; 185 175 #define TLB_MISS_STATS_D(name) \ 186 176 addi r9,r13,MMSTAT_DSTATS+name; \ 187 177 bl .tlb_stat_inc;
+5 -3
arch/powerpc/include/asm/kvm_booke_hv_asm.h
··· 45 45 * 46 46 * Expected inputs (TLB exception type): 47 47 * r10 = saved CR 48 + * r12 = extlb pointer 48 49 * r13 = PACA_POINTER 49 - * *(r13 + PACA_EX##type + EX_TLB_R10) = saved r10 50 - * *(r13 + PACA_EX##type + EX_TLB_R11) = saved r11 51 - * SPRN_SPRG_GEN_SCRATCH = saved r13 50 + * *(r12 + EX_TLB_R10) = saved r10 51 + * *(r12 + EX_TLB_R11) = saved r11 52 + * *(r12 + EX_TLB_R13) = saved r13 53 + * SPRN_SPRG_GEN_SCRATCH = saved r12 52 54 * 53 55 * Only the bolted version of TLB miss exception handlers is supported now. 54 56 */
+9 -2
arch/powerpc/kvm/bookehv_interrupts.S
··· 229 229 stw r10, VCPU_CR(r4) 230 230 PPC_STL r11, VCPU_GPR(R4)(r4) 231 231 PPC_STL r5, VCPU_GPR(R5)(r4) 232 - mfspr r5, \scratch 233 232 PPC_STL r6, VCPU_GPR(R6)(r4) 234 233 PPC_STL r8, VCPU_GPR(R8)(r4) 235 234 PPC_STL r9, VCPU_GPR(R9)(r4) 236 - PPC_STL r5, VCPU_GPR(R13)(r4) 235 + .if \type == EX_TLB 236 + PPC_LL r5, EX_TLB_R13(r12) 237 + PPC_LL r6, EX_TLB_R10(r12) 238 + PPC_LL r8, EX_TLB_R11(r12) 239 + mfspr r12, \scratch 240 + .else 241 + mfspr r5, \scratch 237 242 PPC_LL r6, (\paca_ex + \ex_r10)(r13) 238 243 PPC_LL r8, (\paca_ex + \ex_r11)(r13) 244 + .endif 245 + PPC_STL r5, VCPU_GPR(R13)(r4) 239 246 PPC_STL r3, VCPU_GPR(R3)(r4) 240 247 PPC_STL r7, VCPU_GPR(R7)(r4) 241 248 PPC_STL r12, VCPU_GPR(R12)(r4)
+28 -16
arch/powerpc/mm/tlb_low_64e.S
··· 39 39 * * 40 40 **********************************************************************/ 41 41 42 + /* 43 + * Note that, unlike non-bolted handlers, TLB_EXFRAME is not 44 + * modified by the TLB miss handlers themselves, since the TLB miss 45 + * handler code will not itself cause a recursive TLB miss. 46 + * 47 + * TLB_EXFRAME will be modified when crit/mc/debug exceptions are 48 + * entered/exited. 49 + */ 42 50 .macro tlb_prolog_bolted intnum addr 43 - mtspr SPRN_SPRG_GEN_SCRATCH,r13 51 + mtspr SPRN_SPRG_GEN_SCRATCH,r12 52 + mfspr r12,SPRN_SPRG_TLB_EXFRAME 53 + std r13,EX_TLB_R13(r12) 54 + std r10,EX_TLB_R10(r12) 44 55 mfspr r13,SPRN_SPRG_PACA 45 - std r10,PACA_EXTLB+EX_TLB_R10(r13) 56 + 46 57 mfcr r10 47 - std r11,PACA_EXTLB+EX_TLB_R11(r13) 58 + std r11,EX_TLB_R11(r12) 48 59 #ifdef CONFIG_KVM_BOOKE_HV 49 60 BEGIN_FTR_SECTION 50 61 mfspr r11, SPRN_SRR1 51 62 END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV) 52 63 #endif 53 64 DO_KVM \intnum, SPRN_SRR1 54 - std r16,PACA_EXTLB+EX_TLB_R16(r13) 65 + std r16,EX_TLB_R16(r12) 55 66 mfspr r16,\addr /* get faulting address */ 56 - std r14,PACA_EXTLB+EX_TLB_R14(r13) 67 + std r14,EX_TLB_R14(r12) 57 68 ld r14,PACAPGD(r13) 58 - std r15,PACA_EXTLB+EX_TLB_R15(r13) 59 - std r10,PACA_EXTLB+EX_TLB_CR(r13) 60 - TLB_MISS_PROLOG_STATS_BOLTED 69 + std r15,EX_TLB_R15(r12) 70 + std r10,EX_TLB_CR(r12) 71 + TLB_MISS_PROLOG_STATS 61 72 .endm 62 73 63 74 .macro tlb_epilog_bolted 64 - ld r14,PACA_EXTLB+EX_TLB_CR(r13) 65 - ld r10,PACA_EXTLB+EX_TLB_R10(r13) 66 - ld r11,PACA_EXTLB+EX_TLB_R11(r13) 75 + ld r14,EX_TLB_CR(r12) 76 + ld r10,EX_TLB_R10(r12) 77 + ld r11,EX_TLB_R11(r12) 78 + ld r13,EX_TLB_R13(r12) 67 79 mtcr r14 68 - ld r14,PACA_EXTLB+EX_TLB_R14(r13) 69 - ld r15,PACA_EXTLB+EX_TLB_R15(r13) 70 - TLB_MISS_RESTORE_STATS_BOLTED 71 - ld r16,PACA_EXTLB+EX_TLB_R16(r13) 72 - mfspr r13,SPRN_SPRG_GEN_SCRATCH 80 + ld r14,EX_TLB_R14(r12) 81 + ld r15,EX_TLB_R15(r12) 82 + TLB_MISS_RESTORE_STATS 83 + ld r16,EX_TLB_R16(r12) 84 + mfspr r12,SPRN_SPRG_GEN_SCRATCH 73 85 .endm 74 86 75 87 /* Data TLB miss */