aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/kernel
diff options
context:
space:
mode:
authorSteven Rostedt (Google) <rostedt@goodmis.org>2024-08-15 08:28:11 -0400
committerSteven Rostedt (Google) <rostedt@goodmis.org>2024-08-15 08:34:48 -0400
commit29a02ec66556ac942d263416c32b97f5b9206f69 (patch)
tree1d3178f813f0cf904239f9e239aa47bd5c81c2c8 /kernel
parenttracing: Fix ifdef of snapshots to not prevent last_boot_info file (diff)
downloadwireguard-linux-29a02ec66556ac942d263416c32b97f5b9206f69.tar.xz
wireguard-linux-29a02ec66556ac942d263416c32b97f5b9206f69.zip
tracing: Allow boot instances to use reserve_mem boot memory
Allow boot instances to use memory reserved by the reserve_mem boot option. reserve_mem=12M:4096:trace trace_instance=boot_mapped@trace The above will allocate 12 megs with 4096 alignment and label it "trace". The second parameter will create a "boot_mapped" instance and use the memory reserved and labeled as "trace" as the memory for the ring buffer. That will create an instance called "boot_mapped": /sys/kernel/tracing/instances/boot_mapped Note, because the ring buffer is using a defined memory ranged, it will act just like a memory mapped ring buffer. It will not have a snapshot buffer, as it can't swap out the buffer. The snapshot files as well as any tracers that uses a snapshot will not be present in the boot_mapped instance. Also note that reserve_mem is not reliable in acquiring the same physical memory at each soft reboot. It is possible that KALSR could map the kernel at the previous boot memory location forcing the reserve_mem to return a different memory location. In this case, the previous ring buffer will be lost. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Ross Zwisler <zwisler@google.com> Cc: Vincent Donnefort <vdonnefort@google.com> Link: https://lore.kernel.org/20240815082811.669f7d8c@gandalf.local.home Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/trace.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8e5a4ca9fd70..9bcef199ae90 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -10465,22 +10465,20 @@ __init static void enable_instances(void)
str = boot_instance_info;
while ((curr_str = strsep(&str, "\t"))) {
- unsigned long start = 0;
- unsigned long size = 0;
+ phys_addr_t start = 0;
+ phys_addr_t size = 0;
unsigned long addr = 0;
tok = strsep(&curr_str, ",");
name = strsep(&tok, "@");
- if (tok) {
+
+ if (tok && isdigit(*tok)) {
start = memparse(tok, &tok);
if (!start) {
pr_warn("Tracing: Invalid boot instance address for %s\n",
name);
continue;
}
- }
-
- if (start) {
if (*tok != ':') {
pr_warn("Tracing: No size specified for instance %s\n", name);
continue;
@@ -10492,10 +10490,19 @@ __init static void enable_instances(void)
name);
continue;
}
+ } else if (tok) {
+ if (!reserve_mem_find_by_name(tok, &start, &size)) {
+ start = 0;
+ pr_warn("Failed to map boot instance %s to %s\n", name, tok);
+ continue;
+ }
+ }
+
+ if (start) {
addr = map_pages(start, size);
if (addr) {
- pr_info("Tracing: mapped boot instance %s at physical memory 0x%lx of size 0x%lx\n",
- name, start, size);
+ pr_info("Tracing: mapped boot instance %s at physical memory %pa of size 0x%lx\n",
+ name, &start, (unsigned long)size);
} else {
pr_warn("Tracing: Failed to map boot instance %s\n", name);
continue;