Commit 58af033e authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: use SYSEMU_SINGLESTEP

This implements using the new ptrace option SYSEMU_SINGLESTEP in UML
(advanced sysemu) in SKAS and TT modes.
To have a fast selection of the appropriate ptrace option to use next,
a 2 dimensional arry is used and singlestepping() is modified to return
0,1 or 2:
    0 = don't do singlestepping
    1 = singlestep a syscall
    2 = singlestep a "non syscall" instruction

In do_syscall() writing of the syscall number is supressed, if the
advanced sysemu is in use (that does it itself).
Signed-off-by: default avatarBodo Stroesser <bstroesser@fujitsu-siemens.com>
Signed-off-by: default avatarJeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent bb1cdf1c
...@@ -29,4 +29,11 @@ void set_using_sysemu(int value); ...@@ -29,4 +29,11 @@ void set_using_sysemu(int value);
int get_using_sysemu(void); int get_using_sysemu(void);
extern int sysemu_supported; extern int sysemu_supported;
#define SELECT_PTRACE_OPERATION(sysemu_mode, singlestep_mode) \
(((int[3][3] ) { \
{ PTRACE_SYSCALL, PTRACE_SYSCALL, PTRACE_SINGLESTEP }, \
{ PTRACE_SYSEMU, PTRACE_SYSEMU, PTRACE_SINGLESTEP }, \
{ PTRACE_SYSEMU, PTRACE_SYSEMU_SINGLESTEP, PTRACE_SYSEMU_SINGLESTEP }}) \
[sysemu_mode][singlestep_mode])
#endif #endif
...@@ -464,9 +464,9 @@ int singlestepping(void * t) ...@@ -464,9 +464,9 @@ int singlestepping(void * t)
return(0); return(0);
if (task->thread.singlestep_syscall) if (task->thread.singlestep_syscall)
return(0); return(1);
return 1; return 2;
} }
/* /*
......
...@@ -140,15 +140,15 @@ void start_userspace(int cpu) ...@@ -140,15 +140,15 @@ void start_userspace(int cpu)
void userspace(union uml_pt_regs *regs) void userspace(union uml_pt_regs *regs)
{ {
int err, status, op, pt_syscall_parm, pid = userspace_pid[0]; int err, status, op, pid = userspace_pid[0];
int local_using_sysemu; /*To prevent races if using_sysemu changes under us.*/ int local_using_sysemu; /*To prevent races if using_sysemu changes under us.*/
restore_registers(regs); restore_registers(regs);
local_using_sysemu = get_using_sysemu(); local_using_sysemu = get_using_sysemu();
pt_syscall_parm = local_using_sysemu ? PTRACE_SYSEMU : PTRACE_SYSCALL; op = local_using_sysemu ? PTRACE_SYSEMU : PTRACE_SYSCALL;
err = ptrace(pt_syscall_parm, pid, 0, 0); err = ptrace(op, pid, 0, 0);
if(err) if(err)
panic("userspace - PTRACE_%s failed, errno = %d\n", panic("userspace - PTRACE_%s failed, errno = %d\n",
...@@ -196,10 +196,8 @@ void userspace(union uml_pt_regs *regs) ...@@ -196,10 +196,8 @@ void userspace(union uml_pt_regs *regs)
/*Now we ended the syscall, so re-read local_using_sysemu.*/ /*Now we ended the syscall, so re-read local_using_sysemu.*/
local_using_sysemu = get_using_sysemu(); local_using_sysemu = get_using_sysemu();
pt_syscall_parm = local_using_sysemu ? PTRACE_SYSEMU : PTRACE_SYSCALL;
op = singlestepping(NULL) ? PTRACE_SINGLESTEP : op = SELECT_PTRACE_OPERATION(local_using_sysemu, singlestepping(NULL));
pt_syscall_parm;
err = ptrace(op, pid, 0, 0); err = ptrace(op, pid, 0, 0);
if(err) if(err)
......
...@@ -62,6 +62,10 @@ void do_syscall(void *task, int pid, int local_using_sysemu) ...@@ -62,6 +62,10 @@ void do_syscall(void *task, int pid, int local_using_sysemu)
((unsigned long *) PT_IP(proc_regs) <= &_etext)) ((unsigned long *) PT_IP(proc_regs) <= &_etext))
tracer_panic("I'm tracing myself and I can't get out"); tracer_panic("I'm tracing myself and I can't get out");
/* advanced sysemu mode set syscall number to -1 automatically */
if (local_using_sysemu==2)
return;
/* syscall number -1 in sysemu skips syscall restarting in host */ /* syscall number -1 in sysemu skips syscall restarting in host */
if(ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET, if(ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET,
local_using_sysemu ? -1 : __NR_getpid) < 0) local_using_sysemu ? -1 : __NR_getpid) < 0)
......
...@@ -186,7 +186,7 @@ int tracer(int (*init_proc)(void *), void *sp) ...@@ -186,7 +186,7 @@ int tracer(int (*init_proc)(void *), void *sp)
unsigned long eip = 0; unsigned long eip = 0;
int status, pid = 0, sig = 0, cont_type, tracing = 0, op = 0; int status, pid = 0, sig = 0, cont_type, tracing = 0, op = 0;
int last_index, proc_id = 0, n, err, old_tracing = 0, strace = 0; int last_index, proc_id = 0, n, err, old_tracing = 0, strace = 0;
int pt_syscall_parm, local_using_sysemu = 0; int local_using_sysemu = 0;
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
setup_tracer_winch(); setup_tracer_winch();
...@@ -391,18 +391,14 @@ int tracer(int (*init_proc)(void *), void *sp) ...@@ -391,18 +391,14 @@ int tracer(int (*init_proc)(void *), void *sp)
} }
local_using_sysemu = get_using_sysemu(); local_using_sysemu = get_using_sysemu();
pt_syscall_parm = local_using_sysemu ? PTRACE_SYSEMU : PTRACE_SYSCALL;
if(tracing){ if(tracing)
if(singlestepping(task)) cont_type = SELECT_PTRACE_OPERATION(local_using_sysemu,
cont_type = PTRACE_SINGLESTEP; singlestepping(task));
else cont_type = pt_syscall_parm; else if((debugger_pid != -1) && strace)
}
else cont_type = PTRACE_CONT;
if((cont_type == PTRACE_CONT) &&
(debugger_pid != -1) && strace)
cont_type = PTRACE_SYSCALL; cont_type = PTRACE_SYSCALL;
else
cont_type = PTRACE_CONT;
if(ptrace(cont_type, pid, 0, sig) != 0){ if(ptrace(cont_type, pid, 0, sig) != 0){
tracer_panic("ptrace failed to continue " tracer_panic("ptrace failed to continue "
......
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