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 6*6b4d6300SChristophe Leroy struct static_key_false disable_kuap_key; 7*6b4d6300SChristophe Leroy EXPORT_SYMBOL(disable_kuap_key); 8*6b4d6300SChristophe Leroy 991ec6671SChristophe Leroy void __init setup_kuap(bool disabled) 1091ec6671SChristophe Leroy { 11*6b4d6300SChristophe Leroy if (!disabled) 1286f46f34SChristophe Leroy kuap_update_sr(mfsr(0) | SR_KS, 0, TASK_SIZE); 1386f46f34SChristophe Leroy 1486f46f34SChristophe Leroy if (smp_processor_id() != boot_cpuid) 1586f46f34SChristophe Leroy return; 1686f46f34SChristophe Leroy 1791ec6671SChristophe Leroy if (disabled) 18*6b4d6300SChristophe Leroy static_branch_enable(&disable_kuap_key); 19*6b4d6300SChristophe Leroy else 20*6b4d6300SChristophe Leroy pr_info("Activating Kernel Userspace Access Protection\n"); 2191ec6671SChristophe Leroy } 22