Commit 2e5003f2 authored by Martin Schwidefsky's avatar Martin Schwidefsky Committed by Linus Torvalds

[PATCH] s390: ptrace.

Fix ptrace system call number replacement code.
parent a214c047
...@@ -267,7 +267,7 @@ sysc_tracesys: ...@@ -267,7 +267,7 @@ sysc_tracesys:
st %r7,SP_R2(%r15) st %r7,SP_R2(%r15)
basr %r14,%r1 basr %r14,%r1
clc SP_R2(4,%r15),BASED(.Lnr_syscalls) clc SP_R2(4,%r15),BASED(.Lnr_syscalls)
bl BASED(sysc_tracego) bnl BASED(sysc_tracenogo)
l %r7,SP_R2(%r15) # strace might have changed the l %r7,SP_R2(%r15) # strace might have changed the
sll %r7,2 # system call sll %r7,2 # system call
l %r8,sys_call_table-entry_base(%r7,%r13) l %r8,sys_call_table-entry_base(%r7,%r13)
...@@ -276,6 +276,7 @@ sysc_tracego: ...@@ -276,6 +276,7 @@ sysc_tracego:
l %r2,SP_ORIG_R2(%r15) l %r2,SP_ORIG_R2(%r15)
basr %r14,%r8 # call sys_xxx basr %r14,%r8 # call sys_xxx
st %r2,SP_R2(%r15) # store return value st %r2,SP_R2(%r15) # store return value
sysc_tracenogo:
tm __TI_flags+3(%r9),_TIF_SYSCALL_TRACE tm __TI_flags+3(%r9),_TIF_SYSCALL_TRACE
bno BASED(sysc_return) bno BASED(sysc_return)
l %r1,BASED(.Ltrace) l %r1,BASED(.Ltrace)
...@@ -486,7 +487,7 @@ pgm_tracesys: ...@@ -486,7 +487,7 @@ pgm_tracesys:
st %r7,SP_R2(%r15) st %r7,SP_R2(%r15)
basr %r14,%r1 basr %r14,%r1
clc SP_R2(4,%r15),BASED(.Lnr_syscalls) clc SP_R2(4,%r15),BASED(.Lnr_syscalls)
bl BASED(pgm_svc_go) bnl BASED(pgm_svc_nogo)
l %r7,SP_R2(%r15) # strace changed the syscall l %r7,SP_R2(%r15) # strace changed the syscall
sll %r7,2 sll %r7,2
l %r8,sys_call_table-entry_base(%r7,%r13) l %r8,sys_call_table-entry_base(%r7,%r13)
...@@ -495,6 +496,7 @@ pgm_svc_go: ...@@ -495,6 +496,7 @@ pgm_svc_go:
l %r2,SP_ORIG_R2(%r15) l %r2,SP_ORIG_R2(%r15)
basr %r14,%r8 # call sys_xxx basr %r14,%r8 # call sys_xxx
st %r2,SP_R2(%r15) # store return value st %r2,SP_R2(%r15) # store return value
pgm_svc_nogo:
tm __TI_flags+3(%r9),_TIF_SYSCALL_TRACE tm __TI_flags+3(%r9),_TIF_SYSCALL_TRACE
bno BASED(pgm_svcret) bno BASED(pgm_svcret)
l %r1,BASED(.Ltrace) l %r1,BASED(.Ltrace)
......
...@@ -254,7 +254,7 @@ sysc_tracesys: ...@@ -254,7 +254,7 @@ sysc_tracesys:
brasl %r14,syscall_trace brasl %r14,syscall_trace
larl %r1,.Lnr_syscalls larl %r1,.Lnr_syscalls
clc SP_R2(8,%r15),0(%r1) clc SP_R2(8,%r15),0(%r1)
jl sysc_tracego jnl sysc_tracenogo
lg %r7,SP_R2(%r15) # strace might have changed the lg %r7,SP_R2(%r15) # strace might have changed the
sll %r7,2 # system call sll %r7,2 # system call
lgf %r8,0(%r7,%r10) lgf %r8,0(%r7,%r10)
...@@ -263,6 +263,7 @@ sysc_tracego: ...@@ -263,6 +263,7 @@ sysc_tracego:
lg %r2,SP_ORIG_R2(%r15) lg %r2,SP_ORIG_R2(%r15)
basr %r14,%r8 # call sys_xxx basr %r14,%r8 # call sys_xxx
stg %r2,SP_R2(%r15) # store return value stg %r2,SP_R2(%r15) # store return value
sysc_tracenogo:
tm __TI_flags+7(%r9),_TIF_SYSCALL_TRACE tm __TI_flags+7(%r9),_TIF_SYSCALL_TRACE
jno sysc_return jno sysc_return
larl %r14,sysc_return # return point is sysc_return larl %r14,sysc_return # return point is sysc_return
...@@ -481,7 +482,7 @@ pgm_per_only: ...@@ -481,7 +482,7 @@ pgm_per_only:
# #
pgm_svcper: pgm_svcper:
SAVE_ALL __LC_SVC_OLD_PSW,1 SAVE_ALL __LC_SVC_OLD_PSW,1
llgh %r8,__LC_SVC_INT_CODE # get svc number from lowcore llgh %r7,__LC_SVC_INT_CODE # get svc number from lowcore
stosm 48(%r15),0x03 # reenable interrupts stosm 48(%r15),0x03 # reenable interrupts
GET_THREAD_INFO # load pointer to task_struct to R9 GET_THREAD_INFO # load pointer to task_struct to R9
slag %r7,%r7,2 # *4 and test for svc 0 slag %r7,%r7,2 # *4 and test for svc 0
...@@ -490,15 +491,15 @@ pgm_svcper: ...@@ -490,15 +491,15 @@ pgm_svcper:
clg %r1,.Lnr_syscalls-.Lconst(%r14) clg %r1,.Lnr_syscalls-.Lconst(%r14)
slag %r7,%r1,2 slag %r7,%r1,2
pgm_svcstd: pgm_svcstd:
larl %r7,sys_call_table larl %r10,sys_call_table
#ifdef CONFIG_S390_SUPPORT #ifdef CONFIG_S390_SUPPORT
tm SP_PSW+3(%r15),0x01 # are we running in 31 bit mode ? tm SP_PSW+3(%r15),0x01 # are we running in 31 bit mode ?
jo pgm_svcper_noemu jo pgm_svcper_noemu
larl %r7,sys_call_table_emu # use 31 bit emulation system calls larl %r10,sys_call_table_emu # use 31 bit emulation system calls
pgm_svcper_noemu: pgm_svcper_noemu:
#endif #endif
tm __TI_flags+3(%r9),_TIF_SYSCALL_TRACE tm __TI_flags+3(%r9),_TIF_SYSCALL_TRACE
lgf %r8,0(%r8,%r7) # load address of system call routine lgf %r8,0(%r7,%r10) # load address of system call routine
jo pgm_tracesys jo pgm_tracesys
basr %r14,%r8 # call sys_xxxx basr %r14,%r8 # call sys_xxxx
stg %r2,SP_R2(%r15) # store return value (change R2 on stack) stg %r2,SP_R2(%r15) # store return value (change R2 on stack)
...@@ -522,19 +523,20 @@ pgm_svcper_nosig: ...@@ -522,19 +523,20 @@ pgm_svcper_nosig:
# call trace before and after sys_call # call trace before and after sys_call
# #
pgm_tracesys: pgm_tracesys:
lgfr %r7,%r7 srlg %r7,%r7,2
stg %r7,SP_R2(%r15) stg %r7,SP_R2(%r15)
brasl %r14,syscall_trace brasl %r14,syscall_trace
clc SP_R2(8,%r15),.Lnr_syscalls clc SP_R2(8,%r15),.Lnr_syscalls
jnl pgm_svc_go jnl pgm_svc_nogo
lg %r2,SP_R2(%r15) lg %r7,SP_R2(%r15)
sllg %r2,%r2,3 # strace wants to change the syscall sllg %r7,%r7,2 # strace wants to change the syscall
lgf %r8,0(%r2,%r7) lgf %r8,0(%r7,%r10)
pgm_svc_go: pgm_svc_go:
lmg %r3,%r6,SP_R3(%r15) lmg %r3,%r6,SP_R3(%r15)
lg %r2,SP_ORIG_R2(%r15) lg %r2,SP_ORIG_R2(%r15)
basr %r14,%r8 # call sys_xxx basr %r14,%r8 # call sys_xxx
stg %r2,SP_R2(%r15) # store return value stg %r2,SP_R2(%r15) # store return value
pgm_svc_nogo:
tm __TI_flags+7(%r9),_TIF_SYSCALL_TRACE tm __TI_flags+7(%r9),_TIF_SYSCALL_TRACE
jno pgm_svcret jno pgm_svcret
larl %r14,pgm_svcret # return point is sysc_return larl %r14,pgm_svcret # return point is sysc_return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment