1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/spinlock.h>
3 #include <linux/errno.h>
4 #include <linux/init.h>
6 #include <asm/pgtable.h>
8 #include <asm/cpufeature.h>
10 static int disable_nx
;
15 * Control non-executable mappings for processes.
20 static int __init
noexec_setup(char *str
)
24 if (!strncmp(str
, "on", 2)) {
26 } else if (!strncmp(str
, "off", 3)) {
32 early_param("noexec", noexec_setup
);
34 void x86_configure_nx(void)
36 if (boot_cpu_has(X86_FEATURE_NX
) && !disable_nx
)
37 __supported_pte_mask
|= _PAGE_NX
;
39 __supported_pte_mask
&= ~_PAGE_NX
;
42 void __init
x86_report_nx(void)
44 if (!boot_cpu_has(X86_FEATURE_NX
)) {
45 printk(KERN_NOTICE
"Notice: NX (Execute Disable) protection "
48 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
50 printk(KERN_INFO
"NX (Execute Disable) protection: "
51 "disabled by kernel command line option\n");
53 printk(KERN_INFO
"NX (Execute Disable) protection: "
57 /* 32bit non-PAE kernel, NX cannot be used */
58 printk(KERN_NOTICE
"Notice: NX (Execute Disable) protection "
59 "cannot be enabled: non-PAE kernel!\n");