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 616132529SChristophe Leroy void kuap_lock_all_ool(void) 716132529SChristophe Leroy { 816132529SChristophe Leroy kuap_lock_all(); 916132529SChristophe Leroy } 1016132529SChristophe Leroy EXPORT_SYMBOL(kuap_lock_all_ool); 1116132529SChristophe Leroy 1216132529SChristophe Leroy void kuap_unlock_all_ool(void) 1316132529SChristophe Leroy { 1416132529SChristophe Leroy kuap_unlock_all(); 1516132529SChristophe Leroy } 1616132529SChristophe Leroy EXPORT_SYMBOL(kuap_unlock_all_ool); 1716132529SChristophe Leroy 18c89e6326SChristophe Leroy void setup_kuap(bool disabled) 1991ec6671SChristophe Leroy { 2070428da9SChristophe Leroy if (!disabled) { 2116132529SChristophe Leroy kuap_lock_all_ool(); 2270428da9SChristophe Leroy init_mm.context.sr0 |= SR_KS; 2370428da9SChristophe Leroy current->thread.sr0 |= SR_KS; 2470428da9SChristophe Leroy } 2586f46f34SChristophe Leroy 2686f46f34SChristophe Leroy if (smp_processor_id() != boot_cpuid) 2786f46f34SChristophe Leroy return; 2886f46f34SChristophe Leroy 2991ec6671SChristophe Leroy if (disabled) 30*26e04120SChristophe Leroy cur_cpu_spec->mmu_features &= ~MMU_FTR_KUAP; 316b4d6300SChristophe Leroy else 326b4d6300SChristophe Leroy pr_info("Activating Kernel Userspace Access Protection\n"); 3391ec6671SChristophe Leroy } 34