From: Michael Ellerman <mpe@ellerman.id.au>
To: <linuxppc-dev@ozlabs.org>
Cc: bsingharora@gmail.com, duwe@lst.de,
<linux-kernel@vger.kernel.org>,
rostedt@goodmis.org, kamalesh@linux.vnet.ibm.com,
pmladek@suse.com, jeyu@redhat.com, jkosina@suse.cz,
live-patching@vger.kernel.org, mbenes@suse.cz
Subject: [PATCH 06/12] powerpc/module: Rework is_early_mcount_callsite()
Date: Thu, 25 Feb 2016 01:28:29 +1100 [thread overview]
Message-ID: <1456324115-21144-6-git-send-email-mpe@ellerman.id.au> (raw)
In-Reply-To: <1456324115-21144-1-git-send-email-mpe@ellerman.id.au>
is_early_mcount_callsite() needs to detect either the two instruction or
the three instruction versions of the _mcount() sequence.
But if we're running a kernel with the two instruction sequence, we need
to be careful not to read instruction - 2, otherwise we might fall off
the front of a page and cause an oops.
While we're here convert to bool to make the return semantics clear.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/module_64.c | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
Squash.
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 32c10e0d2aa5..495df4340623 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -449,27 +449,25 @@ static unsigned long stub_for_addr(const Elf64_Shdr *sechdrs,
}
#ifdef CC_USING_MPROFILE_KERNEL
-static int is_early_mcount_callsite(u32 *instruction)
+static bool is_early_mcount_callsite(u32 *instruction)
{
- /* -mprofile-kernel sequence starting with
- * mflr r0 and maybe std r0, LRSAVE(r1).
+ /*
+ * Check if this is one of the -mprofile-kernel sequences.
*/
- if ((instruction[-3] == PPC_INST_MFLR &&
- instruction[-2] == PPC_INST_STD_LR) ||
- instruction[-2] == PPC_INST_MFLR) {
- /* Nothing to be done here, it's an _mcount
- * call location and r2 will have to be
- * restored in the _mcount function.
- */
- return 1;
- }
- return 0;
+ if (instruction[-1] == PPC_INST_STD_LR &&
+ instruction[-2] == PPC_INST_MFLR)
+ return true;
+
+ if (instruction[-1] == PPC_INST_MFLR)
+ return true;
+
+ return false;
}
#else
/* without -mprofile-kernel, mcount calls are never early */
-static int is_early_mcount_callsite(u32 *instruction)
+static bool is_early_mcount_callsite(u32 *instruction)
{
- return 0;
+ return false;
}
#endif
@@ -478,7 +476,7 @@ static int is_early_mcount_callsite(u32 *instruction)
static int restore_r2(u32 *instruction, struct module *me)
{
if (*instruction != PPC_INST_NOP) {
- if (is_early_mcount_callsite(instruction))
+ if (is_early_mcount_callsite(instruction - 1))
return 1;
pr_err("%s: Expect noop after relocate, got %08x\n",
me->name, *instruction);
--
2.5.0
next prev parent reply other threads:[~2016-02-24 14:31 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-24 14:28 [PATCH 01/12] powerpc/module: Only try to generate the ftrace_caller() stub once Michael Ellerman
2016-02-24 14:28 ` [PATCH 02/12] powerpc/module: Mark module stubs with a magic value Michael Ellerman
2016-02-25 0:04 ` Balbir Singh
2016-02-25 6:43 ` Michael Ellerman
2016-02-25 13:17 ` Torsten Duwe
2016-02-26 10:37 ` Michael Ellerman
2016-02-24 14:28 ` [PATCH 03/12] powerpc/module: Create a special stub for ftrace_caller() Michael Ellerman
2016-02-25 0:08 ` Balbir Singh
2016-02-25 10:48 ` Michael Ellerman
2016-02-25 13:31 ` Torsten Duwe
2016-02-26 10:35 ` Michael Ellerman
2016-02-24 14:28 ` [PATCH 04/12] powerpc/ftrace: Prepare for -mprofile-kernel Michael Ellerman
2016-02-25 0:28 ` Balbir Singh
2016-02-25 10:37 ` Michael Ellerman
2016-02-25 13:52 ` Torsten Duwe
2016-02-26 10:14 ` Michael Ellerman
2016-02-24 14:28 ` [PATCH 05/12] powerpc/ftrace: ftrace_graph_caller() needs to save/restore toc Michael Ellerman
2016-02-25 0:30 ` Balbir Singh
2016-02-25 10:39 ` Michael Ellerman
2016-02-25 14:02 ` Torsten Duwe
2016-02-24 14:28 ` Michael Ellerman [this message]
2016-02-24 23:39 ` [PATCH 06/12] powerpc/module: Rework is_early_mcount_callsite() Balbir Singh
2016-02-25 10:28 ` Michael Ellerman
2016-02-25 14:06 ` Torsten Duwe
2016-02-24 14:28 ` [PATCH 07/12] powerpc/ftrace: FTRACE_WITH_REGS implementation for ppc64le Michael Ellerman
2016-02-25 0:48 ` Balbir Singh
2016-02-25 15:11 ` Torsten Duwe
2016-02-26 10:14 ` Michael Ellerman
2016-02-24 14:28 ` [PATCH 08/12] powerpc/ftrace: Rework ftrace_caller() Michael Ellerman
2016-02-25 1:06 ` Balbir Singh
2016-02-25 14:25 ` Torsten Duwe
2016-02-24 14:28 ` [PATCH 09/12] powerpc/ftrace: Use generic ftrace_modify_all_code() Michael Ellerman
2016-02-25 1:10 ` Balbir Singh
2016-02-24 14:28 ` [PATCH 10/12] powerpc/ftrace: FTRACE_WITH_REGS configuration variables Michael Ellerman
2016-02-25 1:11 ` Balbir Singh
2016-02-25 14:34 ` Torsten Duwe
2016-02-24 14:28 ` [PATCH 11/12] powerpc/ftrace: Rework __ftrace_make_nop() Michael Ellerman
2016-02-24 14:28 ` [PATCH 12/12] powerpc/ftrace: Disable profiling for some files Michael Ellerman
2016-02-25 1:13 ` Balbir Singh
2016-02-24 23:55 ` [PATCH 01/12] powerpc/module: Only try to generate the ftrace_caller() stub once Balbir Singh
2016-02-25 4:36 ` Balbir Singh
2016-02-25 13:08 ` Torsten Duwe
2016-02-25 14:38 ` Kamalesh Babulal
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=1456324115-21144-6-git-send-email-mpe@ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=bsingharora@gmail.com \
--cc=duwe@lst.de \
--cc=jeyu@redhat.com \
--cc=jkosina@suse.cz \
--cc=kamalesh@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.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
all inboxes | Powered by JetHome®