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
..
2009-02-22 20:05:19 +01:00
2009-01-20 12:29:20 +09:00
2009-02-24 22:43:15 +01:00
2009-03-05 21:48:50 +01:00
2009-01-20 12:29:19 +09:00
2008-12-12 11:08:42 +01:00
2009-02-10 13:13:23 +01:00
2009-02-23 00:08:11 +01:00
2008-12-31 18:07:42 -05:00
2009-02-09 12:16:05 +01:00
2009-02-17 17:52:44 +01:00
2009-02-23 00:08:11 +01:00
2009-01-02 17:46:24 +01:00
2009-02-23 00:08:11 +01:00
2009-03-04 20:55:04 +01:00
2009-01-12 11:22:50 +01:00
2009-01-20 17:14:28 +01:00
2009-02-23 00:08:11 +01:00
2009-03-10 09:55:18 +01:00
2008-10-20 08:52:41 -07:00
2009-02-17 17:52:44 +01:00
2009-01-31 04:21:18 +01:00
2008-07-22 14:35:57 +02:00
2008-10-22 22:55:23 -07:00
2009-02-23 00:08:11 +01:00
2008-07-22 14:35:57 +02:00
2009-02-17 17:52:44 +01:00
2008-10-16 16:53:13 +02:00
2009-02-17 17:52:44 +01:00
2009-02-26 06:40:06 +01:00