From: Paul Mackerras <paulus@samba.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
David Miller <davem@davemloft.net>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Pekka Paalanen <pq@iki.fi>,
linuxppc-dev@ozlabs.org, Rusty Russell <rusty@rustcorp.com.au>,
Paul Mundt <lethal@linux-sh.org>
Subject: Re: [PATCH 0/7] Porting dynmaic ftrace to PowerPC
Date: Mon, 17 Nov 2008 09:55:29 +1100 [thread overview]
Message-ID: <18720.42209.880409.297291@cargo.ozlabs.ibm.com> (raw)
In-Reply-To: <20081116212428.938752312@goodmis.org>
Steven Rostedt writes:
> The following patches are for my work on porting the new dynamic ftrace
> framework to PowerPC. The issue I had with both PPC64 and PPC32 is
> that the calls to mcount are 24 bit jumps. Since the modules are
> loaded in vmalloc address space, the call to mcount is farther than
> what a 24 bit jump can make. The way PPC solves this is with the use
> of trampolines. The trampoline is a memory space allocated within the
> 24 bit region of the module. The code in the trampoline that the
> jump is made to does a far jump to the core kernel code.
Thanks for doing this work. I'll go through the patches in detail
today, but first I'd like to clear up a couple of things for you. The
first is that unconditional branches on PowerPC effectively have a
26-bit sign-extended offset, not 24-bit. The offset field in the
instruction is 24 bits long, but because all instructions are 4 bytes
long, two extra 0 bits get appended to the offset field, giving a
26-bit offset and a range of +/- 32MB from the branch instruction.
> PPC64, although works with 64 bit registers, the op codes are still
> 32 bit in length. PPC64 uses table of contents (TOC) fields
> to make their calls to functions. A function name is really a pointer
> into the TOC table that stores the actual address of the function
> along with the TOC of that function. The r2 register plays as the
> TOC pointer. The actual name of the function is the function name
> with a dot '.' prefix. The reference name "schedule" is really
> to the TOC entry, which calls the actual code with the reference
> name ".schedule". This also explains why the list of available filter
> functions on PPC64 all have a dot prefix.
A little more detail: the TOC mainly stores addresses and other
constants. Functions have a descriptor that is stored in a .opd
section (not the TOC, though the TOC may contain pointers to procedure
descriptors). Each descriptor has the address of the code, the
address of the TOC for the function, and a static chain pointer (not
used for C, but can used for other languages). As you note, the
symbol for a function will be the address of the descriptor rather
than the address of the function code.
> When a funtion is called, it uses the 'bl' command which is a 24
> bit function jump (saving the return address in the link register).
> The next operation after all 'bl' calls is a nop. What the module
> load code does when one of these 'bl' calls is farther than 24 bits
> can handle, it creates a entry in the TOC and has the 'bl' call to
The module loader allocates some memory for these trampolines, but
that's a distinct area from the TOC and the OPD section.
> that entry. The entry in the TOC will save the r2 register on the
> stack "40(r1)" load the actually function into the ctrl register
"counter" register, actually, not "ctrl".
> The work for PPC32 is very much the same as the PPC64 code but the 32
> version does not need to deal with TOCS. This makes the code much
> simpler. Pretty much everything as PPC64 is done, except it does not
> need to index a TOC.
Right.
> I've tested the following patches on both PPC64 and PPC32. I will
> admit that the PPC64 does not seem that stable, but neither does the
> code when all this is not enabled ;-) I'll debug it more to see if
> I can find the cause of my crashes, which may or may not be related
> to the dynamic ftrace code. But the use of TOCS in PPC64 make me
> a bit nervious that I did not do this correctly. Any help in reviewing
> my code for mistakes would be greatly appreciated.
Hmmm. What sort of crashes are you seeing?
Regards,
Paul.
next prev parent reply other threads:[~2008-11-16 22:56 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-16 21:24 Steven Rostedt
2008-11-16 21:24 ` [PATCH 1/7] ftrace, PPC: do not latency trace idle Steven Rostedt
2008-11-17 3:43 ` Paul Mackerras
2008-11-17 15:43 ` Steven Rostedt
2008-11-16 21:24 ` [PATCH 2/7] ftrace, ppc: convert to new dynamic ftrace arch API Steven Rostedt
2008-11-17 3:57 ` Paul Mackerras
2008-11-17 15:47 ` Steven Rostedt
2008-11-16 21:24 ` [PATCH 3/7] ftrace: powerpc mcount record port Steven Rostedt
2008-11-16 21:24 ` [PATCH 4/7] ftrace, PPC: use probe_kernel API to modify code Steven Rostedt
2008-11-17 4:44 ` Paul Mackerras
2008-11-17 15:51 ` Steven Rostedt
2008-11-16 21:24 ` [PATCH 5/7] ftrace, PPC64: handle module trampolines for dyn ftrace Steven Rostedt
2008-11-17 5:00 ` Paul Mackerras
2008-11-17 16:02 ` Steven Rostedt
2008-11-17 16:18 ` Steven Rostedt
2008-11-16 21:24 ` [PATCH 6/7] ftrace,ppc32: enabled dynamic ftrace Steven Rostedt
2008-11-16 21:24 ` [PATCH 7/7] ftrace,ppc32: dynamic ftrace to handle modules Steven Rostedt
2008-11-16 22:55 ` Paul Mackerras [this message]
2008-11-17 15:42 ` [PATCH 0/7] Porting dynmaic ftrace to PowerPC Steven Rostedt
2008-11-17 20:03 ` Steven Rostedt
2008-11-18 13:56 ` Steven Rostedt
2008-11-19 2:38 ` Paul Mackerras
2008-11-19 3:04 ` Steven Rostedt
2008-11-19 9:27 ` Ingo Molnar
2008-11-19 10:38 ` Paul Mackerras
2008-11-19 10:57 ` Ingo Molnar
2008-11-19 11:35 ` Paul Mackerras
2008-11-19 12:10 ` Steven Rostedt
2008-11-19 12:15 ` 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=18720.42209.880409.297291@cargo.ozlabs.ibm.com \
--to=paulus@samba.org \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=fweisbec@gmail.com \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=pq@iki.fi \
--cc=rostedt@goodmis.org \
--cc=rusty@rustcorp.com.au \
--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
all inboxes | Powered by JetHome®