* [PATCH v4 0/2] Forcibly enable some MISC_ENABLE features on Intel
@ 2011-08-17 14:03 Andy Lutomirski
2011-08-17 14:03 ` [PATCH v4 1/2] x86: Enable fast strings on Intel if BIOS hasn't already Andy Lutomirski
2011-08-17 14:03 ` [PATCH v4 2/2] x86: Enable monitor/mwait " Andy Lutomirski
0 siblings, 2 replies; 4+ messages in thread
From: Andy Lutomirski @ 2011-08-17 14:03 UTC (permalink / raw)
To: x86, linux-kernel
Cc: Fenghua Yu, Matthew Garrett, Len Brown, linux-acpi, Ingo Molnar,
Andy Lutomirski
Intel allows BIOS or the OS to enable or disable some CPU fueatures via
IA32_MISC_ENABLE. I have machines that don't enable fast strings or
monitor/mwait in BIOS, so do it on bootup instead.
Changes from v3:
- Don't display CPU index (and therefore don't break !SMP build)
- Don't display "Failed to enable..." when kmemcheck is on
Changes from v2:
- Don't linebreak printk messages (for ease of grepping)
- Use printk_once
- Update the "Disabled fast string operations" message
Changes from v1:
- Display FW_WARN messages.
- Don't change the kmemcheck message.
- Improve the fast string comment.
- Improve the changelogs.
Andy Lutomirski (2):
x86: Enable fast strings on Intel if BIOS hasn't already
x86: Enable monitor/mwait on Intel if BIOS hasn't already
arch/x86/kernel/cpu/intel.c | 51 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 46 insertions(+), 5 deletions(-)
--
1.7.6
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v4 1/2] x86: Enable fast strings on Intel if BIOS hasn't already
2011-08-17 14:03 [PATCH v4 0/2] Forcibly enable some MISC_ENABLE features on Intel Andy Lutomirski
@ 2011-08-17 14:03 ` Andy Lutomirski
2011-08-17 21:38 ` Yu, Fenghua
2011-08-17 14:03 ` [PATCH v4 2/2] x86: Enable monitor/mwait " Andy Lutomirski
1 sibling, 1 reply; 4+ messages in thread
From: Andy Lutomirski @ 2011-08-17 14:03 UTC (permalink / raw)
To: x86, linux-kernel
Cc: Fenghua Yu, Matthew Garrett, Len Brown, linux-acpi, Ingo Molnar,
Andy Lutomirski
Intel SDM volume 3A, 8.4.2 says:
Software can disable fast-string operation by clearing the
fast-string-enable bit (bit 0) of IA32_MISC_ENABLE MSR.
However, Intel recomments that system software always enable
fast-string operation.
The Intel DQ67SW board (with latest BIOS) disables fast string
operations if TXT is enabled. A Lenovo X220 disables it regardless
of TXT setting. I doubt I'm the only person with a dumb BIOS like
this.
Signed-off-by: Andy Lutomirski <luto@mit.edu>
---
arch/x86/kernel/cpu/intel.c | 28 +++++++++++++++++++++++-----
1 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index ed6086e..1f7367d 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -30,6 +30,7 @@
static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
{
u64 misc_enable;
+ bool allow_fast_string = true;
/* Unmask CPUID levels if masked: */
if (c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xd)) {
@@ -118,10 +119,11 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
* (model 2) with the same problem.
*/
if (c->x86 == 15) {
- rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
+ allow_fast_string = false;
+ rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
if (misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING) {
- printk(KERN_INFO "kmemcheck: Disabling fast string operations\n");
+ printk_once(KERN_INFO "kmemcheck: Disabling fast string operations\n");
misc_enable &= ~MSR_IA32_MISC_ENABLE_FAST_STRING;
wrmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
@@ -130,13 +132,29 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
#endif
/*
- * If fast string is not enabled in IA32_MISC_ENABLE for any reason,
- * clear the fast string and enhanced fast string CPU capabilities.
+ * If BIOS didn't enable fast string operation, try to enable
+ * it ourselves. If that fails, then clear the fast string
+ * and enhanced fast string CPU capabilities.
*/
if (c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xd)) {
rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
+
+ if (allow_fast_string &&
+ !(misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING)) {
+ misc_enable |= MSR_IA32_MISC_ENABLE_FAST_STRING;
+ wrmsr_safe(MSR_IA32_MISC_ENABLE, (u32)misc_enable,
+ (u32)(misc_enable >> 32));
+
+ /* Re-read to make sure it stuck. */
+ rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
+
+ if (misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING)
+ printk_once(KERN_INFO FW_WARN "IA32_MISC_ENABLE.FAST_STRING_ENABLE was not set\n");
+ }
+
if (!(misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING)) {
- printk(KERN_INFO "Disabled fast string operations\n");
+ if (allow_fast_string)
+ printk_once(KERN_INFO "Failed to enable fast string operations\n");
setup_clear_cpu_cap(X86_FEATURE_REP_GOOD);
setup_clear_cpu_cap(X86_FEATURE_ERMS);
}
--
1.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v4 2/2] x86: Enable monitor/mwait on Intel if BIOS hasn't already
2011-08-17 14:03 [PATCH v4 0/2] Forcibly enable some MISC_ENABLE features on Intel Andy Lutomirski
2011-08-17 14:03 ` [PATCH v4 1/2] x86: Enable fast strings on Intel if BIOS hasn't already Andy Lutomirski
@ 2011-08-17 14:03 ` Andy Lutomirski
1 sibling, 0 replies; 4+ messages in thread
From: Andy Lutomirski @ 2011-08-17 14:03 UTC (permalink / raw)
To: x86, linux-kernel
Cc: Fenghua Yu, Matthew Garrett, Len Brown, linux-acpi, Ingo Molnar,
Andy Lutomirski
My Intel DQ67SW (latest BIOS) disables monitor/mwait on the boot CPU
if TXT is enabled. We're lucky that the system works at all, since
the feature is still enabled on other CPUs.
The obvious fix is to just re-enable it ourselves.
Signed-off-by: Andy Lutomirski <luto@mit.edu>
---
arch/x86/kernel/cpu/intel.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 1f7367d..c79e7b7 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -492,6 +492,29 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
wrmsrl(MSR_IA32_ENERGY_PERF_BIAS, epb);
}
}
+
+ /* Enable monitor/mwait if BIOS didn't do it for us. */
+ if (!cpu_has(c, X86_FEATURE_MWAIT) && cpu_has(c, X86_FEATURE_XMM3)
+ && c->x86 >= 6 && !(c->x86 == 6 && c->x86_model < 0x1c)
+ && !(c->x86 == 0xf && c->x86_model < 3)) {
+ u64 misc_enable;
+ rdmsrl(MSR_IA32_MISC_ENABLE, misc_enable);
+ misc_enable |= MSR_IA32_MISC_ENABLE_MWAIT;
+
+ /*
+ * Some non-SSE3 cpus will #GP. We check for that,
+ * but it can't hurt to be safe.
+ */
+ wrmsr_safe(MSR_IA32_MISC_ENABLE, (u32)misc_enable,
+ (u32)(misc_enable >> 32));
+
+ /* Re-read monitor capability. */
+ if (cpuid_ecx(1) & 0x8) {
+ set_cpu_cap(c, X86_FEATURE_MWAIT);
+
+ printk(KERN_WARNING FW_WARN "IA32_MISC_ENABLE.ENABLE_MONITOR_FSM was not set\n");
+ }
+ }
}
#ifdef CONFIG_X86_32
--
1.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH v4 1/2] x86: Enable fast strings on Intel if BIOS hasn't already
2011-08-17 14:03 ` [PATCH v4 1/2] x86: Enable fast strings on Intel if BIOS hasn't already Andy Lutomirski
@ 2011-08-17 21:38 ` Yu, Fenghua
0 siblings, 0 replies; 4+ messages in thread
From: Yu, Fenghua @ 2011-08-17 21:38 UTC (permalink / raw)
To: Andy Lutomirski, x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Matthew Garrett, Len Brown, linux-acpi@vger.kernel.org,
Ingo Molnar, H. Peter Anvin
> -----Original Message-----
> From: Andy Lutomirski [mailto:luto@MIT.EDU]
> Sent: Wednesday, August 17, 2011 7:03 AM
> To: x86@kernel.org; linux-kernel@vger.kernel.org
> Cc: Yu, Fenghua; Matthew Garrett; Len Brown; linux-
> acpi@vger.kernel.org; Ingo Molnar; Andy Lutomirski
> Subject: [PATCH v4 1/2] x86: Enable fast strings on Intel if BIOS
> hasn't already
>
> Intel SDM volume 3A, 8.4.2 says:
>
> Software can disable fast-string operation by clearing the
> fast-string-enable bit (bit 0) of IA32_MISC_ENABLE MSR.
> However, Intel recomments that system software always enable
> fast-string operation.
>
> The Intel DQ67SW board (with latest BIOS) disables fast string
> operations if TXT is enabled. A Lenovo X220 disables it regardless
> of TXT setting. I doubt I'm the only person with a dumb BIOS like
> this.
>
> Signed-off-by: Andy Lutomirski <luto@mit.edu>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-17 21:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-17 14:03 [PATCH v4 0/2] Forcibly enable some MISC_ENABLE features on Intel Andy Lutomirski
2011-08-17 14:03 ` [PATCH v4 1/2] x86: Enable fast strings on Intel if BIOS hasn't already Andy Lutomirski
2011-08-17 21:38 ` Yu, Fenghua
2011-08-17 14:03 ` [PATCH v4 2/2] x86: Enable monitor/mwait " Andy Lutomirski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox