From: Michael Ellerman <michael@ellerman.id.au>
To: <linuxppc-dev@ozlabs.org>
Subject: [PATCH 04/14] powerpc: Add ppc_function_entry() which gets the entry point for a function
Date: Tue, 24 Jun 2008 11:32:28 +1000 (EST) [thread overview]
Message-ID: <d66e1bcc6428a3fde7665e09ded9a9331f5b480d.1214271072.git.michael@ellerman.id.au> (raw)
In-Reply-To: <fd46b7fc5f4785affb58f1de2b85a63b154e0de8.1214271072.git.michael@ellerman.id.au>
Because function pointers point to different things on 32-bit vs 64-bit,
add a macro that deals with dereferencing the OPD on 64-bit. The soon to
be merged ftrace wants this, as well as other code I am working on.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
include/asm-powerpc/code-patching.h | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/include/asm-powerpc/code-patching.h b/include/asm-powerpc/code-patching.h
index fdb187c..a45a7ff 100644
--- a/include/asm-powerpc/code-patching.h
+++ b/include/asm-powerpc/code-patching.h
@@ -10,6 +10,8 @@
* 2 of the License, or (at your option) any later version.
*/
+#include <asm/types.h>
+
/* Flags for create_branch:
* "b" == create_branch(addr, target, 0);
* "ba" == create_branch(addr, target, BRANCH_ABSOLUTE);
@@ -24,4 +26,18 @@ unsigned int create_branch(const unsigned int *addr,
void patch_branch(unsigned int *addr, unsigned long target, int flags);
void patch_instruction(unsigned int *addr, unsigned int instr);
+static inline unsigned long ppc_function_entry(void *func)
+{
+#ifdef CONFIG_PPC64
+ /*
+ * On PPC64 the function pointer actually points to the function's
+ * descriptor. The first entry in the descriptor is the address
+ * of the function text.
+ */
+ return ((func_descr_t *)func)->entry;
+#else
+ return (unsigned long)func;
+#endif
+}
+
#endif /* _ASM_POWERPC_CODE_PATCHING_H */
--
1.5.5
next prev parent reply other threads:[~2008-06-24 1:32 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-24 1:32 [PATCH 01/14] powerpc: Move code patching code into arch/powerpc/lib/code-patching.c Michael Ellerman
2008-06-24 1:32 ` [PATCH 02/14] powerpc: Allow create_branch() to return errors Michael Ellerman
2008-06-24 13:20 ` Kumar Gala
2008-06-24 13:26 ` Jon Loeliger
2008-06-24 1:32 ` [PATCH 03/14] powerpc: Make create_branch() return errors if the branch target is too large Michael Ellerman
2008-06-24 13:21 ` Kumar Gala
2008-06-24 1:32 ` Michael Ellerman [this message]
2008-06-24 13:39 ` [PATCH 04/14] powerpc: Add ppc_function_entry() which gets the entry point for a function Kumar Gala
2008-06-24 1:32 ` [PATCH 05/14] powerpc: Add new code patching routines Michael Ellerman
2008-06-24 13:48 ` Kumar Gala
2008-06-26 3:54 ` Michael Ellerman
2008-06-24 1:32 ` [PATCH 06/14] powerpc: Add tests of the " Michael Ellerman
2008-06-24 13:48 ` Kumar Gala
2008-06-24 1:32 ` [PATCH 07/14] powerpc: Add PPC_NOP_INSTR, a hash define for the preferred nop instruction Michael Ellerman
2008-06-24 13:48 ` Kumar Gala
2008-06-24 1:32 ` [PATCH 08/14] powerpc: Split out do_feature_fixups() from cputable.c Michael Ellerman
2008-06-24 13:48 ` Kumar Gala
2008-06-24 1:32 ` [PATCH 09/14] powerpc: Consolidate CPU and firmware feature fixup macros Michael Ellerman
2008-06-24 13:48 ` Kumar Gala
2008-06-24 1:32 ` [PATCH 10/14] powerpc: Consolidate feature fixup macros for 64/32 bit Michael Ellerman
2008-06-24 13:48 ` Kumar Gala
2008-06-26 3:47 ` Michael Ellerman
2008-06-24 1:32 ` [PATCH 11/14] powerpc: Introduce infrastructure for feature sections with alternatives Michael Ellerman
2008-06-24 1:33 ` [PATCH 12/14] powerpc: Add logic to patch alternative feature sections Michael Ellerman
2008-06-24 13:47 ` Kumar Gala
2008-06-26 3:45 ` Michael Ellerman
2008-06-24 1:33 ` [PATCH 13/14] powerpc: Add self-tests of the feature fixup code Michael Ellerman
2008-06-24 1:33 ` [PATCH 14/14] powerpc: Use an alternative feature section in entry_64.S Michael Ellerman
2008-06-24 13:23 ` [PATCH 01/14] powerpc: Move code patching code into arch/powerpc/lib/code-patching.c Kumar Gala
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=d66e1bcc6428a3fde7665e09ded9a9331f5b480d.1214271072.git.michael@ellerman.id.au \
--to=michael@ellerman.id.au \
--cc=linuxppc-dev@ozlabs.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;
as well as URLs for NNTP newsgroup(s).