From: Masami Hiramatsu <mhiramat@kernel.org>
To: David Long <dave.long@linaro.org>
Cc: "Pratyush Anand" <panand@redhat.com>,
"Mark Brown" <broonie@kernel.org>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Huang Shijie" <shijie.huang@arm.com>,
"James Morse" <james.morse@arm.com>,
"Marc Zyngier" <marc.zyngier@arm.com>,
"Sandeepa Prabhu" <sandeepa.s.prabhu@gmail.com>,
"Will Deacon" <will.deacon@arm.com>,
"William Cohen" <wcohen@redhat.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
"Steve Capper" <steve.capper@linaro.org>,
"Li Bin" <huawei.libin@huawei.com>,
"Adam Buchbinder" <adam.buchbinder@gmail.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Andrey Ryabinin" <ryabinin.a.a@gmail.com>,
"Ard Biesheuvel" <ard.biesheuvel@linaro.org>,
"Christoffer Dall" <christoffer.dall@linaro.org>,
"Daniel Thompson" <daniel.thompson@linaro.org>,
"Dave P Martin" <Dave.Martin@arm.com>,
"Jens Wiklander" <jens.wiklander@linaro.org>,
"Jisheng Zhang" <jszhang@marvell.com>,
"John Blackwood" <john.blackwood@ccur.com>,
"Mark Rutland" <mark.rutland@arm.com>,
"Petr Mladek" <pmladek@suse.com>,
"Robin Murphy" <robin.murphy@arm.com>,
"Suzuki K Poulose" <suzuki.poulose@arm.com>,
"Vladimir Murzin" <Vladimir.Murzin@arm.com>,
"Yang Shi" <yang.shi@linaro.org>,
"Zi Shen Lim" <zlim.lnx@gmail.com>,
"yalin wang" <yalin.wang2010@gmail.com>
Subject: Re: [PATCH v14 04/10] arm64: Kprobes with single stepping support
Date: Tue, 28 Jun 2016 16:25:22 +0900 [thread overview]
Message-ID: <20160628162522.ee8ec57e686d8dc80c265211@kernel.org> (raw)
In-Reply-To: <57713301.2020706@linaro.org>
On Mon, 27 Jun 2016 10:06:57 -0400
David Long <dave.long@linaro.org> wrote:
> On 06/27/2016 02:57 AM, Pratyush Anand wrote:
> > Hi David,
> >
> > On 26/06/2016:11:06:47 PM, David Long wrote:
> >> From: Sandeepa Prabhu <sandeepa.s.prabhu@gmail.com>
> >>
> >> Add support for basic kernel probes(kprobes) and jump probes
> >> (jprobes) for ARM64.
> >>
> >> Kprobes utilizes software breakpoint and single step debug
> >> exceptions supported on ARM v8.
> >>
> >> A software breakpoint is placed at the probe address to trap the
> >> kernel execution into the kprobe handler.
> >>
> >> ARM v8 supports enabling single stepping before the break exception
> >> return (ERET), with next PC in exception return address (ELR_EL1). The
> >> kprobe handler prepares an executable memory slot for out-of-line
> >> execution with a copy of the original instruction being probed, and
> >> enables single stepping. The PC is set to the out-of-line slot address
> >> before the ERET. With this scheme, the instruction is executed with the
> >> exact same register context except for the PC (and DAIF) registers.
> >>
> >> Debug mask (PSTATE.D) is enabled only when single stepping a recursive
> >> kprobe, e.g.: during kprobes reenter so that probed instruction can be
> >> single stepped within the kprobe handler -exception- context.
> >> The recursion depth of kprobe is always 2, i.e. upon probe re-entry,
> >> any further re-entry is prevented by not calling handlers and the case
> >> counted as a missed kprobe).
> >>
> >> Single stepping from the x-o-l slot has a drawback for PC-relative accesses
> >> like branching and symbolic literals access as the offset from the new PC
> >> (slot address) may not be ensured to fit in the immediate value of
> >> the opcode. Such instructions need simulation, so reject
> >> probing them.
> >>
> >> Instructions generating exceptions or cpu mode change are rejected
> >> for probing.
> >>
> >> Exclusive load/store instructions are rejected too. Additionally, the
> >> code is checked to see if it is inside an exclusive load/store sequence
> >> (code from Pratyush).
> >>
> >> System instructions are mostly enabled for stepping, except MSR/MRS
> >> accesses to "DAIF" flags in PSTATE, which are not safe for
> >> probing.
> >>
> >> Thanks to Steve Capper and Pratyush Anand for several suggested
> >> Changes.
> >>
> >> Signed-off-by: Sandeepa Prabhu <sandeepa.s.prabhu@gmail.com>
> >> Signed-off-by: David A. Long <dave.long@linaro.org>
> >> Signed-off-by: Pratyush Anand <panand@redhat.com>
> >> ---
> >> arch/arm64/Kconfig | 1 +
> >> arch/arm64/include/asm/debug-monitors.h | 5 +
> >> arch/arm64/include/asm/insn.h | 2 +
> >> arch/arm64/include/asm/kprobes.h | 60 ++++
> >> arch/arm64/include/asm/probes.h | 34 +++
> >> arch/arm64/include/asm/ptrace.h | 1 +
> >> arch/arm64/kernel/Makefile | 2 +-
> >> arch/arm64/kernel/debug-monitors.c | 16 +-
> >> arch/arm64/kernel/kprobes/Makefile | 1 +
> >> arch/arm64/kernel/kprobes/decode-insn.c | 143 +++++++++
> >> arch/arm64/kernel/kprobes/decode-insn.h | 34 +++
> >> arch/arm64/kernel/kprobes/kprobes.c | 525 ++++++++++++++++++++++++++++++++
> >> arch/arm64/kernel/vmlinux.lds.S | 1 +
> >> arch/arm64/mm/fault.c | 26 ++
> >> 14 files changed, 848 insertions(+), 3 deletions(-)
> >> create mode 100644 arch/arm64/include/asm/kprobes.h
> >> create mode 100644 arch/arm64/include/asm/probes.h
> >> create mode 100644 arch/arm64/kernel/kprobes/Makefile
> >> create mode 100644 arch/arm64/kernel/kprobes/decode-insn.c
> >> create mode 100644 arch/arm64/kernel/kprobes/decode-insn.h
> >
> > Can we rename kernel/kprobes as kernel/probes? uprobes code will use
> > decode-insn.c and further simulate-insn.c as well. So, I would like to place my
> > uprobes.c in same directory.
>
> I had some reservations about making it a "kprobes" subdir for that
> reason but the advice I got was to simply go with Masami Hiramatsu's
> specific feedback and have a subsequent uprobes patch move these files
> to a replacement "probes" subdir. If there ends up being yet another
> revision of this patch maybe he will consider allowing it to be called
> "probes" from the start.
Yeah, if you've already been sure it will be done,
I'm OK to rename it "probe" :) I just didn't know your work.
>
> >
> >> create mode 100644 arch/arm64/kernel/kprobes/kprobes.c
> >>
> >
> > [...]
> >
> >> diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
> >> index 6c0c7d3..c7bbeed 100644
> >> --- a/arch/arm64/include/asm/ptrace.h
> >> +++ b/arch/arm64/include/asm/ptrace.h
> >> @@ -209,6 +209,7 @@ struct task_struct;
> >> int valid_user_regs(struct user_pt_regs *regs, struct task_struct *task);
> >>
> >> #define instruction_pointer(regs) ((unsigned long)(regs)->pc)
> >> +#define instruction_pointer_set(regs, value) ((regs)->pc = ((u64) (value)))
> >
> > IIRC, Will Daecon had asked to include asm-generic/ptrace.h into asm/ptrace.h when
> > I had done similar changes for uprobe needs. May be you can pick patch from
> > my uprobe tree.
Ah, right. we have something similar routines in asm-generic/ptrace.h.
Feel free to include it.
Thanks,
> >
> > https://github.com/pratyushanand/linux/commit/bb3e114797c2888ed8ad528cca20e569dd2d818e
>
> I will look at this.
>
> >
> > ~Pratyush
> >
>
> Thanks,
> -dl
>
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2016-06-28 7:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-27 3:06 [PATCH v14 00/10] arm64: Add kernel probes (kprobes) support David Long
2016-06-27 3:06 ` [PATCH v14 01/10] arm64: Add HAVE_REGS_AND_STACK_ACCESS_API feature David Long
2016-06-27 3:06 ` [PATCH v14 02/10] arm64: Add more test functions to insn.c David Long
2016-06-27 3:06 ` [PATCH v14 03/10] arm64: add conditional instruction simulation support David Long
2016-06-27 3:06 ` [PATCH v14 04/10] arm64: Kprobes with single stepping support David Long
2016-06-27 6:57 ` Pratyush Anand
2016-06-27 14:06 ` David Long
2016-06-28 7:25 ` Masami Hiramatsu [this message]
2016-06-27 3:06 ` [PATCH v14 05/10] arm64: Blacklist non-kprobe-able symbol David Long
2016-06-27 3:06 ` [PATCH v14 06/10] arm64: Treat all entry code as non-kprobe-able David Long
2016-06-27 3:06 ` [PATCH v14 07/10] arm64: kprobes instruction simulation support David Long
2016-06-27 3:06 ` [PATCH v14 08/10] arm64: Add trampoline code for kretprobes David Long
2016-06-27 3:06 ` [PATCH v14 09/10] arm64: Add kernel return probes support (kretprobes) David Long
2016-06-27 3:06 ` [PATCH v14 10/10] kprobes: Add arm64 case in kprobe example module David Long
2016-06-28 7:31 ` [PATCH v14 00/10] arm64: Add kernel probes (kprobes) support Masami Hiramatsu
2016-06-28 8:13 ` Huang Shijie
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=20160628162522.ee8ec57e686d8dc80c265211@kernel.org \
--to=mhiramat@kernel.org \
--cc=Dave.Martin@arm.com \
--cc=Vladimir.Murzin@arm.com \
--cc=adam.buchbinder@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alex.bennee@linaro.org \
--cc=ard.biesheuvel@linaro.org \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=christoffer.dall@linaro.org \
--cc=daniel.thompson@linaro.org \
--cc=dave.long@linaro.org \
--cc=huawei.libin@huawei.com \
--cc=james.morse@arm.com \
--cc=jens.wiklander@linaro.org \
--cc=john.blackwood@ccur.com \
--cc=jszhang@marvell.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=mark.rutland@arm.com \
--cc=panand@redhat.com \
--cc=pmladek@suse.com \
--cc=robin.murphy@arm.com \
--cc=ryabinin.a.a@gmail.com \
--cc=sandeepa.s.prabhu@gmail.com \
--cc=shijie.huang@arm.com \
--cc=steve.capper@linaro.org \
--cc=suzuki.poulose@arm.com \
--cc=wcohen@redhat.com \
--cc=will.deacon@arm.com \
--cc=yalin.wang2010@gmail.com \
--cc=yang.shi@linaro.org \
--cc=zlim.lnx@gmail.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
Powered by JetHome