Mention branches and keyring.
[releases.git] / powerpc / mm / book3s32 / kuap.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2
3 #include <asm/kup.h>
4 #include <asm/smp.h>
5
6 struct static_key_false disable_kuap_key;
7 EXPORT_SYMBOL(disable_kuap_key);
8
9 void kuap_lock_all_ool(void)
10 {
11         kuap_lock_all();
12 }
13 EXPORT_SYMBOL(kuap_lock_all_ool);
14
15 void kuap_unlock_all_ool(void)
16 {
17         kuap_unlock_all();
18 }
19 EXPORT_SYMBOL(kuap_unlock_all_ool);
20
21 void 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 }