Check AMD SYSCFG DramModEn bit for MTRR configuration
PATCH 1/1 Check AMD SYSCFG DramModEn bit for MTRR configuration
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.
PS: If OK, please apply it to both xen-4.1 and xen-4.0 trees.
xen/arch/x86/cpu/mtrr/generic.c +27 -1
@@ -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);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
This patch has some problem on SMP system. I am creating another one. Sorry...
-Wei
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Wei Huang
Sent: Tuesday, March 01, 2011 3:12 PM
To: '[email protected]'
Subject: [Xen-devel] [PATCH] Check AMD SYSCFG DramModEn bit for MTRR configuration
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.
PS: If OK, please apply it to both xen-4.1 and xen-4.0 trees.
Quoted 4 lines · Wei Huang
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.
How common are these buggy BIOSes? Can't we just get users to update their BIOS?
-- Keir
Quoted 9 lines
Signed-off-by Wei Huang <[email protected]>PS: If OK, please apply it to both xen-4.1 and xen-4.0 trees.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Buggy BIOSes are more common than you think. especially from small shops, and some times they don't tend to release BIOS updates for their platforms.
Quoted 27 lines · Keir Fraser
Quoted 4 lines · Wei Huang
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.
How common are these buggy BIOSes? Can't we just get users to update their BIOS?
-- Keir
Quoted 9 lines
Signed-off-by Wei Huang<[email protected]>PS: If OK, please apply it to both xen-4.1 and xen-4.0 trees.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
It is indeed very rare. But such bug, whenever it happens, is very hard to spot. Linux kernel forces this bit to clear when read fixed MTRR. I think we should at least print out a warning message.
-Wei
Quoted 36 lines · Anish Patel
Buggy BIOSes are more common than you think. especially from small shops, and some times they don't tend to release BIOS updates for their platforms.
Quoted 27 lines · Keir Fraser
Quoted 4 lines · Wei Huang
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.
How common are these buggy BIOSes? Can't we just get users to update their BIOS?
-- Keir
Quoted 9 lines
Signed-off-by Wei Huang<[email protected]>PS: If OK, please apply it to both xen-4.1 and xen-4.0 trees.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel