xref: /openbmc/linux/arch/powerpc/mm/book3s32/kuap.c (revision 3c8c1539)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 #include <asm/kup.h>
4 #include <asm/smp.h>
5 
6 struct static_key_false disable_kuap_key;
7 EXPORT_SYMBOL(disable_kuap_key);
8 
9 void kuap_lock_all_ool(void)
10 {
11 	kuap_lock_all();
12 }
13 EXPORT_SYMBOL(kuap_lock_all_ool);
14 
15 void kuap_unlock_all_ool(void)
16 {
17 	kuap_unlock_all();
18 }
19 EXPORT_SYMBOL(kuap_unlock_all_ool);
20 
21 void setup_kuap(bool disabled)
22 {
23 	if (!disabled)
24 		kuap_lock_all_ool();
25 
26 	if (smp_processor_id() != boot_cpuid)
27 		return;
28 
29 	if (disabled)
30 		static_branch_enable(&disable_kuap_key);
31 	else
32 		pr_info("Activating Kernel Userspace Access Protection\n");
33 }
34