diff options
author | Yinghai Lu <yinghai@kernel.org> | 2009-03-12 21:43:54 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-12 21:52:18 -0400 |
commit | 8ad9790588ee2e69118b2b294ddab6f3f0379ad9 (patch) | |
tree | 12f8d7a19474f520379f84e629f643744085473b /arch/x86/kernel/cpu/mtrr/generic.c | |
parent | a98fe7f3425c6b4e90de16f8da63b0429a8fed08 (diff) |
x86: more MTRR debug printouts
Impact: improve MTRR debugging messages
There's still inefficiencies suspected with the MTRR sanitizing
code, so make sure we get all the info we need from a dmesg.
- Remove unneeded mtrr_show
(It will only printout one time by first cpu, so it is no big deal.)
- Also print out directly from get_mtrr, because it doesn't update mtrr_state.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
LKML-Reference: <49B9BA5A.40108@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/cpu/mtrr/generic.c')
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/generic.c | 95 |
1 files changed, 51 insertions, 44 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c index 0c0a455fe95c..964403520100 100644 --- a/arch/x86/kernel/cpu/mtrr/generic.c +++ b/arch/x86/kernel/cpu/mtrr/generic.c | |||
@@ -33,14 +33,6 @@ u64 mtrr_tom2; | |||
33 | struct mtrr_state_type mtrr_state = {}; | 33 | struct mtrr_state_type mtrr_state = {}; |
34 | EXPORT_SYMBOL_GPL(mtrr_state); | 34 | EXPORT_SYMBOL_GPL(mtrr_state); |
35 | 35 | ||
36 | static int __initdata mtrr_show; | ||
37 | static int __init mtrr_debug(char *opt) | ||
38 | { | ||
39 | mtrr_show = 1; | ||
40 | return 0; | ||
41 | } | ||
42 | early_param("mtrr.show", mtrr_debug); | ||
43 | |||
44 | /* | 36 | /* |
45 | * Returns the effective MTRR type for the region | 37 | * Returns the effective MTRR type for the region |
46 | * Error returns: | 38 | * Error returns: |
@@ -193,13 +185,51 @@ static void print_fixed(unsigned base, unsigned step, const mtrr_type*types) | |||
193 | unsigned i; | 185 | unsigned i; |
194 | 186 | ||
195 | for (i = 0; i < 8; ++i, ++types, base += step) | 187 | for (i = 0; i < 8; ++i, ++types, base += step) |
196 | printk(KERN_INFO "MTRR %05X-%05X %s\n", | 188 | printk(KERN_INFO " %05X-%05X %s\n", |
197 | base, base + step - 1, mtrr_attrib_to_str(*types)); | 189 | base, base + step - 1, mtrr_attrib_to_str(*types)); |
198 | } | 190 | } |
199 | 191 | ||
200 | static void prepare_set(void); | 192 | static void prepare_set(void); |
201 | static void post_set(void); | 193 | static void post_set(void); |
202 | 194 | ||
195 | static void __init print_mtrr_state(void) | ||
196 | { | ||
197 | unsigned int i; | ||
198 | int high_width; | ||
199 | |||
200 | printk(KERN_INFO "MTRR default type: %s\n", mtrr_attrib_to_str(mtrr_state.def_type)); | ||
201 | if (mtrr_state.have_fixed) { | ||
202 | printk(KERN_INFO "MTRR fixed ranges %sabled:\n", | ||
203 | mtrr_state.enabled & 1 ? "en" : "dis"); | ||
204 | print_fixed(0x00000, 0x10000, mtrr_state.fixed_ranges + 0); | ||
205 | for (i = 0; i < 2; ++i) | ||
206 | print_fixed(0x80000 + i * 0x20000, 0x04000, mtrr_state.fixed_ranges + (i + 1) * 8); | ||
207 | for (i = 0; i < 8; ++i) | ||
208 | print_fixed(0xC0000 + i * 0x08000, 0x01000, mtrr_state.fixed_ranges + (i + 3) * 8); | ||
209 | } | ||
210 | printk(KERN_INFO "MTRR variable ranges %sabled:\n", | ||
211 | mtrr_state.enabled & 2 ? "en" : "dis"); | ||
212 | high_width = ((size_or_mask ? ffs(size_or_mask) - 1 : 32) - (32 - PAGE_SHIFT) + 3) / 4; | ||
213 | for (i = 0; i < num_var_ranges; ++i) { | ||
214 | if (mtrr_state.var_ranges[i].mask_lo & (1 << 11)) | ||
215 | printk(KERN_INFO " %u base %0*X%05X000 mask %0*X%05X000 %s\n", | ||
216 | i, | ||
217 | high_width, | ||
218 | mtrr_state.var_ranges[i].base_hi, | ||
219 | mtrr_state.var_ranges[i].base_lo >> 12, | ||
220 | high_width, | ||
221 | mtrr_state.var_ranges[i].mask_hi, | ||
222 | mtrr_state.var_ranges[i].mask_lo >> 12, | ||
223 | mtrr_attrib_to_str(mtrr_state.var_ranges[i].base_lo & 0xff)); | ||
224 | else | ||
225 | printk(KERN_INFO " %u disabled\n", i); | ||
226 | } | ||
227 | if (mtrr_tom2) { | ||
228 | printk(KERN_INFO "TOM2: %016llx aka %lldM\n", | ||
229 | mtrr_tom2, mtrr_tom2>>20); | ||
230 | } | ||
231 | } | ||
232 | |||
203 | /* Grab all of the MTRR state for this CPU into *state */ | 233 | /* Grab all of the MTRR state for this CPU into *state */ |
204 | void __init get_mtrr_state(void) | 234 | void __init get_mtrr_state(void) |
205 | { | 235 | { |
@@ -231,41 +261,9 @@ void __init get_mtrr_state(void) | |||
231 | mtrr_tom2 |= low; | 261 | mtrr_tom2 |= low; |
232 | mtrr_tom2 &= 0xffffff800000ULL; | 262 | mtrr_tom2 &= 0xffffff800000ULL; |
233 | } | 263 | } |
234 | if (mtrr_show) { | 264 | |
235 | int high_width; | 265 | print_mtrr_state(); |
236 | 266 | ||
237 | printk(KERN_INFO "MTRR default type: %s\n", mtrr_attrib_to_str(mtrr_state.def_type)); | ||
238 | if (mtrr_state.have_fixed) { | ||
239 | printk(KERN_INFO "MTRR fixed ranges %sabled:\n", | ||
240 | mtrr_state.enabled & 1 ? "en" : "dis"); | ||
241 | print_fixed(0x00000, 0x10000, mtrr_state.fixed_ranges + 0); | ||
242 | for (i = 0; i < 2; ++i) | ||
243 | print_fixed(0x80000 + i * 0x20000, 0x04000, mtrr_state.fixed_ranges + (i + 1) * 8); | ||
244 | for (i = 0; i < 8; ++i) | ||
245 | print_fixed(0xC0000 + i * 0x08000, 0x01000, mtrr_state.fixed_ranges + (i + 3) * 8); | ||
246 | } | ||
247 | printk(KERN_INFO "MTRR variable ranges %sabled:\n", | ||
248 | mtrr_state.enabled & 2 ? "en" : "dis"); | ||
249 | high_width = ((size_or_mask ? ffs(size_or_mask) - 1 : 32) - (32 - PAGE_SHIFT) + 3) / 4; | ||
250 | for (i = 0; i < num_var_ranges; ++i) { | ||
251 | if (mtrr_state.var_ranges[i].mask_lo & (1 << 11)) | ||
252 | printk(KERN_INFO "MTRR %u base %0*X%05X000 mask %0*X%05X000 %s\n", | ||
253 | i, | ||
254 | high_width, | ||
255 | mtrr_state.var_ranges[i].base_hi, | ||
256 | mtrr_state.var_ranges[i].base_lo >> 12, | ||
257 | high_width, | ||
258 | mtrr_state.var_ranges[i].mask_hi, | ||
259 | mtrr_state.var_ranges[i].mask_lo >> 12, | ||
260 | mtrr_attrib_to_str(mtrr_state.var_ranges[i].base_lo & 0xff)); | ||
261 | else | ||
262 | printk(KERN_INFO "MTRR %u disabled\n", i); | ||
263 | } | ||
264 | if (mtrr_tom2) { | ||
265 | printk(KERN_INFO "TOM2: %016llx aka %lldM\n", | ||
266 | mtrr_tom2, mtrr_tom2>>20); | ||
267 | } | ||
268 | } | ||
269 | mtrr_state_set = 1; | 267 | mtrr_state_set = 1; |
270 | 268 | ||
271 | /* PAT setup for BP. We need to go through sync steps here */ | 269 | /* PAT setup for BP. We need to go through sync steps here */ |
@@ -377,7 +375,12 @@ static void generic_get_mtrr(unsigned int reg, unsigned long *base, | |||
377 | unsigned int mask_lo, mask_hi, base_lo, base_hi; | 375 | unsigned int mask_lo, mask_hi, base_lo, base_hi; |
378 | unsigned int tmp, hi; | 376 | unsigned int tmp, hi; |
379 | 377 | ||
378 | /* | ||
379 | * get_mtrr doesn't need to update mtrr_state, also it could be called | ||
380 | * from any cpu, so try to print it out directly. | ||
381 | */ | ||
380 | rdmsr(MTRRphysMask_MSR(reg), mask_lo, mask_hi); | 382 | rdmsr(MTRRphysMask_MSR(reg), mask_lo, mask_hi); |
383 | |||
381 | if ((mask_lo & 0x800) == 0) { | 384 | if ((mask_lo & 0x800) == 0) { |
382 | /* Invalid (i.e. free) range */ | 385 | /* Invalid (i.e. free) range */ |
383 | *base = 0; | 386 | *base = 0; |
@@ -407,6 +410,10 @@ static void generic_get_mtrr(unsigned int reg, unsigned long *base, | |||
407 | *size = -mask_lo; | 410 | *size = -mask_lo; |
408 | *base = base_hi << (32 - PAGE_SHIFT) | base_lo >> PAGE_SHIFT; | 411 | *base = base_hi << (32 - PAGE_SHIFT) | base_lo >> PAGE_SHIFT; |
409 | *type = base_lo & 0xff; | 412 | *type = base_lo & 0xff; |
413 | |||
414 | printk(KERN_DEBUG " get_mtrr: cpu%d reg%02d base=%010lx size=%010lx %s\n", | ||
415 | smp_processor_id(), reg, *base, *size, | ||
416 | mtrr_attrib_to_str(*type & 0xff)); | ||
410 | } | 417 | } |
411 | 418 | ||
412 | /** | 419 | /** |