[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1256685826.15873.41.camel@sbs-t61.sc.intel.com>
Date: Tue, 27 Oct 2009 15:23:46 -0800
From: Suresh Siddha <suresh.b.siddha@...el.com>
To: "rostedt@...dmis.org" <rostedt@...dmis.org>
Cc: LKML <linux-kernel@...r.kernel.org>, Ingo Molnar <mingo@...e.hu>,
"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH] [GIT PULL] tracing: allow to change permissions for
text with dynamic ftrace enabled
On Tue, 2009-10-27 at 14:35 -0700, Steven Rostedt wrote:
> On Tue, 2009-10-27 at 14:26 -0800, Suresh Siddha wrote:
> >
> > + /*
> > + * On x86_64, we use the kernel identity mapping instead of the
> > + * kernel text mapping to modify the kernel text. This is a nop
> > + * for 32bit kernels.
> > + */
>
> Is it really a nop on 32bit? Does it just turn into ip = ip?
Yes. it will be ip = ip for 32bit.
> > + if (within(ip, (unsigned long)_text, (unsigned long)_etext))
> > + ip = (unsigned long)__va(__pa(ip));
> > +
> > /* replace the text with the new text */
> > if (do_ftrace_mod_code(ip, new_code))
> > return -EPERM;
>
> I'll test it out, and if it does work, you can write up a formal patch
> and remove the !define that I added.
I just saw one more place calling do_ftrace_mod_code(). So moved this
check inside the do_ftrace_mod_code(). Does this cover all the cases?
Thanks.
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 5a1b975..e239fd7 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -189,9 +189,23 @@ static void wait_for_nmi(void)
nmi_wait_count++;
}
+static inline int
+within(unsigned long addr, unsigned long start, unsigned long end)
+{
+ return addr >= start && addr < end;
+}
+
static int
do_ftrace_mod_code(unsigned long ip, void *new_code)
{
+ /*
+ * On x86_64, we use the kernel identity mapping instead of the
+ * kernel text mapping to modify the kernel text. For 32bit kernels,
+ * these mappings are same.
+ */
+ if (within(ip, (unsigned long)_text, (unsigned long)_etext))
+ ip = (unsigned long)__va(__pa(ip));
+
mod_code_ip = (void *)ip;
mod_code_newcode = new_code;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists