From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L8x8e-0004CU-Ol for qemu-devel@nongnu.org; Sat, 06 Dec 2008 08:24:05 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L8x8b-0004AY-M6 for qemu-devel@nongnu.org; Sat, 06 Dec 2008 08:24:02 -0500 Received: from [199.232.76.173] (port=58657 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L8x8b-0004A6-3b for qemu-devel@nongnu.org; Sat, 06 Dec 2008 08:24:01 -0500 Received: from soufre.accelance.net ([213.162.48.15]:50980) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L8x8Z-0003pz-BC for qemu-devel@nongnu.org; Sat, 06 Dec 2008 08:24:00 -0500 Received: from [192.168.0.3] (potipota.net [88.168.176.51]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by soufre.accelance.net (Postfix) with ESMTP id 2B49745020 for ; Sat, 6 Dec 2008 14:23:56 +0100 (CET) Subject: Re: [Qemu-devel] Modular qemu? From: Lionel Landwerlin In-Reply-To: <20081205221007.GB25555@edgar.se.axis.com> References: <3056442136ca43729c6a2aec02c038aa.squirrel@www.boonen.name> <49393B8D.40209@codemonkey.ws> <20081205221007.GB25555@edgar.se.axis.com> Content-Type: multipart/mixed; boundary="=-XHbj0Apl6wl7jPsN6j9+" Date: Sat, 06 Dec 2008 14:23:51 +0100 Message-Id: <1228569831.3948.6.camel@cocoduo.atr> Mime-Version: 1.0 Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --=-XHbj0Apl6wl7jPsN6j9+ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Le vendredi 05 d=C3=A9cembre 2008 =C3=A0 23:10 +0100, Edgar E. Iglesias a= =C3=A9crit : > On Fri, Dec 05, 2008 at 08:32:45AM -0600, Anthony Liguori wrote: > > Joop Boonen wrote: > >> Hello All, > >> >=20 > Personnaly I would welcome some kind of plugin interface for some parts= of > QEMU but only if someone comes up wiht a an interface that does not hur= t > performace. I'd definitely have a use to plugin callbacks for every mem= ory > accesse in system-mode and I've noticed a reocurring request for hooks = to > trap syscalls while user-mode emulating. >=20 > Best regards > Edgar >=20 >=20 Hello everyone, Edgar, that's exactly what I implemented the past week. I needed to simulate a proprietary driver from a syscall point of view. I added hooks for syscalls with basic priorities. Here a few patch (it's a work in progress). I'm also interrested in splitting the big sys.call.c (~6k lines) using theses hooks. Regards, --=20 =EF=BB=BFLione Landwerlin =20 =EF=BB=BF O p e n W i d e 14, rue Gaillon 75002 Paris --=-XHbj0Apl6wl7jPsN6j9+ Content-Disposition: attachment; filename=0001-Added-syscall-hooks.patch Content-Type: application/mbox; name=0001-Added-syscall-hooks.patch Content-Transfer-Encoding: 7bit >>From eac6fc3bc1adbfeb95da16e82df4851a9ef6c468 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Tue, 2 Dec 2008 07:40:03 +0100 Subject: [PATCH] Added syscall hooks --- linux-user/syscall_hook.c | 178 +++++++++++++++++++++++++++++++++++++++++++++ linux-user/syscall_hook.h | 43 +++++++++++ 2 files changed, 221 insertions(+), 0 deletions(-) create mode 100644 linux-user/syscall_hook.c create mode 100644 linux-user/syscall_hook.h diff --git a/linux-user/syscall_hook.c b/linux-user/syscall_hook.c new file mode 100644 index 0000000..06fbff3 --- /dev/null +++ b/linux-user/syscall_hook.c @@ -0,0 +1,178 @@ +/* + * Syscall hooks + * + * Copyright (c) 2008 Lionel Landwerlin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include + +#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0])) + +typedef struct _qemu_syscall_hook_t { + struct _qemu_syscall_hook_t prev; + struct _qemu_syscall_hook_t next; + + unsigned int priority; + + syscall_hook_cb_t callback; +} qemu_syscall_hook_t; + +static qemu_syscall_hook_t *syscall_hooks[MAX_SYSCALL]; + +static qemu_syscall_hook_t * +_hook_new (syscall_hook_cb_t callback, unsigned int prio) +{ + qemu_syscall_hook_t *hook = + (qemu_syscall_hook_t *) calloc (1, sizeof (qemu_syscall_hook_t)); + + if (hook) { + hook->callback = callback; + hook->prio = prio; + } + + return hook; +} + +static void +_hook_free (qemu_syscall_hook_t *hook) +{ + if (hook) + free (hook); +} + +static void +_hook_insert_after (int num, + qemu_syscall_hook_t *old, + qemu_syscall_hook_t *new) +{ + new->prev = old; + new->next = old->next; + if (old->next) + old->next->prev = new; +} + +static void +_hook_insert_before (int num, + qemu_syscall_hook_t *old, + qemu_syscall_hook_t *new) +{ + new->prev = old->prev; + new->next = old; + if (old->prev) + old->prev->next = new; +} + +static void +_hook_remove (int num, + qemu_syscall_hook_t *hook) +{ + if (list->prev) + list->prev->next = list->next; + if (list->next) + list->next->prev = list->prev; + if (list == syscall_hooks[num]) + syscall_hooks[num] = list->prev ? list->prev : list->next; +} + +void +qemu_syscall_hook_init (void) +{ + int i; + + for (i = 0 ; i < ARRAY_SIZE (syscall_hooks) ; i++) + syscall_hooks[i] = NULL; +} + +int +qemu_syscall_hook_register (int num, syscall_hook_cb_t callback, unsigned int prio) +{ + qemu_syscall_hook_t *new; + + if (num >= ARRAY_SIZE (syscall_hooks)) + return 0; + + new = _hook_new (callback, prio); + + if (syscall_hooks[num] == NULL) { + syscall_hooks[num] = new; + } else { + qemu_syscall_hook_t *plist, *nlist; + + plist = NULL; + nlist = syscall_hooks[num]; + + while (nlist && + nlist->prio < prio) { + plist = nlist; + nlist = nlist->next; + } + + if (nlist) { + _insert_before (nlist, new); + if (nlist == syscall_hooks[num]) + syscall_hooks[num] = new; + } else { + _insert_after (plist, new); + } + } + + return 1; +} + +void +qemu_syscall_hook_unregister (int num, syscall_hook_cb_t callback) +{ + qemu_syscall_hook_t *list; + + if (num >= ARRAY_SIZE (syscall_hooks)) + return; + + list = syscall_hooks[num]; + + while (list && + (list->callback != callback)) + list = list->next; + + if (list) { + _hook_remove (num, list); + _hook_free (list); + } +} + +int +qemu_syscall_traverse (void *cpu_env, int num, + abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, + abi_long arg5, abi_long arg6) +{ + qemu_syscall_hook_t *list; + + if (num >= ARRAY_SIZE (syscall_hooks)) + return 0; + + list = syscall_hooks[num]; + + while (list) { + if (list->callback (cpu_env, num, + arg1, arg2, arg3, + arg4, arg5, arg5)) + break; + + list = list->next; + } + + return (list == NULL); +} diff --git a/linux-user/syscall_hook.h b/linux-user/syscall_hook.h new file mode 100644 index 0000000..ad6a69b --- /dev/null +++ b/linux-user/syscall_hook.h @@ -0,0 +1,43 @@ +/* + * Syscall hooks + * + * Copyright (c) 2008 Lionel Landwerlin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#ifndef __SYSCALL_HOOK_H__ +#define __SYSCALL_HOOK_H__ + +#include "qemu.h" + +#define MAX_SYSCALL (500) // How much ??? + +typedef int (*syscall_hook_cb_t) (void *cpu_env, int num, + abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, + abi_long arg5, abi_long arg6); + +void qemu_syscall_hook_init (void); + +int qemu_syscall_hook_register (int num, syscall_hook_cb_t callback, + unsigned int prio); +void qemu_syscall_hook_unregister (int num, syscall_hook_cb_t callback); + +int qemu_syscall_traverse (void *cpu_env, int num, + abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, + abi_long arg5, abi_long arg6); + +#endif /* __SYSCALL_HOOK_H__ */ -- 1.5.6.5 --=-XHbj0Apl6wl7jPsN6j9+ Content-Disposition: attachment; filename=0002-Rename-syscall_hook-functions.patch Content-Type: application/mbox; name=0002-Rename-syscall_hook-functions.patch Content-Transfer-Encoding: 7bit >>From ec887d9e029910f089eff2f6352ae19d8af508f5 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Tue, 2 Dec 2008 10:19:46 +0100 Subject: [PATCH] Rename syscall_hook functions --- linux-user/syscall_hook.c | 46 ++++++++++++++++++++++---------------------- linux-user/syscall_hook.h | 16 +++++++------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/linux-user/syscall_hook.c b/linux-user/syscall_hook.c index 06fbff3..b85628f 100644 --- a/linux-user/syscall_hook.c +++ b/linux-user/syscall_hook.c @@ -21,22 +21,22 @@ #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0])) -typedef struct _qemu_syscall_hook_t { - struct _qemu_syscall_hook_t prev; - struct _qemu_syscall_hook_t next; +typedef struct _syscall_hook_t { + struct _syscall_hook_t prev; + struct _syscall_hook_t next; unsigned int priority; syscall_hook_cb_t callback; -} qemu_syscall_hook_t; +} syscall_hook_t; -static qemu_syscall_hook_t *syscall_hooks[MAX_SYSCALL]; +static syscall_hook_t *syscall_hooks[MAX_SYSCALL]; -static qemu_syscall_hook_t * +static syscall_hook_t * _hook_new (syscall_hook_cb_t callback, unsigned int prio) { - qemu_syscall_hook_t *hook = - (qemu_syscall_hook_t *) calloc (1, sizeof (qemu_syscall_hook_t)); + syscall_hook_t *hook = + (syscall_hook_t *) calloc (1, sizeof (syscall_hook_t)); if (hook) { hook->callback = callback; @@ -47,7 +47,7 @@ _hook_new (syscall_hook_cb_t callback, unsigned int prio) } static void -_hook_free (qemu_syscall_hook_t *hook) +_hook_free (syscall_hook_t *hook) { if (hook) free (hook); @@ -55,8 +55,8 @@ _hook_free (qemu_syscall_hook_t *hook) static void _hook_insert_after (int num, - qemu_syscall_hook_t *old, - qemu_syscall_hook_t *new) + syscall_hook_t *old, + syscall_hook_t *new) { new->prev = old; new->next = old->next; @@ -66,8 +66,8 @@ _hook_insert_after (int num, static void _hook_insert_before (int num, - qemu_syscall_hook_t *old, - qemu_syscall_hook_t *new) + syscall_hook_t *old, + syscall_hook_t *new) { new->prev = old->prev; new->next = old; @@ -76,8 +76,7 @@ _hook_insert_before (int num, } static void -_hook_remove (int num, - qemu_syscall_hook_t *hook) +_hook_remove (int num, syscall_hook_t *hook) { if (list->prev) list->prev->next = list->next; @@ -88,7 +87,7 @@ _hook_remove (int num, } void -qemu_syscall_hook_init (void) +syscall_hook_init (void) { int i; @@ -97,9 +96,10 @@ qemu_syscall_hook_init (void) } int -qemu_syscall_hook_register (int num, syscall_hook_cb_t callback, unsigned int prio) +syscall_hook_register (int num, syscall_hook_cb_t callback, + unsigned int prio) { - qemu_syscall_hook_t *new; + syscall_hook_t *new; if (num >= ARRAY_SIZE (syscall_hooks)) return 0; @@ -109,7 +109,7 @@ qemu_syscall_hook_register (int num, syscall_hook_cb_t callback, unsigned int pr if (syscall_hooks[num] == NULL) { syscall_hooks[num] = new; } else { - qemu_syscall_hook_t *plist, *nlist; + syscall_hook_t *plist, *nlist; plist = NULL; nlist = syscall_hooks[num]; @@ -133,9 +133,9 @@ qemu_syscall_hook_register (int num, syscall_hook_cb_t callback, unsigned int pr } void -qemu_syscall_hook_unregister (int num, syscall_hook_cb_t callback) +syscall_hook_unregister (int num, syscall_hook_cb_t callback) { - qemu_syscall_hook_t *list; + syscall_hook_t *list; if (num >= ARRAY_SIZE (syscall_hooks)) return; @@ -153,12 +153,12 @@ qemu_syscall_hook_unregister (int num, syscall_hook_cb_t callback) } int -qemu_syscall_traverse (void *cpu_env, int num, +syscall_hook_traverse (void *cpu_env, int num, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) { - qemu_syscall_hook_t *list; + syscall_hook_t *list; if (num >= ARRAY_SIZE (syscall_hooks)) return 0; diff --git a/linux-user/syscall_hook.h b/linux-user/syscall_hook.h index ad6a69b..72c0306 100644 --- a/linux-user/syscall_hook.h +++ b/linux-user/syscall_hook.h @@ -29,15 +29,15 @@ typedef int (*syscall_hook_cb_t) (void *cpu_env, int num, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6); -void qemu_syscall_hook_init (void); +void syscall_hook_init (void); -int qemu_syscall_hook_register (int num, syscall_hook_cb_t callback, - unsigned int prio); -void qemu_syscall_hook_unregister (int num, syscall_hook_cb_t callback); +int syscall_hook_register (int num, syscall_hook_cb_t callback, + unsigned int prio); +void syscall_hook_unregister (int num, syscall_hook_cb_t callback); -int qemu_syscall_traverse (void *cpu_env, int num, - abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, - abi_long arg5, abi_long arg6); +int syscall_traverse (void *cpu_env, int num, + abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, + abi_long arg5, abi_long arg6); #endif /* __SYSCALL_HOOK_H__ */ -- 1.5.6.5 --=-XHbj0Apl6wl7jPsN6j9+ Content-Disposition: attachment; filename=0003-Integration-of-syscall-hooks.patch Content-Type: application/mbox; name=0003-Integration-of-syscall-hooks.patch Content-Transfer-Encoding: 7bit >>From f29bff214a9660e69bad10240e0c08897cacd092 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Tue, 2 Dec 2008 11:45:42 +0100 Subject: [PATCH] Integration of syscall hooks --- Makefile.target | 6 +++--- linux-user/main.c | 2 ++ linux-user/syscall_hook.c | 26 +++++++++++++------------- linux-user/syscall_hook.h | 1 + 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Makefile.target b/Makefile.target index 3cdf7db..2b69fb1 100644 --- a/Makefile.target +++ b/Makefile.target @@ -357,7 +357,7 @@ LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld endif ifeq ($(ARCH),sparc) -# -static is used to avoid g1/g3 usage by the dynamic linker +# -static is used to avoid g1/g3 usage by the dynamic linker LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld -static endif @@ -403,8 +403,8 @@ LDFLAGS+=-p CFLAGS+=-p endif -OBJS= main.o syscall.o strace.o mmap.o signal.o path.o thunk.o \ - elfload.o linuxload.o uaccess.o +OBJS= main.o syscall.o syscall_hook.o strace.o mmap.o signal.o path.o\ + thunk.o elfload.o linuxload.o uaccess.o LIBS+= $(AIOLIBS) ifdef TARGET_HAS_BFLT OBJS+= flatload.o diff --git a/linux-user/main.c b/linux-user/main.c index 0d5115d..5b70e56 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -27,6 +27,7 @@ #include "qemu.h" #include "qemu-common.h" +#include "syscall_hook.h" /* For tb_lock */ #include "exec-all.h" @@ -2415,6 +2416,7 @@ int main(int argc, char **argv) } target_set_brk(info->brk); + syscall_hook_init(); syscall_init(); signal_init(); diff --git a/linux-user/syscall_hook.c b/linux-user/syscall_hook.c index b85628f..67d11f7 100644 --- a/linux-user/syscall_hook.c +++ b/linux-user/syscall_hook.c @@ -19,11 +19,11 @@ */ #include -#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0])) +#include "syscall_hook.h" typedef struct _syscall_hook_t { - struct _syscall_hook_t prev; - struct _syscall_hook_t next; + struct _syscall_hook_t *prev; + struct _syscall_hook_t *next; unsigned int priority; @@ -40,7 +40,7 @@ _hook_new (syscall_hook_cb_t callback, unsigned int prio) if (hook) { hook->callback = callback; - hook->prio = prio; + hook->priority = prio; } return hook; @@ -78,12 +78,12 @@ _hook_insert_before (int num, static void _hook_remove (int num, syscall_hook_t *hook) { - if (list->prev) - list->prev->next = list->next; - if (list->next) - list->next->prev = list->prev; - if (list == syscall_hooks[num]) - syscall_hooks[num] = list->prev ? list->prev : list->next; + if (hook->prev) + hook->prev->next = hook->next; + if (hook->next) + hook->next->prev = hook->prev; + if (hook == syscall_hooks[num]) + syscall_hooks[num] = hook->prev ? hook->prev : hook->next; } void @@ -115,17 +115,17 @@ syscall_hook_register (int num, syscall_hook_cb_t callback, nlist = syscall_hooks[num]; while (nlist && - nlist->prio < prio) { + nlist->priority < prio) { plist = nlist; nlist = nlist->next; } if (nlist) { - _insert_before (nlist, new); + _hook_insert_before (num, nlist, new); if (nlist == syscall_hooks[num]) syscall_hooks[num] = new; } else { - _insert_after (plist, new); + _hook_insert_after (num, plist, new); } } diff --git a/linux-user/syscall_hook.h b/linux-user/syscall_hook.h index 72c0306..8965779 100644 --- a/linux-user/syscall_hook.h +++ b/linux-user/syscall_hook.h @@ -20,6 +20,7 @@ #ifndef __SYSCALL_HOOK_H__ #define __SYSCALL_HOOK_H__ +#include "qemu-common.h" #include "qemu.h" #define MAX_SYSCALL (500) // How much ??? -- 1.5.6.5 --=-XHbj0Apl6wl7jPsN6j9+ Content-Disposition: attachment; filename=0004-hooks-integration.patch Content-Type: application/mbox; name=0004-hooks-integration.patch Content-Transfer-Encoding: 7bit >>From 0273c8bc8ce12ec28ab3a29c0f6d253660654d7f Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Tue, 2 Dec 2008 15:00:15 +0100 Subject: [PATCH] hooks integration: * fixed returned value --- linux-user/syscall.c | 5 +++++ linux-user/syscall_hook.c | 6 +++--- linux-user/syscall_hook.h | 10 +++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c4dd38a..3629439 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3433,6 +3433,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, if(do_strace) print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); + if (syscall_hook_traverse (&ret, cpu_env, num, + arg1, arg2, arg3, + arg4, arg5, arg6)) + goto fail; + switch(num) { case TARGET_NR_exit: #ifdef HAVE_GPROF diff --git a/linux-user/syscall_hook.c b/linux-user/syscall_hook.c index 67d11f7..ee96e59 100644 --- a/linux-user/syscall_hook.c +++ b/linux-user/syscall_hook.c @@ -153,7 +153,7 @@ syscall_hook_unregister (int num, syscall_hook_cb_t callback) } int -syscall_hook_traverse (void *cpu_env, int num, +syscall_hook_traverse (abi_long *ret, void *cpu_env, int num, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6) @@ -166,7 +166,7 @@ syscall_hook_traverse (void *cpu_env, int num, list = syscall_hooks[num]; while (list) { - if (list->callback (cpu_env, num, + if (list->callback (ret, cpu_env, num, arg1, arg2, arg3, arg4, arg5, arg5)) break; @@ -174,5 +174,5 @@ syscall_hook_traverse (void *cpu_env, int num, list = list->next; } - return (list == NULL); + return (list != NULL); } diff --git a/linux-user/syscall_hook.h b/linux-user/syscall_hook.h index 8965779..52c2afe 100644 --- a/linux-user/syscall_hook.h +++ b/linux-user/syscall_hook.h @@ -25,7 +25,7 @@ #define MAX_SYSCALL (500) // How much ??? -typedef int (*syscall_hook_cb_t) (void *cpu_env, int num, +typedef int (*syscall_hook_cb_t) (abi_long *ret, void *cpu_env, int num, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6); @@ -36,9 +36,9 @@ int syscall_hook_register (int num, syscall_hook_cb_t callback, unsigned int prio); void syscall_hook_unregister (int num, syscall_hook_cb_t callback); -int syscall_traverse (void *cpu_env, int num, - abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, - abi_long arg5, abi_long arg6); +int syscall_hook_traverse (abi_long *ret, void *cpu_env, int num, + abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, + abi_long arg5, abi_long arg6); #endif /* __SYSCALL_HOOK_H__ */ -- 1.5.6.5 --=-XHbj0Apl6wl7jPsN6j9+ Content-Disposition: attachment; filename=0005-Splitted-syscalls-static-arrays.patch Content-Type: application/mbox; name=0005-Splitted-syscalls-static-arrays.patch Content-Transfer-Encoding: 7bit >>From a48e606fe428ee8486ed2000d1077b49da0cf93c Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Wed, 3 Dec 2008 02:27:36 +0100 Subject: [PATCH] Splitted syscalls static arrays. --- linux-user/syscall.c | 269 +++++++++++++++++++++++---------------------- linux-user/syscall_hook.c | 10 +- 2 files changed, 293 insertions(+), 136 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3629439..3f48191 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -79,2 +79,2 @@ #include "qemu.h" #include "qemu-common.h" +#include "syscall_hook.h" + #if defined(USE_NPTL) #include #define CLONE_NPTL_FLAGS2 (CLONE_SETTLS | \ @@ -3436,4 +3440,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, if (syscall_hook_traverse (&ret, cpu_env, num, arg1, arg2, arg3, arg4, arg5, arg6)) - goto fail; + { + ret = get_errno(ret); + goto fail; /* Even if we don't fail... */ + } switch(num) { case TARGET_NR_exit: diff --git a/linux-user/syscall_hook.c b/linux-user/syscall_hook.c index ee96e59..92f2f7e 100644 --- a/linux-user/syscall_hook.c +++ b/linux-user/syscall_hook.c @@ -166,12 +166,12 @@ syscall_hook_traverse (abi_long *ret, void *cpu_env, int num, list = syscall_hooks[num]; while (list) { - if (list->callback (ret, cpu_env, num, - arg1, arg2, arg3, - arg4, arg5, arg5)) - break; + if (list->callback (ret, cpu_env, num, + arg1, arg2, arg3, + arg4, arg5, arg5)) + break; - list = list->next; + list = list->next; } return (list != NULL); -- 1.5.6.5 --=-XHbj0Apl6wl7jPsN6j9+--