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 setup_kuap(bool disabled)6c89e6326SChristophe Leroyvoid setup_kuap(bool disabled) 791ec6671SChristophe Leroy { 870428da9SChristophe Leroy if (!disabled) { 9*5222a1d5SChristophe Leroy update_user_segments(mfsr(0) | SR_KS); 10*5222a1d5SChristophe Leroy isync(); /* Context sync required after mtsr() */ 1170428da9SChristophe Leroy init_mm.context.sr0 |= SR_KS; 1270428da9SChristophe Leroy current->thread.sr0 |= SR_KS; 1370428da9SChristophe Leroy } 1486f46f34SChristophe Leroy 1586f46f34SChristophe Leroy if (smp_processor_id() != boot_cpuid) 1686f46f34SChristophe Leroy return; 1786f46f34SChristophe Leroy 1891ec6671SChristophe Leroy if (disabled) 1926e04120SChristophe Leroy cur_cpu_spec->mmu_features &= ~MMU_FTR_KUAP; 206b4d6300SChristophe Leroy else 216b4d6300SChristophe Leroy pr_info("Activating Kernel Userspace Access Protection\n"); 2291ec6671SChristophe Leroy } 23