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