From: me@packi.ch (Patrick Stählin) To: linux-riscv@lists.infradead.org Subject: [RFC/RFT 0/2] RISC-V: kprobes/kretprobe support Date: Tue, 13 Nov 2018 20:58:02 +0100 [thread overview] Message-ID: <20181113195804.22825-1-me@packi.ch> (raw) Hi, this is first version of kprobes/kretprobe support for RISC-V. Most of the code is based on arm64 but obviously without the single-step functionality. It will insert a C.EBREAK instruction that is later being captured. The only instruction supported at the moment is C.ADDISP16 as this sets-up the stack frames for all the functions I've tested. I've tested this on QEMU with multiple CPUs but don't have any real hardware available for testing, and from experience that's when things start breaking. The plan is to expand compressed instructions to full ones and simulate those to reduce the decoding overhead per intercepted call. Please let me know if you have any objections to path I've chosen and which instructions you absolutely need for a first version. To enable this you need the following defines: CONFIG_FUNCTION_TRACER=y CONFIG_KPROBES=y CONFIG_MODULES=y The CONFIG_FUNCTION_TRACER is not strictly needed but makes testing easier using debugfs. After that, any example documented in Documentation/trace/kprobetrace.rst should work. Patrick St?hlin (2): RISC-V: Implement ptrace regs and stack API RISC-V: kprobes/kretprobe support arch/riscv/Kconfig | 6 +- arch/riscv/include/asm/kprobes.h | 30 ++ arch/riscv/include/asm/probes.h | 26 ++ arch/riscv/include/asm/ptrace.h | 34 ++ arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/probes/Makefile | 3 + arch/riscv/kernel/probes/decode-insn.c | 38 ++ arch/riscv/kernel/probes/decode-insn.h | 23 + arch/riscv/kernel/probes/kprobes.c | 401 ++++++++++++++++++ arch/riscv/kernel/probes/kprobes_trampoline.S | 91 ++++ arch/riscv/kernel/probes/simulate-insn.c | 33 ++ arch/riscv/kernel/probes/simulate-insn.h | 8 + arch/riscv/kernel/ptrace.c | 99 +++++ arch/riscv/kernel/traps.c | 13 +- arch/riscv/mm/fault.c | 28 +- 15 files changed, 828 insertions(+), 6 deletions(-) create mode 100644 arch/riscv/include/asm/probes.h create mode 100644 arch/riscv/kernel/probes/Makefile create mode 100644 arch/riscv/kernel/probes/decode-insn.c create mode 100644 arch/riscv/kernel/probes/decode-insn.h create mode 100644 arch/riscv/kernel/probes/kprobes.c create mode 100644 arch/riscv/kernel/probes/kprobes_trampoline.S create mode 100644 arch/riscv/kernel/probes/simulate-insn.c create mode 100644 arch/riscv/kernel/probes/simulate-insn.h -- 2.17.1
WARNING: multiple messages have this Message-ID (diff)
From: "Patrick Stählin" <me@packi.ch> To: linux-riscv@lists.infradead.org Cc: "Patrick Stählin" <me@packi.ch>, "Palmer Dabbelt" <palmer@sifive.com>, linux-kernel@vger.kernel.org, "Albert Ou" <aou@eecs.berkeley.edu> Subject: [RFC/RFT 0/2] RISC-V: kprobes/kretprobe support Date: Tue, 13 Nov 2018 20:58:02 +0100 [thread overview] Message-ID: <20181113195804.22825-1-me@packi.ch> (raw) Message-ID: <20181113195802.H18eKLkopFS0xoFYFe4mwWRxrp7OrZX0Uho5ZktPUrU@z> (raw) Hi, this is first version of kprobes/kretprobe support for RISC-V. Most of the code is based on arm64 but obviously without the single-step functionality. It will insert a C.EBREAK instruction that is later being captured. The only instruction supported at the moment is C.ADDISP16 as this sets-up the stack frames for all the functions I've tested. I've tested this on QEMU with multiple CPUs but don't have any real hardware available for testing, and from experience that's when things start breaking. The plan is to expand compressed instructions to full ones and simulate those to reduce the decoding overhead per intercepted call. Please let me know if you have any objections to path I've chosen and which instructions you absolutely need for a first version. To enable this you need the following defines: CONFIG_FUNCTION_TRACER=y CONFIG_KPROBES=y CONFIG_MODULES=y The CONFIG_FUNCTION_TRACER is not strictly needed but makes testing easier using debugfs. After that, any example documented in Documentation/trace/kprobetrace.rst should work. Patrick Stählin (2): RISC-V: Implement ptrace regs and stack API RISC-V: kprobes/kretprobe support arch/riscv/Kconfig | 6 +- arch/riscv/include/asm/kprobes.h | 30 ++ arch/riscv/include/asm/probes.h | 26 ++ arch/riscv/include/asm/ptrace.h | 34 ++ arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/probes/Makefile | 3 + arch/riscv/kernel/probes/decode-insn.c | 38 ++ arch/riscv/kernel/probes/decode-insn.h | 23 + arch/riscv/kernel/probes/kprobes.c | 401 ++++++++++++++++++ arch/riscv/kernel/probes/kprobes_trampoline.S | 91 ++++ arch/riscv/kernel/probes/simulate-insn.c | 33 ++ arch/riscv/kernel/probes/simulate-insn.h | 8 + arch/riscv/kernel/ptrace.c | 99 +++++ arch/riscv/kernel/traps.c | 13 +- arch/riscv/mm/fault.c | 28 +- 15 files changed, 828 insertions(+), 6 deletions(-) create mode 100644 arch/riscv/include/asm/probes.h create mode 100644 arch/riscv/kernel/probes/Makefile create mode 100644 arch/riscv/kernel/probes/decode-insn.c create mode 100644 arch/riscv/kernel/probes/decode-insn.h create mode 100644 arch/riscv/kernel/probes/kprobes.c create mode 100644 arch/riscv/kernel/probes/kprobes_trampoline.S create mode 100644 arch/riscv/kernel/probes/simulate-insn.c create mode 100644 arch/riscv/kernel/probes/simulate-insn.h -- 2.17.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv
next reply other threads:[~2018-11-13 19:58 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-11-13 19:58 Patrick Stählin [this message] 2018-11-13 19:58 ` [RFC/RFT 0/2] RISC-V: kprobes/kretprobe support Patrick Stählin 2018-11-13 19:58 ` [RFC/RFT 1/2] RISC-V: Implement ptrace regs and stack API Patrick Stählin 2018-11-13 19:58 ` Patrick Stählin 2019-11-21 22:34 ` Paul Walmsley 2018-11-13 19:58 ` [RFC/RFT 2/2] RISC-V: kprobes/kretprobe support Patrick Stählin 2018-11-13 19:58 ` Patrick Stählin 2018-11-14 8:37 ` Masami Hiramatsu 2018-11-14 8:37 ` Masami Hiramatsu 2018-11-14 15:49 ` Masami Hiramatsu 2018-11-14 15:49 ` Masami Hiramatsu 2018-11-14 21:10 ` Patrick Staehlin 2018-11-14 21:10 ` Patrick Staehlin 2018-11-15 7:50 ` Masami Hiramatsu 2018-11-15 7:50 ` Masami Hiramatsu 2019-12-20 11:14 ` Paul Walmsley 2019-12-20 22:46 ` Paul Walmsley 2018-11-14 20:52 ` Patrick Staehlin 2018-11-14 20:52 ` Patrick Staehlin 2018-11-15 8:41 ` Masami Hiramatsu 2018-11-15 8:41 ` Masami Hiramatsu [not found] ` <CANXhq0qWwKRrz80Q3LSeQu-cH19otCF1my6dDGDxH0Q5j1RYYw@mail.gmail.com> [not found] ` <9cdd84b5-6c81-9bfa-5d35-6645f542f71e@packi.ch> 2019-12-19 9:28 ` Zong Li 2020-03-31 2:45 ` Zong Li 2020-06-12 5:57 ` David Abdurachmanov 2020-06-17 12:58 ` Guo Ren 2020-06-17 14:54 ` Masami Hiramatsu 2020-06-18 16:14 ` Guo Ren 2020-07-05 14:57 ` 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=20181113195804.22825-1-me@packi.ch \ --to=me@packi.ch \ --cc=linux-riscv@lists.infradead.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: linkBe 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).