|
@@ -37,14 +37,14 @@
|
|
#undef pr_fmt
|
|
#undef pr_fmt
|
|
#define pr_fmt(fmt) "" fmt
|
|
#define pr_fmt(fmt) "" fmt
|
|
|
|
|
|
-static bool boot_cpu_done;
|
|
|
|
-
|
|
|
|
-static int __read_mostly __pat_enabled = IS_ENABLED(CONFIG_X86_PAT);
|
|
|
|
-static void init_cache_modes(void);
|
|
|
|
|
|
+static bool __read_mostly boot_cpu_done;
|
|
|
|
+static bool __read_mostly pat_disabled = !IS_ENABLED(CONFIG_X86_PAT);
|
|
|
|
+static bool __read_mostly pat_initialized;
|
|
|
|
+static bool __read_mostly init_cm_done;
|
|
|
|
|
|
void pat_disable(const char *reason)
|
|
void pat_disable(const char *reason)
|
|
{
|
|
{
|
|
- if (!__pat_enabled)
|
|
|
|
|
|
+ if (pat_disabled)
|
|
return;
|
|
return;
|
|
|
|
|
|
if (boot_cpu_done) {
|
|
if (boot_cpu_done) {
|
|
@@ -52,10 +52,8 @@ void pat_disable(const char *reason)
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- __pat_enabled = 0;
|
|
|
|
|
|
+ pat_disabled = true;
|
|
pr_info("x86/PAT: %s\n", reason);
|
|
pr_info("x86/PAT: %s\n", reason);
|
|
-
|
|
|
|
- init_cache_modes();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
static int __init nopat(char *str)
|
|
static int __init nopat(char *str)
|
|
@@ -67,7 +65,7 @@ early_param("nopat", nopat);
|
|
|
|
|
|
bool pat_enabled(void)
|
|
bool pat_enabled(void)
|
|
{
|
|
{
|
|
- return !!__pat_enabled;
|
|
|
|
|
|
+ return pat_initialized;
|
|
}
|
|
}
|
|
EXPORT_SYMBOL_GPL(pat_enabled);
|
|
EXPORT_SYMBOL_GPL(pat_enabled);
|
|
|
|
|
|
@@ -205,6 +203,8 @@ static void __init_cache_modes(u64 pat)
|
|
update_cache_mode_entry(i, cache);
|
|
update_cache_mode_entry(i, cache);
|
|
}
|
|
}
|
|
pr_info("x86/PAT: Configuration [0-7]: %s\n", pat_msg);
|
|
pr_info("x86/PAT: Configuration [0-7]: %s\n", pat_msg);
|
|
|
|
+
|
|
|
|
+ init_cm_done = true;
|
|
}
|
|
}
|
|
|
|
|
|
#define PAT(x, y) ((u64)PAT_ ## y << ((x)*8))
|
|
#define PAT(x, y) ((u64)PAT_ ## y << ((x)*8))
|
|
@@ -225,6 +225,7 @@ static void pat_bsp_init(u64 pat)
|
|
}
|
|
}
|
|
|
|
|
|
wrmsrl(MSR_IA32_CR_PAT, pat);
|
|
wrmsrl(MSR_IA32_CR_PAT, pat);
|
|
|
|
+ pat_initialized = true;
|
|
|
|
|
|
__init_cache_modes(pat);
|
|
__init_cache_modes(pat);
|
|
}
|
|
}
|
|
@@ -242,10 +243,9 @@ static void pat_ap_init(u64 pat)
|
|
wrmsrl(MSR_IA32_CR_PAT, pat);
|
|
wrmsrl(MSR_IA32_CR_PAT, pat);
|
|
}
|
|
}
|
|
|
|
|
|
-static void init_cache_modes(void)
|
|
|
|
|
|
+void init_cache_modes(void)
|
|
{
|
|
{
|
|
u64 pat = 0;
|
|
u64 pat = 0;
|
|
- static int init_cm_done;
|
|
|
|
|
|
|
|
if (init_cm_done)
|
|
if (init_cm_done)
|
|
return;
|
|
return;
|
|
@@ -287,8 +287,6 @@ static void init_cache_modes(void)
|
|
}
|
|
}
|
|
|
|
|
|
__init_cache_modes(pat);
|
|
__init_cache_modes(pat);
|
|
-
|
|
|
|
- init_cm_done = 1;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -306,10 +304,8 @@ void pat_init(void)
|
|
u64 pat;
|
|
u64 pat;
|
|
struct cpuinfo_x86 *c = &boot_cpu_data;
|
|
struct cpuinfo_x86 *c = &boot_cpu_data;
|
|
|
|
|
|
- if (!pat_enabled()) {
|
|
|
|
- init_cache_modes();
|
|
|
|
|
|
+ if (pat_disabled)
|
|
return;
|
|
return;
|
|
- }
|
|
|
|
|
|
|
|
if ((c->x86_vendor == X86_VENDOR_INTEL) &&
|
|
if ((c->x86_vendor == X86_VENDOR_INTEL) &&
|
|
(((c->x86 == 0x6) && (c->x86_model <= 0xd)) ||
|
|
(((c->x86 == 0x6) && (c->x86_model <= 0xd)) ||
|