powerpc/603: Inconditionally use task PGDIR in ITLB misses
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 20 Aug 2024 17:23:57 +0000 (19:23 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 30 Aug 2024 11:29:54 +0000 (21:29 +1000)
Now that modules exec page tables are preallocated, the instruction
TLBmiss handler can use task PGDIR inconditionally.

Also revise the identification of user vs kernel user space by doing
a calculation instead of a comparison: Get the segment number and
subtract the number of the first kernel segment. The result is
positive for kernel addresses and negative for user addresses,
which means that upper 2 bits are 0 for kernel and 3 for user.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/9a3242162ad2faab8019c698e501b326a126ee9e.1724173828.git.christophe.leroy@csgroup.eu
arch/powerpc/kernel/head_book3s_32.S

index 7995506e7fbd7b752b6407352d0a212e79187e56..156304c00ecead739256fe3ca3b94ae88af11633 100644 (file)
@@ -413,22 +413,15 @@ END_FTR_SECTION_IFSET(CPU_FTR_FPU_UNAVAILABLE)
 InstructionTLBMiss:
        /* Get PTE (linux-style) and check access */
        mfspr   r0,SPRN_IMISS
-#ifdef CONFIG_EXECMEM
-       lis     r1, TASK_SIZE@h         /* check if kernel address */
-       cmplw   0,r1,r0
-#endif
        mfspr   r2, SPRN_SDR1
        li      r1,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC
        rlwinm  r2, r2, 28, 0xfffff000
+       rlwimi  r2,r0,12,20,29          /* insert top 10 bits of address */
+       lwz     r2,0(r2)                /* get pmd entry */
 #ifdef CONFIG_EXECMEM
-       li      r3, 3
-       bgt-    112f
-       lis     r2, (swapper_pg_dir - PAGE_OFFSET)@ha   /* if kernel address, use */
-       li      r3, 0
-       addi    r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l        /* kernel page table */
+       rlwinm  r3, r0, 4, 0xf
+       subi    r3, r3, (TASK_SIZE >> 28) & 0xf
 #endif
-112:   rlwimi  r2,r0,12,20,29          /* insert top 10 bits of address */
-       lwz     r2,0(r2)                /* get pmd entry */
        rlwinm. r2,r2,0,0,19            /* extract address of pte page */
        beq-    InstructionAddressInvalid       /* return if no mapping */
        rlwimi  r2,r0,22,20,29          /* insert next 10 bits of address */
@@ -437,7 +430,7 @@ InstructionTLBMiss:
        bne-    InstructionAddressInvalid /* return if access not permitted */
        /* Convert linux-style PTE to low word of PPC-style PTE */
 #ifdef CONFIG_EXECMEM
-       rlwimi  r2, r3, 0, 31, 31       /* userspace ? -> PP lsb */
+       rlwimi  r2, r3, 1, 31, 31       /* userspace ? -> PP lsb */
 #endif
        ori     r1, r1, 0xe06           /* clear out reserved bits */
        andc    r1, r2, r1              /* PP = user? 1 : 0 */