Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 173049
b: refs/heads/master
c: 4763ed4
h: refs/heads/master
i:
  173047: 7be4fa9
v: v3
  • Loading branch information
H. Peter Anvin committed Nov 16, 2009
1 parent c80a92d commit 7f55236
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 51 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 583140afb989f24d115e80be5c91e503b58ccfc0
refs/heads/master: 4763ed4d45522b876c97e1f7f4b659d211f75571
2 changes: 1 addition & 1 deletion trunk/arch/x86/include/asm/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern void ia32_sysenter_target(void);

extern void syscall32_cpu_init(void);

extern void check_efer(void);
extern void x86_configure_nx(void);

extern int reboot_force;

Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/kernel/cpu/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ void __cpuinit cpu_init(void)
wrmsrl(MSR_KERNEL_GS_BASE, 0);
barrier();

check_efer();
x86_configure_nx();
if (cpu != 0)
enable_x2apic();

Expand Down
8 changes: 2 additions & 6 deletions trunk/arch/x86/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,21 +787,17 @@ void __init setup_arch(char **cmdline_p)
strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
*cmdline_p = command_line;

#ifdef CONFIG_X86_64
/*
* Must call this twice: Once just to detect whether hardware doesn't
* support NX (so that the early EHCI debug console setup can safely
* call set_fixmap(), and then again after parsing early parameters to
* honor the respective command line option.
*/
check_efer();
#endif
x86_configure_nx();

parse_early_param();

#ifdef CONFIG_X86_64
check_efer();
#endif
x86_configure_nx();

/* Must be before kernel pagetables are setup */
vmi_activate();
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/x86/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
use_gbpages = direct_gbpages;
#endif

set_nx();
if (nx_enabled)
/* XXX: replace this with Kees' improved messages */
if (__supported_pte_mask & _PAGE_NX)
printk(KERN_INFO "NX (Execute Disable) protection: active\n");

/* Enable PSE if available */
Expand Down
43 changes: 6 additions & 37 deletions trunk/arch/x86/mm/setup_nx.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
#include <linux/init.h>

#include <asm/pgtable.h>
#include <asm/proto.h>

int nx_enabled;

#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
static int disable_nx __cpuinitdata;

/*
Expand All @@ -22,48 +20,19 @@ static int __init noexec_setup(char *str)
if (!str)
return -EINVAL;
if (!strncmp(str, "on", 2)) {
__supported_pte_mask |= _PAGE_NX;
disable_nx = 0;
} else if (!strncmp(str, "off", 3)) {
disable_nx = 1;
__supported_pte_mask &= ~_PAGE_NX;
}
x86_configure_nx();
return 0;
}
early_param("noexec", noexec_setup);
#endif

#ifdef CONFIG_X86_PAE
void __init set_nx(void)
{
unsigned int v[4], l, h;

if (cpu_has_pae && (cpuid_eax(0x80000000) > 0x80000001)) {
cpuid(0x80000001, &v[0], &v[1], &v[2], &v[3]);

if ((v[3] & (1 << 20)) && !disable_nx) {
rdmsr(MSR_EFER, l, h);
l |= EFER_NX;
wrmsr(MSR_EFER, l, h);
nx_enabled = 1;
__supported_pte_mask |= _PAGE_NX;
}
}
}
#else
void set_nx(void)
{
}
#endif

#ifdef CONFIG_X86_64
void __cpuinit check_efer(void)
void __cpuinit x86_configure_nx(void)
{
unsigned long efer;

rdmsrl(MSR_EFER, efer);
if (!(efer & EFER_NX) || disable_nx)
if (cpu_has_nx && !disable_nx)
__supported_pte_mask |= _PAGE_NX;
else
__supported_pte_mask &= ~_PAGE_NX;
}
#endif

4 changes: 1 addition & 3 deletions trunk/arch/x86/xen/enlighten.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,10 +1082,8 @@ asmlinkage void __init xen_start_kernel(void)

__supported_pte_mask |= _PAGE_IOMAP;

#ifdef CONFIG_X86_64
/* Work out if we support NX */
check_efer();
#endif
x86_configure_nx();

xen_setup_features();

Expand Down

0 comments on commit 7f55236

Please sign in to comment.