Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 
0003 #include <asm/kup.h>
0004 #include <asm/smp.h>
0005 
0006 struct static_key_false disable_kuap_key;
0007 EXPORT_SYMBOL(disable_kuap_key);
0008 
0009 void kuap_lock_all_ool(void)
0010 {
0011     kuap_lock_all();
0012 }
0013 EXPORT_SYMBOL(kuap_lock_all_ool);
0014 
0015 void kuap_unlock_all_ool(void)
0016 {
0017     kuap_unlock_all();
0018 }
0019 EXPORT_SYMBOL(kuap_unlock_all_ool);
0020 
0021 void setup_kuap(bool disabled)
0022 {
0023     if (!disabled) {
0024         kuap_lock_all_ool();
0025         init_mm.context.sr0 |= SR_KS;
0026         current->thread.sr0 |= SR_KS;
0027     }
0028 
0029     if (smp_processor_id() != boot_cpuid)
0030         return;
0031 
0032     if (disabled)
0033         static_branch_enable(&disable_kuap_key);
0034     else
0035         pr_info("Activating Kernel Userspace Access Protection\n");
0036 }