mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: LKML <linux-kernel@vger.kernel.org>,
	Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Subject: [PATCH] tracing: Use _text and the kernel offset in last_boot_info
Date: Wed, 26 Mar 2025 22:03:04 -0400	[thread overview]
Message-ID: <20250326220304.38dbedcd@gandalf.local.home> (raw)

From: Steven Rostedt <rostedt@goodmis.org>

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.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 kernel/trace/trace.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 85128ef96246..3b8f5e3313e0 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -51,7 +51,7 @@
 #include <linux/workqueue.h>
 #include <linux/sort.h>
 
-#include <asm/setup.h> /* COMMAND_LINE_SIZE and kaslr_offset() */
+#include <asm/setup.h> /* COMMAND_LINE_SIZE */
 
 #include "trace.h"
 #include "trace_output.h"
@@ -5995,7 +5995,7 @@ struct trace_mod_entry {
 };
 
 struct trace_scratch {
-	unsigned long		kaslr_addr;
+	unsigned long		text_addr;
 	unsigned long		nr_entries;
 	struct trace_mod_entry	entries[];
 };
@@ -6137,11 +6137,7 @@ static void update_last_data(struct trace_array *tr)
 	kfree_rcu(module_delta, rcu);
 
 	/* Set the persistent ring buffer meta data to this address */
-#ifdef CONFIG_RANDOMIZE_BASE
-	tscratch->kaslr_addr = kaslr_offset();
-#else
-	tscratch->kaslr_addr = 0;
-#endif
+	tscratch->text_addr = (unsigned long)_text;
 }
 
 /**
@@ -7000,7 +6996,7 @@ static void show_last_boot_header(struct seq_file *m, struct trace_array *tr)
 	 * should not be the same as the current boot.
 	 */
 	if (tscratch && (tr->flags & TRACE_ARRAY_FL_LAST_BOOT))
-		seq_printf(m, "%lx\t[kernel]\n", tscratch->kaslr_addr);
+		seq_printf(m, "%lx\t[kernel]\n", tscratch->text_addr);
 	else
 		seq_puts(m, "# Current\n");
 }
@@ -9465,10 +9461,8 @@ static void setup_trace_scratch(struct trace_array *tr,
 	tr->scratch = tscratch;
 	tr->scratch_size = size;
 
-#ifdef CONFIG_RANDOMIZE_BASE
-	if (tscratch->kaslr_addr)
-		tr->text_delta = kaslr_offset() - tscratch->kaslr_addr;
-#endif
+	if (tscratch->text_addr)
+		tr->text_delta = (unsigned long)_text - tscratch->text_addr;
 
 	if (struct_size(tscratch, entries, tscratch->nr_entries) > size)
 		goto reset;
-- 
2.47.2


             reply	other threads:[~2025-03-27  2:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-27  2:03 Steven Rostedt [this message]
2025-03-27 21:38 ` Masami Hiramatsu

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=20250326220304.38dbedcd@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@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

all inboxes | Powered by JetHome®