xref: /linux/arch/powerpc/mm/book3s32/kuap.c (revision c89e632658e793fbbdcbfbe80a6c13bbf7203e9b)
191ec6671SChristophe Leroy // SPDX-License-Identifier: GPL-2.0-or-later
291ec6671SChristophe Leroy 
391ec6671SChristophe Leroy #include <asm/kup.h>
486f46f34SChristophe Leroy #include <asm/smp.h>
591ec6671SChristophe Leroy 
66b4d6300SChristophe Leroy struct static_key_false disable_kuap_key;
76b4d6300SChristophe Leroy EXPORT_SYMBOL(disable_kuap_key);
86b4d6300SChristophe Leroy 
916132529SChristophe Leroy void kuap_lock_all_ool(void)
1016132529SChristophe Leroy {
1116132529SChristophe Leroy 	kuap_lock_all();
1216132529SChristophe Leroy }
1316132529SChristophe Leroy EXPORT_SYMBOL(kuap_lock_all_ool);
1416132529SChristophe Leroy 
1516132529SChristophe Leroy void kuap_unlock_all_ool(void)
1616132529SChristophe Leroy {
1716132529SChristophe Leroy 	kuap_unlock_all();
1816132529SChristophe Leroy }
1916132529SChristophe Leroy EXPORT_SYMBOL(kuap_unlock_all_ool);
2016132529SChristophe Leroy 
21*c89e6326SChristophe Leroy void setup_kuap(bool disabled)
2291ec6671SChristophe Leroy {
236b4d6300SChristophe Leroy 	if (!disabled)
2416132529SChristophe Leroy 		kuap_lock_all_ool();
2586f46f34SChristophe Leroy 
2686f46f34SChristophe Leroy 	if (smp_processor_id() != boot_cpuid)
2786f46f34SChristophe Leroy 		return;
2886f46f34SChristophe Leroy 
2991ec6671SChristophe Leroy 	if (disabled)
306b4d6300SChristophe Leroy 		static_branch_enable(&disable_kuap_key);
316b4d6300SChristophe Leroy 	else
326b4d6300SChristophe Leroy 		pr_info("Activating Kernel Userspace Access Protection\n");
3391ec6671SChristophe Leroy }
34