Linux-RISC-V Archive on lore.kernel.org
 help / color / Atom feed
* [RFC/RFT 0/2] RISC-V: kprobes/kretprobe support
@ 2018-11-13 19:58 me
  2018-11-13 19:58 ` Patrick Stählin
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: me @ 2018-11-13 19:58 UTC (permalink / raw)
  To: linux-riscv

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, back to index

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-13 19:58 [RFC/RFT 0/2] RISC-V: kprobes/kretprobe support me
2018-11-13 19:58 ` Patrick Stählin
2018-11-13 19:58 ` [RFC/RFT 1/2] RISC-V: Implement ptrace regs and stack API me
2018-11-13 19:58   ` Patrick Stählin
2018-11-13 19:58 ` [RFC/RFT 2/2] RISC-V: kprobes/kretprobe support me
2018-11-13 19:58   ` Patrick Stählin
2018-11-14  8:37   ` mhiramat
2018-11-14  8:37     ` Masami Hiramatsu
2018-11-14 15:49     ` mhiramat
2018-11-14 15:49       ` Masami Hiramatsu
2018-11-14 21:10       ` me
2018-11-14 21:10         ` Patrick Staehlin
2018-11-15  7:50         ` mhiramat
2018-11-15  7:50           ` Masami Hiramatsu
2018-11-14 20:52     ` me
2018-11-14 20:52       ` Patrick Staehlin
2018-11-15  8:41       ` mhiramat
2018-11-15  8:41         ` Masami Hiramatsu

Linux-RISC-V Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-riscv/0 linux-riscv/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-riscv linux-riscv/ https://lore.kernel.org/linux-riscv \
		linux-riscv@lists.infradead.org infradead-linux-riscv@archiver.kernel.org
	public-inbox-index linux-riscv


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-riscv


AGPL code for this site: git clone https://public-inbox.org/ public-inbox