kernel-fxtec-pro1x/arch/x86/kernel/cpu
Andreas Herrmann 3ff42da504 x86: mtrr: don't modify RdDram/WrDram bits of fixed MTRRs
Impact: bug fix + BIOS workaround

BIOS is expected to clear the SYSCFG[MtrrFixDramModEn] on AMD CPUs
after fixed MTRRs are configured.

Some BIOSes do not clear SYSCFG[MtrrFixDramModEn] on BP (and on APs).

This can lead to obfuscation in Linux when this bit is not cleared on
BP but cleared on APs. A consequence of this is that the saved
fixed-MTRR state (from BP) differs from the fixed-MTRRs of APs --
because RdDram/WrDram bits are read as zero when
SYSCFG[MtrrFixDramModEn] is cleared -- and Linux tries to sync
fixed-MTRR state from BP to AP. This implies that Linux sets
SYSCFG[MtrrFixDramEn] and activates those bits.

More important is that (some) systems change these bits in SMM when
ACPI is enabled. Hence it is racy if Linux modifies RdMem/WrMem bits,
too.

(1) The patch modifies an old fix from Bernhard Kaindl to get
    suspend/resume working on some Acer Laptops. Bernhard's patch
    tried to sync RdMem/WrMem bits of fixed MTRR registers and that
    helped on those old Laptops. (Don't ask me why -- can't test it
    myself). But this old problem was not the motivation for the
    patch. (See http://lkml.org/lkml/2007/4/3/110)

(2) The more important effect is to fix issues on some more current systems.

    On those systems Linux panics or just freezes, see

    http://bugzilla.kernel.org/show_bug.cgi?id=11541
    (and also duplicates of this bug:
    http://bugzilla.kernel.org/show_bug.cgi?id=11737
    http://bugzilla.kernel.org/show_bug.cgi?id=11714)

    The affected systems boot only using acpi=ht, acpi=off or
    when the kernel is built with CONFIG_MTRR=n.

    The acpi options prevent full enablement of ACPI.  Obviously when
    ACPI is enabled the BIOS/SMM modfies RdMem/WrMem bits.  When
    CONFIG_MTRR=y Linux also accesses and modifies those bits when it
    needs to sync fixed-MTRRs across cores (Bernhard's fix, see (1)).
    How do you synchronize that? You can't. As a consequence Linux
    shouldn't touch those bits at all (Rationale are AMD's BKDGs which
    recommend to clear the bit that makes RdMem/WrMem accessible).
    This is the purpose of this patch. And (so far) this suffices to
    fix (1) and (2).

I suggest not to touch RdDram/WrDram bits of fixed-MTRRs and
SYSCFG[MtrrFixDramEn] and to clear SYSCFG[MtrrFixDramModEn] as
suggested by AMD K8, and AMD family 10h/11h BKDGs.
BIOS is expected to do this anyway. This should avoid that
Linux and SMM tread on each other's toes ...

Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
Cc: trenn@suse.de
Cc: Yinghai Lu <yinghai@kernel.org>
LKML-Reference: <20090312163937.GH20716@alberich.amd.com>
Cc: <stable@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-03-13 10:19:27 +01:00
..
cpufreq Merge branches 'x86/cleanups', 'x86/kexec', 'x86/mce2' and 'linus' into x86/core 2009-03-11 10:49:15 +01:00
mcheck x86, mce: use round_jiffies() instead round_jiffies_relative() 2009-03-10 22:33:06 -07:00
mtrr x86: mtrr: don't modify RdDram/WrDram bits of fixed MTRRs 2009-03-13 10:19:27 +01:00
.gitignore
addon_cpuid_features.c x86, apic: remove genapic.h 2009-02-17 17:52:44 +01:00
amd.c x86: remove smp_apply_quirks()/smp_checks() 2009-03-08 16:22:56 +01:00
bugs.c
bugs_64.c
centaur.c
centaur_64.c
cmpxchg.c
common.c x86: BUG to BUG_ON changes 2009-03-10 09:55:18 +01:00
cpu.h
cpu_debug.c x86: cpu architecture debug code, build fix, cleanup 2009-03-11 14:52:03 +01:00
cyrix.c
hypervisor.c
intel.c x86: remove smp_apply_quirks()/smp_checks() 2009-03-08 16:22:56 +01:00
intel_cacheinfo.c Merge commit 'v2.6.29-rc4' into core/percpu 2009-02-09 14:58:11 +01:00
Makefile x86: cpu architecture debug code 2009-03-10 18:39:45 +01:00
mkcapflags.pl
perfctr-watchdog.c x86: fold apic_ops into genapic 2009-02-17 12:22:20 +01:00
powerflags.c
proc.c x86: remove double copy of show_cpuinfo_core for 32 and 64 bit 2009-02-28 19:26:33 -08:00
transmeta.c
umc.c
vmware.c