Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 326246
b: refs/heads/master
c: b2cc2a0
h: refs/heads/master
v: v3
  • Loading branch information
H. Peter Anvin committed Sep 27, 2012
1 parent f6e47ad commit 97ef006
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 32 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: 73201dbec64aebf6b0dca855b523f437972dc7bb
refs/heads/master: b2cc2a074de75671bbed5e2dda67a9252ef353ea
49 changes: 18 additions & 31 deletions trunk/arch/x86/kernel/cpu/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,48 +259,36 @@ static inline void squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
}
#endif

static int disable_smep __cpuinitdata;
static __init int setup_disable_smep(char *arg)
{
disable_smep = 1;
setup_clear_cpu_cap(X86_FEATURE_SMEP);
return 1;
}
__setup("nosmep", setup_disable_smep);

static __cpuinit void setup_smep(struct cpuinfo_x86 *c)
static __always_inline void setup_smep(struct cpuinfo_x86 *c)
{
if (cpu_has(c, X86_FEATURE_SMEP)) {
if (unlikely(disable_smep)) {
setup_clear_cpu_cap(X86_FEATURE_SMEP);
clear_in_cr4(X86_CR4_SMEP);
} else
set_in_cr4(X86_CR4_SMEP);
}
if (cpu_has(c, X86_FEATURE_SMEP))
set_in_cr4(X86_CR4_SMEP);
}

static int disable_smap __cpuinitdata;
static __init int setup_disable_smap(char *arg)
{
disable_smap = 1;
setup_clear_cpu_cap(X86_FEATURE_SMAP);
return 1;
}
__setup("nosmap", setup_disable_smap);

static __cpuinit void setup_smap(struct cpuinfo_x86 *c)
static __always_inline void setup_smap(struct cpuinfo_x86 *c)
{
if (cpu_has(c, X86_FEATURE_SMAP)) {
if (unlikely(disable_smap)) {
setup_clear_cpu_cap(X86_FEATURE_SMAP);
clear_in_cr4(X86_CR4_SMAP);
} else {
set_in_cr4(X86_CR4_SMAP);
/*
* Don't use clac() here since alternatives
* haven't run yet...
*/
asm volatile(__stringify(__ASM_CLAC) ::: "memory");
}
}
unsigned long eflags;

/* This should have been cleared long ago */
raw_local_save_flags(eflags);
BUG_ON(eflags & X86_EFLAGS_AC);

if (cpu_has(c, X86_FEATURE_SMAP))
set_in_cr4(X86_CR4_SMAP);
}

/*
Expand Down Expand Up @@ -737,9 +725,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
c->cpu_index = 0;
filter_cpuid_features(c, false);

setup_smep(c);
setup_smap(c);

if (this_cpu->c_bsp_init)
this_cpu->c_bsp_init(c);
}
Expand Down Expand Up @@ -824,8 +809,6 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
c->phys_proc_id = c->initial_apicid;
}

setup_smep(c);

get_model_name(c); /* Default name */

detect_nopl(c);
Expand Down Expand Up @@ -890,6 +873,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
/* Disable the PN if appropriate */
squash_the_stupid_serial_number(c);

/* Set up SMEP/SMAP */
setup_smep(c);
setup_smap(c);

/*
* The vendor-specific functions might have changed features.
* Now we do "generic changes."
Expand Down

0 comments on commit 97ef006

Please sign in to comment.