powerpc/4xx: Fix setup_kuep() on SMP

On SMP, setup_kuep() is also called from start_secondary() since
commit 86f46f3432 ("powerpc/32s: Initialise KUAP and KUEP in C").

start_secondary() is not an __init function.

Remove the __init marker from setup_kuep() and bail out when
not caller on the first CPU as the work is already done.

Fixes: 10248dcba1 ("powerpc/44x: Implement Kernel Userspace Exec Protection (KUEP)")
Fixes: 86f46f3432 ("powerpc/32s: Initialise KUAP and KUEP in C")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/8ee05934288994a65743a987acb1558f12c0c8c1.1624969450.git.christophe.leroy@csgroup.eu
This commit is contained in:
Christophe Leroy 2021-06-29 12:24:21 +00:00 committed by Michael Ellerman
parent c89e632658
commit fc4999864b
1 changed files with 5 additions and 1 deletions

View File

@ -25,6 +25,7 @@
#include <asm/page.h>
#include <asm/cacheflush.h>
#include <asm/code-patching.h>
#include <asm/smp.h>
#include <mm/mmu_decl.h>
@ -241,8 +242,11 @@ void __init mmu_init_secondary(int cpu)
#endif /* CONFIG_SMP */
#ifdef CONFIG_PPC_KUEP
void __init setup_kuep(bool disabled)
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