Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1342062

[PATCH 11/12] powerpc/ftrace: Rework __ftrace_make_nop()

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Michael Ellerman <mpe@ellerman.id.au>
Newsgroups linux.kernel
Subject [PATCH 11/12] powerpc/ftrace: Rework __ftrace_make_nop()
Date Wed, 24 Feb 2016 15:30:01 +0100
Message-ID <r5IBX-5Pl-9@gated-at.bofh.it> (permalink)
References <r5IBX-5Pl-7@gated-at.bofh.it>
X-Mailer git-send-email 2.5.0
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 60
Organization linux.* mail to news gateway
X-Original-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
X-Original-Date Thu, 25 Feb 2016 01:28:34 +1100
X-Original-Message-ID <1456324115-21144-11-git-send-email-mpe@ellerman.id.au>
X-Original-References <1456324115-21144-1-git-send-email-mpe@ellerman.id.au>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1342062

Show key headers only | View raw


__ftrace_make_nop() 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 from ip - 8, or we'll fault and (possibly)
incorrectly declare the sequence doesn't match.

To keep the code simpler just look at ip - 4, and if it is either of the
expected instructions declare it good. We've already passed a lot of
other checks.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/ftrace.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

Squash.

diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index f190528e3781..fe7486f9849e 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -174,28 +174,19 @@ __ftrace_make_nop(struct module *mod,
 		return -EFAULT;
 	}
 
-	if (op != PPC_INST_LD_TOC)
-	{
-		unsigned int op0, op1;
+	if (op != PPC_INST_LD_TOC) {
+		unsigned int inst;
 
-		if (probe_kernel_read(&op0, (void *)(ip-8), MCOUNT_INSN_SIZE)) {
-			pr_err("Fetching op0 failed.\n");
+		if (probe_kernel_read(&inst, (void *)(ip - 4), 4)) {
+			pr_err("Fetching instruction at %lx failed.\n", ip - 4);
 			return -EFAULT;
 		}
 
-		if (probe_kernel_read(&op1, (void *)(ip-4), MCOUNT_INSN_SIZE)) {
-			pr_err("Fetching op1 failed.\n");
-			return -EFAULT;
-		}
-
-		/* mflr r0 ; [ std r0,LRSAVE(r1) ]? */
-		if ( (op0 != PPC_INST_MFLR ||
-		      op1 != PPC_INST_STD_LR)
-		     && op1 != PPC_INST_MFLR )
-		{
+		/* We expect either a mlfr r0, or a std r0, LRSAVE(r1) */
+		if (inst != PPC_INST_MFLR && inst != PPC_INST_STD_LR) {
 			pr_err("Unexpected instructions around bl _mcount\n"
 			       "when enabling dynamic ftrace!\t"
-			       "(%08x,%08x,bl,%08x)\n", op0, op1, op);
+			       "(%08x,bl,%08x)\n", inst, op);
 			return -EINVAL;
 		}
 
-- 
2.5.0

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 11/12] powerpc/ftrace: Rework __ftrace_make_nop() Michael Ellerman <mpe@ellerman.id.au> - 2016-02-24 15:30 +0100

csiph-web