This patchset adds support for basic kernel probes(kprobes), jump probes(jprobes)
and return probes(kretprobes) support for AArch64.
This kprobes mechanism make use of software breakpoint and single stepping
support available in ARM v8 kernel.
Basic verification is done with sample test modules available as part of
"samples/kprobes/" running on ARM v8 fast model (RTSM).
Patch 1 (AArch64-Add-single-step-and-breakpoint-handler-hooks.patch) is v3 version of:
http://permalink.gmane.org/gmane.linux.ports.arm.kernel/269733
Changes:
v2 -> v3
- Renamed break_lock to break_hook_lock
- Use rcu protected list traversal for step_hook
- eliminated addr argument for debug hooks, now callback functions shall extract address from pt_regs instead.
- refined entry.S changes only to handler 'BRK64' esr value.
Patch 2 (arm64-Kernel-code-patching-support.patch) implement basic code patching support needed for kprobes.
Similar api is published earlier on LKML/LAKML as part of jump label support: https://lkml.org/lkml/2013/9/25/250
However, for kprobes some changes required with that version, can rebase on new version of patch from Jiang.
Sandeepa Prabhu (5):
AArch64: Add single-step and breakpoint handler hooks
arm64: Kernel code patching support
AArch64: Instruction simulation and decode support
AArch64: Add Kprobes support for ARM v8 kernel
AArch64: Support kretprobe support for ARM v8
arch/arm64/Kconfig | 2 +
arch/arm64/include/asm/debug-monitors.h | 23 ++
arch/arm64/include/asm/kprobes.h | 58 +++
arch/arm64/include/asm/probes.h | 48 +++
arch/arm64/include/asm/ptrace.h | 6 +
arch/arm64/kernel/Makefile | 2 +
arch/arm64/kernel/debug-monitors.c | 85 ++++-
arch/arm64/kernel/entry.S | 2 +
arch/arm64/kernel/kprobes-arm64.c | 245 ++++++++++++
arch/arm64/kernel/kprobes-arm64.h | 26 ++
arch/arm64/kernel/kprobes.c | 642 ++++++++++++++++++++++++++++++++
arch/arm64/kernel/kprobes.h | 28 ++
arch/arm64/kernel/patch.c | 58 +++
arch/arm64/kernel/patch.h | 20 +
arch/arm64/kernel/probes-aarch64.c | 235 ++++++++++++
arch/arm64/kernel/probes-aarch64.h | 127 +++++++
arch/arm64/kernel/probes-common.c | 117 ++++++
arch/arm64/kernel/vmlinux.lds.S | 1 +
18 files changed, 1722 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-arm64.c
create mode 100644 arch/arm64/kernel/kprobes-arm64.h
create mode 100644 arch/arm64/kernel/kprobes.c
create mode 100644 arch/arm64/kernel/kprobes.h
create mode 100644 arch/arm64/kernel/patch.c
create mode 100644 arch/arm64/kernel/patch.h
create mode 100644 arch/arm64/kernel/probes-aarch64.c
create mode 100644 arch/arm64/kernel/probes-aarch64.h
create mode 100644 arch/arm64/kernel/probes-common.c
--
1.8.1.2
The sleep_length is computed in the tick_nohz_stop_sched_tick function but it
is used later in the code with in between the local irq enabled.
cpu_idle_loop
tick_nohz_idle_enter [ exits with local irq enabled ]
__tick_nohz_idle_enter
tick_nohz_stop_sched_tick
...
arch_cpu_idle
menu_select [ uses here 'sleep_length' ]
...
Between the computation of the sleep length and its usage, some interrupts
may occur, making the sleep length shorter than actually it is because of the
interrupt processing, or different if the timer itself expired.
This patch fixes that by moving the sleep_length computation in the
tick_nohz_get_sleep_length function and using the tick device's next_event.
As the sleep_length field is no longer needed, it is removed from the
tick_sched structure.
Signed-off-by: Daniel Lezcano <daniel.lezcano(a)linaro.org>
Signed-off-by: Stephen Boyd <sboyd(a)codeaurora.org>
---
include/linux/tick.h | 2 --
kernel/time/tick-sched.c | 5 +++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/include/linux/tick.h b/include/linux/tick.h
index 5128d33..53dbbd7 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -48,7 +48,6 @@ enum tick_nohz_mode {
* @idle_exittime: Time when the idle state was left
* @idle_sleeptime: Sum of the time slept in idle with sched tick stopped
* @iowait_sleeptime: Sum of the time slept in idle with sched tick stopped, with IO outstanding
- * @sleep_length: Duration of the current idle sleep
* @do_timer_lst: CPU was the last one doing do_timer before going idle
*/
struct tick_sched {
@@ -67,7 +66,6 @@ struct tick_sched {
ktime_t idle_exittime;
ktime_t idle_sleeptime;
ktime_t iowait_sleeptime;
- ktime_t sleep_length;
unsigned long last_jiffies;
unsigned long next_jiffies;
ktime_t idle_expires;
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 3612fc7..60b1dcd 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -673,7 +673,6 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,
out:
ts->next_jiffies = next_jiffies;
ts->last_jiffies = last_jiffies;
- ts->sleep_length = ktime_sub(dev->next_event, now);
return ret;
}
@@ -837,8 +836,10 @@ void tick_nohz_irq_exit(void)
ktime_t tick_nohz_get_sleep_length(void)
{
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
+ struct clock_event_device *dev = __get_cpu_var(tick_cpu_device).evtdev;
+ ktime_t now = ktime_get();
- return ts->sleep_length;
+ return ktime_sub(dev->next_event, now);
}
static void tick_nohz_restart(struct tick_sched *ts, ktime_t now)
--
1.7.9.5