From: Paul Mackerras <paulus@samba.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, Milton Miller <miltonm@bga.com>,
linuxppc-dev@ozlabs.org, Steven Rostedt <srostedt@redhat.com>,
Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 4/5] powerpc/ppc64: ftrace, handle module trampolines for dyn ftrace
Date: Mon, 24 Nov 2008 13:26:46 +1100 [thread overview]
Message-ID: <18730.4326.745599.500581@drongo.ozlabs.ibm.com> (raw)
In-Reply-To: <20081120191149.759009300@goodmis.org>
Steven Rostedt writes:
> +#ifdef CONFIG_PPC64
> +static int
> +__ftrace_make_nop(struct module *mod,
> + struct dyn_ftrace *rec, unsigned long addr)
> +{
> + unsigned char replaced[MCOUNT_INSN_SIZE * 2];
> + unsigned int *op = (unsigned *)&replaced;
This makes me a little nervous, since it looks to me to be breaking
aliasing rules. I know we use -fno-strict-aliasing, but still it
would be better to avoid doing these casts if possible - and we should
be able to avoid most of them by using unsigned int for instructions
consistently, instead of a mix of unsigned int and unsigned char.
> + DEBUGP("ip:%lx jumps to %lx r2: %lx", ip, tramp, mod->arch.toc);
> +
> + /* Find where the trampoline jumps to */
> + if (probe_kernel_read(jmp, (void *)tramp, 8)) {
> + printk(KERN_ERR "Failed to read %lx\n", tramp);
> + return -EFAULT;
> + }
> +
> + DEBUGP(" %08x %08x",
> + (unsigned)(*ptr >> 32),
> + (unsigned)*ptr);
> +
> + offset = (unsigned)jmp[2] << 24 |
> + (unsigned)jmp[3] << 16 |
> + (unsigned)jmp[6] << 8 |
> + (unsigned)jmp[7];
We don't seem to be checking that these instructions look like the
start of a trampoline created by module_64.c, which makes me a little
nervous.
If the kernel text goes over 32MB, the linker will insert trampolines
automatically. Those trampolines either look like a direct branch to
the target, or else they look like this:
addis r12,r2,xxxx
ld r11,yyyy(r12)
mtctr r11
bctr
where xxxx/yyyy gives the offset from the kernel TOC to the procedure
descriptor for the target.
Now, a kernel with > 32MB of text probably won't work for other
reasons at the moment (like the linker putting trampolines before the
interrupt vectors), so in a sense it doesn't matter. It also doesn't
matter since we only get here for calls in modules (something that
could stand to be mentioned in a comment at the top of the function).
Nevertheless, I think it would be worthwhile to check that the first
two instructions look like the addis and addi that we are expecting.
> + if (probe_kernel_write((void *)ip, replaced, MCOUNT_INSN_SIZE))
> + return -EPERM;
> +
> + return 0;
> +}
We don't seem to do anything to ensure I-cache consistency. I think
we probably need a flush_icache_range call here. Similarly in
__ftrace_make_call.
Paul.
next prev parent reply other threads:[~2008-11-24 2:26 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-20 19:09 [PATCH 0/5] powerpc: dynamic ftrace port Steven Rostedt
2008-11-20 19:09 ` [PATCH 1/5] powerpc: ftrace, do not latency trace idle Steven Rostedt
2008-11-20 19:09 ` [PATCH 2/5] powerpc: ftrace, convert to new dynamic ftrace arch API Steven Rostedt
2008-11-24 1:43 ` Paul Mackerras
2008-11-24 2:49 ` Michael Ellerman
2008-11-24 18:00 ` Steven Rostedt
2008-11-20 19:09 ` [PATCH 3/5] powerpc: ftrace, use probe_kernel API to modify code Steven Rostedt
2008-11-20 19:09 ` [PATCH 4/5] powerpc/ppc64: ftrace, handle module trampolines for dyn ftrace Steven Rostedt
2008-11-24 2:26 ` Paul Mackerras [this message]
2008-11-24 17:56 ` Steven Rostedt
2008-11-24 20:59 ` Steven Rostedt
2008-11-20 19:09 ` [PATCH 5/5] powerpc/ppc32: ftrace, dynamic ftrace to handle modules Steven Rostedt
2008-11-24 2:35 ` Paul Mackerras
2008-11-20 19:15 ` [PATCH 0/5] powerpc: dynamic ftrace port Steven Rostedt
2008-11-20 19:20 ` Ingo Molnar
2008-11-20 19:16 ` Ingo Molnar
2008-11-20 19:24 ` Steven Rostedt
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=18730.4326.745599.500581@drongo.ozlabs.ibm.com \
--to=paulus@samba.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=miltonm@bga.com \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=srostedt@redhat.com \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).