aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/cpu/mtrr/generic.c
diff options
context:
space:
mode:
authorJesse Barnes <jesse.barnes@intel.com>2008-01-30 07:33:18 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:33:18 -0500
commit99fc8d424bc5d803fe92cad56c068fe64e73747a (patch)
tree983f615ed69b98c614f38b7240c343c9d7f9418d /arch/x86/kernel/cpu/mtrr/generic.c
parent03252919b79891063cf99145612360efbdf9500b (diff)
x86, 32-bit: trim memory not covered by wb mtrrs
On some machines, buggy BIOSes don't properly setup WB MTRRs to cover all available RAM, meaning the last few megs (or even gigs) of memory will be marked uncached. Since Linux tends to allocate from high memory addresses first, this causes the machine to be unusably slow as soon as the kernel starts really using memory (i.e. right around init time). This patch works around the problem by scanning the MTRRs at boot and figuring out whether the current end_pfn value (setup by early e820 code) goes beyond the highest WB MTRR range, and if so, trimming it to match. A fairly obnoxious KERN_WARNING is printed too, letting the user know that not all of their memory is available due to a likely BIOS bug. Something similar could be done on i386 if needed, but the boot ordering would be slightly different, since the MTRR code on i386 depends on the boot_cpu_data structure being setup. This patch fixes a bug in the last patch that caused the code to run on non-Intel machines (AMD machines apparently don't need it and it's untested on other non-Intel machines, so best keep it off). Further enhancements and fixes from: Yinghai Lu <Yinghai.Lu@Sun.COM> Andi Kleen <ak@suse.de> Signed-off-by: Jesse Barnes <jesse.barnes@intel.com> Tested-by: Justin Piszcz <jpiszcz@lucidpixels.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Yinghai Lu <yhlu.kernel@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/cpu/mtrr/generic.c')
-rw-r--r--arch/x86/kernel/cpu/mtrr/generic.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c
index 55d31ff118fb..103d61a59b19 100644
--- a/arch/x86/kernel/cpu/mtrr/generic.c
+++ b/arch/x86/kernel/cpu/mtrr/generic.c
@@ -14,7 +14,7 @@
14#include "mtrr.h" 14#include "mtrr.h"
15 15
16struct mtrr_state { 16struct mtrr_state {
17 struct mtrr_var_range *var_ranges; 17 struct mtrr_var_range var_ranges[MAX_VAR_RANGES];
18 mtrr_type fixed_ranges[NUM_FIXED_RANGES]; 18 mtrr_type fixed_ranges[NUM_FIXED_RANGES];
19 unsigned char enabled; 19 unsigned char enabled;
20 unsigned char have_fixed; 20 unsigned char have_fixed;
@@ -86,12 +86,6 @@ void __init get_mtrr_state(void)
86 struct mtrr_var_range *vrs; 86 struct mtrr_var_range *vrs;
87 unsigned lo, dummy; 87 unsigned lo, dummy;
88 88
89 if (!mtrr_state.var_ranges) {
90 mtrr_state.var_ranges = kmalloc(num_var_ranges * sizeof (struct mtrr_var_range),
91 GFP_KERNEL);
92 if (!mtrr_state.var_ranges)
93 return;
94 }
95 vrs = mtrr_state.var_ranges; 89 vrs = mtrr_state.var_ranges;
96 90
97 rdmsr(MTRRcap_MSR, lo, dummy); 91 rdmsr(MTRRcap_MSR, lo, dummy);