lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Sat, 19 Jan 2008 05:32:19 +0100 (CET) From: Andi Kleen <ak@...e.de> To: mingo@...e.hu, tglx@...utronix.de, jesse.barnes@...el.com, andreas.herrmann3@....com, linux-kernel@...r.kernel.org Subject: [PATCH] [2/2] Fix MTRR check on AMD systems with > 4GB RAM Newer AMD systems (since K8RevF) have a magic SYSCFG MSR bit to force WB on memory beyond 4GB. This is not reflected in the standard MTRR MSRs, so the MTRR checking routine would get confused and disable perfectly good RAM beyond 4GB. Implement code for checking that bit. Signed-off-by: Andi Kleen <ak@...e.de> --- arch/x86/kernel/cpu/mtrr/main.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) Index: linux/arch/x86/kernel/cpu/mtrr/main.c =================================================================== --- linux.orig/arch/x86/kernel/cpu/mtrr/main.c +++ linux/arch/x86/kernel/cpu/mtrr/main.c @@ -634,6 +634,37 @@ static int __init disable_mtrr_trim_setu early_param("disable_mtrr_trim", disable_mtrr_trim_setup); #ifdef CONFIG_X86_64 + +/* + * Newer AMD K8s and later CPUs have a special magic MSR way to force WB + * for memory >4GB. Check for that here. + * Note this won't check if the MTRRs < 4GB where the magic bit doesn't + * apply to are wrong, but so far we don't know of any such case in the wild. + */ + +#define Tom2ForceMemTypeWB (1U << 22) +static __init int amd_special_default_mtrr(void) +{ + u32 l, h; + + /* Doesn't apply to memory < 4GB */ + if (end_pfn <= (0xffffffff >> PAGE_SHIFT)) + return 0; + if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) + return 0; + if (boot_cpu_data.x86 < 0xf || boot_cpu_data.x86 > 0x11) + return 0; + /* In case some hypervisor doesn't pass SYSCFG through */ + if (rdmsr_safe(MSR_K8_SYSCFG, &l, &h) < 0) + return 0; + /* Memory between 4GB and top of mem is forced WB by this magic bit. + * Reserved before K8RevF, but should be zero there. + */ + if (l & Tom2ForceMemTypeWB) + return 1; + return 0; +} + /** * mtrr_trim_uncached_memory - trim RAM not covered by MTRRs * @@ -667,6 +698,9 @@ void __init mtrr_trim_uncached_memory(vo highest_addr = base + size; } + if (amd_special_default_mtrr()) + return; + if ((highest_addr >> PAGE_SHIFT) < end_pfn) { printk(KERN_WARNING "***************\n"); printk(KERN_WARNING "**** WARNING: likely BIOS bug\n"); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists