Commit ee263160 authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman

powerpc/44x: Activate KUEP at all time

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: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/2414d662558e7fb27d1ed41c8e47c591d576acac.1634627931.git.christophe.leroy@csgroup.eu
parent 13dac4e3
...@@ -113,7 +113,6 @@ typedef struct { ...@@ -113,7 +113,6 @@ typedef struct {
/* patch sites */ /* patch sites */
extern s32 patch__tlb_44x_hwater_D, patch__tlb_44x_hwater_I; extern s32 patch__tlb_44x_hwater_D, patch__tlb_44x_hwater_I;
extern s32 patch__tlb_44x_kuep, patch__tlb_47x_kuep;
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */
......
...@@ -532,10 +532,7 @@ finish_tlb_load_44x: ...@@ -532,10 +532,7 @@ finish_tlb_load_44x:
andi. r10,r12,_PAGE_USER /* User page ? */ andi. r10,r12,_PAGE_USER /* User page ? */
beq 1f /* nope, leave U bits empty */ beq 1f /* nope, leave U bits empty */
rlwimi r11,r11,3,26,28 /* yes, copy S bits to U */ rlwimi r11,r11,3,26,28 /* yes, copy S bits to U */
#ifdef CONFIG_PPC_KUEP rlwinm r11,r11,0,~PPC44x_TLB_SX /* Clear SX if User page */
0: rlwinm r11,r11,0,~PPC44x_TLB_SX /* Clear SX if User page */
patch_site 0b, patch__tlb_44x_kuep
#endif
1: tlbwe r11,r13,PPC44x_TLB_ATTRIB /* Write ATTRIB */ 1: tlbwe r11,r13,PPC44x_TLB_ATTRIB /* Write ATTRIB */
/* Done...restore registers and get out of here. /* Done...restore registers and get out of here.
...@@ -747,10 +744,7 @@ finish_tlb_load_47x: ...@@ -747,10 +744,7 @@ finish_tlb_load_47x:
andi. r10,r12,_PAGE_USER /* User page ? */ andi. r10,r12,_PAGE_USER /* User page ? */
beq 1f /* nope, leave U bits empty */ beq 1f /* nope, leave U bits empty */
rlwimi r11,r11,3,26,28 /* yes, copy S bits to U */ rlwimi r11,r11,3,26,28 /* yes, copy S bits to U */
#ifdef CONFIG_PPC_KUEP rlwinm r11,r11,0,~PPC47x_TLB2_SX /* Clear SX if User page */
0: rlwinm r11,r11,0,~PPC47x_TLB2_SX /* Clear SX if User page */
patch_site 0b, patch__tlb_47x_kuep
#endif
1: tlbwe r11,r13,2 1: tlbwe r11,r13,2
/* Done...restore registers and get out of here. /* Done...restore registers and get out of here.
......
...@@ -247,12 +247,6 @@ void setup_kuep(bool disabled) ...@@ -247,12 +247,6 @@ void setup_kuep(bool disabled)
if (smp_processor_id() != boot_cpuid) if (smp_processor_id() != boot_cpuid)
return; return;
if (disabled) pr_info("Activating Kernel Userspace Execution Prevention\n");
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()));
} }
#endif #endif
...@@ -63,6 +63,7 @@ config 44x ...@@ -63,6 +63,7 @@ config 44x
select HAVE_PCI select HAVE_PCI
select PHYS_64BIT select PHYS_64BIT
select PPC_HAVE_KUEP select PPC_HAVE_KUEP
select PPC_KUEP
endchoice endchoice
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment