Skip to content

Commit f14488c

Browse files
Shaohua Liaegl
authored andcommitted
[IA64] utrace use generic trace hook
Make IA64 use generic trace hook in some paths. Signed-off-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
1 parent cfb361f commit f14488c

7 files changed

Lines changed: 41 additions & 55 deletions

File tree

‎arch/ia64/ia32/ia32_entry.S‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ GLOBAL_ENTRY(ia32_trace_syscall)
108108
;;
109109
st8 [r2]=r3 // initialize return code to -ENOSYS
110110
br.call.sptk.few rp=syscall_trace_enter // give parent a chance to catch syscall args
111+
cmp.lt p6,p0=r8,r0 // check tracehook
112+
adds r2=IA64_PT_REGS_R8_OFFSET+16,sp // r2 = &pt_regs.r8
113+
;;
114+
(p6) st8.spill [r2]=r8 // store return value in slot for r8
115+
(p6) br.spnt.few .ret4
111116
.ret2: // Need to reload arguments (they may be changed by the tracing process)
112117
adds r2=IA64_PT_REGS_R1_OFFSET+16,sp // r2 = &pt_regs.r1
113118
adds r3=IA64_PT_REGS_R13_OFFSET+16,sp // r3 = &pt_regs.r13

‎arch/ia64/include/asm/thread_info.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ struct thread_info {
8787
#define alloc_task_struct() ((struct task_struct *)__get_free_pages(GFP_KERNEL | __GFP_COMP, KERNEL_STACK_SIZE_ORDER))
8888
#define free_task_struct(tsk) free_pages((unsigned long) (tsk), KERNEL_STACK_SIZE_ORDER)
8989

90-
#define tsk_set_notify_resume(tsk) \
91-
set_ti_thread_flag(task_thread_info(tsk), TIF_NOTIFY_RESUME)
92-
extern void tsk_clear_notify_resume(struct task_struct *tsk);
9390
#endif /* !__ASSEMBLY */
9491

9592
/*

‎arch/ia64/kernel/entry.S‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,11 @@ GLOBAL_ENTRY(ia64_trace_syscall)
534534
stf.spill [r16]=f10
535535
stf.spill [r17]=f11
536536
br.call.sptk.many rp=syscall_trace_enter // give parent a chance to catch syscall args
537+
cmp.lt p6,p0=r8,r0 // check tracehook
538+
adds r2=PT(R8)+16,sp // r2 = &pt_regs.r8
539+
adds r3=PT(R10)+16,sp // r3 = &pt_regs.r10
540+
mov r10=0
541+
(p6) br.cond.sptk strace_error // syscall failed ->
537542
adds r16=PT(F6)+16,sp
538543
adds r17=PT(F7)+16,sp
539544
;;

‎arch/ia64/kernel/perfmon.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <linux/capability.h>
4141
#include <linux/rcupdate.h>
4242
#include <linux/completion.h>
43+
#include <linux/tracehook.h>
4344

4445
#include <asm/errno.h>
4546
#include <asm/intrinsics.h>
@@ -3684,7 +3685,7 @@ pfm_restart(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
36843685

36853686
PFM_SET_WORK_PENDING(task, 1);
36863687

3687-
tsk_set_notify_resume(task);
3688+
set_notify_resume(task);
36883689

36893690
/*
36903691
* XXX: send reschedule if task runs on another CPU
@@ -5044,8 +5045,6 @@ pfm_handle_work(void)
50445045

50455046
PFM_SET_WORK_PENDING(current, 0);
50465047

5047-
tsk_clear_notify_resume(current);
5048-
50495048
regs = task_pt_regs(current);
50505049

50515050
/*
@@ -5414,7 +5413,7 @@ pfm_overflow_handler(struct task_struct *task, pfm_context_t *ctx, u64 pmc0, str
54145413
* when coming from ctxsw, current still points to the
54155414
* previous task, therefore we must work with task and not current.
54165415
*/
5417-
tsk_set_notify_resume(task);
5416+
set_notify_resume(task);
54185417
}
54195418
/*
54205419
* defer until state is changed (shorten spin window). the context is locked

‎arch/ia64/kernel/process.c‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/delay.h>
2929
#include <linux/kdebug.h>
3030
#include <linux/utsname.h>
31+
#include <linux/tracehook.h>
3132

3233
#include <asm/cpu.h>
3334
#include <asm/delay.h>
@@ -160,21 +161,6 @@ show_regs (struct pt_regs *regs)
160161
show_stack(NULL, NULL);
161162
}
162163

163-
void tsk_clear_notify_resume(struct task_struct *tsk)
164-
{
165-
#ifdef CONFIG_PERFMON
166-
if (tsk->thread.pfm_needs_checking)
167-
return;
168-
#endif
169-
if (test_ti_thread_flag(task_thread_info(tsk), TIF_RESTORE_RSE))
170-
return;
171-
clear_ti_thread_flag(task_thread_info(tsk), TIF_NOTIFY_RESUME);
172-
}
173-
174-
/*
175-
* do_notify_resume_user():
176-
* Called from notify_resume_user at entry.S, with interrupts disabled.
177-
*/
178164
void
179165
do_notify_resume_user(sigset_t *unused, struct sigscratch *scr, long in_syscall)
180166
{
@@ -203,6 +189,11 @@ do_notify_resume_user(sigset_t *unused, struct sigscratch *scr, long in_syscall)
203189
ia64_do_signal(scr, in_syscall);
204190
}
205191

192+
if (test_thread_flag(TIF_NOTIFY_RESUME)) {
193+
clear_thread_flag(TIF_NOTIFY_RESUME);
194+
tracehook_notify_resume(&scr->pt);
195+
}
196+
206197
/* copy user rbs to kernel rbs */
207198
if (unlikely(test_thread_flag(TIF_RESTORE_RSE))) {
208199
local_irq_enable(); /* force interrupt enable */

‎arch/ia64/kernel/ptrace.c‎

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/signal.h>
2323
#include <linux/regset.h>
2424
#include <linux/elf.h>
25+
#include <linux/tracehook.h>
2526

2627
#include <asm/pgtable.h>
2728
#include <asm/processor.h>
@@ -603,7 +604,7 @@ void ia64_ptrace_stop(void)
603604
{
604605
if (test_and_set_tsk_thread_flag(current, TIF_RESTORE_RSE))
605606
return;
606-
tsk_set_notify_resume(current);
607+
set_notify_resume(current);
607608
unw_init_running(do_sync_rbs, ia64_sync_user_rbs);
608609
}
609610

@@ -613,7 +614,6 @@ void ia64_ptrace_stop(void)
613614
void ia64_sync_krbs(void)
614615
{
615616
clear_tsk_thread_flag(current, TIF_RESTORE_RSE);
616-
tsk_clear_notify_resume(current);
617617

618618
unw_init_running(do_sync_rbs, ia64_sync_kernel_rbs);
619619
}
@@ -644,7 +644,7 @@ ptrace_attach_sync_user_rbs (struct task_struct *child)
644644
spin_lock_irq(&child->sighand->siglock);
645645
if (child->state == TASK_STOPPED &&
646646
!test_and_set_tsk_thread_flag(child, TIF_RESTORE_RSE)) {
647-
tsk_set_notify_resume(child);
647+
set_notify_resume(child);
648648

649649
child->state = TASK_TRACED;
650650
stopped = 1;
@@ -1232,37 +1232,16 @@ arch_ptrace (struct task_struct *child, long request, long addr, long data)
12321232
}
12331233

12341234

1235-
static void
1236-
syscall_trace (void)
1237-
{
1238-
/*
1239-
* The 0x80 provides a way for the tracing parent to
1240-
* distinguish between a syscall stop and SIGTRAP delivery.
1241-
*/
1242-
ptrace_notify(SIGTRAP
1243-
| ((current->ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
1244-
1245-
/*
1246-
* This isn't the same as continuing with a signal, but it
1247-
* will do for normal use. strace only continues with a
1248-
* signal if the stopping signal is not SIGTRAP. -brl
1249-
*/
1250-
if (current->exit_code) {
1251-
send_sig(current->exit_code, current, 1);
1252-
current->exit_code = 0;
1253-
}
1254-
}
1255-
12561235
/* "asmlinkage" so the input arguments are preserved... */
12571236

1258-
asmlinkage void
1237+
asmlinkage long
12591238
syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
12601239
long arg4, long arg5, long arg6, long arg7,
12611240
struct pt_regs regs)
12621241
{
1263-
if (test_thread_flag(TIF_SYSCALL_TRACE)
1264-
&& (current->ptrace & PT_PTRACED))
1265-
syscall_trace();
1242+
if (test_thread_flag(TIF_SYSCALL_TRACE))
1243+
if (tracehook_report_syscall_entry(&regs))
1244+
return -ENOSYS;
12661245

12671246
/* copy user rbs to kernel rbs */
12681247
if (test_thread_flag(TIF_RESTORE_RSE))
@@ -1283,6 +1262,7 @@ syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
12831262
audit_syscall_entry(arch, syscall, arg0, arg1, arg2, arg3);
12841263
}
12851264

1265+
return 0;
12861266
}
12871267

12881268
/* "asmlinkage" so the input arguments are preserved... */
@@ -1292,6 +1272,8 @@ syscall_trace_leave (long arg0, long arg1, long arg2, long arg3,
12921272
long arg4, long arg5, long arg6, long arg7,
12931273
struct pt_regs regs)
12941274
{
1275+
int step;
1276+
12951277
if (unlikely(current->audit_context)) {
12961278
int success = AUDITSC_RESULT(regs.r10);
12971279
long result = regs.r8;
@@ -1301,10 +1283,9 @@ syscall_trace_leave (long arg0, long arg1, long arg2, long arg3,
13011283
audit_syscall_exit(success, result);
13021284
}
13031285

1304-
if ((test_thread_flag(TIF_SYSCALL_TRACE)
1305-
|| test_thread_flag(TIF_SINGLESTEP))
1306-
&& (current->ptrace & PT_PTRACED))
1307-
syscall_trace();
1286+
step = test_thread_flag(TIF_SINGLESTEP);
1287+
if (step || test_thread_flag(TIF_SYSCALL_TRACE))
1288+
tracehook_report_syscall_exit(&regs, step);
13081289

13091290
/* copy user rbs to kernel rbs */
13101291
if (test_thread_flag(TIF_RESTORE_RSE))
@@ -1940,7 +1921,7 @@ gpregs_writeback(struct task_struct *target,
19401921
{
19411922
if (test_and_set_tsk_thread_flag(target, TIF_RESTORE_RSE))
19421923
return 0;
1943-
tsk_set_notify_resume(target);
1924+
set_notify_resume(target);
19441925
return do_regset_call(do_gpregs_writeback, target, regset, 0, 0,
19451926
NULL, NULL);
19461927
}

‎arch/ia64/kernel/signal.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/kernel.h>
1212
#include <linux/mm.h>
1313
#include <linux/ptrace.h>
14+
#include <linux/tracehook.h>
1415
#include <linux/sched.h>
1516
#include <linux/signal.h>
1617
#include <linux/smp.h>
@@ -439,6 +440,13 @@ handle_signal (unsigned long sig, struct k_sigaction *ka, siginfo_t *info, sigse
439440
sigaddset(&current->blocked, sig);
440441
recalc_sigpending();
441442
spin_unlock_irq(&current->sighand->siglock);
443+
444+
/*
445+
* Let tracing know that we've done the handler setup.
446+
*/
447+
tracehook_signal_handler(sig, info, ka, &scr->pt,
448+
test_thread_flag(TIF_SINGLESTEP));
449+
442450
return 1;
443451
}
444452

0 commit comments

Comments
 (0)