From: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
To: BlaisorBlade <blaisorblade_spam@yahoo.it>
Cc: Jeff Dike <jdike@addtoit.com>,
User-mode Linux Kernel Development
<user-mode-linux-devel@lists.sourceforge.net>
Subject: [uml-devel] [Patch 1/1] uml: fix uml-use-sysemu-for-tt.patch
Date: Fri, 12 Nov 2004 15:10:05 +0100 [thread overview]
Message-ID: <4194C43D.6030107@fujitsu-siemens.com> (raw)
From: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
The patch needs some small corrections:
1) local_using_sysemu must be sampled *before* the next
ptrace(PTRACE_SYSEMU/SYSCALL) and must stay the same until do_syscall()
has been done. Currently it is sampled before do_syscall() and is used
after this for ptrace(PTRACE_SYSEMU/SYSCALL). Even if no problem is
visible to the UML user, a single syscall could be executed on the host
when switching on sysemu. The result of this then is overwritten by the
syscall execution in UML.
Since the first event the tracer has to handle is not a syscall, it's
enough to initialize local_using_sysemu to 0;
2) Even if the host never *does* a syscall in SYSEMU, we have to write the
syscall number with -1, to not have the host doing syscall restarting.
This would happen only with an invalid syscall number equal to one of
the -ERESTART values. But to be perfect ...
Additionally I changed do_syscall() to be void instead of int.
Signed-off-by: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
---
--- a/arch/um/kernel/tt/include/tt.h 2004-11-11 21:27:08.405134680 +0100
+++ b/arch/um/kernel/tt/include/tt.h 2004-11-11 21:27:23.807793120 +0100
@@ -26,7 +26,7 @@ extern void set_tracing(void *t, int tra
extern int is_tracing(void *task);
extern void syscall_handler(int sig, union uml_pt_regs *regs);
extern void exit_kernel(int pid, void *task);
-extern int do_syscall(void *task, int pid, int local_using_sysemu);
+extern void do_syscall(void *task, int pid, int local_using_sysemu);
extern void do_sigtrap(void *task);
extern int is_valid_pid(int pid);
extern void remap_data(void *segment_start, void *segment_end, int w);
--- a/arch/um/kernel/tt/tracer.c 2004-11-12 10:28:46.776498528 +0100
+++ a/arch/um/kernel/tt/tracer.c 2004-11-12 10:34:41.381590360 +0100
@@ -186,7 +186,7 @@ int tracer(int (*init_proc)(void *), voi
unsigned long eip = 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 pt_syscall_parm, local_using_sysemu;
+ int pt_syscall_parm, local_using_sysemu = 0;
signal(SIGPIPE, SIG_IGN);
setup_tracer_winch();
@@ -305,9 +305,6 @@ int tracer(int (*init_proc)(void *), voi
if ( tracing ) /* Assume: no syscall, when coming from user */
do_sigtrap(task);
- local_using_sysemu = get_using_sysemu();
- pt_syscall_parm = local_using_sysemu ? PTRACE_SYSEMU : PTRACE_SYSCALL;
-
switch(sig){
case SIGUSR1:
sig = 0;
@@ -385,6 +382,9 @@ int tracer(int (*init_proc)(void *), voi
continue;
}
+ local_using_sysemu = get_using_sysemu();
+ pt_syscall_parm = local_using_sysemu ? PTRACE_SYSEMU : PTRACE_SYSCALL;
+
if(tracing){
if(singlestepping(task))
cont_type = PTRACE_SINGLESTEP;
--- a/arch/um/kernel/tt/syscall_user.c 2004-11-12 10:30:32.181474536 +0100
+++ b/arch/um/kernel/tt/syscall_user.c 2004-11-12 10:41:04.146401264 +0100
@@ -48,7 +48,7 @@ void do_sigtrap(void *task)
UPT_SYSCALL_NR(TASK_REGS(task)) = -1;
}
-int do_syscall(void *task, int pid, int local_using_sysemu)
+void do_syscall(void *task, int pid, int local_using_sysemu)
{
unsigned long proc_regs[FRAME_SIZE];
@@ -61,14 +61,11 @@ int do_syscall(void *task, int pid, int
((unsigned long *) PT_IP(proc_regs) <= &_etext))
tracer_panic("I'm tracing myself and I can't get out");
- if(local_using_sysemu)
- return(1);
-
+ /* syscall number -1 in sysemu skips syscall restarting in host */
if(ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET,
- __NR_getpid) < 0)
+ local_using_sysemu ? -1 : __NR_getpid) < 0)
tracer_panic("do_syscall : Nullifying syscall failed, "
"errno = %d", errno);
- return(1);
}
/*
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next reply other threads:[~2004-11-12 14:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-12 14:10 Bodo Stroesser [this message]
2004-11-13 7:54 ` [uml-devel] [Patch 1/1] uml: fix uml-use-sysemu-for-tt.patch Blaisorblade
2004-11-15 19:04 ` Bodo Stroesser
2004-11-15 20:10 ` Blaisorblade
2004-11-16 9:18 ` Bodo Stroesser
2004-11-26 2:39 ` Blaisorblade
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4194C43D.6030107@fujitsu-siemens.com \
--to=bstroesser@fujitsu-siemens.com \
--cc=blaisorblade_spam@yahoo.it \
--cc=jdike@addtoit.com \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox