aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Huang <wei.huang2@amd.com>2011-04-07 15:44:19 +0100
committerWei Huang <wei.huang2@amd.com>2011-04-07 15:44:19 +0100
commit5cd35299674dece1d5b99c745b2ddd54a9b7895d (patch)
tree1f804b897dd7a32b4acba93520761bc5e7ba1a2e
parent64ddf302cfb53c679eb1dbe23a5028b1a7725d43 (diff)
downloadxen-5cd35299674dece1d5b99c745b2ddd54a9b7895d.tar.gz
xen-5cd35299674dece1d5b99c745b2ddd54a9b7895d.tar.bz2
xen-5cd35299674dece1d5b99c745b2ddd54a9b7895d.zip
x86, amd, MTRR: correct DramModEn bit of SYS_CFG MSR
Some buggy BIOS might set SYS_CFG DramModEn bit to 1, which can cause unexpected behavior on AMD platforms. This patch clears DramModEn bit if it is 1. Signed-off-by: Wei Huang <wei.huang2@amd.com> xen-unstable changeset: 23153:8fb61c9ebe49 xen-unstable date: Wed Apr 06 09:01:31 2011 +0100
-rw-r--r--xen/arch/x86/cpu/amd.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index d236b30d92..d0c0b1602f 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -347,6 +347,32 @@ static void check_disable_c1e(unsigned int port, u8 value)
on_each_cpu(disable_c1e, NULL, 1);
}
+/*
+ * BIOS is expected to clear MtrrFixDramModEn bit. According to AMD BKDG :
+ * "The MtrrFixDramModEn bit should be set to 1 during BIOS initalization of
+ * the fixed MTRRs, then cleared to 0 for operation."
+ */
+static void check_syscfg_dram_mod_en(void)
+{
+ uint64_t syscfg;
+ static bool_t printed = 0;
+
+ if (!((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&
+ (boot_cpu_data.x86 >= 0x0f)))
+ return;
+
+ rdmsrl(MSR_K8_SYSCFG, syscfg);
+ if (!(syscfg & K8_MTRRFIXRANGE_DRAM_MODIFY))
+ return;
+
+ if (!test_and_set_bool(printed))
+ printk(KERN_ERR "MTRR: SYSCFG[MtrrFixDramModEn] not "
+ "cleared by BIOS, clearing this bit\n");
+
+ syscfg &= ~K8_MTRRFIXRANGE_DRAM_MODIFY;
+ wrmsrl(MSR_K8_SYSCFG, syscfg);
+}
+
static void __devinit init_amd(struct cpuinfo_x86 *c)
{
u32 l, h;
@@ -624,6 +650,8 @@ static void __devinit init_amd(struct cpuinfo_x86 *c)
set_cpuidmask(c);
+ check_syscfg_dram_mod_en();
+
start_svm(c);
}