Commit 7c1dee73 authored by Borislav Petkov (AMD)'s avatar Borislav Petkov (AMD)

x86/mtrr: Unify debugging printing

Put all the debugging output behind "mtrr=debug" and get rid of
"mtrr_cleanup_debug" which wasn't even documented anywhere.

No functional changes.
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/20230531174857.GDZHeIib57h5lT5Vh1@fat_crate.local
parent 08611a3a
...@@ -55,9 +55,6 @@ static int __initdata nr_range; ...@@ -55,9 +55,6 @@ static int __initdata nr_range;
static struct var_mtrr_range_state __initdata range_state[RANGE_NUM]; static struct var_mtrr_range_state __initdata range_state[RANGE_NUM];
static int __initdata debug_print;
#define Dprintk(x...) do { if (debug_print) pr_debug(x); } while (0)
#define BIOS_BUG_MSG \ #define BIOS_BUG_MSG \
"WARNING: BIOS bug: VAR MTRR %d contains strange UC entry under 1M, check with your system vendor!\n" "WARNING: BIOS bug: VAR MTRR %d contains strange UC entry under 1M, check with your system vendor!\n"
...@@ -79,12 +76,11 @@ x86_get_mtrr_mem_range(struct range *range, int nr_range, ...@@ -79,12 +76,11 @@ x86_get_mtrr_mem_range(struct range *range, int nr_range,
nr_range = add_range_with_merge(range, RANGE_NUM, nr_range, nr_range = add_range_with_merge(range, RANGE_NUM, nr_range,
base, base + size); base, base + size);
} }
if (debug_print) {
pr_debug("After WB checking\n"); Dprintk("After WB checking\n");
for (i = 0; i < nr_range; i++) for (i = 0; i < nr_range; i++)
pr_debug("MTRR MAP PFN: %016llx - %016llx\n", Dprintk("MTRR MAP PFN: %016llx - %016llx\n",
range[i].start, range[i].end); range[i].start, range[i].end);
}
/* Take out UC ranges: */ /* Take out UC ranges: */
for (i = 0; i < num_var_ranges; i++) { for (i = 0; i < num_var_ranges; i++) {
...@@ -112,24 +108,22 @@ x86_get_mtrr_mem_range(struct range *range, int nr_range, ...@@ -112,24 +108,22 @@ x86_get_mtrr_mem_range(struct range *range, int nr_range,
subtract_range(range, RANGE_NUM, extra_remove_base, subtract_range(range, RANGE_NUM, extra_remove_base,
extra_remove_base + extra_remove_size); extra_remove_base + extra_remove_size);
if (debug_print) { Dprintk("After UC checking\n");
pr_debug("After UC checking\n"); for (i = 0; i < RANGE_NUM; i++) {
for (i = 0; i < RANGE_NUM; i++) { if (!range[i].end)
if (!range[i].end) continue;
continue;
pr_debug("MTRR MAP PFN: %016llx - %016llx\n", Dprintk("MTRR MAP PFN: %016llx - %016llx\n",
range[i].start, range[i].end); range[i].start, range[i].end);
}
} }
/* sort the ranges */ /* sort the ranges */
nr_range = clean_sort_range(range, RANGE_NUM); nr_range = clean_sort_range(range, RANGE_NUM);
if (debug_print) {
pr_debug("After sorting\n"); Dprintk("After sorting\n");
for (i = 0; i < nr_range; i++) for (i = 0; i < nr_range; i++)
pr_debug("MTRR MAP PFN: %016llx - %016llx\n", Dprintk("MTRR MAP PFN: %016llx - %016llx\n",
range[i].start, range[i].end); range[i].start, range[i].end);
}
return nr_range; return nr_range;
} }
...@@ -164,13 +158,6 @@ static int __init enable_mtrr_cleanup_setup(char *str) ...@@ -164,13 +158,6 @@ static int __init enable_mtrr_cleanup_setup(char *str)
} }
early_param("enable_mtrr_cleanup", enable_mtrr_cleanup_setup); early_param("enable_mtrr_cleanup", enable_mtrr_cleanup_setup);
static int __init mtrr_cleanup_debug_setup(char *str)
{
debug_print = 1;
return 0;
}
early_param("mtrr_cleanup_debug", mtrr_cleanup_debug_setup);
static void __init static void __init
set_var_mtrr(unsigned int reg, unsigned long basek, unsigned long sizek, set_var_mtrr(unsigned int reg, unsigned long basek, unsigned long sizek,
unsigned char type) unsigned char type)
...@@ -267,7 +254,7 @@ range_to_mtrr(unsigned int reg, unsigned long range_startk, ...@@ -267,7 +254,7 @@ range_to_mtrr(unsigned int reg, unsigned long range_startk,
align = max_align; align = max_align;
sizek = 1UL << align; sizek = 1UL << align;
if (debug_print) { if (mtrr_debug) {
char start_factor = 'K', size_factor = 'K'; char start_factor = 'K', size_factor = 'K';
unsigned long start_base, size_base; unsigned long start_base, size_base;
...@@ -542,7 +529,7 @@ static void __init print_out_mtrr_range_state(void) ...@@ -542,7 +529,7 @@ static void __init print_out_mtrr_range_state(void)
start_base = to_size_factor(start_base, &start_factor); start_base = to_size_factor(start_base, &start_factor);
type = range_state[i].type; type = range_state[i].type;
pr_debug("reg %d, base: %ld%cB, range: %ld%cB, type %s\n", Dprintk("reg %d, base: %ld%cB, range: %ld%cB, type %s\n",
i, start_base, start_factor, i, start_base, start_factor,
size_base, size_factor, size_base, size_factor,
(type == MTRR_TYPE_UNCACHABLE) ? "UC" : (type == MTRR_TYPE_UNCACHABLE) ? "UC" :
...@@ -714,7 +701,7 @@ int __init mtrr_cleanup(void) ...@@ -714,7 +701,7 @@ int __init mtrr_cleanup(void)
return 0; return 0;
/* Print original var MTRRs at first, for debugging: */ /* Print original var MTRRs at first, for debugging: */
pr_debug("original variable MTRRs\n"); Dprintk("original variable MTRRs\n");
print_out_mtrr_range_state(); print_out_mtrr_range_state();
memset(range, 0, sizeof(range)); memset(range, 0, sizeof(range));
...@@ -746,7 +733,7 @@ int __init mtrr_cleanup(void) ...@@ -746,7 +733,7 @@ int __init mtrr_cleanup(void)
if (!result[i].bad) { if (!result[i].bad) {
set_var_mtrr_all(); set_var_mtrr_all();
pr_debug("New variable MTRRs\n"); Dprintk("New variable MTRRs\n");
print_out_mtrr_range_state(); print_out_mtrr_range_state();
return 1; return 1;
} }
...@@ -766,7 +753,7 @@ int __init mtrr_cleanup(void) ...@@ -766,7 +753,7 @@ int __init mtrr_cleanup(void)
mtrr_calc_range_state(chunk_size, gran_size, mtrr_calc_range_state(chunk_size, gran_size,
x_remove_base, x_remove_size, i); x_remove_base, x_remove_size, i);
if (debug_print) { if (mtrr_debug) {
mtrr_print_out_one_result(i); mtrr_print_out_one_result(i);
pr_info("\n"); pr_info("\n");
} }
...@@ -790,7 +777,7 @@ int __init mtrr_cleanup(void) ...@@ -790,7 +777,7 @@ int __init mtrr_cleanup(void)
gran_size <<= 10; gran_size <<= 10;
x86_setup_var_mtrrs(range, nr_range, chunk_size, gran_size); x86_setup_var_mtrrs(range, nr_range, chunk_size, gran_size);
set_var_mtrr_all(); set_var_mtrr_all();
pr_debug("New variable MTRRs\n"); Dprintk("New variable MTRRs\n");
print_out_mtrr_range_state(); print_out_mtrr_range_state();
return 1; return 1;
} else { } else {
......
...@@ -41,7 +41,7 @@ struct cache_map { ...@@ -41,7 +41,7 @@ struct cache_map {
u64 fixed:1; u64 fixed:1;
}; };
static bool mtrr_debug; bool mtrr_debug;
static int __init mtrr_param_setup(char *str) static int __init mtrr_param_setup(char *str)
{ {
......
...@@ -332,7 +332,7 @@ static int mtrr_check(unsigned long base, unsigned long size) ...@@ -332,7 +332,7 @@ static int mtrr_check(unsigned long base, unsigned long size)
{ {
if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) {
pr_warn("size and base must be multiples of 4 kiB\n"); pr_warn("size and base must be multiples of 4 kiB\n");
pr_debug("size: 0x%lx base: 0x%lx\n", size, base); Dprintk("size: 0x%lx base: 0x%lx\n", size, base);
dump_stack(); dump_stack();
return -1; return -1;
} }
...@@ -423,8 +423,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size) ...@@ -423,8 +423,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
} }
} }
if (reg < 0) { if (reg < 0) {
pr_debug("no MTRR for %lx000,%lx000 found\n", Dprintk("no MTRR for %lx000,%lx000 found\n", base, size);
base, size);
goto out; goto out;
} }
} }
......
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
#define MTRR_CHANGE_MASK_VARIABLE 0x02 #define MTRR_CHANGE_MASK_VARIABLE 0x02
#define MTRR_CHANGE_MASK_DEFTYPE 0x04 #define MTRR_CHANGE_MASK_DEFTYPE 0x04
extern bool mtrr_debug;
#define Dprintk(x...) do { if (mtrr_debug) pr_info(x); } while (0)
extern unsigned int mtrr_usage_table[MTRR_MAX_VAR_RANGES]; extern unsigned int mtrr_usage_table[MTRR_MAX_VAR_RANGES];
struct mtrr_ops { struct mtrr_ops {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment