Skip to content

Commit 028a58e

Browse files
committed
tracing: Use _text and the kernel offset in last_boot_info
Instead of using kaslr_offset() just record the location of "_text". This makes it possible for user space to use either the System.map or /proc/kallsyms as what to map all addresses to functions with. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Link: https://lore.kernel.org/20250326220304.38dbedcd@gandalf.local.home Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 35a380d commit 028a58e

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

kernel/trace/trace.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#include <linux/workqueue.h>
5252
#include <linux/sort.h>
5353

54-
#include <asm/setup.h> /* COMMAND_LINE_SIZE and kaslr_offset() */
54+
#include <asm/setup.h> /* COMMAND_LINE_SIZE */
5555

5656
#include "trace.h"
5757
#include "trace_output.h"
@@ -5995,7 +5995,7 @@ struct trace_mod_entry {
59955995
};
59965996

59975997
struct trace_scratch {
5998-
unsigned long kaslr_addr;
5998+
unsigned long text_addr;
59995999
unsigned long nr_entries;
60006000
struct trace_mod_entry entries[];
60016001
};
@@ -6133,11 +6133,7 @@ static void update_last_data(struct trace_array *tr)
61336133
kfree_rcu(module_delta, rcu);
61346134

61356135
/* Set the persistent ring buffer meta data to this address */
6136-
#ifdef CONFIG_RANDOMIZE_BASE
6137-
tscratch->kaslr_addr = kaslr_offset();
6138-
#else
6139-
tscratch->kaslr_addr = 0;
6140-
#endif
6136+
tscratch->text_addr = (unsigned long)_text;
61416137
}
61426138

61436139
/**
@@ -6996,7 +6992,7 @@ static void show_last_boot_header(struct seq_file *m, struct trace_array *tr)
69966992
* should not be the same as the current boot.
69976993
*/
69986994
if (tscratch && (tr->flags & TRACE_ARRAY_FL_LAST_BOOT))
6999-
seq_printf(m, "%lx\t[kernel]\n", tscratch->kaslr_addr);
6995+
seq_printf(m, "%lx\t[kernel]\n", tscratch->text_addr);
70006996
else
70016997
seq_puts(m, "# Current\n");
70026998
}
@@ -9465,10 +9461,8 @@ static void setup_trace_scratch(struct trace_array *tr,
94659461
tr->scratch = tscratch;
94669462
tr->scratch_size = size;
94679463

9468-
#ifdef CONFIG_RANDOMIZE_BASE
9469-
if (tscratch->kaslr_addr)
9470-
tr->text_delta = kaslr_offset() - tscratch->kaslr_addr;
9471-
#endif
9464+
if (tscratch->text_addr)
9465+
tr->text_delta = (unsigned long)_text - tscratch->text_addr;
94729466

94739467
if (struct_size(tscratch, entries, tscratch->nr_entries) > size)
94749468
goto reset;

0 commit comments

Comments
 (0)