1 #include <linux/spinlock.h>
2 #include <linux/errno.h>
3 #include <linux/init.h>
5 #include <asm/pgtable.h>
9 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
10 static int disable_nx __cpuinitdata
;
15 * Control non-executable mappings for processes.
20 static int __init
noexec_setup(char *str
)
24 if (!strncmp(str
, "on", 2)) {
25 __supported_pte_mask
|= _PAGE_NX
;
27 } else if (!strncmp(str
, "off", 3)) {
29 __supported_pte_mask
&= ~_PAGE_NX
;
33 early_param("noexec", noexec_setup
);
37 void __init
set_nx(void)
39 unsigned int v
[4], l
, h
;
41 if (cpu_has_pae
&& (cpuid_eax(0x80000000) > 0x80000001)) {
42 cpuid(0x80000001, &v
[0], &v
[1], &v
[2], &v
[3]);
44 if ((v
[3] & (1 << 20)) && !disable_nx
) {
45 rdmsr(MSR_EFER
, l
, h
);
47 wrmsr(MSR_EFER
, l
, h
);
49 __supported_pte_mask
|= _PAGE_NX
;
60 void __cpuinit
check_efer(void)
64 rdmsrl(MSR_EFER
, efer
);
65 if (!(efer
& EFER_NX
) || disable_nx
)
66 __supported_pte_mask
&= ~_PAGE_NX
;