From: Juergen Gross <jgross@suse.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-doc@vger.kernel.org
Cc: mikelley@microsoft.com, Juergen Gross <jgross@suse.com>,
Jonathan Corbet <corbet@lwn.net>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: [PATCH v6 12/16] x86/mtrr: add mtrr=debug command line option
Date: Tue, 2 May 2023 14:09:27 +0200 [thread overview]
Message-ID: <20230502120931.20719-13-jgross@suse.com> (raw)
In-Reply-To: <20230502120931.20719-1-jgross@suse.com>
Add a new command line option "mtrr=debug" for getting debug output
after building the new cache mode map. The output will include MTRR
register values and the resulting map.
For printing the MTRR register values print_mtrr_state() can be used.
Just change it to use pr_info() instead of pr_debug() and call it only
if mtrr=debug was specified.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
V6:
- new patch (Boris Petkov)
---
.../admin-guide/kernel-parameters.txt | 4 ++
arch/x86/kernel/cpu/mtrr/generic.c | 64 +++++++++++++------
2 files changed, 49 insertions(+), 19 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 9e5bab29685f..44a87ada7145 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3423,6 +3423,10 @@
[HW] Make the MicroTouch USB driver use raw coordinates
('y', default) or cooked coordinates ('n')
+ mtrr=debug [X86]
+ Enable printing debug information related to MTRR
+ registers at boot time.
+
mtrr_chunk_size=nn[KMG] [X86]
used for mtrr cleanup. It is largest continuous chunk
that could hold holes aka. UC entries.
diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c
index a6dd240a09cb..e002856a5f4e 100644
--- a/arch/x86/kernel/cpu/mtrr/generic.c
+++ b/arch/x86/kernel/cpu/mtrr/generic.c
@@ -41,6 +41,23 @@ struct cache_map {
u64 fixed:1;
};
+static bool mtrr_debug;
+
+static int __init mtrr_param_setup(char *str)
+{
+ int rc = 0;
+
+ if (!str)
+ return -EINVAL;
+ if (!strcmp(str, "debug"))
+ mtrr_debug = true;
+ else
+ rc = -EINVAL;
+
+ return rc;
+}
+early_param("mtrr", mtrr_param_setup);
+
/*
* CACHE_MAP_MAX is the maximum number of memory ranges in cache_map, where
* no 2 adjacent ranges have the same cache mode (those would be merged).
@@ -519,6 +536,14 @@ void __init mtrr_build_map(void)
pr_info("MTRR map: %u entries (%u fixed + %u variable; max %u), built from %u variable MTRRs\n",
cache_map_n, cache_map_fixed, cache_map_n - cache_map_fixed,
get_cache_map_size(), num_var_ranges + (mtrr_tom2 != 0));
+
+ if (mtrr_debug) {
+ for (i = 0; i < cache_map_n; i++) {
+ pr_info("%3u: %016llx-%016llx %s\n", i,
+ cache_map[i].start, cache_map[i].end - 1,
+ mtrr_attrib_to_str(cache_map[i].type));
+ }
+ }
}
/* Copy the cache_map from __initdata memory to dynamically allocated one. */
@@ -725,8 +750,8 @@ static void __init print_fixed_last(void)
if (!last_fixed_end)
return;
- pr_debug(" %05X-%05X %s\n", last_fixed_start,
- last_fixed_end - 1, mtrr_attrib_to_str(last_fixed_type));
+ pr_info(" %05X-%05X %s\n", last_fixed_start,
+ last_fixed_end - 1, mtrr_attrib_to_str(last_fixed_type));
last_fixed_end = 0;
}
@@ -764,10 +789,10 @@ static void __init print_mtrr_state(void)
unsigned int i;
int high_width;
- pr_debug("MTRR default type: %s\n",
- mtrr_attrib_to_str(mtrr_state.def_type));
+ pr_info("MTRR default type: %s\n",
+ mtrr_attrib_to_str(mtrr_state.def_type));
if (mtrr_state.have_fixed) {
- pr_debug("MTRR fixed ranges %sabled:\n",
+ pr_info("MTRR fixed ranges %sabled:\n",
((mtrr_state.enabled & MTRR_STATE_MTRR_ENABLED) &&
(mtrr_state.enabled & MTRR_STATE_MTRR_FIXED_ENABLED)) ?
"en" : "dis");
@@ -782,27 +807,27 @@ static void __init print_mtrr_state(void)
/* tail */
print_fixed_last();
}
- pr_debug("MTRR variable ranges %sabled:\n",
- mtrr_state.enabled & MTRR_STATE_MTRR_ENABLED ? "en" : "dis");
+ pr_info("MTRR variable ranges %sabled:\n",
+ mtrr_state.enabled & MTRR_STATE_MTRR_ENABLED ? "en" : "dis");
high_width = (boot_cpu_data.x86_phys_bits - (32 - PAGE_SHIFT) + 3) / 4;
for (i = 0; i < num_var_ranges; ++i) {
if (mtrr_state.var_ranges[i].mask_lo & MTRR_PHYSMASK_V)
- pr_debug(" %u base %0*X%05X000 mask %0*X%05X000 %s\n",
- i,
- high_width,
- mtrr_state.var_ranges[i].base_hi,
- mtrr_state.var_ranges[i].base_lo >> 12,
- high_width,
- mtrr_state.var_ranges[i].mask_hi,
- mtrr_state.var_ranges[i].mask_lo >> 12,
- mtrr_attrib_to_str(mtrr_state.var_ranges[i].base_lo &
+ pr_info(" %u base %0*X%05X000 mask %0*X%05X000 %s\n",
+ i,
+ high_width,
+ mtrr_state.var_ranges[i].base_hi,
+ mtrr_state.var_ranges[i].base_lo >> 12,
+ high_width,
+ mtrr_state.var_ranges[i].mask_hi,
+ mtrr_state.var_ranges[i].mask_lo >> 12,
+ mtrr_attrib_to_str(mtrr_state.var_ranges[i].base_lo &
MTRR_PHYSBASE_TYPE));
else
- pr_debug(" %u disabled\n", i);
+ pr_info(" %u disabled\n", i);
}
if (mtrr_tom2)
- pr_debug("TOM2: %016llx aka %lldM\n", mtrr_tom2, mtrr_tom2>>20);
+ pr_info("TOM2: %016llx aka %lldM\n", mtrr_tom2, mtrr_tom2>>20);
}
/* Grab all of the MTRR state for this CPU into *state */
@@ -838,7 +863,8 @@ bool __init get_mtrr_state(void)
mtrr_tom2 &= 0xffffff800000ULL;
}
- print_mtrr_state();
+ if (mtrr_debug)
+ print_mtrr_state();
mtrr_state_set = 1;
--
2.35.3
next prev parent reply other threads:[~2023-05-02 12:11 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-02 12:09 [PATCH v6 00/16] x86/mtrr: fix handling with PAT but without MTRR Juergen Gross
2023-05-02 12:09 ` [PATCH v6 01/16] x86/mtrr: remove physical address size calculation Juergen Gross
2023-05-04 7:47 ` Borislav Petkov
2023-05-04 8:02 ` Juergen Gross
2023-06-05 14:08 ` [tip: x86/mtrr] x86/mtrr: Remove " tip-bot2 for Juergen Gross
2023-05-02 12:09 ` [PATCH v6 02/16] x86/mtrr: replace some constants with defines Juergen Gross
2023-05-05 18:49 ` Borislav Petkov
2023-05-08 13:00 ` Juergen Gross
2023-05-08 14:07 ` Borislav Petkov
2023-06-05 14:08 ` [tip: x86/mtrr] x86/mtrr: Replace size_or_mask and size_and_mask with a much easier concept tip-bot2 for Juergen Gross
2023-05-02 12:09 ` [PATCH v6 03/16] x86/mtrr: support setting MTRR state for software defined MTRRs Juergen Gross
2023-05-02 12:09 ` [PATCH v6 04/16] x86/hyperv: set MTRR state when running as SEV-SNP Hyper-V guest Juergen Gross
2023-06-05 14:08 ` [tip: x86/mtrr] x86/hyperv: Set " tip-bot2 for Juergen Gross
2023-06-08 4:31 ` Michael Kelley (LINUX)
2023-05-02 12:09 ` [PATCH v6 05/16] x86/xen: set MTRR state when running as Xen PV initial domain Juergen Gross
2023-06-05 14:08 ` [tip: x86/mtrr] x86/xen: Set " tip-bot2 for Juergen Gross
2023-05-02 12:09 ` [PATCH v6 06/16] x86/mtrr: replace vendor tests in MTRR code Juergen Gross
2023-05-09 18:37 ` Borislav Petkov
2023-06-05 14:08 ` [tip: x86/mtrr] x86/mtrr: Replace " tip-bot2 for Juergen Gross
2023-05-02 12:09 ` [PATCH v6 07/16] x86/mtrr: have only one set_mtrr() variant Juergen Gross
2023-06-05 14:08 ` [tip: x86/mtrr] x86/mtrr: Have " tip-bot2 for Juergen Gross
2023-05-02 12:09 ` [PATCH v6 08/16] x86/mtrr: move 32-bit code from mtrr.c to legacy.c Juergen Gross
2023-06-05 14:08 ` [tip: x86/mtrr] x86/mtrr: Move " tip-bot2 for Juergen Gross
2023-05-02 12:09 ` [PATCH v6 09/16] x86/mtrr: allocate mtrr_value array dynamically Juergen Gross
2023-06-05 14:08 ` [tip: x86/mtrr] x86/mtrr: Allocate " tip-bot2 for Juergen Gross
2023-05-02 12:09 ` [PATCH v6 10/16] x86/mtrr: add get_effective_type() service function Juergen Gross
2023-06-05 14:08 ` [tip: x86/mtrr] x86/mtrr: Add " tip-bot2 for Juergen Gross
2023-05-02 12:09 ` [PATCH v6 11/16] x86/mtrr: construct a memory map with cache modes Juergen Gross
2023-05-09 11:36 ` Borislav Petkov
2023-05-09 11:47 ` Juergen Gross
2023-05-09 12:10 ` Borislav Petkov
2023-06-05 14:08 ` [tip: x86/mtrr] x86/mtrr: Construct " tip-bot2 for Juergen Gross
2023-05-02 12:09 ` Juergen Gross [this message]
2023-06-05 14:08 ` [tip: x86/mtrr] x86/mtrr: Add mtrr=debug command line option tip-bot2 for Juergen Gross
2023-05-02 12:09 ` [PATCH v6 13/16] x86/mtrr: use new cache_map in mtrr_type_lookup() Juergen Gross
2023-06-05 14:08 ` [tip: x86/mtrr] x86/mtrr: Use " tip-bot2 for Juergen Gross
2023-05-02 12:09 ` [PATCH v6 14/16] x86/mtrr: don't let mtrr_type_lookup() return MTRR_TYPE_INVALID Juergen Gross
2023-06-05 14:08 ` [tip: x86/mtrr] x86/mtrr: Don't " tip-bot2 for Juergen Gross
2023-05-02 12:09 ` [PATCH v6 15/16] x86/mm: only check uniform after calling mtrr_type_lookup() Juergen Gross
2023-06-05 14:08 ` [tip: x86/mtrr] x86/mm: Only " tip-bot2 for Juergen Gross
2023-05-02 12:09 ` [PATCH v6 16/16] x86/mtrr: remove unused code Juergen Gross
2023-06-05 14:08 ` [tip: x86/mtrr] x86/mtrr: Remove " tip-bot2 for Juergen Gross
2023-05-03 4:22 ` [PATCH v6 00/16] x86/mtrr: fix handling with PAT but without MTRR Michael Kelley (LINUX)
2023-05-03 18:14 ` Sohil Mehta
2023-05-03 19:12 ` Borislav Petkov
2023-05-09 20:14 ` Borislav Petkov
2023-05-09 23:36 ` Borislav Petkov
2023-05-10 13:30 ` Borislav Petkov
2023-05-10 13:31 ` Borislav Petkov
2023-05-10 15:53 ` Juergen Gross
2023-05-11 16:32 ` Borislav Petkov
2023-05-22 14:17 ` Juergen Gross
2023-05-30 15:28 ` Borislav Petkov
2023-05-31 7:28 ` Juergen Gross
2023-05-31 8:35 ` Borislav Petkov
2023-05-31 9:31 ` Juergen Gross
2023-05-31 9:58 ` Borislav Petkov
2023-05-31 14:20 ` Juergen Gross
2023-05-31 17:48 ` Borislav Petkov
2023-06-01 6:39 ` Juergen Gross
2023-06-01 12:48 ` Borislav Petkov
2023-06-01 12:53 ` Juergen Gross
2023-06-01 8:19 ` Juergen Gross
2023-06-01 13:22 ` Borislav Petkov
2023-06-01 14:33 ` Borislav Petkov
2023-06-01 14:34 ` Juergen Gross
2023-06-01 13:10 ` Juergen Gross
2023-06-05 14:08 ` [tip: x86/mtrr] x86/mtrr: Unify debugging printing tip-bot2 for Borislav Petkov (AMD)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230502120931.20719-13-jgross@suse.com \
--to=jgross@suse.com \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikelley@microsoft.com \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox