LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: mingo@elte.hu, rostedt@goodmis.org, fweisbec@gmail.com
Cc: linux-kernel@vger.kernel.org, masami.hiramatsu.pt@hitachi.com
Subject: [PATCH 2/4] tracing - adding size parameter to do_ftrace_mod_code
Date: Thu,  3 Feb 2011 16:42:39 +0100	[thread overview]
Message-ID: <1296747761-9082-3-git-send-email-jolsa@redhat.com> (raw)
In-Reply-To: <1296747761-9082-1-git-send-email-jolsa@redhat.com>

adding size parameter to be able to restore the saved
instructions, which could be longer than relative call

wbr,
jirka
---
 arch/x86/kernel/ftrace.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 382eb29..979ec14 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -124,6 +124,7 @@ static atomic_t nmi_running = ATOMIC_INIT(0);
 static int mod_code_status;		/* holds return value of text write */
 static void *mod_code_ip;		/* holds the IP to write to */
 static void *mod_code_newcode;		/* holds the text to write to the IP */
+static int mod_code_size;		/* holds the size of the new code */
 
 static unsigned nmi_wait_count;
 static atomic_t nmi_update_count = ATOMIC_INIT(0);
@@ -161,7 +162,7 @@ static void ftrace_mod_code(void)
 	 * to succeed, then they all should.
 	 */
 	mod_code_status = probe_kernel_write(mod_code_ip, mod_code_newcode,
-					     MCOUNT_INSN_SIZE);
+					     mod_code_size);
 
 	/* if we fail, then kill any new writers */
 	if (mod_code_status)
@@ -225,7 +226,7 @@ within(unsigned long addr, unsigned long start, unsigned long end)
 }
 
 static int
-do_ftrace_mod_code(unsigned long ip, void *new_code)
+do_ftrace_mod_code(unsigned long ip, void *new_code, int size)
 {
 	/*
 	 * On x86_64, kernel text mappings are mapped read-only with
@@ -240,6 +241,7 @@ do_ftrace_mod_code(unsigned long ip, void *new_code)
 
 	mod_code_ip = (void *)ip;
 	mod_code_newcode = new_code;
+	mod_code_size = size;
 
 	/* The buffers need to be visible before we let NMIs write them */
 	smp_mb();
@@ -290,7 +292,7 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
 		return -EINVAL;
 
 	/* replace the text with the new text */
-	if (do_ftrace_mod_code(ip, new_code))
+	if (do_ftrace_mod_code(ip, new_code, MCOUNT_INSN_SIZE))
 		return -EPERM;
 
 	sync_core();
@@ -361,7 +363,7 @@ static int ftrace_mod_jmp(unsigned long ip,
 
 	*(int *)(&code[1]) = new_offset;
 
-	if (do_ftrace_mod_code(ip, &code))
+	if (do_ftrace_mod_code(ip, &code, MCOUNT_INSN_SIZE))
 		return -EPERM;
 
 	return 0;
-- 
1.7.1


  parent reply	other threads:[~2011-02-03 15:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-03 15:42 [RFC 0/4] tracing,x86_64 - function/graph trace without mcount/-pg/framepointer Jiri Olsa
2011-02-03 15:42 ` [PATCH 1/4] kprobe - ktrace instruction slot cache interface Jiri Olsa
2011-02-03 15:42 ` Jiri Olsa [this message]
2011-02-03 15:42 ` [PATCH 3/4] ktrace - function trace support Jiri Olsa
2011-02-03 15:42 ` [PATCH 4/4] ktrace - function graph " Jiri Olsa
2011-02-03 16:33 ` [RFC 0/4] tracing,x86_64 - function/graph trace without mcount/-pg/framepointer Steven Rostedt
2011-02-03 17:35   ` Frederic Weisbecker
2011-02-03 19:00     ` Steven Rostedt
2011-02-04  6:03 ` 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=1296747761-9082-3-git-send-email-jolsa@redhat.com \
    --to=jolsa@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --subject='Re: [PATCH 2/4] tracing - adding size parameter to do_ftrace_mod_code' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).