xref: /openbmc/linux/arch/powerpc/mm/nohash/kup.c (revision 3ddc8b84)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * This file contains the routines for initializing kernel userspace protection
4  */
5 
6 #include <linux/export.h>
7 #include <linux/init.h>
8 #include <linux/printk.h>
9 #include <linux/smp.h>
10 
11 #include <asm/kup.h>
12 #include <asm/smp.h>
13 
14 #ifdef CONFIG_PPC_KUAP
15 void setup_kuap(bool disabled)
16 {
17 	if (disabled) {
18 		if (IS_ENABLED(CONFIG_40x))
19 			disable_kuep = true;
20 		if (smp_processor_id() == boot_cpuid)
21 			cur_cpu_spec->mmu_features &= ~MMU_FTR_KUAP;
22 		return;
23 	}
24 
25 	pr_info("Activating Kernel Userspace Access Protection\n");
26 
27 	prevent_user_access(KUAP_READ_WRITE);
28 }
29 #endif
30