linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: guoren@kernel.org
To: palmerdabbelt@google.com, paul.walmsley@sifive.com,
	mhiramat@kernel.org, oleg@redhat.com
Cc: me@packi.ch, Guo Ren <guoren@linux.alibaba.com>,
	anup@brainfault.org, linux-kernel@vger.kernel.org,
	linux-csky@vger.kernel.org, guoren@kernel.org,
	zong.li@sifive.com, bjorn.topel@gmail.com,
	greentime.hu@sifive.com, linux-riscv@lists.infradead.org
Subject: [PATCH v3 3/7] riscv: Fixup kprobes handler couldn't change pc
Date: Mon, 13 Jul 2020 23:39:18 +0000	[thread overview]
Message-ID: <1594683562-68149-4-git-send-email-guoren@kernel.org> (raw)
In-Reply-To: <1594683562-68149-1-git-send-email-guoren@kernel.org>

From: Guo Ren <guoren@linux.alibaba.com>

The "Changing Execution Path" section in the Documentation/kprobes.txt
said:

Since kprobes can probe into a running kernel code, it can change the
register set, including instruction pointer.

Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Palmer Dabbelt <palmerdabbelt@google.com>
---
 arch/riscv/kernel/mcount-dyn.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/mcount-dyn.S b/arch/riscv/kernel/mcount-dyn.S
index 35a6ed7..4b58b54 100644
--- a/arch/riscv/kernel/mcount-dyn.S
+++ b/arch/riscv/kernel/mcount-dyn.S
@@ -123,6 +123,7 @@ ENDPROC(ftrace_caller)
 	sd	ra, (PT_SIZE_ON_STACK+8)(sp)
 	addi	s0, sp, (PT_SIZE_ON_STACK+16)
 
+	sd ra,  PT_EPC(sp)
 	sd x1,  PT_RA(sp)
 	sd x2,  PT_SP(sp)
 	sd x3,  PT_GP(sp)
@@ -157,6 +158,7 @@ ENDPROC(ftrace_caller)
 	.endm
 
 	.macro RESTORE_ALL
+	ld ra,  PT_EPC(sp)
 	ld x1,  PT_RA(sp)
 	ld x2,  PT_SP(sp)
 	ld x3,  PT_GP(sp)
@@ -190,7 +192,6 @@ ENDPROC(ftrace_caller)
 	ld x31, PT_T6(sp)
 
 	ld	s0, (PT_SIZE_ON_STACK)(sp)
-	ld	ra, (PT_SIZE_ON_STACK+8)(sp)
 	addi	sp, sp, (PT_SIZE_ON_STACK+16)
 	.endm
 
-- 
2.7.4


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2020-07-13 23:40 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-13 23:39 [PATCH v3 0/7] riscv: Add k/uprobe supported guoren
2020-07-13 23:39 ` [PATCH v3 1/7] RISC-V: Implement ptrace regs and stack API guoren
2020-07-14 11:25   ` Masami Hiramatsu
2020-07-13 23:39 ` [PATCH v3 2/7] riscv: Fixup compile error BUILD_BUG_ON failed guoren
2020-07-13 23:39 ` guoren [this message]
2020-07-14 11:32   ` [PATCH v3 3/7] riscv: Fixup kprobes handler couldn't change pc Masami Hiramatsu
2020-08-14 22:36   ` Palmer Dabbelt
2020-08-17 12:47     ` Guo Ren
2020-07-13 23:39 ` [PATCH v3 4/7] riscv: Add kprobes supported guoren
2020-08-14 22:36   ` Palmer Dabbelt
2020-08-17 13:48     ` Guo Ren
2020-07-13 23:39 ` [PATCH v3 5/7] riscv: Add uprobes supported guoren
2020-07-13 23:39 ` [PATCH v3 6/7] riscv: Add KPROBES_ON_FTRACE supported guoren
2020-07-14 11:37   ` Masami Hiramatsu
2020-07-14 16:24     ` Guo Ren
2020-07-21 13:27       ` Masami Hiramatsu
2020-07-22  8:39         ` Guo Ren
2020-07-23 15:55           ` Masami Hiramatsu
2020-07-22 13:31         ` Guo Ren
2020-07-23 16:11           ` Masami Hiramatsu
2020-07-13 23:39 ` [PATCH v3 7/7] riscv: Add support for function error injection guoren
2020-07-14 11:43   ` Masami Hiramatsu
2020-07-14 11:23 ` [PATCH v3 0/7] riscv: Add k/uprobe supported Masami Hiramatsu
2020-07-15  6:45   ` Guo Ren

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=1594683562-68149-4-git-send-email-guoren@kernel.org \
    --to=guoren@kernel.org \
    --cc=anup@brainfault.org \
    --cc=bjorn.topel@gmail.com \
    --cc=greentime.hu@sifive.com \
    --cc=guoren@linux.alibaba.com \
    --cc=linux-csky@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=me@packi.ch \
    --cc=mhiramat@kernel.org \
    --cc=oleg@redhat.com \
    --cc=palmerdabbelt@google.com \
    --cc=paul.walmsley@sifive.com \
    --cc=zong.li@sifive.com \
    /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).