]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
powerpc/44x: Activate KUEP at all time
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 19 Oct 2021 07:29:14 +0000 (09:29 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 9 Dec 2021 11:41:17 +0000 (22:41 +1100)
On 44x, KUEP is implemented by clearing SX bit during TLB miss
for user pages. The impact is minimal and not worth neither
boot time nor build time selection.

Activate it at all time.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/2414d662558e7fb27d1ed41c8e47c591d576acac.1634627931.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/nohash/32/mmu-44x.h
arch/powerpc/kernel/head_44x.S
arch/powerpc/mm/nohash/44x.c
arch/powerpc/platforms/Kconfig.cputype

index 43ceca128531f965d2850b61bd1b8032be66d4f4..2d92a39d8f2e808ffd8ace7afc0dcc14e8743d6b 100644 (file)
@@ -113,7 +113,6 @@ typedef struct {
 
 /* patch sites */
 extern s32 patch__tlb_44x_hwater_D, patch__tlb_44x_hwater_I;
-extern s32 patch__tlb_44x_kuep, patch__tlb_47x_kuep;
 
 #endif /* !__ASSEMBLY__ */
 
index 02d2928d1e01064fa463db64fb7d66883609e8f7..916f7e91c6dee763e735819d50196d9fe6599f98 100644 (file)
@@ -532,10 +532,7 @@ finish_tlb_load_44x:
        andi.   r10,r12,_PAGE_USER              /* User page ? */
        beq     1f                              /* nope, leave U bits empty */
        rlwimi  r11,r11,3,26,28                 /* yes, copy S bits to U */
-#ifdef CONFIG_PPC_KUEP
-0:     rlwinm  r11,r11,0,~PPC44x_TLB_SX        /* Clear SX if User page */
-       patch_site 0b, patch__tlb_44x_kuep
-#endif
+       rlwinm  r11,r11,0,~PPC44x_TLB_SX        /* Clear SX if User page */
 1:     tlbwe   r11,r13,PPC44x_TLB_ATTRIB       /* Write ATTRIB */
 
        /* Done...restore registers and get out of here.
@@ -747,10 +744,7 @@ finish_tlb_load_47x:
        andi.   r10,r12,_PAGE_USER              /* User page ? */
        beq     1f                              /* nope, leave U bits empty */
        rlwimi  r11,r11,3,26,28                 /* yes, copy S bits to U */
-#ifdef CONFIG_PPC_KUEP
-0:     rlwinm  r11,r11,0,~PPC47x_TLB2_SX       /* Clear SX if User page */
-       patch_site 0b, patch__tlb_47x_kuep
-#endif
+       rlwinm  r11,r11,0,~PPC47x_TLB2_SX       /* Clear SX if User page */
 1:     tlbwe   r11,r13,2
 
        /* Done...restore registers and get out of here.
index e079f26b267ec19be8eb176e06fc97e38bb8e359..ceb290df1fb562c6d93409b962c5e7a21a94a2ed 100644 (file)
@@ -247,12 +247,6 @@ void setup_kuep(bool disabled)
        if (smp_processor_id() != boot_cpuid)
                return;
 
-       if (disabled)
-               patch_instruction_site(&patch__tlb_44x_kuep, ppc_inst(PPC_RAW_NOP()));
-       else
-               pr_info("Activating Kernel Userspace Execution Prevention\n");
-
-       if (IS_ENABLED(CONFIG_PPC_47x) && disabled)
-               patch_instruction_site(&patch__tlb_47x_kuep, ppc_inst(PPC_RAW_NOP()));
+       pr_info("Activating Kernel Userspace Execution Prevention\n");
 }
 #endif
index 8b36608c7888d0f72ebf266c61689ba6226c3bb0..4f8774d65aa8c8828ea55bd0c679452058891edb 100644 (file)
@@ -63,6 +63,7 @@ config 44x
        select HAVE_PCI
        select PHYS_64BIT
        select PPC_HAVE_KUEP
+       select PPC_KUEP
 
 endchoice