blob: c20733d6e02cb6013b847f2a7ba315b480984582 [file] [log] [blame]
Christophe Leroyb5efec02021-03-12 12:50:47 +00001// SPDX-License-Identifier: GPL-2.0-or-later
2
3#include <asm/kup.h>
Christophe Leroy86f46f32021-06-03 08:41:41 +00004#include <asm/smp.h>
Christophe Leroy91ec6672021-06-03 08:41:36 +00005
Christophe Leroy50d2f102021-06-03 08:41:42 +00006struct static_key_false disable_kuep_key;
7
Christophe Leroyc89e6322021-06-28 06:56:11 +00008void setup_kuep(bool disabled)
Christophe Leroy91ec6672021-06-03 08:41:36 +00009{
Christophe Leroy50d2f102021-06-03 08:41:42 +000010 if (!disabled)
11 kuep_lock();
Christophe Leroy86f46f32021-06-03 08:41:41 +000012
13 if (smp_processor_id() != boot_cpuid)
14 return;
15
Christophe Leroy91ec6672021-06-03 08:41:36 +000016 if (disabled)
Christophe Leroy50d2f102021-06-03 08:41:42 +000017 static_branch_enable(&disable_kuep_key);
18 else
19 pr_info("Activating Kernel Userspace Execution Prevention\n");
Christophe Leroy91ec6672021-06-03 08:41:36 +000020}