Skip to content

Commit 4ba069b

Browse files
Michael GrundyMartin Schwidefsky
authored andcommitted
[S390] add kprobes support.
Signed-off-by: Michael Grundy <[email protected]> Signed-off-by: David Wilder <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent 5432114 commit 4ba069b

File tree

10 files changed

+937
-4
lines changed

10 files changed

+937
-4
lines changed

arch/s390/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,22 @@ source "drivers/net/Kconfig"
487487

488488
source "fs/Kconfig"
489489

490+
menu "Instrumentation Support"
491+
490492
source "arch/s390/oprofile/Kconfig"
491493

494+
config KPROBES
495+
bool "Kprobes (EXPERIMENTAL)"
496+
depends on EXPERIMENTAL && MODULES
497+
help
498+
Kprobes allows you to trap at almost any kernel address and
499+
execute a callback function. register_kprobe() establishes
500+
a probepoint and specifies the callback. Kprobes is useful
501+
for kernel debugging, non-intrusive instrumentation and testing.
502+
If in doubt, say "N".
503+
504+
endmenu
505+
492506
source "arch/s390/Kconfig.debug"
493507

494508
source "security/Kconfig"

arch/s390/kernel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ obj-$(CONFIG_COMPAT) += compat_linux.o compat_signal.o \
2424

2525
obj-$(CONFIG_VIRT_TIMER) += vtime.o
2626
obj-$(CONFIG_STACKTRACE) += stacktrace.o
27+
obj-$(CONFIG_KPROBES) += kprobes.o
2728

2829
# Kexec part
2930
S390_KEXEC_OBJS := machine_kexec.o crash.o

arch/s390/kernel/entry.S

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ pgm_no_vtime2:
505505
mvc __THREAD_per+__PER_address(4,%r1),__LC_PER_ADDRESS
506506
mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
507507
oi __TI_flags+3(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
508+
tm SP_PSW+1(%r15),0x01 # kernel per event ?
509+
bz BASED(kernel_per)
508510
l %r3,__LC_PGM_ILC # load program interruption code
509511
la %r8,0x7f
510512
nr %r8,%r3 # clear per-event-bit and ilc
@@ -536,6 +538,16 @@ pgm_no_vtime3:
536538
stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
537539
b BASED(sysc_do_svc)
538540

541+
#
542+
# per was called from kernel, must be kprobes
543+
#
544+
kernel_per:
545+
mvi SP_TRAP+1(%r15),0x28 # set trap indication to pgm check
546+
la %r2,SP_PTREGS(%r15) # address of register-save area
547+
l %r1,BASED(.Lhandle_per) # load adr. of per handler
548+
la %r14,BASED(sysc_leave) # load adr. of system return
549+
br %r1 # branch to do_single_step
550+
539551
/*
540552
* IO interrupt handler routine
541553
*/

arch/s390/kernel/entry64.S

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,8 @@ pgm_no_vtime2:
518518
#endif
519519
lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
520520
lg %r1,__TI_task(%r9)
521+
tm SP_PSW+1(%r15),0x01 # kernel per event ?
522+
jz kernel_per
521523
mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
522524
mvc __THREAD_per+__PER_address(8,%r1),__LC_PER_ADDRESS
523525
mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
@@ -553,6 +555,16 @@ pgm_no_vtime3:
553555
stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
554556
j sysc_do_svc
555557

558+
#
559+
# per was called from kernel, must be kprobes
560+
#
561+
kernel_per:
562+
lhi %r0,__LC_PGM_OLD_PSW
563+
sth %r0,SP_TRAP(%r15) # set trap indication to pgm check
564+
la %r2,SP_PTREGS(%r15) # address of register-save area
565+
larl %r14,sysc_leave # load adr. of system ret, no work
566+
jg do_single_step # branch to do_single_step
567+
556568
/*
557569
* IO interrupt handler routine
558570
*/

0 commit comments

Comments
 (0)