powerpc/kuap: Wire-up KUAP on 85xx in 32 bits mode.
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 19 Oct 2021 07:29:31 +0000 (09:29 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 9 Dec 2021 11:41:20 +0000 (22:41 +1100)
This adds KUAP support to 85xx in 32 bits mode.
This is done by reading the content of SPRN_MAS1 and checking
the TID at the time user pgtable is loaded.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/f8696f8980ca1532ada3a2f0e0a03e756269c7fe.1634627931.git.christophe.leroy@csgroup.eu
arch/powerpc/kernel/head_fsl_booke.S
arch/powerpc/platforms/Kconfig.cputype

index 4622b50a5208d14c6eb6cd3970cc799b77a072bd..ac2b4dcf5fd385ce9556ee78f9de86b94ba50ddb 100644 (file)
@@ -462,6 +462,12 @@ END_BTB_FLUSH_SECTION
        mfspr   r11,SPRN_SPRG_THREAD
        lwz     r11,PGDIR(r11)
 
+#ifdef CONFIG_PPC_KUAP
+       mfspr   r12, SPRN_MAS1
+       rlwinm. r12,r12,0,0x3fff0000
+       beq     2f                      /* KUAP fault */
+#endif
+
 4:
        /* Mask of required permission bits. Note that while we
         * do copy ESR:ST to _PAGE_RW position as trying to write
@@ -571,6 +577,12 @@ END_BTB_FLUSH_SECTION
        mfspr   r11,SPRN_SPRG_THREAD
        lwz     r11,PGDIR(r11)
 
+#ifdef CONFIG_PPC_KUAP
+       mfspr   r12, SPRN_MAS1
+       rlwinm. r12,r12,0,0x3fff0000
+       beq     2f                      /* KUAP fault */
+#endif
+
        /* Make up the required permissions for user code */
 #ifdef CONFIG_PTE_64BIT
        li      r13,_PAGE_PRESENT | _PAGE_BAP_UX
index 95e034e061c2f0e194071645fcf44ab542c607ef..3ad2f3fc67a4f256e971a707f65cc4381615db56 100644 (file)
@@ -37,6 +37,7 @@ config PPC_BOOK3S_32
 config PPC_85xx
        bool "Freescale 85xx"
        select E500
+       select PPC_HAVE_KUAP
 
 config PPC_8xx
        bool "Freescale 8xx"