xref: /linux/arch/powerpc/mm/book3s32/kuap.c (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 #include <asm/kup.h>
4 #include <asm/smp.h>
5 
6 void setup_kuap(bool disabled)
7 {
8 	if (!disabled) {
9 		update_user_segments(mfsr(0) | SR_KS);
10 		isync();        /* Context sync required after mtsr() */
11 		init_mm.context.sr0 |= SR_KS;
12 		current->thread.sr0 |= SR_KS;
13 	}
14 
15 	if (smp_processor_id() != boot_cpuid)
16 		return;
17 
18 	if (disabled)
19 		cur_cpu_spec->mmu_features &= ~MMU_FTR_KUAP;
20 	else
21 		pr_info("Activating Kernel Userspace Access Protection\n");
22 }
23