diff options
author | Jesse Barnes <jesse.barnes@intel.com> | 2008-01-30 07:33:18 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:33:18 -0500 |
commit | 99fc8d424bc5d803fe92cad56c068fe64e73747a (patch) | |
tree | 983f615ed69b98c614f38b7240c343c9d7f9418d /include | |
parent | 03252919b79891063cf99145612360efbdf9500b (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 'include')
-rw-r--r-- | include/asm-x86/mtrr.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/include/asm-x86/mtrr.h b/include/asm-x86/mtrr.h index 262670e42078..319d065800be 100644 --- a/include/asm-x86/mtrr.h +++ b/include/asm-x86/mtrr.h | |||
@@ -97,6 +97,7 @@ extern int mtrr_del_page (int reg, unsigned long base, unsigned long size); | |||
97 | extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi); | 97 | extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi); |
98 | extern void mtrr_ap_init(void); | 98 | extern void mtrr_ap_init(void); |
99 | extern void mtrr_bp_init(void); | 99 | extern void mtrr_bp_init(void); |
100 | extern int mtrr_trim_uncached_memory(unsigned long end_pfn); | ||
100 | # else | 101 | # else |
101 | #define mtrr_save_fixed_ranges(arg) do {} while (0) | 102 | #define mtrr_save_fixed_ranges(arg) do {} while (0) |
102 | #define mtrr_save_state() do {} while (0) | 103 | #define mtrr_save_state() do {} while (0) |
@@ -120,7 +121,10 @@ static __inline__ int mtrr_del_page (int reg, unsigned long base, | |||
120 | { | 121 | { |
121 | return -ENODEV; | 122 | return -ENODEV; |
122 | } | 123 | } |
123 | 124 | static inline int mtrr_trim_uncached_memory(unsigned long end_pfn) | |
125 | { | ||
126 | return 0; | ||
127 | } | ||
124 | static __inline__ void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi) {;} | 128 | static __inline__ void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi) {;} |
125 | 129 | ||
126 | #define mtrr_ap_init() do {} while (0) | 130 | #define mtrr_ap_init() do {} while (0) |