All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Huang <wei.huang2@amd.com>
To: "'xen-devel@lists.xensource.com'" <xen-devel@lists.xensource.com>
Subject: [PATCH] Check AMD SYSCFG DramModEn bit for MTRR configuration
Date: Tue, 1 Mar 2011 15:11:48 -0600	[thread overview]
Message-ID: <4D6D6114.4020708@amd.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 355 bytes --]

This patch checks whether SYSCFG DramModEn bit is clear by BIOS. Some 
buggy BIOS might set this bit to 1, which causes unexpected behavior on 
AMD platforms. This patch also increase family check for AMD CPUs when 
setting fixed MTRR ranges.

Signed-off-by: Wei Huang <wei.huang2@amd.com>


PS: If OK, please apply it to both xen-4.1 and xen-4.0 trees.


[-- Attachment #2: check_amd_syscfg_moden_bit.txt --]
[-- Type: text/plain, Size: 1472 bytes --]

diff -r cb4d42aaf673 xen/arch/x86/cpu/mtrr/generic.c
--- a/xen/arch/x86/cpu/mtrr/generic.c	Tue Mar 01 14:03:16 2011 -0600
+++ b/xen/arch/x86/cpu/mtrr/generic.c	Tue Mar 01 15:31:36 2011 -0600
@@ -34,12 +34,38 @@
 	rdmsrl(MTRRphysMask_MSR(index), vr->mask);
 }
 
+
+/*
+ * 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 inline void amd_check_syscfg_dram_mod_en(void)
+{
+	uint64_t syscfg;
+
+	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) {
+		printk(KERN_ERR "MTRR: CPU %u: SYSCFG[MtrrFixDramModEn]"
+			   " not cleared by BIOS, clearing this bit\n",
+			   smp_processor_id());
+		syscfg &= ~K8_MTRRFIXRANGE_DRAM_MODIFY;
+		wrmsr_safe(MSR_K8_SYSCFG, syscfg);
+	}
+}
+
 static void
 get_fixed_ranges(mtrr_type * frs)
 {
 	uint64_t *p = (uint64_t *) frs;
 	int i;
 
+        amd_check_syscfg_dram_mod_en();
+
 	rdmsrl(MTRRfix64K_00000_MSR, p[0]);
 
 	for (i = 0; i < 2; i++)
@@ -146,7 +172,7 @@
 
 	if (msr_content != val) {
 		if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
-		    boot_cpu_data.x86 == 15 &&
+		    boot_cpu_data.x86 >= 0xf &&
 		    ((msrwords[0] | msrwords[1]) & K8_MTRR_RDMEM_WRMEM_MASK))
 			k8_enable_fixed_iorrs();
 		mtrr_wrmsr(msr, val);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2011-03-01 21:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-01 21:11 Wei Huang [this message]
2011-03-02  0:52 ` [PATCH] Check AMD SYSCFG DramModEn bit for MTRR configuration Huang2, Wei
2011-03-02  7:01 ` Keir Fraser
2011-03-02 15:20   ` Anish Patel
2011-03-02 17:25     ` Wei Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D6D6114.4020708@amd.com \
    --to=wei.huang2@amd.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.