linux-user: Split do_syscall
v3 cover linux-user: Split do_syscall
Version 3 does not attempt the whole thing in one go, and does attempt to incorporate strace into the reorg.
Thoughts?
r~
Richard Henderson (19):
linux-user/alpha: Fix epoll syscalls linux-user/hppa: Fix typo in mknodat syscall linux-user/microblaze: Fix typo in accept4 syscall linux-user/sparc64: Add inotify_rm_watch and tee syscalls
linux-user: Remove DEBUG
linux-user: Split out do_syscall1
linux-user: Relax single exit from "break"
linux-user: Propagate goto efault to return
linux-user: Propagate goto unimplemented_nowarn to return
linux-user: Propagate goto unimplemented to default
linux-user: Propagate goto fail to return
linux-user: Setup split syscall infrastructure
linux-user: Split out close, open, openat, read, write
linux-user: Split out preadv, pwritev, readv, writev
linux-user: Split out pread64, pwrite64
linux-user: Split out name_to_handle_at, open_by_handle_at
linux-user: Split out ipc syscalls
linux-user: Split out memory syscalls
linux-user: Split out some process syscalls
linux-user/alpha/syscall_nr.h | 6 +- linux-user/hppa/syscall_nr.h | 2 +- linux-user/microblaze/syscall_nr.h | 2 +- linux-user/sparc64/syscall_nr.h | 4 +- linux-user/syscall.h | 389 +++ linux-user/strace.c | 600 ++--- linux-user/syscall.c | 4015 ++++------------------------ linux-user/syscall_file.c | 669 +++++ linux-user/syscall_ipc.c | 1095 ++++++++ linux-user/syscall_mem.c | 190 ++ linux-user/syscall_proc.c | 914 +++++++ linux-user/Makefile.objs | 17 +- linux-user/gen_syscall_list.py | 160 ++ linux-user/strace.list | 264 -- 14 files changed, 4300 insertions(+), 4027 deletions(-) create mode 100644 linux-user/syscall.h create mode 100644 linux-user/syscall_file.c create mode 100644 linux-user/syscall_ipc.c create mode 100644 linux-user/syscall_mem.c create mode 100644 linux-user/syscall_proc.c create mode 100644 linux-user/gen_syscall_list.py
Signature · 1 line
2.17.1
PATCH v3 1/19 linux-user/alpha: Fix epoll syscalls
These were named incorrectly, going so far as to invade strace.list.
--- linux-user/alpha/syscall_nr.h | 6 +++--- linux-user/strace.list | 9 --------- 2 files changed, 3 insertions(+), 12 deletions(-)
linux-user/alpha/syscall_nr.h +3 -3
@@ -343,9 +343,9 @@#define TARGET_NR_io_cancel 402#define TARGET_NR_exit_group 405#define TARGET_NR_lookup_dcookie 406 -#define TARGET_NR_sys_epoll_create 407 -#define TARGET_NR_sys_epoll_ctl 408 -#define TARGET_NR_sys_epoll_wait 409 +#define TARGET_NR_epoll_create 407 +#define TARGET_NR_epoll_ctl 408 +#define TARGET_NR_epoll_wait 409#define TARGET_NR_remap_file_pages 410#define TARGET_NR_set_tid_address 411#define TARGET_NR_restart_syscall 412
linux-user/strace.list +0 -9
@@ -1467,15 +1467,6 @@ #ifdef TARGET_NR__sysctl { TARGET_NR__sysctl, "_sysctl" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_sys_epoll_create -{ TARGET_NR_sys_epoll_create, "sys_epoll_create" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_sys_epoll_ctl -{ TARGET_NR_sys_epoll_ctl, "sys_epoll_ctl" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_sys_epoll_wait -{ TARGET_NR_sys_epoll_wait, "sys_epoll_wait" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_sysfs { TARGET_NR_sysfs, "sysfs" , NULL, NULL, NULL }, #endif
Signature · 1 line
2.17.1
PATCH v3 2/19 linux-user/hppa: Fix typo in mknodat syscall
In reply to Richard Henderson--- linux-user/hppa/syscall_nr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/hppa/syscall_nr.h +1 -1
@@ -279,7 +279,7 @@#define TARGET_NR_ppoll 274#define TARGET_NR_openat 275#define TARGET_NR_mkdirat 276 -#define TARGET_NR_mknotat 277 +#define TARGET_NR_mknodat 277#define TARGET_NR_fchownat 278#define TARGET_NR_futimesat 279#define TARGET_NR_fstatat64 280
Signature · 1 line
2.17.1
PATCH v3 3/19 linux-user/microblaze: Fix typo in accept4 syscall
In reply to Richard Henderson--- linux-user/microblaze/syscall_nr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/microblaze/syscall_nr.h +1 -1
@@ -363,7 +363,7 @@#define TARGET_NR_shutdown 359/* new */ #define TARGET_NR_sendmsg 360/* new */ #define TARGET_NR_recvmsg 361/* new */ -#define TARGET_NR_accept04 362/* new */ +#define TARGET_NR_accept4 362/* new */ #define TARGET_NR_preadv 363/* new */ #define TARGET_NR_pwritev 364/* new */ #define TARGET_NR_rt_tgsigqueueinfo 365/* new */
Signature · 1 line
2.17.1
PATCH v3 4/19 linux-user/sparc64: Add inotify_rm_watch and tee syscalls
In reply to Richard Henderson--- linux-user/sparc64/syscall_nr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/sparc64/syscall_nr.h +2 -2
@@ -154,7 +154,7 @@#define TARGET_NR_poll 153/* Common */ #define TARGET_NR_getdents64 154/* Linux specific */ #define TARGET_NR_fcntl64 155/* Linux sparc32 Specific */ -/* #define TARGET_NR_getdirentries 156 SunOS Specific */ +#define TARGET_NR_inotify_rm_watch 156/* Linux specific */ #define TARGET_NR_statfs 157/* Common */ #define TARGET_NR_fstatfs 158/* Common */ #define TARGET_NR_umount 159/* Common */
@@ -278,7 +278,7 @@#define TARGET_NR_mq_notify 277#define TARGET_NR_mq_getsetattr 278#define TARGET_NR_waitid 279 -/*#define TARGET_NR_sys_setaltroot 280 available (was setaltroot) */ +#define TARGET_NR_tee 280#define TARGET_NR_add_key 281#define TARGET_NR_request_key 282#define TARGET_NR_keyctl 283
Signature · 1 line
2.17.1
PATCH v3 5/19 linux-user: Remove DEBUG
In reply to Richard HendersonThis is redundant with both -strace and actual tracing.
--- linux-user/syscall.c | 10 ---------- 1 file changed, 10 deletions(-)
linux-user/syscall.c +0 -10
@@ -163,7 +163,6 @@* (The one remaining unallocated bit is 0x1000 which used to be CLONE_PID.) */ -//#define DEBUG /* Define DEBUG_ERESTARTSYS to force every syscall to be restarted * once. This exercises the codepaths for restart. */
@@ -5777,9 +5776,6 @@ static abi_long do_ioctl(int fd, int cmd, abi_long arg) ie++; } arg_type = ie->arg_type; -#if defined(DEBUG ) -gemu_log ("ioctl: cmd=0x%04lx (%s)\n" , (long )cmd, ie->name); -#endif if (ie->do_ioctl) {return ie->do_ioctl (ie, buf_temp, fd, cmd, arg); }else if (!ie->host_cmd) {
@@ -7980,9 +7976,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, }#endif -#ifdef DEBUG -gemu_log ("syscall %d" , num); -#endif trace_guest_user_syscall (cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);if (do_strace)print_syscall (num, arg1, arg2, arg3, arg4, arg5, arg6);
@@ -12772,9 +12765,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ; } fail: -#ifdef DEBUG -gemu_log (" = " TARGET_ABI_FMT_ld"\n" , ret); -#endif if (do_strace)print_syscall_ret (num, ret);trace_guest_user_syscall_ret (cpu, num, ret);
Signature · 1 line
2.17.1
PATCH v3 6/19 linux-user: Split out do_syscall1
In reply to Richard HendersonThere was supposed to be a single point of return for do_syscall so that tracing works properly. However, there are a few bugs in that area. It is significantly simpler to simply split out an inner function to enforce this.
--- linux-user/syscall.c | 77 +++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 29 deletions(-)
linux-user/syscall.c +48 -29
@@ -7947,13 +7947,15 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask,return 0 ; } -/* do_syscall() should always have a single exit point at the end so -that actions, such as logging of syscall results, can be performed. -All errnos that do_syscall() returns must be -TARGET_<errcode>. */ -abi_long do_syscall (void *cpu_env,int num,abi_long arg1, -abi_long arg2,abi_long arg3,abi_long arg4, -abi_long arg5,abi_long arg6,abi_long arg7, -abi_long arg8) +/* This is an internal helper for do_syscall so that it is easier +* to have a single return point, so that actions, such as logging +* of syscall results, can be performed. +* All errnos that do_syscall() returns must be -TARGET_<errcode>. +*/ +static abi_long do_syscall1 (void *cpu_env,int num,abi_long arg1, +abi_long arg2,abi_long arg3,abi_long arg4, +abi_long arg5,abi_long arg6,abi_long arg7, +abi_long arg8) {CPUState *cpu =ENV_GET_CPU (cpu_env);abi_long ret;
@@ -7961,25 +7963,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,struct statfs stfs;void *p; -#if defined(DEBUG_ERESTARTSYS ) -/* Debug-only code for exercising the syscall-restart code paths -* in the per-architecture cpu main loops: restart every syscall -* the guest makes once before letting it through. -*/ - { -static int flag; - - flag = !flag; -if (flag) { -return -TARGET_ERESTARTSYS ; - } - } -#endif - -trace_guest_user_syscall (cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); -if (do_strace) -print_syscall (num, arg1, arg2, arg3, arg4, arg5, arg6); -switch (num) {case TARGET_NR_exit:/* In old applications this may be used to implement _exit(2).
@@ -12765,11 +12748,47 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ; } fail: -if (do_strace) -print_syscall_ret (num, ret); -trace_guest_user_syscall_ret (cpu, num, ret);return ret; efault: ret = -TARGET_EFAULT ; goto fail; } + +abi_long do_syscall (void *cpu_env,int num,abi_long arg1, +abi_long arg2,abi_long arg3,abi_long arg4, +abi_long arg5,abi_long arg6,abi_long arg7, +abi_long arg8) +{ +CPUState *cpu =ENV_GET_CPU (cpu_env); +abi_long ret; + +#ifdef DEBUG_ERESTARTSYS +/* Debug-only code for exercising the syscall-restart code paths +* in the per-architecture cpu main loops: restart every syscall +* the guest makes once before letting it through. +*/ + { +static bool flag; + flag = !flag; +if (flag) { +return -TARGET_ERESTARTSYS ; + } + } +#endif + +trace_guest_user_syscall (cpu, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); + +if (unlikely (do_strace)) { +print_syscall (num, arg1, arg2, arg3, arg4, arg5, arg6); + ret =do_syscall1 (cpu_env, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); +print_syscall_ret (num, ret); + }else { + ret =do_syscall1 (cpu_env, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); + } + +trace_guest_user_syscall_ret (cpu, num, ret); +return ret; +}
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v3 06/19] linux-user: Split out do_syscall1
Quoted 7 lines · Richard Henderson
There was supposed to be a single point of return for
do_syscallso that tracing works properly. However, there are a few bugs in that area. It is significantly simpler to simply split out an inner function to enforce this.Reviewed-by Laurent Vivier <[email protected]>Signed-off-by Richard Henderson <[email protected]>
Quoted 109 lines
--- linux-user/syscall.c | 77 +++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 29 deletions(-)linux-user/syscall.c +48
-29@@ -7947,13 +7947,15 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask,return 0 ; } -/* do_syscall() should always have a single exit point at the end so -that actions, such as logging of syscall results, can be performed. -All errnos that do_syscall() returns must be -TARGET_<errcode>. */ -abi_long do_syscall (void *cpu_env,int num,abi_long arg1, -abi_long arg2,abi_long arg3,abi_long arg4, -abi_long arg5,abi_long arg6,abi_long arg7, -abi_long arg8) +/* This is an internal helper for do_syscall so that it is easier +* to have a single return point, so that actions, such as logging +* of syscall results, can be performed. +* All errnos that do_syscall() returns must be -TARGET_<errcode>. +*/ +static abi_long do_syscall1 (void *cpu_env,int num,abi_long arg1, +abi_long arg2,abi_long arg3,abi_long arg4, +abi_long arg5,abi_long arg6,abi_long arg7, +abi_long arg8) {CPUState *cpu =ENV_GET_CPU (cpu_env);abi_long ret;@@ -7961,25 +7963,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,struct statfs stfs;void *p; -#if defined(DEBUG_ERESTARTSYS ) -/* Debug-only code for exercising the syscall-restart code paths -* in the per-architecture cpu main loops: restart every syscall -* the guest makes once before letting it through. -*/ - { -static int flag; - - flag = !flag; -if (flag) { -return -TARGET_ERESTARTSYS ; - } - } -#endif - -trace_guest_user_syscall (cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); -if (do_strace) -print_syscall (num, arg1, arg2, arg3, arg4, arg5, arg6); -switch (num) {case TARGET_NR_exit:/* In old applications this may be used to implement _exit(2). @@ -12765,11 +12748,47 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,break ; } fail: -if (do_strace) -print_syscall_ret (num, ret); -trace_guest_user_syscall_ret (cpu, num, ret);return ret; efault: ret = -TARGET_EFAULT ; goto fail; } + +abi_long do_syscall (void *cpu_env,int num,abi_long arg1, +abi_long arg2,abi_long arg3,abi_long arg4, +abi_long arg5,abi_long arg6,abi_long arg7, +abi_long arg8) +{ +CPUState *cpu =ENV_GET_CPU (cpu_env); +abi_long ret; + +#ifdef DEBUG_ERESTARTSYS +/* Debug-only code for exercising the syscall-restart code paths +* in the per-architecture cpu main loops: restart every syscall +* the guest makes once before letting it through. +*/ + { +static bool flag; + flag = !flag; +if (flag) { +return -TARGET_ERESTARTSYS ; + } + } +#endif + +trace_guest_user_syscall (cpu, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); + +if (unlikely (do_strace)) { +print_syscall (num, arg1, arg2, arg3, arg4, arg5, arg6); + ret =do_syscall1 (cpu_env, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); +print_syscall_ret (num, ret); + }else { + ret =do_syscall1 (cpu_env, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); + } + +trace_guest_user_syscall_ret (cpu, num, ret); +return ret; +}
PATCH v3 7/19 linux-user: Relax single exit from "break"
In reply to Richard HendersonTransform outermost "break" to "return ret". If the immediately preceeding statement was an assignment to ret, return the value directly.
--- linux-user/syscall.c | 970 +++++++++++++++++-------------------------- 1 file changed, 390 insertions(+), 580 deletions(-)
linux-user/syscall.c +390 -580
@@ -7971,8 +7971,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,Do thread termination if we have more then one thread. */ if (block_signals ()) { - ret = -TARGET_ERESTARTSYS ; -break ; +return -TARGET_ERESTARTSYS ; }cpu_list_lock ();
@@ -8004,12 +8003,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif gdb_exit (cpu_env, arg1);_exit (arg1); - ret =0 ;/* avoid warning */ -break ; +return 0 ;/* avoid warning */ case TARGET_NR_read: -if (arg3 ==0 ) - ret =0 ; -else { +if (arg3 ==0 ) { +return 0 ; + }else {if (!(p =lock_user (VERIFY_WRITE , arg2, arg3,0 ))) goto efault; ret =get_errno (safe_read (arg1, p, arg3));
@@ -8019,7 +8017,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user (p, arg2, ret); } -break ; +return ret;case TARGET_NR_write:if (!(p =lock_user (VERIFY_READ , arg2, arg3,1 ))) goto efault;
@@ -8035,7 +8033,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (safe_write (arg1, p, arg3)); }unlock_user (p, arg2,0 ); -break ; +return ret; +#ifdef TARGET_NR_opencase TARGET_NR_open:if (!(p =lock_user_string (arg1)))
@@ -8045,7 +8044,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg3));fd_trans_unregister (ret);unlock_user (p, arg1,0 ); -break ; +return ret;#endif case TARGET_NR_openat:if (!(p =lock_user_string (arg2)))
@@ -8055,29 +8054,27 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg4));fd_trans_unregister (ret);unlock_user (p, arg2,0 ); -break ; +return ret;#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE )case TARGET_NR_name_to_handle_at: ret =do_name_to_handle_at (arg1, arg2, arg3, arg4, arg5); -break ; +return ret;#endif #if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE )case TARGET_NR_open_by_handle_at: ret =do_open_by_handle_at (arg1, arg2, arg3);fd_trans_unregister (ret); -break ; +return ret;#endif case TARGET_NR_close:fd_trans_unregister (arg1); - ret =get_errno (close (arg1)); -break ; +return get_errno (close (arg1)); +case TARGET_NR_brk: - ret =do_brk (arg1); -break ; +return do_brk (arg1);#ifdef TARGET_NR_forkcase TARGET_NR_fork: - ret =get_errno (do_fork (cpu_env,TARGET_SIGCHLD ,0 ,0 ,0 ,0 )); -break ; +return get_errno (do_fork (cpu_env,TARGET_SIGCHLD ,0 ,0 ,0 ,0 ));#endif #ifdef TARGET_NR_waitpidcase TARGET_NR_waitpid:
@@ -8088,7 +8085,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, && put_user_s32(host_to_target_waitstatus(status), arg2)) goto efault; } -break ; +return ret;#endif #ifdef TARGET_NR_waitidcase TARGET_NR_waitid:
@@ -8103,7 +8100,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg3, sizeof(target_siginfo_t)); } } -break ; +return ret;#endif #ifdef TARGET_NR_creat/* not on alpha */ case TARGET_NR_creat:
@@ -8112,7 +8109,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (creat (p, arg2));fd_trans_unregister (ret);unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_linkcase TARGET_NR_link:
@@ -8127,7 +8124,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg2,0 ); unlock_user(p, arg1, 0); } -break ; +return ret;#endif #if defined(TARGET_NR_linkat)case TARGET_NR_linkat:
@@ -8144,7 +8141,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg2,0 ); unlock_user(p2, arg4, 0); } -break ; +return ret;#endif #ifdef TARGET_NR_unlinkcase TARGET_NR_unlink:
@@ -8152,7 +8149,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (unlink (p));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #if defined(TARGET_NR_unlinkat)case TARGET_NR_unlinkat:
@@ -8160,7 +8157,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (unlinkat (arg1, p, arg3));unlock_user (p, arg2,0 ); -break ; +return ret;#endif case TARGET_NR_execve: {
@@ -8258,13 +8255,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,g_free (argp);g_free (envp); } -break ; +return ret;case TARGET_NR_chdir:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (chdir (p));unlock_user (p, arg1,0 ); -break ; +return ret;#ifdef TARGET_NR_timecase TARGET_NR_time: {
@@ -8275,7 +8272,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, && put_user_sal(host_time, arg1)) goto efault; } -break ; +return ret;#endif #ifdef TARGET_NR_mknodcase TARGET_NR_mknod:
@@ -8283,7 +8280,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (mknod (p, arg2, arg3));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #if defined(TARGET_NR_mknodat)case TARGET_NR_mknodat:
@@ -8291,7 +8288,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (mknodat (arg1, p, arg3, arg4));unlock_user (p, arg2,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_chmodcase TARGET_NR_chmod:
@@ -8299,7 +8296,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (chmod (p, arg2));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_breakcase TARGET_NR_break:
@@ -8310,19 +8307,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented;#endif case TARGET_NR_lseek: - ret =get_errno (lseek (arg1, arg2, arg3)); -break ; +return get_errno (lseek (arg1, arg2, arg3));#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA )/* Alpha specific */ case TARGET_NR_getxpid: ((CPUAlphaState *)cpu_env)->ir[IR_A4 ] =getppid (); - ret =get_errno (getpid ()); -break ; +return get_errno (getpid ());#endif #ifdef TARGET_NR_getpidcase TARGET_NR_getpid: - ret =get_errno (getpid ()); -break ; +return get_errno (getpid ());#endif case TARGET_NR_mount: {
@@ -8378,14 +8372,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p3, arg3,0 ); } } -break ; +return ret;#ifdef TARGET_NR_umountcase TARGET_NR_umount:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (umount (p));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_stime/* not on alpha */ case TARGET_NR_stime:
@@ -8393,16 +8387,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,time_t host_time;if (get_user_sal (host_time, arg1)) goto efault; - ret = get_errno(stime(&host_time)); + return get_errno(stime(&host_time)); } -break ;#endif case TARGET_NR_ptrace: goto unimplemented;#ifdef TARGET_NR_alarm/* not on alpha */ case TARGET_NR_alarm: - ret =alarm (arg1); -break ; +return alarm (arg1);#endif #ifdef TARGET_NR_oldfstatcase TARGET_NR_oldfstat:
@@ -8413,8 +8405,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!block_signals ()) {sigsuspend (&((TaskState *)cpu->opaque)->signal_mask); } - ret = -TARGET_EINTR ; -break ; +return -TARGET_EINTR ;#endif #ifdef TARGET_NR_utimecase TARGET_NR_utime:
@@ -8436,7 +8427,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (utime (p, host_tbuf)); unlock_user(p, arg1, 0); } -break ; +return ret;#endif #ifdef TARGET_NR_utimescase TARGET_NR_utimes:
@@ -8456,7 +8447,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (utimes (p, tvp)); unlock_user(p, arg1, 0); } -break ; +return ret;#endif #if defined(TARGET_NR_futimesat)case TARGET_NR_futimesat:
@@ -8476,7 +8467,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (futimesat (arg1,path (p), tvp)); unlock_user(p, arg2, 0); } -break ; +return ret;#endif #ifdef TARGET_NR_sttycase TARGET_NR_stty:
@@ -8492,7 +8483,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (access (path (p), arg2));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)case TARGET_NR_faccessat:
@@ -8500,12 +8491,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (faccessat (arg1, p, arg3,0 ));unlock_user (p, arg2,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_nice/* not on alpha */ case TARGET_NR_nice: - ret =get_errno (nice (arg1)); -break ; +return get_errno (nice (arg1));#endif #ifdef TARGET_NR_ftimecase TARGET_NR_ftime:
@@ -8513,16 +8503,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif case TARGET_NR_sync:sync (); - ret =0 ; -break ; +return 0 ;#if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS )case TARGET_NR_syncfs: - ret =get_errno (syncfs (arg1)); -break ; +return get_errno (syncfs (arg1));#endif case TARGET_NR_kill: - ret =get_errno (safe_kill (arg1,target_to_host_signal (arg2))); -break ; +return get_errno (safe_kill (arg1,target_to_host_signal (arg2)));#ifdef TARGET_NR_renamecase TARGET_NR_rename: {
@@ -8536,7 +8523,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg2,0 ); unlock_user(p, arg1, 0); } -break ; +return ret;#endif #if defined(TARGET_NR_renameat)case TARGET_NR_renameat:
@@ -8551,7 +8538,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg4,0 ); unlock_user(p, arg2, 0); } -break ; +return ret;#endif #if defined(TARGET_NR_renameat2)case TARGET_NR_renameat2:
@@ -8567,7 +8554,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg4,0 ); unlock_user(p, arg2, 0); } -break ; +return ret;#endif #ifdef TARGET_NR_mkdircase TARGET_NR_mkdir:
@@ -8575,7 +8562,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (mkdir (p, arg2));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #if defined(TARGET_NR_mkdirat)case TARGET_NR_mkdirat:
@@ -8583,7 +8570,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (mkdirat (arg1, p, arg3));unlock_user (p, arg2,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_rmdircase TARGET_NR_rmdir:
@@ -8591,24 +8578,22 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (rmdir (p));unlock_user (p, arg1,0 ); -break ; +return ret;#endif case TARGET_NR_dup: ret =get_errno (dup (arg1));if (ret >=0 ) {fd_trans_dup (arg1, ret); } -break ; +return ret;#ifdef TARGET_NR_pipecase TARGET_NR_pipe: - ret =do_pipe (cpu_env, arg1,0 ,0 ); -break ; +return do_pipe (cpu_env, arg1,0 ,0 );#endif #ifdef TARGET_NR_pipe2case TARGET_NR_pipe2: - ret =do_pipe (cpu_env, arg1, -target_to_host_bitmask (arg2, fcntl_flags_tbl),1 ); -break ; +return do_pipe (cpu_env, arg1, +target_to_host_bitmask (arg2, fcntl_flags_tbl),1 );#endif case TARGET_NR_times: {
@@ -8627,7 +8612,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) ret =host_to_target_clock_t (ret); } -break ; +return ret;#ifdef TARGET_NR_profcase TARGET_NR_prof: goto unimplemented;
@@ -8645,34 +8630,31 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (acct (path (p)));unlock_user (p, arg1,0 ); } -break ; +return ret;#ifdef TARGET_NR_umount2case TARGET_NR_umount2:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (umount2 (p, arg2));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_lockcase TARGET_NR_lock: goto unimplemented;#endif case TARGET_NR_ioctl: - ret =do_ioctl (arg1, arg2, arg3); -break ; +return do_ioctl (arg1, arg2, arg3);#ifdef TARGET_NR_fcntlcase TARGET_NR_fcntl: - ret =do_fcntl (arg1, arg2, arg3); -break ; +return do_fcntl (arg1, arg2, arg3);#endif #ifdef TARGET_NR_mpxcase TARGET_NR_mpx: goto unimplemented;#endif case TARGET_NR_setpgid: - ret =get_errno (setpgid (arg1, arg2)); -break ; +return get_errno (setpgid (arg1, arg2));#ifdef TARGET_NR_ulimitcase TARGET_NR_ulimit: goto unimplemented;
@@ -8682,14 +8664,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented;#endif case TARGET_NR_umask: - ret =get_errno (umask (arg1)); -break ; +return get_errno (umask (arg1));case TARGET_NR_chroot:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (chroot (p));unlock_user (p, arg1,0 ); -break ; +return ret;#ifdef TARGET_NR_ustatcase TARGET_NR_ustat: goto unimplemented;
@@ -8700,7 +8681,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (ret >=0 ) {fd_trans_dup (arg1, arg2); } -break ; +return ret;#endif #if defined(CONFIG_DUP3 ) && defined(TARGET_NR_dup3)case TARGET_NR_dup3:
@@ -8715,22 +8696,19 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (ret >=0 ) {fd_trans_dup (arg1, arg2); } -break ; +return ret; }#endif #ifdef TARGET_NR_getppid/* not on alpha */ case TARGET_NR_getppid: - ret =get_errno (getppid ()); -break ; +return get_errno (getppid ());#endif #ifdef TARGET_NR_getpgrpcase TARGET_NR_getpgrp: - ret =get_errno (getpgrp ()); -break ; +return get_errno (getpgrp ());#endif case TARGET_NR_setsid: - ret =get_errno (setsid ()); -break ; +return get_errno (setsid ());#ifdef TARGET_NR_sigactioncase TARGET_NR_sigaction: {
@@ -8814,7 +8792,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }#endif } -break ; +return ret;#endif case TARGET_NR_rt_sigaction: {
@@ -8831,8 +8809,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_sigaction act, oact, *pact =0 ;if (arg4 !=sizeof (target_sigset_t)) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; }if (arg2) {if (!lock_user_struct (VERIFY_READ , rt_act, arg2,1 ))
@@ -8864,8 +8841,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_sigaction *oact;if (sigsetsize !=sizeof (target_sigset_t)) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; }if (arg2) {if (!lock_user_struct (VERIFY_READ , act, arg2,1 )) {
@@ -8892,7 +8868,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user_struct (oact, arg3,1 );#endif } -break ; +return ret;#ifdef TARGET_NR_sgetmask/* not on alpha */ case TARGET_NR_sgetmask: {
@@ -8904,7 +8880,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = target_set; } } -break ; +return ret;#endif #ifdef TARGET_NR_ssetmask/* not on alpha */ case TARGET_NR_ssetmask:
@@ -8918,7 +8894,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = target_set; } } -break ; +return ret;#endif #ifdef TARGET_NR_sigprocmaskcase TARGET_NR_sigprocmask:
@@ -8988,7 +8964,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }#endif } -break ; +return ret;#endif case TARGET_NR_rt_sigprocmask: {
@@ -8996,8 +8972,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,sigset_t set, oldset, *set_ptr;if (arg4 !=sizeof (target_sigset_t)) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; }if (arg2) {
@@ -9032,7 +9007,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg3,sizeof (target_sigset_t)); } } -break ; +return ret;#ifdef TARGET_NR_sigpendingcase TARGET_NR_sigpending: {
@@ -9045,7 +9020,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, sizeof(target_sigset_t)); } } -break ; +return ret;#endif case TARGET_NR_rt_sigpending: {
@@ -9057,8 +9032,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,* the old_sigset_t is smaller in size. */ if (arg2 >sizeof (target_sigset_t)) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; } ret =get_errno (sigpending (&set));
@@ -9069,7 +9043,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg1,sizeof (target_sigset_t)); } } -break ; +return ret;#ifdef TARGET_NR_sigsuspendcase TARGET_NR_sigsuspend: {
@@ -9089,15 +9063,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ts->in_sigsuspend = 1; } } -break ; +return ret;#endif case TARGET_NR_rt_sigsuspend: {TaskState *ts = cpu->opaque;if (arg2 !=sizeof (target_sigset_t)) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; }if (!(p =lock_user (VERIFY_READ , arg1,sizeof (target_sigset_t),1 ))) goto efault;
@@ -9109,7 +9082,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ts->in_sigsuspend =1 ; } } -break ; +return ret;case TARGET_NR_rt_sigtimedwait: {sigset_t set;
@@ -9117,8 +9090,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,siginfo_t uinfo;if (arg4 !=sizeof (target_sigset_t)) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; }if (!(p =lock_user (VERIFY_READ , arg1,sizeof (target_sigset_t),1 )))
@@ -9146,7 +9118,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =host_to_target_signal (ret); } } -break ; +return ret;case TARGET_NR_rt_sigqueueinfo: {siginfo_t uinfo;
@@ -9159,7 +9131,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg3,0 ); ret =get_errno (sys_rt_sigqueueinfo (arg1, arg2, &uinfo)); } -break ; +return ret;case TARGET_NR_rt_tgsigqueueinfo: {siginfo_t uinfo;
@@ -9172,7 +9144,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg4,0 ); ret =get_errno (sys_rt_tgsigqueueinfo (arg1, arg2, arg3, &uinfo)); } -break ; +return ret;#ifdef TARGET_NR_sigreturncase TARGET_NR_sigreturn:if (block_signals ()) {
@@ -9180,21 +9152,20 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } else { ret =do_sigreturn (cpu_env); } -break ; +return ret;#endif case TARGET_NR_rt_sigreturn:if (block_signals ()) { - ret = -TARGET_ERESTARTSYS ; +return -TARGET_ERESTARTSYS ; }else { - ret =do_rt_sigreturn (cpu_env); +return do_rt_sigreturn (cpu_env); } -break ;case TARGET_NR_sethostname:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (sethostname (p, arg2));unlock_user (p, arg1,0 ); -break ; +return ret;case TARGET_NR_setrlimit: {int resource =target_to_host_resource (arg1);
@@ -9205,9 +9176,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, rlim.rlim_cur =target_to_host_rlim (target_rlim->rlim_cur); rlim.rlim_max =target_to_host_rlim (target_rlim->rlim_max);unlock_user_struct (target_rlim, arg2,0 ); - ret =get_errno (setrlimit (resource, &rlim)); +return get_errno (setrlimit (resource, &rlim)); } -break ;case TARGET_NR_getrlimit: {int resource =target_to_host_resource (arg1);
@@ -9223,7 +9193,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user_struct (target_rlim, arg2,1 ); } } -break ; +return ret;case TARGET_NR_getrusage: {struct rusage rusage;
@@ -9232,7 +9202,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =host_to_target_rusage (arg2, &rusage); } } -break ; +return ret;case TARGET_NR_gettimeofday: {struct timeval tv;
@@ -9242,7 +9212,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;case TARGET_NR_settimeofday: {struct timeval tv, *ptv =NULL ;
@@ -9262,9 +9232,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ptz = &tz; } - ret =get_errno (settimeofday (ptv, ptz)); +return get_errno (settimeofday (ptv, ptz)); } -break ;#if defined(TARGET_NR_select)case TARGET_NR_select:#if defined(TARGET_WANT_NI_OLD_SELECT )
@@ -9277,7 +9246,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#else ret =do_select (arg1, arg2, arg3, arg4, arg5);#endif -break ; +return ret;#endif #ifdef TARGET_NR_pselect6case TARGET_NR_pselect6:
@@ -9381,7 +9350,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #ifdef TARGET_NR_symlinkcase TARGET_NR_symlink:
@@ -9396,7 +9365,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg2,0 ); unlock_user(p, arg1, 0); } -break ; +return ret;#endif #if defined(TARGET_NR_symlinkat)case TARGET_NR_symlinkat:
@@ -9411,7 +9380,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg3,0 ); unlock_user(p, arg1, 0); } -break ; +return ret;#endif #ifdef TARGET_NR_oldlstatcase TARGET_NR_oldlstat:
@@ -9447,7 +9416,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg2, ret); unlock_user(p, arg1, 0); } -break ; +return ret;#endif #if defined(TARGET_NR_readlinkat)case TARGET_NR_readlinkat:
@@ -9468,7 +9437,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg3, ret); unlock_user(p, arg2, 0); } -break ; +return ret;#endif #ifdef TARGET_NR_uselibcase TARGET_NR_uselib:
@@ -9480,7 +9449,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (swapon (p, arg2));unlock_user (p, arg1,0 ); -break ; +return ret;#endif case TARGET_NR_reboot:if (arg3 ==LINUX_REBOOT_CMD_RESTART2 ) {
@@ -9494,7 +9463,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }else { ret =get_errno (reboot (arg1, arg2, arg3,NULL )); } -break ; +return ret;#ifdef TARGET_NR_readdircase TARGET_NR_readdir: goto unimplemented;
@@ -9527,22 +9496,20 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg5, arg6));#endif -break ; +return ret;#endif #ifdef TARGET_NR_mmap2case TARGET_NR_mmap2:#ifndef MMAP_SHIFT #define MMAP_SHIFT 12#endif - ret =get_errno (target_mmap (arg1, arg2, arg3, -target_to_host_bitmask (arg4, mmap_flags_tbl), - arg5, - arg6 <<MMAP_SHIFT )); -break ; + ret =target_mmap (arg1, arg2, arg3, +target_to_host_bitmask (arg4, mmap_flags_tbl), + arg5, arg6 <<MMAP_SHIFT ); +return get_errno (ret);#endif case TARGET_NR_munmap: - ret =get_errno (target_munmap (arg1, arg2)); -break ; +return get_errno (target_munmap (arg1, arg2));case TARGET_NR_mprotect: {TaskState *ts = cpu->opaque;
@@ -9555,58 +9522,49 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg1 = ts->info->stack_limit; } } - ret =get_errno (target_mprotect (arg1, arg2, arg3)); -break ; +return get_errno (target_mprotect (arg1, arg2, arg3));#ifdef TARGET_NR_mremapcase TARGET_NR_mremap: - ret =get_errno (target_mremap (arg1, arg2, arg3, arg4, arg5)); -break ; +return get_errno (target_mremap (arg1, arg2, arg3, arg4, arg5));#endif /* ??? msync/mlock/munlock are broken for softmmu. */ #ifdef TARGET_NR_msynccase TARGET_NR_msync: - ret =get_errno (msync (g2h (arg1), arg2, arg3)); -break ; +return get_errno (msync (g2h (arg1), arg2, arg3));#endif #ifdef TARGET_NR_mlockcase TARGET_NR_mlock: - ret =get_errno (mlock (g2h (arg1), arg2)); -break ; +return get_errno (mlock (g2h (arg1), arg2));#endif #ifdef TARGET_NR_munlockcase TARGET_NR_munlock: - ret =get_errno (munlock (g2h (arg1), arg2)); -break ; +return get_errno (munlock (g2h (arg1), arg2));#endif #ifdef TARGET_NR_mlockallcase TARGET_NR_mlockall: - ret =get_errno (mlockall (target_to_host_mlockall_arg (arg1))); -break ; +return get_errno (mlockall (target_to_host_mlockall_arg (arg1)));#endif #ifdef TARGET_NR_munlockallcase TARGET_NR_munlockall: - ret =get_errno (munlockall ()); -break ; +return get_errno (munlockall ());#endif case TARGET_NR_truncate:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (truncate (p, arg2));unlock_user (p, arg1,0 ); -break ; +return ret;case TARGET_NR_ftruncate: - ret =get_errno (ftruncate (arg1, arg2)); -break ; +return get_errno (ftruncate (arg1, arg2));case TARGET_NR_fchmod: - ret =get_errno (fchmod (arg1, arg2)); -break ; +return get_errno (fchmod (arg1, arg2));#if defined(TARGET_NR_fchmodat)case TARGET_NR_fchmodat:if (!(p =lock_user_string (arg2))) goto efault; ret =get_errno (fchmodat (arg1, p, arg3,0 ));unlock_user (p, arg2,0 ); -break ; +return ret;#endif case TARGET_NR_getpriority:/* Note that negative values are valid for getpriority, so we must
@@ -9614,8 +9572,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, errno =0 ; ret =getpriority (arg1, arg2);if (ret ==-1 && errno !=0 ) { - ret = -host_to_target_errno (errno); -break ; +return -host_to_target_errno (errno); }#ifdef TARGET_ALPHA /* Return value is the unbiased priority. Signal no error. */
@@ -9624,10 +9581,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,/* Return value is a biased priority to avoid negative numbers. */ ret =20 - ret;#endif -break ; +return ret;case TARGET_NR_setpriority: - ret =get_errno (setpriority (arg1, arg2, arg3)); -break ; +return get_errno (setpriority (arg1, arg2, arg3));#ifdef TARGET_NR_profilcase TARGET_NR_profil: goto unimplemented;
@@ -9662,7 +9618,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,memset (target_stfs->f_spare,0 ,sizeof (target_stfs->f_spare));unlock_user_struct (target_stfs, arg2,1 ); } -break ; +return ret;case TARGET_NR_fstatfs: ret =get_errno (fstatfs (arg1, &stfs)); goto convert_statfs;
@@ -9692,7 +9648,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,memset (target_stfs->f_spare,0 ,sizeof (target_stfs->f_spare));unlock_user_struct (target_stfs, arg3,1 ); } -break ; +return ret;case TARGET_NR_fstatfs64: ret =get_errno (fstatfs (arg1, &stfs)); goto convert_statfs64;
@@ -9703,91 +9659,73 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_socketcallcase TARGET_NR_socketcall: - ret =do_socketcall (arg1, arg2); -break ; +return do_socketcall (arg1, arg2);#endif #ifdef TARGET_NR_acceptcase TARGET_NR_accept: - ret =do_accept4 (arg1, arg2, arg3,0 ); -break ; +return do_accept4 (arg1, arg2, arg3,0 );#endif #ifdef TARGET_NR_accept4case TARGET_NR_accept4: - ret =do_accept4 (arg1, arg2, arg3, arg4); -break ; +return do_accept4 (arg1, arg2, arg3, arg4);#endif #ifdef TARGET_NR_bindcase TARGET_NR_bind: - ret =do_bind (arg1, arg2, arg3); -break ; +return do_bind (arg1, arg2, arg3);#endif #ifdef TARGET_NR_connectcase TARGET_NR_connect: - ret =do_connect (arg1, arg2, arg3); -break ; +return do_connect (arg1, arg2, arg3);#endif #ifdef TARGET_NR_getpeernamecase TARGET_NR_getpeername: - ret =do_getpeername (arg1, arg2, arg3); -break ; +return do_getpeername (arg1, arg2, arg3);#endif #ifdef TARGET_NR_getsocknamecase TARGET_NR_getsockname: - ret =do_getsockname (arg1, arg2, arg3); -break ; +return do_getsockname (arg1, arg2, arg3);#endif #ifdef TARGET_NR_getsockoptcase TARGET_NR_getsockopt: - ret =do_getsockopt (arg1, arg2, arg3, arg4, arg5); -break ; +return do_getsockopt (arg1, arg2, arg3, arg4, arg5);#endif #ifdef TARGET_NR_listencase TARGET_NR_listen: - ret =get_errno (listen (arg1, arg2)); -break ; +return get_errno (listen (arg1, arg2));#endif #ifdef TARGET_NR_recvcase TARGET_NR_recv: - ret =do_recvfrom (arg1, arg2, arg3, arg4,0 ,0 ); -break ; +return do_recvfrom (arg1, arg2, arg3, arg4,0 ,0 );#endif #ifdef TARGET_NR_recvfromcase TARGET_NR_recvfrom: - ret =do_recvfrom (arg1, arg2, arg3, arg4, arg5, arg6); -break ; +return do_recvfrom (arg1, arg2, arg3, arg4, arg5, arg6);#endif #ifdef TARGET_NR_recvmsgcase TARGET_NR_recvmsg: - ret =do_sendrecvmsg (arg1, arg2, arg3,0 ); -break ; +return do_sendrecvmsg (arg1, arg2, arg3,0 );#endif #ifdef TARGET_NR_sendcase TARGET_NR_send: - ret =do_sendto (arg1, arg2, arg3, arg4,0 ,0 ); -break ; +return do_sendto (arg1, arg2, arg3, arg4,0 ,0 );#endif #ifdef TARGET_NR_sendmsgcase TARGET_NR_sendmsg: - ret =do_sendrecvmsg (arg1, arg2, arg3,1 ); -break ; +return do_sendrecvmsg (arg1, arg2, arg3,1 );#endif #ifdef TARGET_NR_sendmmsgcase TARGET_NR_sendmmsg: - ret =do_sendrecvmmsg (arg1, arg2, arg3, arg4,1 ); -break ; +return do_sendrecvmmsg (arg1, arg2, arg3, arg4,1 );case TARGET_NR_recvmmsg: - ret =do_sendrecvmmsg (arg1, arg2, arg3, arg4,0 ); -break ; +return do_sendrecvmmsg (arg1, arg2, arg3, arg4,0 );#endif #ifdef TARGET_NR_sendtocase TARGET_NR_sendto: - ret =do_sendto (arg1, arg2, arg3, arg4, arg5, arg6); -break ; +return do_sendto (arg1, arg2, arg3, arg4, arg5, arg6);#endif #ifdef TARGET_NR_shutdowncase TARGET_NR_shutdown: - ret =get_errno (shutdown (arg1, arg2)); -break ; +return get_errno (shutdown (arg1, arg2));#endif #if defined(TARGET_NR_getrandom) && defined(__NR_getrandom)case TARGET_NR_getrandom:
@@ -9797,22 +9735,19 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } ret =get_errno (getrandom (p, arg2, arg3));unlock_user (p, arg1, ret); -break ; +return ret;#endif #ifdef TARGET_NR_socketcase TARGET_NR_socket: - ret =do_socket (arg1, arg2, arg3); -break ; +return do_socket (arg1, arg2, arg3);#endif #ifdef TARGET_NR_socketpaircase TARGET_NR_socketpair: - ret =do_socketpair (arg1, arg2, arg3, arg4); -break ; +return do_socketpair (arg1, arg2, arg3, arg4);#endif #ifdef TARGET_NR_setsockoptcase TARGET_NR_setsockopt: - ret =do_setsockopt (arg1, arg2, arg3, arg4, (socklen_t ) arg5); -break ; +return do_setsockopt (arg1, arg2, arg3, arg4, (socklen_t ) arg5);#endif #if defined(TARGET_NR_syslog)case TARGET_NR_syslog:
@@ -9828,10 +9763,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL :/* Set messages level */ case TARGET_SYSLOG_ACTION_SIZE_UNREAD :/* Number of chars */ case TARGET_SYSLOG_ACTION_SIZE_BUFFER :/* Size of the buffer */ - { - ret =get_errno (sys_syslog ((int )arg1,NULL , (int )arg3)); - } -break ; +return get_errno (sys_syslog ((int )arg1,NULL , (int )arg3));case TARGET_SYSLOG_ACTION_READ :/* Read from log */ case TARGET_SYSLOG_ACTION_READ_CLEAR :/* Read/clear msgs */ case TARGET_SYSLOG_ACTION_READ_ALL :/* Read last messages */
@@ -9840,9 +9772,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (len <0 ) { goto fail; } - ret =0 ;if (len ==0 ) { -break ; +return 0 ; } p =lock_user (VERIFY_WRITE , arg2, arg3,0 );if (!p) {
@@ -9852,10 +9783,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (sys_syslog ((int )arg1, p, (int )arg3));unlock_user (p, arg2, arg3); } -break ; +return ret;default : - ret = -EINVAL ; -break ; +return -TARGET_EINVAL ; } }break ;
@@ -9882,7 +9812,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;case TARGET_NR_getitimer: {struct itimerval value;
@@ -9896,7 +9826,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#ifdef TARGET_NR_statcase TARGET_NR_stat:if (!(p =lock_user_string (arg1)))
@@ -9941,7 +9871,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user_struct (target_st, arg2,1 ); } } -break ; +return ret;#ifdef TARGET_NR_oldunamecase TARGET_NR_olduname: goto unimplemented;
@@ -9951,17 +9881,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented;#endif case TARGET_NR_vhangup: - ret =get_errno (vhangup ()); -break ; +return get_errno (vhangup ());#ifdef TARGET_NR_idlecase TARGET_NR_idle: goto unimplemented;#endif #ifdef TARGET_NR_syscallcase TARGET_NR_syscall: - ret =do_syscall (cpu_env, arg1 &0xffff , arg2, arg3, arg4, arg5, - arg6, arg7, arg8,0 ); -break ; +return do_syscall (cpu_env, arg1 &0xffff , arg2, arg3, arg4, arg5, + arg6, arg7, arg8,0 );#endif case TARGET_NR_wait4: {
@@ -9989,14 +9917,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } -break ; +return ret;#ifdef TARGET_NR_swapoffcase TARGET_NR_swapoff:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (swapoff (p));unlock_user (p, arg1,0 ); -break ; +return ret;#endif case TARGET_NR_sysinfo: {
@@ -10024,70 +9952,57 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user_struct (target_value, arg1,1 ); } } -break ; +return ret;#ifdef TARGET_NR_ipccase TARGET_NR_ipc: - ret =do_ipc (cpu_env, arg1, arg2, arg3, arg4, arg5, arg6); -break ; +return do_ipc (cpu_env, arg1, arg2, arg3, arg4, arg5, arg6);#endif #ifdef TARGET_NR_semgetcase TARGET_NR_semget: - ret =get_errno (semget (arg1, arg2, arg3)); -break ; +return get_errno (semget (arg1, arg2, arg3));#endif #ifdef TARGET_NR_semopcase TARGET_NR_semop: - ret =do_semop (arg1, arg2, arg3); -break ; +return do_semop (arg1, arg2, arg3);#endif #ifdef TARGET_NR_semctlcase TARGET_NR_semctl: - ret =do_semctl (arg1, arg2, arg3, arg4); -break ; +return do_semctl (arg1, arg2, arg3, arg4);#endif #ifdef TARGET_NR_msgctlcase TARGET_NR_msgctl: - ret =do_msgctl (arg1, arg2, arg3); -break ; +return do_msgctl (arg1, arg2, arg3);#endif #ifdef TARGET_NR_msggetcase TARGET_NR_msgget: - ret =get_errno (msgget (arg1, arg2)); -break ; +return get_errno (msgget (arg1, arg2));#endif #ifdef TARGET_NR_msgrcvcase TARGET_NR_msgrcv: - ret =do_msgrcv (arg1, arg2, arg3, arg4, arg5); -break ; +return do_msgrcv (arg1, arg2, arg3, arg4, arg5);#endif #ifdef TARGET_NR_msgsndcase TARGET_NR_msgsnd: - ret =do_msgsnd (arg1, arg2, arg3, arg4); -break ; +return do_msgsnd (arg1, arg2, arg3, arg4);#endif #ifdef TARGET_NR_shmgetcase TARGET_NR_shmget: - ret =get_errno (shmget (arg1, arg2, arg3)); -break ; +return get_errno (shmget (arg1, arg2, arg3));#endif #ifdef TARGET_NR_shmctlcase TARGET_NR_shmctl: - ret =do_shmctl (arg1, arg2, arg3); -break ; +return do_shmctl (arg1, arg2, arg3);#endif #ifdef TARGET_NR_shmatcase TARGET_NR_shmat: - ret =do_shmat (cpu_env, arg1, arg2, arg3); -break ; +return do_shmat (cpu_env, arg1, arg2, arg3);#endif #ifdef TARGET_NR_shmdtcase TARGET_NR_shmdt: - ret =do_shmdt (arg1); -break ; +return do_shmdt (arg1);#endif case TARGET_NR_fsync: - ret =get_errno (fsync (arg1)); -break ; +return get_errno (fsync (arg1));case TARGET_NR_clone:/* Linux manages to have three different orderings for its * arguments to clone(); the BACKWARDS and BACKWARDS2 defines
@@ -10104,7 +10019,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#else ret =get_errno (do_fork (cpu_env, arg1, arg2, arg3, arg5, arg4));#endif -break ; +return ret;#ifdef __NR_exit_group/* new thread calls */ case TARGET_NR_exit_group:
@@ -10112,15 +10027,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,_mcleanup ();#endif gdb_exit (cpu_env, arg1); - ret =get_errno (exit_group (arg1)); -break ; +return get_errno (exit_group (arg1));#endif case TARGET_NR_setdomainname:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (setdomainname (p, arg2));unlock_user (p, arg1,0 ); -break ; +return ret;case TARGET_NR_uname:/* no need to transcode because we use the linux syscall */ {
@@ -10142,17 +10056,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user_struct (buf, arg1,1 ); } -break ; +return ret;#ifdef TARGET_I386 case TARGET_NR_modify_ldt: - ret =do_modify_ldt (cpu_env, arg1, arg2, arg3); -break ; +return do_modify_ldt (cpu_env, arg1, arg2, arg3);#if !defined(TARGET_X86_64 )case TARGET_NR_vm86old: goto unimplemented;case TARGET_NR_vm86: - ret =do_vm86 (cpu_env, arg1, arg2); -break ; +return do_vm86 (cpu_env, arg1, arg2);#endif #endif case TARGET_NR_adjtimex:
@@ -10169,7 +10081,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } -break ; +return ret;#if defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME )case TARGET_NR_clock_adjtime: {
@@ -10185,7 +10097,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } -break ; +return ret;#endif #ifdef TARGET_NR_create_modulecase TARGET_NR_create_module:
@@ -10199,11 +10111,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,case TARGET_NR_quotactl: goto unimplemented;case TARGET_NR_getpgid: - ret =get_errno (getpgid (arg1)); -break ; +return get_errno (getpgid (arg1));case TARGET_NR_fchdir: - ret =get_errno (fchdir (arg1)); -break ; +return get_errno (fchdir (arg1));#ifdef TARGET_NR_bdflush/* not on x86_64 */ case TARGET_NR_bdflush: goto unimplemented;
@@ -10213,8 +10123,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented;#endif case TARGET_NR_personality: - ret =get_errno (personality (arg1)); -break ; +return get_errno (personality (arg1));#ifdef TARGET_NR_afs_syscallcase TARGET_NR_afs_syscall: goto unimplemented;
@@ -10237,7 +10146,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #ifdef TARGET_NR_getdentscase TARGET_NR_getdents:
@@ -10369,7 +10278,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (dirp, arg2, ret); }#endif -break ; +return ret;#endif /* TARGET_NR_getdents */ #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)case TARGET_NR_getdents64:
@@ -10397,12 +10306,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user (dirp, arg2, ret); } -break ; +return ret;#endif /* TARGET_NR_getdents64 */ #if defined(TARGET_NR__newselect)case TARGET_NR__newselect: - ret =do_select (arg1, arg2, arg3, arg4, arg5); -break ; +return do_select (arg1, arg2, arg3, arg4, arg5);#endif #if defined(TARGET_NR_poll) || defined(TARGET_NR_ppoll)# ifdef TARGET_NR_poll
@@ -10421,8 +10329,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_pfd =NULL ;if (nfds) {if (nfds > (INT_MAX /sizeof (struct target_pollfd ))) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; } target_pfd = lock_user(VERIFY_WRITE, arg1,
@@ -10458,8 +10365,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg4) {if (arg5 !=sizeof (target_sigset_t)) {unlock_user (target_pfd, arg1,0 ); - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; } target_set =lock_user (VERIFY_READ , arg4,sizeof (target_sigset_t),1 );
@@ -10481,7 +10387,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg4) {unlock_user (target_set, arg4,0 ); } - break; + return ret; }# endif # ifdef TARGET_NR_poll
@@ -10498,8 +10404,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,/* -ve poll() timeout means "infinite" */ pts = NULL; } - ret =get_errno (safe_ppoll (pfd, nfds, pts,NULL ,0 )); -break ; +return get_errno (safe_ppoll (pfd, nfds, pts,NULL ,0 )); }# endif default :
@@ -10513,13 +10418,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user (target_pfd, arg1,sizeof (struct target_pollfd ) * nfds); } -break ; +return ret;#endif case TARGET_NR_flock:/* NOTE: the flock constant seems to be the same for every Linux platform */ - ret =get_errno (safe_flock (arg1, arg2)); -break ; +return get_errno (safe_flock (arg1, arg2));case TARGET_NR_readv: {struct iovec *vec =lock_iovec (VERIFY_WRITE , arg2, arg3,0 );
@@ -10530,7 +10434,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno (errno); } } -break ; +return ret;case TARGET_NR_writev: {struct iovec *vec =lock_iovec (VERIFY_READ , arg2, arg3,1 );
@@ -10541,7 +10445,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno (errno); } } -break ; +return ret;#if defined(TARGET_NR_preadv)case TARGET_NR_preadv: {
@@ -10556,7 +10460,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno(errno); } } -break ; +return ret;#endif #if defined(TARGET_NR_pwritev)case TARGET_NR_pwritev:
@@ -10572,22 +10476,19 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno(errno); } } -break ; +return ret;#endif case TARGET_NR_getsid: - ret =get_errno (getsid (arg1)); -break ; +return get_errno (getsid (arg1));#if defined(TARGET_NR_fdatasync)/* Not on alpha (osf_datasync ?) */ case TARGET_NR_fdatasync: - ret =get_errno (fdatasync (arg1)); -break ; +return get_errno (fdatasync (arg1));#endif #ifdef TARGET_NR__sysctlcase TARGET_NR__sysctl:/* We don't implement this, but ENOTDIR is always a safe return value. */ - ret = -TARGET_ENOTDIR ; -break ; +return -TARGET_ENOTDIR ;#endif case TARGET_NR_sched_getaffinity: {
@@ -10599,8 +10500,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,* care of mismatches between target ulong and host ulong sizes. */ if (arg2 & (sizeof (abi_ulong) -1 )) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; } mask_size = (arg2 + (sizeof (*mask) -1 )) & ~(sizeof (*mask) -1 );
@@ -10619,8 +10519,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,*/ int numcpus =sysconf (_SC_NPROCESSORS_CONF);if (numcpus > arg2 *8 ) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; } ret = arg2; }
@@ -10630,7 +10529,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } -break ; +return ret;case TARGET_NR_sched_setaffinity: {unsigned int mask_size;
@@ -10641,20 +10540,18 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,* care of mismatches between target ulong and host ulong sizes. */ if (arg2 & (sizeof (abi_ulong) -1 )) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; } mask_size = (arg2 + (sizeof (*mask) -1 )) & ~(sizeof (*mask) -1 ); mask =alloca (mask_size); ret =target_to_host_cpu_mask (mask, mask_size, arg3, arg2);if (ret) { -break ; +return ret; } - ret =get_errno (sys_sched_setaffinity (arg1, mask_size, mask)); +return get_errno (sys_sched_setaffinity (arg1, mask_size, mask)); } -break ;case TARGET_NR_getcpu: {unsigned cpu, node;
@@ -10671,7 +10568,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;case TARGET_NR_sched_setparam: {struct sched_param *target_schp;
@@ -10684,9 +10581,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; schp.sched_priority =tswap32 (target_schp->sched_priority);unlock_user_struct (target_schp, arg2,0 ); - ret =get_errno (sched_setparam (arg1, &schp)); +return get_errno (sched_setparam (arg1, &schp)); } -break ;case TARGET_NR_sched_getparam: {struct sched_param *target_schp;
@@ -10703,7 +10599,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user_struct (target_schp, arg2,1 ); } } -break ; +return ret;case TARGET_NR_sched_setscheduler: {struct sched_param *target_schp;
@@ -10715,21 +10611,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; schp.sched_priority =tswap32 (target_schp->sched_priority);unlock_user_struct (target_schp, arg3,0 ); - ret =get_errno (sched_setscheduler (arg1, arg2, &schp)); +return get_errno (sched_setscheduler (arg1, arg2, &schp)); } -break ;case TARGET_NR_sched_getscheduler: - ret =get_errno (sched_getscheduler (arg1)); -break ; +return get_errno (sched_getscheduler (arg1));case TARGET_NR_sched_yield: - ret =get_errno (sched_yield ()); -break ; +return get_errno (sched_yield ());case TARGET_NR_sched_get_priority_max: - ret =get_errno (sched_get_priority_max (arg1)); -break ; +return get_errno (sched_get_priority_max (arg1));case TARGET_NR_sched_get_priority_min: - ret =get_errno (sched_get_priority_min (arg1)); -break ; +return get_errno (sched_get_priority_min (arg1));case TARGET_NR_sched_rr_get_interval: {struct timespec ts;
@@ -10738,7 +10629,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =host_to_target_timespec (arg2, &ts); } } -break ; +return ret;case TARGET_NR_nanosleep: {struct timespec req, rem;
@@ -10748,7 +10639,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,host_to_target_timespec (arg2, &rem); } } -break ; +return ret;#ifdef TARGET_NR_query_modulecase TARGET_NR_query_module: goto unimplemented;
@@ -10767,7 +10658,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, && put_user_ual(deathsig, arg2)) { goto efault; } -break ; +return ret; }#ifdef PR_GET_NAME case PR_GET_NAME :
@@ -10779,7 +10670,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (prctl (arg1, (unsigned long )name, arg3, arg4, arg5));unlock_user (name, arg2,16 ); -break ; +return ret; }case PR_SET_NAME : {
@@ -10790,7 +10681,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (prctl (arg1, (unsigned long )name, arg3, arg4, arg5));unlock_user (name, arg2,0 ); - break; + return ret; }#endif #ifdef TARGET_AARCH64
@@ -10811,32 +10702,29 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, env->vfp.zcr_el[1 ] = vq -1 ; ret = vq * 16; } -break ; +return ret;case TARGET_PR_SVE_GET_VL : ret = -TARGET_EINVAL ;if (arm_feature (cpu_env,ARM_FEATURE_SVE )) {CPUARMState *env = cpu_env; ret = ((env->vfp.zcr_el[1 ] &0xf ) +1 ) *16 ; } -break ; +return ret;#endif /* AARCH64 */ case PR_GET_SECCOMP :case PR_SET_SECCOMP :/* Disable seccomp to prevent the target disabling syscalls we * need. */ - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ;default :/* Most prctl options have no pointer arguments */ - ret =get_errno (prctl (arg1, arg2, arg3, arg4, arg5)); -break ; +return get_errno (prctl (arg1, arg2, arg3, arg4, arg5)); }break ;#ifdef TARGET_NR_arch_prctlcase TARGET_NR_arch_prctl:#if defined(TARGET_I386 ) && !defined(TARGET_ABI32 ) - ret =do_arch_prctl (cpu_env, arg1, arg2); -break ; +return do_arch_prctl (cpu_env, arg1, arg2);#else goto unimplemented;#endif
@@ -10851,7 +10739,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (pread64 (arg1, p, arg3,target_offset64 (arg4, arg5)));unlock_user (p, arg2, ret); -break ; +return ret;case TARGET_NR_pwrite64:if (regpairs_aligned (cpu_env, num)) { arg4 = arg5;
@@ -10861,14 +10749,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (pwrite64 (arg1, p, arg3,target_offset64 (arg4, arg5)));unlock_user (p, arg2,0 ); -break ; +return ret;#endif case TARGET_NR_getcwd:if (!(p =lock_user (VERIFY_WRITE , arg1, arg2,0 ))) goto efault; ret =get_errno (sys_getcwd1 (p, arg2));unlock_user (p, arg1, ret); -break ; +return ret;case TARGET_NR_capget:case TARGET_NR_capset: {
@@ -10937,11 +10825,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (target_data, arg2,0 ); } } -break ; +return ret; }case TARGET_NR_sigaltstack: - ret =do_sigaltstack (arg1, arg2,get_sp_from_cpustate ((CPUArchState *)cpu_env)); -break ; +return do_sigaltstack (arg1, arg2, +get_sp_from_cpustate ((CPUArchState *)cpu_env));#ifdef CONFIG_SENDFILE case TARGET_NR_sendfile:
@@ -10951,7 +10839,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg3) { ret =get_user_sal (off, arg3);if (is_error (ret)) { -break ; +return ret; } offp = &off; }
@@ -10962,7 +10850,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = ret2; } } -break ; +return ret; }#ifdef TARGET_NR_sendfile64case TARGET_NR_sendfile64:
@@ -10972,7 +10860,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg3) { ret =get_user_s64 (off, arg3);if (is_error (ret)) { -break ; +return ret; } offp = &off; }
@@ -10983,7 +10871,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = ret2; } } -break ; +return ret; }#endif #else
@@ -11004,10 +10892,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_vforkcase TARGET_NR_vfork: - ret =get_errno (do_fork (cpu_env, -CLONE_VFORK |CLONE_VM |TARGET_SIGCHLD , -0 ,0 ,0 ,0 )); -break ; +return get_errno (do_fork (cpu_env, +CLONE_VFORK |CLONE_VM |TARGET_SIGCHLD , +0 ,0 ,0 ,0 ));#endif #ifdef TARGET_NR_ugetrlimitcase TARGET_NR_ugetrlimit:
@@ -11023,7 +10910,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_rlim->rlim_max =host_to_target_rlim (rlim.rlim_max); unlock_user_struct(target_rlim, arg2, 1); } -break ; +return ret; }#endif #ifdef TARGET_NR_truncate64
@@ -11032,12 +10919,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =target_truncate64 (cpu_env, p, arg2, arg3, arg4);unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_ftruncate64case TARGET_NR_ftruncate64: - ret =target_ftruncate64 (cpu_env, arg1, arg2, arg3, arg4); -break ; +return target_ftruncate64 (cpu_env, arg1, arg2, arg3, arg4);#endif #ifdef TARGET_NR_stat64case TARGET_NR_stat64:
@@ -11047,7 +10933,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg1,0 );if (!is_error (ret)) ret =host_to_target_stat64 (cpu_env, arg2, &st); -break ; +return ret;#endif #ifdef TARGET_NR_lstat64case TARGET_NR_lstat64:
@@ -11057,14 +10943,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg1,0 );if (!is_error (ret)) ret =host_to_target_stat64 (cpu_env, arg2, &st); -break ; +return ret;#endif #ifdef TARGET_NR_fstat64case TARGET_NR_fstat64: ret =get_errno (fstat (arg1, &st));if (!is_error (ret)) ret =host_to_target_stat64 (cpu_env, arg2, &st); -break ; +return ret;#endif #if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat))#ifdef TARGET_NR_fstatat64
@@ -11078,7 +10964,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (fstatat (arg1,path (p), &st, arg4));if (!is_error (ret)) ret =host_to_target_stat64 (cpu_env, arg3, &st); -break ; +return ret;#endif #ifdef TARGET_NR_lchowncase TARGET_NR_lchown:
@@ -11086,34 +10972,28 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (lchown (p,low2highuid (arg2),low2highgid (arg3)));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_getuidcase TARGET_NR_getuid: - ret =get_errno (high2lowuid (getuid ())); -break ; +return get_errno (high2lowuid (getuid ()));#endif #ifdef TARGET_NR_getgidcase TARGET_NR_getgid: - ret =get_errno (high2lowgid (getgid ())); -break ; +return get_errno (high2lowgid (getgid ()));#endif #ifdef TARGET_NR_geteuidcase TARGET_NR_geteuid: - ret =get_errno (high2lowuid (geteuid ())); -break ; +return get_errno (high2lowuid (geteuid ()));#endif #ifdef TARGET_NR_getegidcase TARGET_NR_getegid: - ret =get_errno (high2lowgid (getegid ())); -break ; +return get_errno (high2lowgid (getegid ()));#endif case TARGET_NR_setreuid: - ret =get_errno (setreuid (low2highuid (arg1),low2highuid (arg2))); -break ; +return get_errno (setreuid (low2highuid (arg1),low2highuid (arg2)));case TARGET_NR_setregid: - ret =get_errno (setregid (low2highgid (arg1),low2highgid (arg2))); -break ; +return get_errno (setregid (low2highgid (arg1),low2highgid (arg2)));case TARGET_NR_getgroups: {int gidsetsize = arg1;
@@ -11124,7 +11004,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, grouplist =alloca (gidsetsize *sizeof (gid_t)); ret =get_errno (getgroups (gidsetsize, grouplist));if (gidsetsize ==0 ) -break ; +return ret;if (!is_error (ret)) { target_grouplist =lock_user (VERIFY_WRITE , arg2, gidsetsize *sizeof (target_id),0 );if (!target_grouplist)
@@ -11134,7 +11014,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (target_grouplist, arg2, gidsetsize *sizeof (target_id)); } } -break ; +return ret;case TARGET_NR_setgroups: {int gidsetsize = arg1;
@@ -11153,12 +11033,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user (target_grouplist, arg2,0 ); } - ret =get_errno (setgroups (gidsetsize, grouplist)); +return get_errno (setgroups (gidsetsize, grouplist)); } -break ;case TARGET_NR_fchown: - ret =get_errno (fchown (arg1,low2highuid (arg2),low2highgid (arg3))); -break ; +return get_errno (fchown (arg1,low2highuid (arg2),low2highgid (arg3)));#if defined(TARGET_NR_fchownat)case TARGET_NR_fchownat:if (!(p =lock_user_string (arg2)))
@@ -11166,14 +11044,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (fchownat (arg1, p,low2highuid (arg3),low2highgid (arg4), arg5));unlock_user (p, arg2,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_setresuidcase TARGET_NR_setresuid: - ret =get_errno (sys_setresuid (low2highuid (arg1), -low2highuid (arg2), -low2highuid (arg3))); -break ; +return get_errno (sys_setresuid (low2highuid (arg1), +low2highuid (arg2), +low2highuid (arg3)));#endif #ifdef TARGET_NR_getresuidcase TARGET_NR_getresuid:
@@ -11187,14 +11064,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #ifdef TARGET_NR_getresgidcase TARGET_NR_setresgid: - ret =get_errno (sys_setresgid (low2highgid (arg1), -low2highgid (arg2), -low2highgid (arg3))); -break ; +return get_errno (sys_setresgid (low2highgid (arg1), +low2highgid (arg2), +low2highgid (arg3)));#endif #ifdef TARGET_NR_getresgidcase TARGET_NR_getresgid:
@@ -11208,7 +11084,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #ifdef TARGET_NR_chowncase TARGET_NR_chown:
@@ -11216,20 +11092,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (chown (p,low2highuid (arg2),low2highgid (arg3)));unlock_user (p, arg1,0 ); -break ; +return ret;#endif case TARGET_NR_setuid: - ret =get_errno (sys_setuid (low2highuid (arg1))); -break ; +return get_errno (sys_setuid (low2highuid (arg1)));case TARGET_NR_setgid: - ret =get_errno (sys_setgid (low2highgid (arg1))); -break ; +return get_errno (sys_setgid (low2highgid (arg1)));case TARGET_NR_setfsuid: - ret =get_errno (setfsuid (arg1)); -break ; +return get_errno (setfsuid (arg1));case TARGET_NR_setfsgid: - ret =get_errno (setfsgid (arg1)); -break ; +return get_errno (setfsgid (arg1));#ifdef TARGET_NR_lchown32case TARGET_NR_lchown32:
@@ -11237,12 +11109,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (lchown (p, arg2, arg3));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_getuid32case TARGET_NR_getuid32: - ret =get_errno (getuid ()); -break ; +return get_errno (getuid ());#endif #if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA )
@@ -11253,8 +11124,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, euid=geteuid (); ((CPUAlphaState *)cpu_env)->ir[IR_A4]=euid; } - ret =get_errno (getuid ()); -break ; +return get_errno (getuid ());#endif #if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA )/* Alpha specific */
@@ -11264,8 +11134,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, egid=getegid (); ((CPUAlphaState *)cpu_env)->ir[IR_A4]=egid; } - ret =get_errno (getgid ()); -break ; +return get_errno (getgid ());#endif #if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA )/* Alpha specific */
@@ -11303,7 +11172,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,-- Grabs a copy of the HWRPB; surely not used. */ } -break ; +return ret;#endif #if defined(TARGET_NR_osf_setsysinfo) && defined(TARGET_ALPHA )/* Alpha specific */
@@ -11394,7 +11263,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,-- Not implemented in linux kernel */ } -break ; +return ret;#endif #ifdef TARGET_NR_osf_sigprocmask/* Alpha specific. */
@@ -11426,33 +11295,28 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = mask; } } -break ; +return ret;#endif #ifdef TARGET_NR_getgid32case TARGET_NR_getgid32: - ret =get_errno (getgid ()); -break ; +return get_errno (getgid ());#endif #ifdef TARGET_NR_geteuid32case TARGET_NR_geteuid32: - ret =get_errno (geteuid ()); -break ; +return get_errno (geteuid ());#endif #ifdef TARGET_NR_getegid32case TARGET_NR_getegid32: - ret =get_errno (getegid ()); -break ; +return get_errno (getegid ());#endif #ifdef TARGET_NR_setreuid32case TARGET_NR_setreuid32: - ret =get_errno (setreuid (arg1, arg2)); -break ; +return get_errno (setreuid (arg1, arg2));#endif #ifdef TARGET_NR_setregid32case TARGET_NR_setregid32: - ret =get_errno (setregid (arg1, arg2)); -break ; +return get_errno (setregid (arg1, arg2));#endif #ifdef TARGET_NR_getgroups32case TARGET_NR_getgroups32:
@@ -11465,7 +11329,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, grouplist =alloca (gidsetsize *sizeof (gid_t)); ret =get_errno (getgroups (gidsetsize, grouplist));if (gidsetsize ==0 ) -break ; +return ret;if (!is_error (ret)) { target_grouplist =lock_user (VERIFY_WRITE , arg2, gidsetsize *4 ,0 );if (!target_grouplist) {
@@ -11477,7 +11341,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(target_grouplist, arg2, gidsetsize * 4); } } -break ; +return ret;#endif #ifdef TARGET_NR_setgroups32case TARGET_NR_setgroups32:
@@ -11496,19 +11360,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,for (i =0 ;i < gidsetsize; i++) grouplist[i] =tswap32 (target_grouplist[i]);unlock_user (target_grouplist, arg2,0 ); - ret = get_errno(setgroups(gidsetsize, grouplist)); + return get_errno(setgroups(gidsetsize, grouplist)); } -break ;#endif #ifdef TARGET_NR_fchown32case TARGET_NR_fchown32: - ret =get_errno (fchown (arg1, arg2, arg3)); -break ; +return get_errno (fchown (arg1, arg2, arg3));#endif #ifdef TARGET_NR_setresuid32case TARGET_NR_setresuid32: - ret =get_errno (sys_setresuid (arg1, arg2, arg3)); -break ; +return get_errno (sys_setresuid (arg1, arg2, arg3));#endif #ifdef TARGET_NR_getresuid32case TARGET_NR_getresuid32:
@@ -11522,12 +11383,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #ifdef TARGET_NR_setresgid32case TARGET_NR_setresgid32: - ret =get_errno (sys_setresgid (arg1, arg2, arg3)); -break ; +return get_errno (sys_setresgid (arg1, arg2, arg3));#endif #ifdef TARGET_NR_getresgid32case TARGET_NR_getresgid32:
@@ -11541,7 +11401,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #ifdef TARGET_NR_chown32case TARGET_NR_chown32:
@@ -11549,27 +11409,23 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (chown (p, arg2, arg3));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_setuid32case TARGET_NR_setuid32: - ret =get_errno (sys_setuid (arg1)); -break ; +return get_errno (sys_setuid (arg1));#endif #ifdef TARGET_NR_setgid32case TARGET_NR_setgid32: - ret =get_errno (sys_setgid (arg1)); -break ; +return get_errno (sys_setgid (arg1));#endif #ifdef TARGET_NR_setfsuid32case TARGET_NR_setfsuid32: - ret =get_errno (setfsuid (arg1)); -break ; +return get_errno (setfsuid (arg1));#endif #ifdef TARGET_NR_setfsgid32case TARGET_NR_setfsgid32: - ret =get_errno (setfsgid (arg1)); -break ; +return get_errno (setfsgid (arg1));#endif case TARGET_NR_pivot_root:
@@ -11593,7 +11449,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, mincore_fail: unlock_user(a, arg1, 0); } -break ; +return ret;#endif #ifdef TARGET_NR_arm_fadvise64_64case TARGET_NR_arm_fadvise64_64:
@@ -11605,8 +11461,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,*/ ret =posix_fadvise (arg1,target_offset64 (arg3, arg4),target_offset64 (arg5, arg6), arg2); - ret = -host_to_target_errno (ret); -break ; +return -host_to_target_errno (ret);#endif #if TARGET_ABI_BITS ==32
@@ -11632,11 +11487,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg6 = arg7; }#endif - ret = -host_to_target_errno (posix_fadvise (arg1, -target_offset64 (arg2, arg3), -target_offset64 (arg4, arg5), - arg6)); -break ; + ret =posix_fadvise (arg1,target_offset64 (arg2, arg3), +target_offset64 (arg4, arg5), arg6); +return -host_to_target_errno (ret);#endif #ifdef TARGET_NR_fadvise64
@@ -11649,10 +11502,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg4 = arg5; arg5 = arg6; } - ret = -host_to_target_errno (posix_fadvise (arg1, -target_offset64 (arg2, arg3), - arg4, arg5)); -break ; + ret =posix_fadvise (arg1,target_offset64 (arg2, arg3), arg4, arg5); +return -host_to_target_errno (ret);#endif #else /* not a 32-bit ABI */
@@ -11672,8 +11523,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,default :break ; }#endif - ret = -host_to_target_errno (posix_fadvise (arg1, arg2, arg3, arg4)); -break ; +return -host_to_target_errno (posix_fadvise (arg1, arg2, arg3, arg4));#endif #endif /* end of 64-bit ABI fadvise handling */
@@ -11683,8 +11533,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,turns private file-backed mappings into anonymous mappings. This will break MADV_DONTNEED. This is a hint, so ignoring and returning success is ok. */ - ret =get_errno (0 ); -break ; +return 0 ;#endif #if TARGET_ABI_BITS ==32 case TARGET_NR_fcntl64:
@@ -11703,8 +11552,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, cmd =target_to_host_fcntl_cmd (arg2);if (cmd == -TARGET_EINVAL ) { - ret = cmd; -break ; +return cmd; }switch (arg2) {
@@ -11731,14 +11579,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =do_fcntl (arg1, arg2, arg3); break; } -break ; +return ret; }#endif #ifdef TARGET_NR_cacheflushcase TARGET_NR_cacheflush:/* self-modifying code is handled automatically, so nothing needed */ - ret =0 ; -break ; +return 0 ;#endif #ifdef TARGET_NR_securitycase TARGET_NR_security:
@@ -11746,12 +11593,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_getpagesizecase TARGET_NR_getpagesize: - ret =TARGET_PAGE_SIZE ; -break ; +return TARGET_PAGE_SIZE ;#endif case TARGET_NR_gettid: - ret =get_errno (gettid ()); -break ; +return get_errno (gettid ());#ifdef TARGET_NR_readaheadcase TARGET_NR_readahead:#if TARGET_ABI_BITS ==32
@@ -11764,7 +11609,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#else ret =get_errno (readahead (arg1, arg2, arg3));#endif -break ; +return ret;#endif #ifdef CONFIG_ATTR #ifdef TARGET_NR_setxattr
@@ -11775,8 +11620,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg2) { b =lock_user (VERIFY_WRITE , arg2, arg3,0 );if (!b) { - ret = -TARGET_EFAULT ; -break ; +return -TARGET_EFAULT ; } } p =lock_user_string (arg1);
@@ -11791,7 +11635,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user (p, arg1,0 );unlock_user (b, arg2, arg3); -break ; +return ret; }case TARGET_NR_flistxattr: {
@@ -11799,13 +11643,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg2) { b =lock_user (VERIFY_WRITE , arg2, arg3,0 );if (!b) { - ret = -TARGET_EFAULT ; -break ; +return -TARGET_EFAULT ; } } ret =get_errno (flistxattr (arg1, b, arg3));unlock_user (b, arg2, arg3); -break ; +return ret; }case TARGET_NR_setxattr:case TARGET_NR_lsetxattr:
@@ -11814,8 +11657,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg3) { v =lock_user (VERIFY_READ , arg3, arg4,1 );if (!v) { - ret = -TARGET_EFAULT ; -break ; +return -TARGET_EFAULT ; } } p =lock_user_string (arg1);
@@ -11833,15 +11675,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (n, arg2,0 );unlock_user (v, arg3,0 ); } -break ; +return ret;case TARGET_NR_fsetxattr: {void *n, *v =0 ;if (arg3) { v =lock_user (VERIFY_READ , arg3, arg4,1 );if (!v) { - ret = -TARGET_EFAULT ; -break ; +return -TARGET_EFAULT ; } } n =lock_user_string (arg2);
@@ -11853,7 +11694,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (n, arg2,0 );unlock_user (v, arg3,0 ); } -break ; +return ret;case TARGET_NR_getxattr:case TARGET_NR_lgetxattr: {
@@ -11861,8 +11702,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg3) { v =lock_user (VERIFY_WRITE , arg3, arg4,0 );if (!v) { - ret = -TARGET_EFAULT ; -break ; +return -TARGET_EFAULT ; } } p =lock_user_string (arg1);
@@ -11880,15 +11720,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (n, arg2,0 );unlock_user (v, arg3, arg4); } -break ; +return ret;case TARGET_NR_fgetxattr: {void *n, *v =0 ;if (arg3) { v =lock_user (VERIFY_WRITE , arg3, arg4,0 );if (!v) { - ret = -TARGET_EFAULT ; -break ; +return -TARGET_EFAULT ; } } n =lock_user_string (arg2);
@@ -11900,7 +11739,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (n, arg2,0 );unlock_user (v, arg3, arg4); } -break ; +return ret;case TARGET_NR_removexattr:case TARGET_NR_lremovexattr: {
@@ -11919,7 +11758,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg1,0 );unlock_user (n, arg2,0 ); } -break ; +return ret;case TARGET_NR_fremovexattr: {void *n;
@@ -11931,15 +11770,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user (n, arg2,0 ); } -break ; +return ret;#endif #endif /* CONFIG_ATTR */ #ifdef TARGET_NR_set_thread_areacase TARGET_NR_set_thread_area:#if defined(TARGET_MIPS ) ((CPUMIPSState *) cpu_env)->active_tc.CP0_UserLocal = arg1; - ret =0 ; -break ; +return 0 ;#elif defined(TARGET_CRIS )if (arg1 &0xff ) ret = -TARGET_EINVAL ;
@@ -11947,16 +11785,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ((CPUCRISState *) cpu_env)->pregs[PR_PID ] = arg1; ret = 0; } -break ; +return ret;#elif defined(TARGET_I386) && defined(TARGET_ABI32) - ret =do_set_thread_area (cpu_env, arg1); -break ; +return do_set_thread_area (cpu_env, arg1);#elif defined(TARGET_M68K) {TaskState *ts = cpu->opaque; ts->tp_value = arg1; - ret =0 ; -break ; +return 0 ; }#else goto unimplemented_nowarn;
@@ -11965,13 +11801,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_get_thread_areacase TARGET_NR_get_thread_area:#if defined(TARGET_I386 ) && defined(TARGET_ABI32 ) - ret =do_get_thread_area (cpu_env, arg1); -break ; +return do_get_thread_area (cpu_env, arg1);#elif defined(TARGET_M68K ) {TaskState *ts = cpu->opaque; - ret = ts->tp_value; -break ; +return ts->tp_value; }#else goto unimplemented_nowarn;
@@ -11991,7 +11825,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) { ret =get_errno (clock_settime (arg1, &ts)); } - break; + return ret; }#endif #ifdef TARGET_NR_clock_gettime
@@ -12002,7 +11836,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) { ret =host_to_target_timespec (arg2, &ts); } - break; + return ret; }#endif #ifdef TARGET_NR_clock_getres
@@ -12013,7 +11847,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) {host_to_target_timespec (arg2, &ts); } - break; + return ret; }#endif #ifdef TARGET_NR_clock_nanosleep
@@ -12033,24 +11867,21 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ((CPUPPCState *)cpu_env)->crf[0 ] |=1 ; }#endif -break ; +return ret; }#endif #if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)case TARGET_NR_set_tid_address: - ret =get_errno (set_tid_address ((int *)g2h (arg1))); -break ; +return get_errno (set_tid_address ((int *)g2h (arg1)));#endif case TARGET_NR_tkill: - ret =get_errno (safe_tkill ((int )arg1,target_to_host_signal (arg2))); -break ; +return get_errno (safe_tkill ((int )arg1,target_to_host_signal (arg2)));case TARGET_NR_tgkill: - ret =get_errno (safe_tgkill ((int )arg1, (int )arg2, -target_to_host_signal (arg3))); -break ; +return get_errno (safe_tgkill ((int )arg1, (int )arg2, +target_to_host_signal (arg3)));#ifdef TARGET_NR_set_robust_listcase TARGET_NR_set_robust_list:
@@ -12092,18 +11923,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg2, 0); } } -break ; +return ret;#endif case TARGET_NR_futex: - ret =do_futex (arg1, arg2, arg3, arg4, arg5, arg6); -break ; +return do_futex (arg1, arg2, arg3, arg4, arg5, arg6);#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)case TARGET_NR_inotify_init: ret =get_errno (sys_inotify_init ());if (ret >=0 ) {fd_trans_register (ret, &target_inotify_trans); } -break ; +return ret;#endif #ifdef CONFIG_INOTIFY1 #if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1)
@@ -12113,7 +11943,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (ret >=0 ) {fd_trans_register (ret, &target_inotify_trans); } -break ; +return ret;#endif #endif #if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch)
@@ -12121,12 +11951,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p =lock_user_string (arg2); ret =get_errno (sys_inotify_add_watch (arg1,path (p), arg3));unlock_user (p, arg2,0 ); -break ; +return ret;#endif #if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch)case TARGET_NR_inotify_rm_watch: - ret =get_errno (sys_inotify_rm_watch (arg1, arg2)); -break ; +return get_errno (sys_inotify_rm_watch (arg1, arg2));#endif #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
@@ -12151,17 +11980,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (mq_open (p, host_flags, arg3, pposix_mq_attr));unlock_user (p, arg1,0 ); } -break ; +return ret;case TARGET_NR_mq_unlink: p =lock_user_string (arg1 -1 );if (!p) { - ret = -TARGET_EFAULT ; -break ; +return -TARGET_EFAULT ; } ret =get_errno (mq_unlink (p));unlock_user (p, arg1,0 ); -break ; +return ret;case TARGET_NR_mq_timedsend: {
@@ -12177,7 +12005,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user (p, arg2, arg3); } -break ; +return ret;case TARGET_NR_mq_timedreceive: {
@@ -12198,7 +12026,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg4 !=0 )put_user_u32 (prio, arg4); } -break ; +return ret;/* Not implemented for now... */ /* case TARGET_NR_mq_notify: */
@@ -12219,7 +12047,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, copy_to_user_mq_attr(arg3, &posix_mq_attr_out); } } -break ; +return ret;#endif #ifdef CONFIG_SPLICE
@@ -12228,7 +12056,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, { ret =get_errno (tee (arg1,arg2,arg3,arg4)); } -break ; +return ret;#endif #ifdef TARGET_NR_splicecase TARGET_NR_splice:
@@ -12259,7 +12087,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } -break ; +return ret;#endif #ifdef TARGET_NR_vmsplicecase TARGET_NR_vmsplice:
@@ -12272,7 +12100,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno (errno); } } -break ; +return ret;#endif #endif /* CONFIG_SPLICE */ #ifdef CONFIG_EVENTFD
@@ -12282,7 +12110,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (ret >=0 ) {fd_trans_register (ret, &target_eventfd_trans); } -break ; +return ret;#endif #if defined(TARGET_NR_eventfd2)case TARGET_NR_eventfd2:
@@ -12298,7 +12126,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (ret >=0 ) {fd_trans_register (ret, &target_eventfd_trans); } -break ; +return ret; }#endif #endif /* CONFIG_EVENTFD */
@@ -12310,7 +12138,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#else ret =get_errno (fallocate (arg1, arg2, arg3, arg4));#endif -break ; +return ret;#endif #if defined(CONFIG_SYNC_FILE_RANGE )#if defined(TARGET_NR_sync_file_range)
@@ -12326,7 +12154,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#else ret =get_errno (sync_file_range (arg1, arg2, arg3, arg4));#endif -break ; +return ret;#endif #if defined(TARGET_NR_sync_file_range2)case TARGET_NR_sync_file_range2:
@@ -12337,29 +12165,25 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#else ret =get_errno (sync_file_range (arg1, arg3, arg4, arg2));#endif -break ; +return ret;#endif #endif #if defined(TARGET_NR_signalfd4)case TARGET_NR_signalfd4: - ret =do_signalfd4 (arg1, arg2, arg4); -break ; +return do_signalfd4 (arg1, arg2, arg4);#endif #if defined(TARGET_NR_signalfd)case TARGET_NR_signalfd: - ret =do_signalfd4 (arg1, arg2,0 ); -break ; +return do_signalfd4 (arg1, arg2,0 );#endif #if defined(CONFIG_EPOLL )#if defined(TARGET_NR_epoll_create)case TARGET_NR_epoll_create: - ret =get_errno (epoll_create (arg1)); -break ; +return get_errno (epoll_create (arg1));#endif #if defined(TARGET_NR_epoll_create1) && defined(CONFIG_EPOLL_CREATE1 )case TARGET_NR_epoll_create1: - ret =get_errno (epoll_create1 (arg1)); -break ; +return get_errno (epoll_create1 (arg1));#endif #if defined(TARGET_NR_epoll_ctl)case TARGET_NR_epoll_ctl:
@@ -12380,8 +12204,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user_struct (target_ep, arg4,0 ); epp = &ep; } - ret =get_errno (epoll_ctl (arg1, arg2, arg3, epp)); -break ; +return get_errno (epoll_ctl (arg1, arg2, arg3, epp)); }#endif
@@ -12400,8 +12223,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,int timeout = arg4;if (maxevents <=0 || maxevents >TARGET_EP_MAX_EVENTS ) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; } target_ep = lock_user(VERIFY_WRITE, arg2,
@@ -12413,8 +12235,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ep = g_try_new(struct epoll_event, maxevents);if (!ep) {unlock_user (target_ep, arg2,0 ); - ret = -TARGET_ENOMEM ; -break ; +return -TARGET_ENOMEM ; }switch (num) {
@@ -12444,7 +12265,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (safe_epoll_pwait (epfd, ep, maxevents, timeout, set, SIGSET_T_SIZE)); - break; }#endif #if defined(TARGET_NR_epoll_wait)
@@ -12468,7 +12288,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (target_ep, arg2,0 ); }g_free (ep); -break ; +return ret; }#endif #endif
@@ -12498,7 +12318,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_rold->rlim_max =tswap64 (rold.rlim_max); unlock_user_struct(target_rold, arg4, 1); } -break ; +return ret; }#endif #ifdef TARGET_NR_gethostname
@@ -12511,7 +12331,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } else { ret = -TARGET_EFAULT ; } -break ; +return ret; }#endif #ifdef TARGET_NR_atomic_cmpxchg_32
@@ -12532,17 +12352,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }if (mem_value == arg2)put_user_u32 (arg1, arg6); - ret = mem_value; -break ; +return mem_value; }#endif #ifdef TARGET_NR_atomic_barriercase TARGET_NR_atomic_barrier: - { -/* Like the kernel implementation and the qemu arm barrier, no-op this? */ - ret =0 ; -break ; - } +/* Like the kernel implementation and the +qemu arm barrier, no-op this? */ +return 0 ;#endif #ifdef TARGET_NR_timer_create
@@ -12564,7 +12381,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, phost_sevp = &host_sevp; ret =target_to_host_sigevent (phost_sevp, arg2);if (ret !=0 ) { -break ; +return ret; } }
@@ -12577,7 +12394,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } -break ; +return ret; }#endif
@@ -12605,7 +12422,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret; }#endif
@@ -12628,7 +12445,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -TARGET_EFAULT; } } -break ; +return ret; }#endif
@@ -12645,7 +12462,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(timer_getoverrun(htimer)); }fd_trans_unregister (ret); -break ; +return ret; }#endif
@@ -12662,15 +12479,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (timer_delete (htimer)); g_posix_timers[timerid] = 0; } -break ; +return ret; }#endif #if defined(TARGET_NR_timerfd_create) && defined(CONFIG_TIMERFD )case TARGET_NR_timerfd_create: - ret =get_errno (timerfd_create (arg1, -target_to_host_bitmask (arg2, fcntl_flags_tbl))); -break ; +return get_errno (timerfd_create (arg1, +target_to_host_bitmask (arg2, fcntl_flags_tbl)));#endif #if defined(TARGET_NR_timerfd_gettime) && defined(CONFIG_TIMERFD )
@@ -12684,7 +12500,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #if defined(TARGET_NR_timerfd_settime) && defined(CONFIG_TIMERFD )
@@ -12707,35 +12523,30 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #if defined(TARGET_NR_ioprio_get) && defined(__NR_ioprio_get)case TARGET_NR_ioprio_get: - ret =get_errno (ioprio_get (arg1, arg2)); -break ; +return get_errno (ioprio_get (arg1, arg2));#endif #if defined(TARGET_NR_ioprio_set) && defined(__NR_ioprio_set)case TARGET_NR_ioprio_set: - ret =get_errno (ioprio_set (arg1, arg2, arg3)); -break ; +return get_errno (ioprio_set (arg1, arg2, arg3));#endif #if defined(TARGET_NR_setns) && defined(CONFIG_SETNS )case TARGET_NR_setns: - ret =get_errno (setns (arg1, arg2)); -break ; +return get_errno (setns (arg1, arg2));#endif #if defined(TARGET_NR_unshare) && defined(CONFIG_SETNS )case TARGET_NR_unshare: - ret =get_errno (unshare (arg1)); -break ; +return get_errno (unshare (arg1));#endif #if defined(TARGET_NR_kcmp) && defined(__NR_kcmp)case TARGET_NR_kcmp: - ret =get_errno (kcmp (arg1, arg2, arg3, arg4, arg5)); -break ; +return get_errno (kcmp (arg1, arg2, arg3, arg4, arg5));#endif default :
@@ -12744,8 +12555,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list) unimplemented_nowarn:#endif - ret = -TARGET_ENOSYS ; -break ; +return -TARGET_ENOSYS ; } fail:return ret;
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v3 07/19] linux-user: Relax single exit from "break"
Quoted 716 lines · Richard Henderson
Transform outermost "break" to "return ret". If the immediately preceeding statement was an assignment to ret, return the value directly.
Reviewed-by Laurent Vivier <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.c | 970 +++++++++++++++++-------------------------- 1 file changed, 390 insertions(+), 580 deletions(-)linux-user/syscall.c +88
-116@@ -7971,8 +7971,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,Do thread termination if we have more then one thread. */ if (block_signals ()) { - ret = -TARGET_ERESTARTSYS ; -break ; +return -TARGET_ERESTARTSYS ; }cpu_list_lock ();@@ -8004,12 +8003,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif gdb_exit (cpu_env, arg1);_exit (arg1); - ret =0 ;/* avoid warning */ -break ; +return 0 ;/* avoid warning */ case TARGET_NR_read: -if (arg3 ==0 ) - ret =0 ; -else { +if (arg3 ==0 ) { +return 0 ; + }else {if (!(p =lock_user (VERIFY_WRITE , arg2, arg3,0 ))) goto efault; ret =get_errno (safe_read (arg1, p, arg3));@@ -8019,7 +8017,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user (p, arg2, ret); } -break ; +return ret;case TARGET_NR_write:if (!(p =lock_user (VERIFY_READ , arg2, arg3,1 ))) goto efault;@@ -8035,7 +8033,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (safe_write (arg1, p, arg3)); }unlock_user (p, arg2,0 ); -break ; +return ret; +#ifdef TARGET_NR_opencase TARGET_NR_open:if (!(p =lock_user_string (arg1)))@@ -8045,7 +8044,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg3));fd_trans_unregister (ret);unlock_user (p, arg1,0 ); -break ; +return ret;#endif case TARGET_NR_openat:if (!(p =lock_user_string (arg2)))@@ -8055,29 +8054,27 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg4));fd_trans_unregister (ret);unlock_user (p, arg2,0 ); -break ; +return ret;#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE )case TARGET_NR_name_to_handle_at: ret =do_name_to_handle_at (arg1, arg2, arg3, arg4, arg5); -break ; +return ret;#endif #if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE )case TARGET_NR_open_by_handle_at: ret =do_open_by_handle_at (arg1, arg2, arg3);fd_trans_unregister (ret); -break ; +return ret;#endif case TARGET_NR_close:fd_trans_unregister (arg1); - ret =get_errno (close (arg1)); -break ; +return get_errno (close (arg1)); +case TARGET_NR_brk: - ret =do_brk (arg1); -break ; +return do_brk (arg1);#ifdef TARGET_NR_forkcase TARGET_NR_fork: - ret =get_errno (do_fork (cpu_env,TARGET_SIGCHLD ,0 ,0 ,0 ,0 )); -break ; +return get_errno (do_fork (cpu_env,TARGET_SIGCHLD ,0 ,0 ,0 ,0 ));#endif #ifdef TARGET_NR_waitpidcase TARGET_NR_waitpid:@@ -8088,7 +8085,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, && put_user_s32(host_to_target_waitstatus(status), arg2)) goto efault; } -break ; +return ret;#endif #ifdef TARGET_NR_waitidcase TARGET_NR_waitid:@@ -8103,7 +8100,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg3, sizeof(target_siginfo_t)); } } -break ; +return ret;#endif #ifdef TARGET_NR_creat/* not on alpha */ case TARGET_NR_creat:@@ -8112,7 +8109,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (creat (p, arg2));fd_trans_unregister (ret);unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_linkcase TARGET_NR_link:@@ -8127,7 +8124,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg2,0 ); unlock_user(p, arg1, 0); } -break ; +return ret;#endif #if defined(TARGET_NR_linkat)case TARGET_NR_linkat:@@ -8144,7 +8141,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg2,0 ); unlock_user(p2, arg4, 0); } -break ; +return ret;#endif #ifdef TARGET_NR_unlinkcase TARGET_NR_unlink:@@ -8152,7 +8149,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (unlink (p));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #if defined(TARGET_NR_unlinkat)case TARGET_NR_unlinkat:@@ -8160,7 +8157,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (unlinkat (arg1, p, arg3));unlock_user (p, arg2,0 ); -break ; +return ret;#endif case TARGET_NR_execve: {@@ -8258,13 +8255,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,g_free (argp);g_free (envp); } -break ; +return ret;case TARGET_NR_chdir:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (chdir (p));unlock_user (p, arg1,0 ); -break ; +return ret;#ifdef TARGET_NR_timecase TARGET_NR_time: {@@ -8275,7 +8272,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, && put_user_sal(host_time, arg1)) goto efault; } -break ; +return ret;#endif #ifdef TARGET_NR_mknodcase TARGET_NR_mknod:@@ -8283,7 +8280,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (mknod (p, arg2, arg3));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #if defined(TARGET_NR_mknodat)case TARGET_NR_mknodat:@@ -8291,7 +8288,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (mknodat (arg1, p, arg3, arg4));unlock_user (p, arg2,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_chmodcase TARGET_NR_chmod:@@ -8299,7 +8296,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (chmod (p, arg2));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_breakcase TARGET_NR_break:@@ -8310,19 +8307,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented;#endif case TARGET_NR_lseek: - ret =get_errno (lseek (arg1, arg2, arg3)); -break ; +return get_errno (lseek (arg1, arg2, arg3));#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA )/* Alpha specific */ case TARGET_NR_getxpid: ((CPUAlphaState *)cpu_env)->ir[IR_A4 ] =getppid (); - ret =get_errno (getpid ()); -break ; +return get_errno (getpid ());#endif #ifdef TARGET_NR_getpidcase TARGET_NR_getpid: - ret =get_errno (getpid ()); -break ; +return get_errno (getpid ());#endif case TARGET_NR_mount: {@@ -8378,14 +8372,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p3, arg3,0 ); } } -break ; +return ret;#ifdef TARGET_NR_umountcase TARGET_NR_umount:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (umount (p));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_stime/* not on alpha */ case TARGET_NR_stime:@@ -8393,16 +8387,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,time_t host_time;if (get_user_sal (host_time, arg1)) goto efault; - ret = get_errno(stime(&host_time)); + return get_errno(stime(&host_time)); } -break ;#endif case TARGET_NR_ptrace: goto unimplemented;#ifdef TARGET_NR_alarm/* not on alpha */ case TARGET_NR_alarm: - ret =alarm (arg1); -break ; +return alarm (arg1);#endif #ifdef TARGET_NR_oldfstatcase TARGET_NR_oldfstat:@@ -8413,8 +8405,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!block_signals ()) {sigsuspend (&((TaskState *)cpu->opaque)->signal_mask); } - ret = -TARGET_EINTR ; -break ; +return -TARGET_EINTR ;#endif #ifdef TARGET_NR_utimecase TARGET_NR_utime:@@ -8436,7 +8427,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (utime (p, host_tbuf)); unlock_user(p, arg1, 0); } -break ; +return ret;#endif #ifdef TARGET_NR_utimescase TARGET_NR_utimes:@@ -8456,7 +8447,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (utimes (p, tvp)); unlock_user(p, arg1, 0); } -break ; +return ret;#endif #if defined(TARGET_NR_futimesat)case TARGET_NR_futimesat:@@ -8476,7 +8467,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (futimesat (arg1,path (p), tvp)); unlock_user(p, arg2, 0); } -break ; +return ret;#endif #ifdef TARGET_NR_sttycase TARGET_NR_stty:@@ -8492,7 +8483,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (access (path (p), arg2));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)case TARGET_NR_faccessat:@@ -8500,12 +8491,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (faccessat (arg1, p, arg3,0 ));unlock_user (p, arg2,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_nice/* not on alpha */ case TARGET_NR_nice: - ret =get_errno (nice (arg1)); -break ; +return get_errno (nice (arg1));#endif #ifdef TARGET_NR_ftimecase TARGET_NR_ftime:@@ -8513,16 +8503,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif case TARGET_NR_sync:sync (); - ret =0 ; -break ; +return 0 ;#if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS )case TARGET_NR_syncfs: - ret =get_errno (syncfs (arg1)); -break ; +return get_errno (syncfs (arg1));#endif case TARGET_NR_kill: - ret =get_errno (safe_kill (arg1,target_to_host_signal (arg2))); -break ; +return get_errno (safe_kill (arg1,target_to_host_signal (arg2)));#ifdef TARGET_NR_renamecase TARGET_NR_rename: {@@ -8536,7 +8523,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg2,0 ); unlock_user(p, arg1, 0); } -break ; +return ret;#endif #if defined(TARGET_NR_renameat)case TARGET_NR_renameat:@@ -8551,7 +8538,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg4,0 ); unlock_user(p, arg2, 0); } -break ; +return ret;#endif #if defined(TARGET_NR_renameat2)case TARGET_NR_renameat2:@@ -8567,7 +8554,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg4,0 ); unlock_user(p, arg2, 0); } -break ; +return ret;#endif #ifdef TARGET_NR_mkdircase TARGET_NR_mkdir:@@ -8575,7 +8562,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (mkdir (p, arg2));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #if defined(TARGET_NR_mkdirat)case TARGET_NR_mkdirat:@@ -8583,7 +8570,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (mkdirat (arg1, p, arg3));unlock_user (p, arg2,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_rmdircase TARGET_NR_rmdir:@@ -8591,24 +8578,22 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (rmdir (p));unlock_user (p, arg1,0 ); -break ; +return ret;#endif case TARGET_NR_dup: ret =get_errno (dup (arg1));if (ret >=0 ) {fd_trans_dup (arg1, ret); } -break ; +return ret;#ifdef TARGET_NR_pipecase TARGET_NR_pipe: - ret =do_pipe (cpu_env, arg1,0 ,0 ); -break ; +return do_pipe (cpu_env, arg1,0 ,0 );#endif #ifdef TARGET_NR_pipe2case TARGET_NR_pipe2: - ret =do_pipe (cpu_env, arg1, -target_to_host_bitmask (arg2, fcntl_flags_tbl),1 ); -break ; +return do_pipe (cpu_env, arg1, +target_to_host_bitmask (arg2, fcntl_flags_tbl),1 );#endif case TARGET_NR_times: {@@ -8627,7 +8612,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) ret =host_to_target_clock_t (ret); } -break ; +return ret;#ifdef TARGET_NR_profcase TARGET_NR_prof: goto unimplemented;@@ -8645,34 +8630,31 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (acct (path (p)));unlock_user (p, arg1,0 ); } -break ; +return ret;#ifdef TARGET_NR_umount2case TARGET_NR_umount2:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (umount2 (p, arg2));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_lockcase TARGET_NR_lock: goto unimplemented;#endif case TARGET_NR_ioctl: - ret =do_ioctl (arg1, arg2, arg3); -break ; +return do_ioctl (arg1, arg2, arg3);#ifdef TARGET_NR_fcntlcase TARGET_NR_fcntl: - ret =do_fcntl (arg1, arg2, arg3); -break ; +return do_fcntl (arg1, arg2, arg3);#endif #ifdef TARGET_NR_mpxcase TARGET_NR_mpx: goto unimplemented;#endif case TARGET_NR_setpgid: - ret =get_errno (setpgid (arg1, arg2)); -break ; +return get_errno (setpgid (arg1, arg2));#ifdef TARGET_NR_ulimitcase TARGET_NR_ulimit: goto unimplemented;@@ -8682,14 +8664,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented;#endif case TARGET_NR_umask: - ret =get_errno (umask (arg1)); -break ; +return get_errno (umask (arg1));case TARGET_NR_chroot:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (chroot (p));unlock_user (p, arg1,0 ); -break ; +return ret;#ifdef TARGET_NR_ustatcase TARGET_NR_ustat: goto unimplemented;@@ -8700,7 +8681,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (ret >=0 ) {fd_trans_dup (arg1, arg2); } -break ; +return ret;#endif #if defined(CONFIG_DUP3 ) && defined(TARGET_NR_dup3)case TARGET_NR_dup3:@@ -8715,22 +8696,19 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (ret >=0 ) {fd_trans_dup (arg1, arg2); } -break ; +return ret; }#endif #ifdef TARGET_NR_getppid/* not on alpha */ case TARGET_NR_getppid: - ret =get_errno (getppid ()); -break ; +return get_errno (getppid ());#endif #ifdef TARGET_NR_getpgrpcase TARGET_NR_getpgrp: - ret =get_errno (getpgrp ()); -break ; +return get_errno (getpgrp ());#endif case TARGET_NR_setsid: - ret =get_errno (setsid ()); -break ; +return get_errno (setsid ());#ifdef TARGET_NR_sigactioncase TARGET_NR_sigaction: {@@ -8814,7 +8792,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }#endif } -break ; +return ret;#endif case TARGET_NR_rt_sigaction: {@@ -8831,8 +8809,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_sigaction act, oact, *pact =0 ;if (arg4 !=sizeof (target_sigset_t)) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; }if (arg2) {if (!lock_user_struct (VERIFY_READ , rt_act, arg2,1 ))@@ -8864,8 +8841,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_sigaction *oact;if (sigsetsize !=sizeof (target_sigset_t)) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; }if (arg2) {if (!lock_user_struct (VERIFY_READ , act, arg2,1 )) {@@ -8892,7 +8868,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user_struct (oact, arg3,1 );#endif } -break ; +return ret;#ifdef TARGET_NR_sgetmask/* not on alpha */ case TARGET_NR_sgetmask: {@@ -8904,7 +8880,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = target_set; } } -break ; +return ret;#endif #ifdef TARGET_NR_ssetmask/* not on alpha */ case TARGET_NR_ssetmask:@@ -8918,7 +8894,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = target_set; } } -break ; +return ret;#endif #ifdef TARGET_NR_sigprocmaskcase TARGET_NR_sigprocmask:@@ -8988,7 +8964,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }#endif } -break ; +return ret;#endif case TARGET_NR_rt_sigprocmask: {@@ -8996,8 +8972,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,sigset_t set, oldset, *set_ptr;if (arg4 !=sizeof (target_sigset_t)) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; }if (arg2) {@@ -9032,7 +9007,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg3,sizeof (target_sigset_t)); } } -break ; +return ret;#ifdef TARGET_NR_sigpendingcase TARGET_NR_sigpending: {@@ -9045,7 +9020,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, sizeof(target_sigset_t)); } } -break ; +return ret;#endif case TARGET_NR_rt_sigpending: {@@ -9057,8 +9032,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,* the old_sigset_t is smaller in size. */ if (arg2 >sizeof (target_sigset_t)) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; } ret =get_errno (sigpending (&set));@@ -9069,7 +9043,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg1,sizeof (target_sigset_t)); } } -break ; +return ret;#ifdef TARGET_NR_sigsuspendcase TARGET_NR_sigsuspend: {@@ -9089,15 +9063,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ts->in_sigsuspend = 1; } } -break ; +return ret;#endif case TARGET_NR_rt_sigsuspend: {TaskState *ts = cpu->opaque;if (arg2 !=sizeof (target_sigset_t)) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; }if (!(p =lock_user (VERIFY_READ , arg1,sizeof (target_sigset_t),1 ))) goto efault;@@ -9109,7 +9082,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ts->in_sigsuspend =1 ; } } -break ; +return ret;case TARGET_NR_rt_sigtimedwait: {sigset_t set;@@ -9117,8 +9090,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,siginfo_t uinfo;if (arg4 !=sizeof (target_sigset_t)) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; }if (!(p =lock_user (VERIFY_READ , arg1,sizeof (target_sigset_t),1 )))@@ -9146,7 +9118,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =host_to_target_signal (ret); } } -break ; +return ret;case TARGET_NR_rt_sigqueueinfo: {siginfo_t uinfo;@@ -9159,7 +9131,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg3,0 ); ret =get_errno (sys_rt_sigqueueinfo (arg1, arg2, &uinfo)); } -break ; +return ret;case TARGET_NR_rt_tgsigqueueinfo: {siginfo_t uinfo;@@ -9172,7 +9144,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg4,0 ); ret =get_errno (sys_rt_tgsigqueueinfo (arg1, arg2, arg3, &uinfo)); } -break ; +return ret;#ifdef TARGET_NR_sigreturncase TARGET_NR_sigreturn:if (block_signals ()) {@@ -9180,21 +9152,20 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }else {
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 9160
Quoted 10 lines
linux-user/syscall.c +2
-2ret = do_sigreturn(cpu_env); } -break ; +return ret;#endif case TARGET_NR_rt_sigreturn:if (block_signals ()) { - ret = -TARGET_ERESTARTSYS ; +return -TARGET_ERESTARTSYS ; }else {
Easier to read removing the else clause.
Quoted 15 lines
linux-user/syscall.c +2
-3- ret =do_rt_sigreturn (cpu_env); +return do_rt_sigreturn (cpu_env); } -break ;case TARGET_NR_sethostname:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (sethostname (p, arg2));unlock_user (p, arg1,0 ); -break ; +return ret;case TARGET_NR_setrlimit: {int resource =target_to_host_resource (arg1);
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 9210
Quoted 7 lines
linux-user/syscall.c +1
-2@@ -9205,9 +9176,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, rlim.rlim_cur =target_to_host_rlim (target_rlim->rlim_cur); rlim.rlim_max =target_to_host_rlim (target_rlim->rlim_max);unlock_user_struct (target_rlim, arg2,0 ); - ret =get_errno (setrlimit (resource, &rlim)); +return get_errno (setrlimit (resource, &rlim)); } -break ;
Also easier to read "return ret;" here but this 'll get cleaned later.
Quoted 31 lines
linux-user/syscall.c +3
-3case TARGET_NR_getrlimit: {int resource =target_to_host_resource (arg1);@@ -9223,7 +9193,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user_struct (target_rlim, arg2,1 ); } } -break ; +return ret;case TARGET_NR_getrusage: {struct rusage rusage;@@ -9232,7 +9202,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =host_to_target_rusage (arg2, &rusage); } } -break ; +return ret;case TARGET_NR_gettimeofday: {struct timeval tv;@@ -9242,7 +9212,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;case TARGET_NR_settimeofday: {struct timeval tv, *ptv =NULL ;
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 9267
Quoted 7 lines
linux-user/syscall.c +1
-2@@ -9262,9 +9232,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ptz = &tz; } - ret =get_errno (settimeofday (ptv, ptz)); +return get_errno (settimeofday (ptv, ptz)); } -break ;
Ditto.
Quoted 353 lines
linux-user/syscall.c +52
-86#if defined(TARGET_NR_select)case TARGET_NR_select:#if defined(TARGET_WANT_NI_OLD_SELECT )@@ -9277,7 +9246,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#else ret =do_select (arg1, arg2, arg3, arg4, arg5);#endif -break ; +return ret;#endif #ifdef TARGET_NR_pselect6case TARGET_NR_pselect6:@@ -9381,7 +9350,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #ifdef TARGET_NR_symlinkcase TARGET_NR_symlink:@@ -9396,7 +9365,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg2,0 ); unlock_user(p, arg1, 0); } -break ; +return ret;#endif #if defined(TARGET_NR_symlinkat)case TARGET_NR_symlinkat:@@ -9411,7 +9380,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg3,0 ); unlock_user(p, arg1, 0); } -break ; +return ret;#endif #ifdef TARGET_NR_oldlstatcase TARGET_NR_oldlstat:@@ -9447,7 +9416,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg2, ret); unlock_user(p, arg1, 0); } -break ; +return ret;#endif #if defined(TARGET_NR_readlinkat)case TARGET_NR_readlinkat:@@ -9468,7 +9437,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p2, arg3, ret); unlock_user(p, arg2, 0); } -break ; +return ret;#endif #ifdef TARGET_NR_uselibcase TARGET_NR_uselib:@@ -9480,7 +9449,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (swapon (p, arg2));unlock_user (p, arg1,0 ); -break ; +return ret;#endif case TARGET_NR_reboot:if (arg3 ==LINUX_REBOOT_CMD_RESTART2 ) {@@ -9494,7 +9463,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }else { ret =get_errno (reboot (arg1, arg2, arg3,NULL )); } -break ; +return ret;#ifdef TARGET_NR_readdircase TARGET_NR_readdir: goto unimplemented;@@ -9527,22 +9496,20 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg5, arg6));#endif -break ; +return ret;#endif #ifdef TARGET_NR_mmap2case TARGET_NR_mmap2:#ifndef MMAP_SHIFT #define MMAP_SHIFT 12#endif - ret =get_errno (target_mmap (arg1, arg2, arg3, -target_to_host_bitmask (arg4, mmap_flags_tbl), - arg5, - arg6 <<MMAP_SHIFT )); -break ; + ret =target_mmap (arg1, arg2, arg3, +target_to_host_bitmask (arg4, mmap_flags_tbl), + arg5, arg6 <<MMAP_SHIFT ); +return get_errno (ret);#endif case TARGET_NR_munmap: - ret =get_errno (target_munmap (arg1, arg2)); -break ; +return get_errno (target_munmap (arg1, arg2));case TARGET_NR_mprotect: {TaskState *ts = cpu->opaque;@@ -9555,58 +9522,49 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg1 = ts->info->stack_limit; } } - ret =get_errno (target_mprotect (arg1, arg2, arg3)); -break ; +return get_errno (target_mprotect (arg1, arg2, arg3));#ifdef TARGET_NR_mremapcase TARGET_NR_mremap: - ret =get_errno (target_mremap (arg1, arg2, arg3, arg4, arg5)); -break ; +return get_errno (target_mremap (arg1, arg2, arg3, arg4, arg5));#endif /* ??? msync/mlock/munlock are broken for softmmu. */ #ifdef TARGET_NR_msynccase TARGET_NR_msync: - ret =get_errno (msync (g2h (arg1), arg2, arg3)); -break ; +return get_errno (msync (g2h (arg1), arg2, arg3));#endif #ifdef TARGET_NR_mlockcase TARGET_NR_mlock: - ret =get_errno (mlock (g2h (arg1), arg2)); -break ; +return get_errno (mlock (g2h (arg1), arg2));#endif #ifdef TARGET_NR_munlockcase TARGET_NR_munlock: - ret =get_errno (munlock (g2h (arg1), arg2)); -break ; +return get_errno (munlock (g2h (arg1), arg2));#endif #ifdef TARGET_NR_mlockallcase TARGET_NR_mlockall: - ret =get_errno (mlockall (target_to_host_mlockall_arg (arg1))); -break ; +return get_errno (mlockall (target_to_host_mlockall_arg (arg1)));#endif #ifdef TARGET_NR_munlockallcase TARGET_NR_munlockall: - ret =get_errno (munlockall ()); -break ; +return get_errno (munlockall ());#endif case TARGET_NR_truncate:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (truncate (p, arg2));unlock_user (p, arg1,0 ); -break ; +return ret;case TARGET_NR_ftruncate: - ret =get_errno (ftruncate (arg1, arg2)); -break ; +return get_errno (ftruncate (arg1, arg2));case TARGET_NR_fchmod: - ret =get_errno (fchmod (arg1, arg2)); -break ; +return get_errno (fchmod (arg1, arg2));#if defined(TARGET_NR_fchmodat)case TARGET_NR_fchmodat:if (!(p =lock_user_string (arg2))) goto efault; ret =get_errno (fchmodat (arg1, p, arg3,0 ));unlock_user (p, arg2,0 ); -break ; +return ret;#endif case TARGET_NR_getpriority:/* Note that negative values are valid for getpriority, so we must @@ -9614,8 +9572,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, errno =0 ; ret =getpriority (arg1, arg2);if (ret ==-1 && errno !=0 ) { - ret = -host_to_target_errno (errno); -break ; +return -host_to_target_errno (errno); }#ifdef TARGET_ALPHA /* Return value is the unbiased priority. Signal no error. */ @@ -9624,10 +9581,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,/* Return value is a biased priority to avoid negative numbers. */ ret =20 - ret;#endif -break ; +return ret;case TARGET_NR_setpriority: - ret =get_errno (setpriority (arg1, arg2, arg3)); -break ; +return get_errno (setpriority (arg1, arg2, arg3));#ifdef TARGET_NR_profilcase TARGET_NR_profil: goto unimplemented;@@ -9662,7 +9618,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,memset (target_stfs->f_spare,0 ,sizeof (target_stfs->f_spare));unlock_user_struct (target_stfs, arg2,1 ); } -break ; +return ret;case TARGET_NR_fstatfs: ret =get_errno (fstatfs (arg1, &stfs)); goto convert_statfs;@@ -9692,7 +9648,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,memset (target_stfs->f_spare,0 ,sizeof (target_stfs->f_spare));unlock_user_struct (target_stfs, arg3,1 ); } -break ; +return ret;case TARGET_NR_fstatfs64: ret =get_errno (fstatfs (arg1, &stfs)); goto convert_statfs64;@@ -9703,91 +9659,73 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_socketcallcase TARGET_NR_socketcall: - ret =do_socketcall (arg1, arg2); -break ; +return do_socketcall (arg1, arg2);#endif #ifdef TARGET_NR_acceptcase TARGET_NR_accept: - ret =do_accept4 (arg1, arg2, arg3,0 ); -break ; +return do_accept4 (arg1, arg2, arg3,0 );#endif #ifdef TARGET_NR_accept4case TARGET_NR_accept4: - ret =do_accept4 (arg1, arg2, arg3, arg4); -break ; +return do_accept4 (arg1, arg2, arg3, arg4);#endif #ifdef TARGET_NR_bindcase TARGET_NR_bind: - ret =do_bind (arg1, arg2, arg3); -break ; +return do_bind (arg1, arg2, arg3);#endif #ifdef TARGET_NR_connectcase TARGET_NR_connect: - ret =do_connect (arg1, arg2, arg3); -break ; +return do_connect (arg1, arg2, arg3);#endif #ifdef TARGET_NR_getpeernamecase TARGET_NR_getpeername: - ret =do_getpeername (arg1, arg2, arg3); -break ; +return do_getpeername (arg1, arg2, arg3);#endif #ifdef TARGET_NR_getsocknamecase TARGET_NR_getsockname: - ret =do_getsockname (arg1, arg2, arg3); -break ; +return do_getsockname (arg1, arg2, arg3);#endif #ifdef TARGET_NR_getsockoptcase TARGET_NR_getsockopt: - ret =do_getsockopt (arg1, arg2, arg3, arg4, arg5); -break ; +return do_getsockopt (arg1, arg2, arg3, arg4, arg5);#endif #ifdef TARGET_NR_listencase TARGET_NR_listen: - ret =get_errno (listen (arg1, arg2)); -break ; +return get_errno (listen (arg1, arg2));#endif #ifdef TARGET_NR_recvcase TARGET_NR_recv: - ret =do_recvfrom (arg1, arg2, arg3, arg4,0 ,0 ); -break ; +return do_recvfrom (arg1, arg2, arg3, arg4,0 ,0 );#endif #ifdef TARGET_NR_recvfromcase TARGET_NR_recvfrom: - ret =do_recvfrom (arg1, arg2, arg3, arg4, arg5, arg6); -break ; +return do_recvfrom (arg1, arg2, arg3, arg4, arg5, arg6);#endif #ifdef TARGET_NR_recvmsgcase TARGET_NR_recvmsg: - ret =do_sendrecvmsg (arg1, arg2, arg3,0 ); -break ; +return do_sendrecvmsg (arg1, arg2, arg3,0 );#endif #ifdef TARGET_NR_sendcase TARGET_NR_send: - ret =do_sendto (arg1, arg2, arg3, arg4,0 ,0 ); -break ; +return do_sendto (arg1, arg2, arg3, arg4,0 ,0 );#endif #ifdef TARGET_NR_sendmsgcase TARGET_NR_sendmsg: - ret =do_sendrecvmsg (arg1, arg2, arg3,1 ); -break ; +return do_sendrecvmsg (arg1, arg2, arg3,1 );#endif #ifdef TARGET_NR_sendmmsgcase TARGET_NR_sendmmsg: - ret =do_sendrecvmmsg (arg1, arg2, arg3, arg4,1 ); -break ; +return do_sendrecvmmsg (arg1, arg2, arg3, arg4,1 );case TARGET_NR_recvmmsg: - ret =do_sendrecvmmsg (arg1, arg2, arg3, arg4,0 ); -break ; +return do_sendrecvmmsg (arg1, arg2, arg3, arg4,0 );#endif #ifdef TARGET_NR_sendtocase TARGET_NR_sendto: - ret =do_sendto (arg1, arg2, arg3, arg4, arg5, arg6); -break ; +return do_sendto (arg1, arg2, arg3, arg4, arg5, arg6);#endif #ifdef TARGET_NR_shutdowncase TARGET_NR_shutdown: - ret =get_errno (shutdown (arg1, arg2)); -break ; +return get_errno (shutdown (arg1, arg2));#endif #if defined(TARGET_NR_getrandom) && defined(__NR_getrandom)case TARGET_NR_getrandom:@@ -9797,22 +9735,19 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } ret =get_errno (getrandom (p, arg2, arg3));unlock_user (p, arg1, ret); -break ; +return ret;#endif #ifdef TARGET_NR_socketcase TARGET_NR_socket: - ret =do_socket (arg1, arg2, arg3); -break ; +return do_socket (arg1, arg2, arg3);#endif #ifdef TARGET_NR_socketpaircase TARGET_NR_socketpair: - ret =do_socketpair (arg1, arg2, arg3, arg4); -break ; +return do_socketpair (arg1, arg2, arg3, arg4);#endif #ifdef TARGET_NR_setsockoptcase TARGET_NR_setsockopt: - ret =do_setsockopt (arg1, arg2, arg3, arg4, (socklen_t ) arg5); -break ; +return do_setsockopt (arg1, arg2, arg3, arg4, (socklen_t ) arg5);#endif #if defined(TARGET_NR_syslog)case TARGET_NR_syslog:
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 9766
Quoted 8 lines
linux-user/syscall.c +1
-4@@ -9828,10 +9763,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL :/* Set messages level */ case TARGET_SYSLOG_ACTION_SIZE_UNREAD :/* Number of chars */ case TARGET_SYSLOG_ACTION_SIZE_BUFFER :/* Size of the buffer */ - { - ret =get_errno (sys_syslog ((int )arg1,NULL , (int )arg3)); - } -break ; +return get_errno (sys_syslog ((int )arg1,NULL , (int )arg3));
:)
Quoted 15 lines
linux-user/syscall.c +1
-2case TARGET_SYSLOG_ACTION_READ :/* Read from log */ case TARGET_SYSLOG_ACTION_READ_CLEAR :/* Read/clear msgs */ case TARGET_SYSLOG_ACTION_READ_ALL :/* Read last messages */ @@ -9840,9 +9772,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (len <0 ) { goto fail; } - ret =0 ;if (len ==0 ) { -break ; +return 0 ; } p =lock_user (VERIFY_WRITE , arg2, arg3,0 );if (!p) {
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 9788
Quoted 9 lines
linux-user/syscall.c +2
-3@@ -9852,10 +9783,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (sys_syslog ((int )arg1, p, (int )arg3));unlock_user (p, arg2, arg3); } -break ; +return ret;default : - ret = -EINVAL ; -break ; +return -TARGET_EINVAL ;
Oh, bug fixed?
Quoted 425 lines
linux-user/syscall.c +54
-86} }break ;@@ -9882,7 +9812,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;case TARGET_NR_getitimer: {struct itimerval value;@@ -9896,7 +9826,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#ifdef TARGET_NR_statcase TARGET_NR_stat:if (!(p =lock_user_string (arg1)))@@ -9941,7 +9871,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user_struct (target_st, arg2,1 ); } } -break ; +return ret;#ifdef TARGET_NR_oldunamecase TARGET_NR_olduname: goto unimplemented;@@ -9951,17 +9881,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented;#endif case TARGET_NR_vhangup: - ret =get_errno (vhangup ()); -break ; +return get_errno (vhangup ());#ifdef TARGET_NR_idlecase TARGET_NR_idle: goto unimplemented;#endif #ifdef TARGET_NR_syscallcase TARGET_NR_syscall: - ret =do_syscall (cpu_env, arg1 &0xffff , arg2, arg3, arg4, arg5, - arg6, arg7, arg8,0 ); -break ; +return do_syscall (cpu_env, arg1 &0xffff , arg2, arg3, arg4, arg5, + arg6, arg7, arg8,0 );#endif case TARGET_NR_wait4: {@@ -9989,14 +9917,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } -break ; +return ret;#ifdef TARGET_NR_swapoffcase TARGET_NR_swapoff:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (swapoff (p));unlock_user (p, arg1,0 ); -break ; +return ret;#endif case TARGET_NR_sysinfo: {@@ -10024,70 +9952,57 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user_struct (target_value, arg1,1 ); } } -break ; +return ret;#ifdef TARGET_NR_ipccase TARGET_NR_ipc: - ret =do_ipc (cpu_env, arg1, arg2, arg3, arg4, arg5, arg6); -break ; +return do_ipc (cpu_env, arg1, arg2, arg3, arg4, arg5, arg6);#endif #ifdef TARGET_NR_semgetcase TARGET_NR_semget: - ret =get_errno (semget (arg1, arg2, arg3)); -break ; +return get_errno (semget (arg1, arg2, arg3));#endif #ifdef TARGET_NR_semopcase TARGET_NR_semop: - ret =do_semop (arg1, arg2, arg3); -break ; +return do_semop (arg1, arg2, arg3);#endif #ifdef TARGET_NR_semctlcase TARGET_NR_semctl: - ret =do_semctl (arg1, arg2, arg3, arg4); -break ; +return do_semctl (arg1, arg2, arg3, arg4);#endif #ifdef TARGET_NR_msgctlcase TARGET_NR_msgctl: - ret =do_msgctl (arg1, arg2, arg3); -break ; +return do_msgctl (arg1, arg2, arg3);#endif #ifdef TARGET_NR_msggetcase TARGET_NR_msgget: - ret =get_errno (msgget (arg1, arg2)); -break ; +return get_errno (msgget (arg1, arg2));#endif #ifdef TARGET_NR_msgrcvcase TARGET_NR_msgrcv: - ret =do_msgrcv (arg1, arg2, arg3, arg4, arg5); -break ; +return do_msgrcv (arg1, arg2, arg3, arg4, arg5);#endif #ifdef TARGET_NR_msgsndcase TARGET_NR_msgsnd: - ret =do_msgsnd (arg1, arg2, arg3, arg4); -break ; +return do_msgsnd (arg1, arg2, arg3, arg4);#endif #ifdef TARGET_NR_shmgetcase TARGET_NR_shmget: - ret =get_errno (shmget (arg1, arg2, arg3)); -break ; +return get_errno (shmget (arg1, arg2, arg3));#endif #ifdef TARGET_NR_shmctlcase TARGET_NR_shmctl: - ret =do_shmctl (arg1, arg2, arg3); -break ; +return do_shmctl (arg1, arg2, arg3);#endif #ifdef TARGET_NR_shmatcase TARGET_NR_shmat: - ret =do_shmat (cpu_env, arg1, arg2, arg3); -break ; +return do_shmat (cpu_env, arg1, arg2, arg3);#endif #ifdef TARGET_NR_shmdtcase TARGET_NR_shmdt: - ret =do_shmdt (arg1); -break ; +return do_shmdt (arg1);#endif case TARGET_NR_fsync: - ret =get_errno (fsync (arg1)); -break ; +return get_errno (fsync (arg1));case TARGET_NR_clone:/* Linux manages to have three different orderings for its * arguments to clone(); the BACKWARDS and BACKWARDS2 defines @@ -10104,7 +10019,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#else ret =get_errno (do_fork (cpu_env, arg1, arg2, arg3, arg5, arg4));#endif -break ; +return ret;#ifdef __NR_exit_group/* new thread calls */ case TARGET_NR_exit_group:@@ -10112,15 +10027,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,_mcleanup ();#endif gdb_exit (cpu_env, arg1); - ret =get_errno (exit_group (arg1)); -break ; +return get_errno (exit_group (arg1));#endif case TARGET_NR_setdomainname:if (!(p =lock_user_string (arg1))) goto efault; ret =get_errno (setdomainname (p, arg2));unlock_user (p, arg1,0 ); -break ; +return ret;case TARGET_NR_uname:/* no need to transcode because we use the linux syscall */ {@@ -10142,17 +10056,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user_struct (buf, arg1,1 ); } -break ; +return ret;#ifdef TARGET_I386 case TARGET_NR_modify_ldt: - ret =do_modify_ldt (cpu_env, arg1, arg2, arg3); -break ; +return do_modify_ldt (cpu_env, arg1, arg2, arg3);#if !defined(TARGET_X86_64 )case TARGET_NR_vm86old: goto unimplemented;case TARGET_NR_vm86: - ret =do_vm86 (cpu_env, arg1, arg2); -break ; +return do_vm86 (cpu_env, arg1, arg2);#endif #endif case TARGET_NR_adjtimex:@@ -10169,7 +10081,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } -break ; +return ret;#if defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME )case TARGET_NR_clock_adjtime: {@@ -10185,7 +10097,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } -break ; +return ret;#endif #ifdef TARGET_NR_create_modulecase TARGET_NR_create_module:@@ -10199,11 +10111,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,case TARGET_NR_quotactl: goto unimplemented;case TARGET_NR_getpgid: - ret =get_errno (getpgid (arg1)); -break ; +return get_errno (getpgid (arg1));case TARGET_NR_fchdir: - ret =get_errno (fchdir (arg1)); -break ; +return get_errno (fchdir (arg1));#ifdef TARGET_NR_bdflush/* not on x86_64 */ case TARGET_NR_bdflush: goto unimplemented;@@ -10213,8 +10123,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented;#endif case TARGET_NR_personality: - ret =get_errno (personality (arg1)); -break ; +return get_errno (personality (arg1));#ifdef TARGET_NR_afs_syscallcase TARGET_NR_afs_syscall: goto unimplemented;@@ -10237,7 +10146,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #ifdef TARGET_NR_getdentscase TARGET_NR_getdents:@@ -10369,7 +10278,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (dirp, arg2, ret); }#endif -break ; +return ret;#endif /* TARGET_NR_getdents */ #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)case TARGET_NR_getdents64:@@ -10397,12 +10306,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user (dirp, arg2, ret); } -break ; +return ret;#endif /* TARGET_NR_getdents64 */ #if defined(TARGET_NR__newselect)case TARGET_NR__newselect: - ret =do_select (arg1, arg2, arg3, arg4, arg5); -break ; +return do_select (arg1, arg2, arg3, arg4, arg5);#endif #if defined(TARGET_NR_poll) || defined(TARGET_NR_ppoll)# ifdef TARGET_NR_poll@@ -10421,8 +10329,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_pfd =NULL ;if (nfds) {if (nfds > (INT_MAX /sizeof (struct target_pollfd ))) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; } target_pfd = lock_user(VERIFY_WRITE, arg1,@@ -10458,8 +10365,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg4) {if (arg5 !=sizeof (target_sigset_t)) {unlock_user (target_pfd, arg1,0 ); - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; } target_set =lock_user (VERIFY_READ , arg4,sizeof (target_sigset_t),1 );@@ -10481,7 +10387,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg4) {unlock_user (target_set, arg4,0 ); } - break; + return ret; }# endif # ifdef TARGET_NR_poll@@ -10498,8 +10404,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,/* -ve poll() timeout means "infinite" */ pts = NULL; } - ret =get_errno (safe_ppoll (pfd, nfds, pts,NULL ,0 )); -break ; +return get_errno (safe_ppoll (pfd, nfds, pts,NULL ,0 )); }# endif default :@@ -10513,13 +10418,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user (target_pfd, arg1,sizeof (struct target_pollfd ) * nfds); } -break ; +return ret;#endif case TARGET_NR_flock:/* NOTE: the flock constant seems to be the same for every Linux platform */ - ret =get_errno (safe_flock (arg1, arg2)); -break ; +return get_errno (safe_flock (arg1, arg2));case TARGET_NR_readv: {struct iovec *vec =lock_iovec (VERIFY_WRITE , arg2, arg3,0 );@@ -10530,7 +10434,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno (errno); } } -break ; +return ret;case TARGET_NR_writev: {struct iovec *vec =lock_iovec (VERIFY_READ , arg2, arg3,1 );@@ -10541,7 +10445,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno (errno); } } -break ; +return ret;#if defined(TARGET_NR_preadv)case TARGET_NR_preadv: {@@ -10556,7 +10460,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno(errno); } } -break ; +return ret;#endif #if defined(TARGET_NR_pwritev)case TARGET_NR_pwritev:@@ -10572,22 +10476,19 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno(errno); } } -break ; +return ret;#endif case TARGET_NR_getsid: - ret =get_errno (getsid (arg1)); -break ; +return get_errno (getsid (arg1));#if defined(TARGET_NR_fdatasync)/* Not on alpha (osf_datasync ?) */ case TARGET_NR_fdatasync: - ret =get_errno (fdatasync (arg1)); -break ; +return get_errno (fdatasync (arg1));#endif #ifdef TARGET_NR__sysctlcase TARGET_NR__sysctl:/* We don't implement this, but ENOTDIR is always a safe return value. */ - ret = -TARGET_ENOTDIR ; -break ; +return -TARGET_ENOTDIR ;#endif case TARGET_NR_sched_getaffinity: {@@ -10599,8 +10500,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,* care of mismatches between target ulong and host ulong sizes. */ if (arg2 & (sizeof (abi_ulong) -1 )) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; } mask_size = (arg2 + (sizeof (*mask) -1 )) & ~(sizeof (*mask) -1 );@@ -10619,8 +10519,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,*/ int numcpus =sysconf (_SC_NPROCESSORS_CONF);if (numcpus > arg2 *8 ) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; } ret = arg2; }@@ -10630,7 +10529,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } -break ; +return ret;case TARGET_NR_sched_setaffinity: {unsigned int mask_size;@@ -10641,20 +10540,18 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,* care of mismatches between target ulong and host ulong sizes. */ if (arg2 & (sizeof (abi_ulong) -1 )) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; } mask_size = (arg2 + (sizeof (*mask) -1 )) & ~(sizeof (*mask) -1 ); mask =alloca (mask_size);
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 10657
Quoted 10 lines
linux-user/syscall.c +2
-3ret =target_to_host_cpu_mask (mask, mask_size, arg3, arg2);if (ret) { -break ; +return ret; } - ret =get_errno (sys_sched_setaffinity (arg1, mask_size, mask)); +return get_errno (sys_sched_setaffinity (arg1, mask_size, mask)); } -break ;
Ditto (and so on) "return ret;" improved later in this series.
Quoted 234 lines
linux-user/syscall.c +31
-41case TARGET_NR_getcpu: {unsigned cpu, node;@@ -10671,7 +10568,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;case TARGET_NR_sched_setparam: {struct sched_param *target_schp;@@ -10684,9 +10581,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; schp.sched_priority =tswap32 (target_schp->sched_priority);unlock_user_struct (target_schp, arg2,0 ); - ret =get_errno (sched_setparam (arg1, &schp)); +return get_errno (sched_setparam (arg1, &schp)); } -break ;case TARGET_NR_sched_getparam: {struct sched_param *target_schp;@@ -10703,7 +10599,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user_struct (target_schp, arg2,1 ); } } -break ; +return ret;case TARGET_NR_sched_setscheduler: {struct sched_param *target_schp;@@ -10715,21 +10611,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; schp.sched_priority =tswap32 (target_schp->sched_priority);unlock_user_struct (target_schp, arg3,0 ); - ret =get_errno (sched_setscheduler (arg1, arg2, &schp)); +return get_errno (sched_setscheduler (arg1, arg2, &schp)); } -break ;case TARGET_NR_sched_getscheduler: - ret =get_errno (sched_getscheduler (arg1)); -break ; +return get_errno (sched_getscheduler (arg1));case TARGET_NR_sched_yield: - ret =get_errno (sched_yield ()); -break ; +return get_errno (sched_yield ());case TARGET_NR_sched_get_priority_max: - ret =get_errno (sched_get_priority_max (arg1)); -break ; +return get_errno (sched_get_priority_max (arg1));case TARGET_NR_sched_get_priority_min: - ret =get_errno (sched_get_priority_min (arg1)); -break ; +return get_errno (sched_get_priority_min (arg1));case TARGET_NR_sched_rr_get_interval: {struct timespec ts;@@ -10738,7 +10629,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =host_to_target_timespec (arg2, &ts); } } -break ; +return ret;case TARGET_NR_nanosleep: {struct timespec req, rem;@@ -10748,7 +10639,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,host_to_target_timespec (arg2, &rem); } } -break ; +return ret;#ifdef TARGET_NR_query_modulecase TARGET_NR_query_module: goto unimplemented;@@ -10767,7 +10658,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, && put_user_ual(deathsig, arg2)) { goto efault; } -break ; +return ret; }#ifdef PR_GET_NAME case PR_GET_NAME :@@ -10779,7 +10670,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (prctl (arg1, (unsigned long )name, arg3, arg4, arg5));unlock_user (name, arg2,16 ); -break ; +return ret; }case PR_SET_NAME : {@@ -10790,7 +10681,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (prctl (arg1, (unsigned long )name, arg3, arg4, arg5));unlock_user (name, arg2,0 ); - break; + return ret; }#endif #ifdef TARGET_AARCH64 @@ -10811,32 +10702,29 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, env->vfp.zcr_el[1 ] = vq -1 ; ret = vq * 16; } -break ; +return ret;case TARGET_PR_SVE_GET_VL : ret = -TARGET_EINVAL ;if (arm_feature (cpu_env,ARM_FEATURE_SVE )) {CPUARMState *env = cpu_env; ret = ((env->vfp.zcr_el[1 ] &0xf ) +1 ) *16 ; } -break ; +return ret;#endif /* AARCH64 */ case PR_GET_SECCOMP :case PR_SET_SECCOMP :/* Disable seccomp to prevent the target disabling syscalls we * need. */ - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ;default :/* Most prctl options have no pointer arguments */ - ret =get_errno (prctl (arg1, arg2, arg3, arg4, arg5)); -break ; +return get_errno (prctl (arg1, arg2, arg3, arg4, arg5)); }break ;#ifdef TARGET_NR_arch_prctlcase TARGET_NR_arch_prctl:#if defined(TARGET_I386 ) && !defined(TARGET_ABI32 ) - ret =do_arch_prctl (cpu_env, arg1, arg2); -break ; +return do_arch_prctl (cpu_env, arg1, arg2);#else goto unimplemented;#endif @@ -10851,7 +10739,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (pread64 (arg1, p, arg3,target_offset64 (arg4, arg5)));unlock_user (p, arg2, ret); -break ; +return ret;case TARGET_NR_pwrite64:if (regpairs_aligned (cpu_env, num)) { arg4 = arg5;@@ -10861,14 +10749,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (pwrite64 (arg1, p, arg3,target_offset64 (arg4, arg5)));unlock_user (p, arg2,0 ); -break ; +return ret;#endif case TARGET_NR_getcwd:if (!(p =lock_user (VERIFY_WRITE , arg1, arg2,0 ))) goto efault; ret =get_errno (sys_getcwd1 (p, arg2));unlock_user (p, arg1, ret); -break ; +return ret;case TARGET_NR_capget:case TARGET_NR_capset: {@@ -10937,11 +10825,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (target_data, arg2,0 ); } } -break ; +return ret; }case TARGET_NR_sigaltstack: - ret =do_sigaltstack (arg1, arg2,get_sp_from_cpustate ((CPUArchState *)cpu_env)); -break ; +return do_sigaltstack (arg1, arg2, +get_sp_from_cpustate ((CPUArchState *)cpu_env));#ifdef CONFIG_SENDFILE case TARGET_NR_sendfile:@@ -10951,7 +10839,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg3) { ret =get_user_sal (off, arg3);if (is_error (ret)) { -break ; +return ret; } offp = &off; }@@ -10962,7 +10850,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = ret2; } } -break ; +return ret; }#ifdef TARGET_NR_sendfile64case TARGET_NR_sendfile64:@@ -10972,7 +10860,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg3) { ret =get_user_s64 (off, arg3);if (is_error (ret)) { -break ; +return ret; } offp = &off; }@@ -10983,7 +10871,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = ret2; } } -break ; +return ret; }#endif #else @@ -11004,10 +10892,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_vforkcase TARGET_NR_vfork: - ret =get_errno (do_fork (cpu_env, -CLONE_VFORK |CLONE_VM |TARGET_SIGCHLD , -0 ,0 ,0 ,0 )); -break ; +return get_errno (do_fork (cpu_env, +CLONE_VFORK |CLONE_VM |TARGET_SIGCHLD , +0 ,0 ,0 ,0 ));#endif #ifdef TARGET_NR_ugetrlimitcase TARGET_NR_ugetrlimit:
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 10913
Quoted 5 lines
linux-user/syscall.c +1
-1@@ -11023,7 +10910,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_rlim->rlim_max =host_to_target_rlim (rlim.rlim_max);unlock_user_struct (target_rlim, arg2,1 ); } -break ; +return ret;
Here we go!
Quoted 1,135 lines
linux-user/syscall.c +148
-224}#endif #ifdef TARGET_NR_truncate64@@ -11032,12 +10919,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =target_truncate64 (cpu_env, p, arg2, arg3, arg4);unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_ftruncate64case TARGET_NR_ftruncate64: - ret =target_ftruncate64 (cpu_env, arg1, arg2, arg3, arg4); -break ; +return target_ftruncate64 (cpu_env, arg1, arg2, arg3, arg4);#endif #ifdef TARGET_NR_stat64case TARGET_NR_stat64:@@ -11047,7 +10933,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg1,0 );if (!is_error (ret)) ret =host_to_target_stat64 (cpu_env, arg2, &st); -break ; +return ret;#endif #ifdef TARGET_NR_lstat64case TARGET_NR_lstat64:@@ -11057,14 +10943,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg1,0 );if (!is_error (ret)) ret =host_to_target_stat64 (cpu_env, arg2, &st); -break ; +return ret;#endif #ifdef TARGET_NR_fstat64case TARGET_NR_fstat64: ret =get_errno (fstat (arg1, &st));if (!is_error (ret)) ret =host_to_target_stat64 (cpu_env, arg2, &st); -break ; +return ret;#endif #if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat))#ifdef TARGET_NR_fstatat64@@ -11078,7 +10964,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (fstatat (arg1,path (p), &st, arg4));if (!is_error (ret)) ret =host_to_target_stat64 (cpu_env, arg3, &st); -break ; +return ret;#endif #ifdef TARGET_NR_lchowncase TARGET_NR_lchown:@@ -11086,34 +10972,28 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (lchown (p,low2highuid (arg2),low2highgid (arg3)));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_getuidcase TARGET_NR_getuid: - ret =get_errno (high2lowuid (getuid ())); -break ; +return get_errno (high2lowuid (getuid ()));#endif #ifdef TARGET_NR_getgidcase TARGET_NR_getgid: - ret =get_errno (high2lowgid (getgid ())); -break ; +return get_errno (high2lowgid (getgid ()));#endif #ifdef TARGET_NR_geteuidcase TARGET_NR_geteuid: - ret =get_errno (high2lowuid (geteuid ())); -break ; +return get_errno (high2lowuid (geteuid ()));#endif #ifdef TARGET_NR_getegidcase TARGET_NR_getegid: - ret =get_errno (high2lowgid (getegid ())); -break ; +return get_errno (high2lowgid (getegid ()));#endif case TARGET_NR_setreuid: - ret =get_errno (setreuid (low2highuid (arg1),low2highuid (arg2))); -break ; +return get_errno (setreuid (low2highuid (arg1),low2highuid (arg2)));case TARGET_NR_setregid: - ret =get_errno (setregid (low2highgid (arg1),low2highgid (arg2))); -break ; +return get_errno (setregid (low2highgid (arg1),low2highgid (arg2)));case TARGET_NR_getgroups: {int gidsetsize = arg1;@@ -11124,7 +11004,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, grouplist =alloca (gidsetsize *sizeof (gid_t)); ret =get_errno (getgroups (gidsetsize, grouplist));if (gidsetsize ==0 ) -break ; +return ret;if (!is_error (ret)) { target_grouplist =lock_user (VERIFY_WRITE , arg2, gidsetsize *sizeof (target_id),0 );if (!target_grouplist)@@ -11134,7 +11014,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (target_grouplist, arg2, gidsetsize *sizeof (target_id)); } } -break ; +return ret;case TARGET_NR_setgroups: {int gidsetsize = arg1;@@ -11153,12 +11033,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user (target_grouplist, arg2,0 ); } - ret =get_errno (setgroups (gidsetsize, grouplist)); +return get_errno (setgroups (gidsetsize, grouplist)); } -break ;case TARGET_NR_fchown: - ret =get_errno (fchown (arg1,low2highuid (arg2),low2highgid (arg3))); -break ; +return get_errno (fchown (arg1,low2highuid (arg2),low2highgid (arg3)));#if defined(TARGET_NR_fchownat)case TARGET_NR_fchownat:if (!(p =lock_user_string (arg2)))@@ -11166,14 +11044,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (fchownat (arg1, p,low2highuid (arg3),low2highgid (arg4), arg5));unlock_user (p, arg2,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_setresuidcase TARGET_NR_setresuid: - ret =get_errno (sys_setresuid (low2highuid (arg1), -low2highuid (arg2), -low2highuid (arg3))); -break ; +return get_errno (sys_setresuid (low2highuid (arg1), +low2highuid (arg2), +low2highuid (arg3)));#endif #ifdef TARGET_NR_getresuidcase TARGET_NR_getresuid:@@ -11187,14 +11064,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #ifdef TARGET_NR_getresgidcase TARGET_NR_setresgid: - ret =get_errno (sys_setresgid (low2highgid (arg1), -low2highgid (arg2), -low2highgid (arg3))); -break ; +return get_errno (sys_setresgid (low2highgid (arg1), +low2highgid (arg2), +low2highgid (arg3)));#endif #ifdef TARGET_NR_getresgidcase TARGET_NR_getresgid:@@ -11208,7 +11084,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #ifdef TARGET_NR_chowncase TARGET_NR_chown:@@ -11216,20 +11092,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (chown (p,low2highuid (arg2),low2highgid (arg3)));unlock_user (p, arg1,0 ); -break ; +return ret;#endif case TARGET_NR_setuid: - ret =get_errno (sys_setuid (low2highuid (arg1))); -break ; +return get_errno (sys_setuid (low2highuid (arg1)));case TARGET_NR_setgid: - ret =get_errno (sys_setgid (low2highgid (arg1))); -break ; +return get_errno (sys_setgid (low2highgid (arg1)));case TARGET_NR_setfsuid: - ret =get_errno (setfsuid (arg1)); -break ; +return get_errno (setfsuid (arg1));case TARGET_NR_setfsgid: - ret =get_errno (setfsgid (arg1)); -break ; +return get_errno (setfsgid (arg1));#ifdef TARGET_NR_lchown32case TARGET_NR_lchown32:@@ -11237,12 +11109,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (lchown (p, arg2, arg3));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_getuid32case TARGET_NR_getuid32: - ret =get_errno (getuid ()); -break ; +return get_errno (getuid ());#endif #if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA )@@ -11253,8 +11124,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, euid=geteuid (); ((CPUAlphaState *)cpu_env)->ir[IR_A4]=euid; } - ret =get_errno (getuid ()); -break ; +return get_errno (getuid ());#endif #if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA )/* Alpha specific */ @@ -11264,8 +11134,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, egid=getegid (); ((CPUAlphaState *)cpu_env)->ir[IR_A4]=egid; } - ret =get_errno (getgid ()); -break ; +return get_errno (getgid ());#endif #if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA )/* Alpha specific */ @@ -11303,7 +11172,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,-- Grabs a copy of the HWRPB; surely not used. */ } -break ; +return ret;#endif #if defined(TARGET_NR_osf_setsysinfo) && defined(TARGET_ALPHA )/* Alpha specific */ @@ -11394,7 +11263,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,-- Not implemented in linux kernel */ } -break ; +return ret;#endif #ifdef TARGET_NR_osf_sigprocmask/* Alpha specific. */ @@ -11426,33 +11295,28 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = mask; } } -break ; +return ret;#endif #ifdef TARGET_NR_getgid32case TARGET_NR_getgid32: - ret =get_errno (getgid ()); -break ; +return get_errno (getgid ());#endif #ifdef TARGET_NR_geteuid32case TARGET_NR_geteuid32: - ret =get_errno (geteuid ()); -break ; +return get_errno (geteuid ());#endif #ifdef TARGET_NR_getegid32case TARGET_NR_getegid32: - ret =get_errno (getegid ()); -break ; +return get_errno (getegid ());#endif #ifdef TARGET_NR_setreuid32case TARGET_NR_setreuid32: - ret =get_errno (setreuid (arg1, arg2)); -break ; +return get_errno (setreuid (arg1, arg2));#endif #ifdef TARGET_NR_setregid32case TARGET_NR_setregid32: - ret =get_errno (setregid (arg1, arg2)); -break ; +return get_errno (setregid (arg1, arg2));#endif #ifdef TARGET_NR_getgroups32case TARGET_NR_getgroups32:@@ -11465,7 +11329,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, grouplist =alloca (gidsetsize *sizeof (gid_t)); ret =get_errno (getgroups (gidsetsize, grouplist));if (gidsetsize ==0 ) -break ; +return ret;if (!is_error (ret)) { target_grouplist =lock_user (VERIFY_WRITE , arg2, gidsetsize *4 ,0 );if (!target_grouplist) {@@ -11477,7 +11341,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(target_grouplist, arg2, gidsetsize * 4); } } -break ; +return ret;#endif #ifdef TARGET_NR_setgroups32case TARGET_NR_setgroups32:@@ -11496,19 +11360,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,for (i =0 ;i < gidsetsize; i++) grouplist[i] =tswap32 (target_grouplist[i]);unlock_user (target_grouplist, arg2,0 ); - ret = get_errno(setgroups(gidsetsize, grouplist)); + return get_errno(setgroups(gidsetsize, grouplist)); } -break ;#endif #ifdef TARGET_NR_fchown32case TARGET_NR_fchown32: - ret =get_errno (fchown (arg1, arg2, arg3)); -break ; +return get_errno (fchown (arg1, arg2, arg3));#endif #ifdef TARGET_NR_setresuid32case TARGET_NR_setresuid32: - ret =get_errno (sys_setresuid (arg1, arg2, arg3)); -break ; +return get_errno (sys_setresuid (arg1, arg2, arg3));#endif #ifdef TARGET_NR_getresuid32case TARGET_NR_getresuid32:@@ -11522,12 +11383,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #ifdef TARGET_NR_setresgid32case TARGET_NR_setresgid32: - ret =get_errno (sys_setresgid (arg1, arg2, arg3)); -break ; +return get_errno (sys_setresgid (arg1, arg2, arg3));#endif #ifdef TARGET_NR_getresgid32case TARGET_NR_getresgid32:@@ -11541,7 +11401,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #ifdef TARGET_NR_chown32case TARGET_NR_chown32:@@ -11549,27 +11409,23 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; ret =get_errno (chown (p, arg2, arg3));unlock_user (p, arg1,0 ); -break ; +return ret;#endif #ifdef TARGET_NR_setuid32case TARGET_NR_setuid32: - ret =get_errno (sys_setuid (arg1)); -break ; +return get_errno (sys_setuid (arg1));#endif #ifdef TARGET_NR_setgid32case TARGET_NR_setgid32: - ret =get_errno (sys_setgid (arg1)); -break ; +return get_errno (sys_setgid (arg1));#endif #ifdef TARGET_NR_setfsuid32case TARGET_NR_setfsuid32: - ret =get_errno (setfsuid (arg1)); -break ; +return get_errno (setfsuid (arg1));#endif #ifdef TARGET_NR_setfsgid32case TARGET_NR_setfsgid32: - ret =get_errno (setfsgid (arg1)); -break ; +return get_errno (setfsgid (arg1));#endif case TARGET_NR_pivot_root:@@ -11593,7 +11449,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, mincore_fail: unlock_user(a, arg1, 0); } -break ; +return ret;#endif #ifdef TARGET_NR_arm_fadvise64_64case TARGET_NR_arm_fadvise64_64:@@ -11605,8 +11461,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,*/ ret =posix_fadvise (arg1,target_offset64 (arg3, arg4),target_offset64 (arg5, arg6), arg2); - ret = -host_to_target_errno (ret); -break ; +return -host_to_target_errno (ret);#endif #if TARGET_ABI_BITS ==32 @@ -11632,11 +11487,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg6 = arg7; }#endif - ret = -host_to_target_errno (posix_fadvise (arg1, -target_offset64 (arg2, arg3), -target_offset64 (arg4, arg5), - arg6)); -break ; + ret =posix_fadvise (arg1,target_offset64 (arg2, arg3), +target_offset64 (arg4, arg5), arg6); +return -host_to_target_errno (ret);#endif #ifdef TARGET_NR_fadvise64@@ -11649,10 +11502,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg4 = arg5; arg5 = arg6; } - ret = -host_to_target_errno (posix_fadvise (arg1, -target_offset64 (arg2, arg3), - arg4, arg5)); -break ; + ret =posix_fadvise (arg1,target_offset64 (arg2, arg3), arg4, arg5); +return -host_to_target_errno (ret);#endif #else /* not a 32-bit ABI */ @@ -11672,8 +11523,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,default :break ; }#endif - ret = -host_to_target_errno (posix_fadvise (arg1, arg2, arg3, arg4)); -break ; +return -host_to_target_errno (posix_fadvise (arg1, arg2, arg3, arg4));#endif #endif /* end of 64-bit ABI fadvise handling */ @@ -11683,8 +11533,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,turns private file-backed mappings into anonymous mappings. This will break MADV_DONTNEED. This is a hint, so ignoring and returning success is ok. */ - ret =get_errno (0 ); -break ; +return 0 ;#endif #if TARGET_ABI_BITS ==32 case TARGET_NR_fcntl64:@@ -11703,8 +11552,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, cmd =target_to_host_fcntl_cmd (arg2);if (cmd == -TARGET_EINVAL ) { - ret = cmd; -break ; +return cmd; }switch (arg2) {@@ -11731,14 +11579,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =do_fcntl (arg1, arg2, arg3); break; } -break ; +return ret; }#endif #ifdef TARGET_NR_cacheflushcase TARGET_NR_cacheflush:/* self-modifying code is handled automatically, so nothing needed */ - ret =0 ; -break ; +return 0 ;#endif #ifdef TARGET_NR_securitycase TARGET_NR_security:@@ -11746,12 +11593,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_getpagesizecase TARGET_NR_getpagesize: - ret =TARGET_PAGE_SIZE ; -break ; +return TARGET_PAGE_SIZE ;#endif case TARGET_NR_gettid: - ret =get_errno (gettid ()); -break ; +return get_errno (gettid ());#ifdef TARGET_NR_readaheadcase TARGET_NR_readahead:#if TARGET_ABI_BITS ==32 @@ -11764,7 +11609,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#else ret =get_errno (readahead (arg1, arg2, arg3));#endif -break ; +return ret;#endif #ifdef CONFIG_ATTR #ifdef TARGET_NR_setxattr@@ -11775,8 +11620,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg2) { b =lock_user (VERIFY_WRITE , arg2, arg3,0 );if (!b) { - ret = -TARGET_EFAULT ; -break ; +return -TARGET_EFAULT ; } } p =lock_user_string (arg1);@@ -11791,7 +11635,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user (p, arg1,0 );unlock_user (b, arg2, arg3); -break ; +return ret; }case TARGET_NR_flistxattr: {@@ -11799,13 +11643,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg2) { b =lock_user (VERIFY_WRITE , arg2, arg3,0 );if (!b) { - ret = -TARGET_EFAULT ; -break ; +return -TARGET_EFAULT ; } } ret =get_errno (flistxattr (arg1, b, arg3));unlock_user (b, arg2, arg3); -break ; +return ret; }case TARGET_NR_setxattr:case TARGET_NR_lsetxattr:@@ -11814,8 +11657,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg3) { v =lock_user (VERIFY_READ , arg3, arg4,1 );if (!v) { - ret = -TARGET_EFAULT ; -break ; +return -TARGET_EFAULT ; } } p =lock_user_string (arg1);@@ -11833,15 +11675,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (n, arg2,0 );unlock_user (v, arg3,0 ); } -break ; +return ret;case TARGET_NR_fsetxattr: {void *n, *v =0 ;if (arg3) { v =lock_user (VERIFY_READ , arg3, arg4,1 );if (!v) { - ret = -TARGET_EFAULT ; -break ; +return -TARGET_EFAULT ; } } n =lock_user_string (arg2);@@ -11853,7 +11694,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (n, arg2,0 );unlock_user (v, arg3,0 ); } -break ; +return ret;case TARGET_NR_getxattr:case TARGET_NR_lgetxattr: {@@ -11861,8 +11702,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg3) { v =lock_user (VERIFY_WRITE , arg3, arg4,0 );if (!v) { - ret = -TARGET_EFAULT ; -break ; +return -TARGET_EFAULT ; } } p =lock_user_string (arg1);@@ -11880,15 +11720,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (n, arg2,0 );unlock_user (v, arg3, arg4); } -break ; +return ret;case TARGET_NR_fgetxattr: {void *n, *v =0 ;if (arg3) { v =lock_user (VERIFY_WRITE , arg3, arg4,0 );if (!v) { - ret = -TARGET_EFAULT ; -break ; +return -TARGET_EFAULT ; } } n =lock_user_string (arg2);@@ -11900,7 +11739,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (n, arg2,0 );unlock_user (v, arg3, arg4); } -break ; +return ret;case TARGET_NR_removexattr:case TARGET_NR_lremovexattr: {@@ -11919,7 +11758,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg1,0 );unlock_user (n, arg2,0 ); } -break ; +return ret;case TARGET_NR_fremovexattr: {void *n;@@ -11931,15 +11770,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user (n, arg2,0 ); } -break ; +return ret;#endif #endif /* CONFIG_ATTR */ #ifdef TARGET_NR_set_thread_areacase TARGET_NR_set_thread_area:#if defined(TARGET_MIPS ) ((CPUMIPSState *) cpu_env)->active_tc.CP0_UserLocal = arg1; - ret =0 ; -break ; +return 0 ;#elif defined(TARGET_CRIS )if (arg1 &0xff ) ret = -TARGET_EINVAL ;@@ -11947,16 +11785,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ((CPUCRISState *) cpu_env)->pregs[PR_PID ] = arg1; ret = 0; } -break ; +return ret;#elif defined(TARGET_I386) && defined(TARGET_ABI32) - ret =do_set_thread_area (cpu_env, arg1); -break ; +return do_set_thread_area (cpu_env, arg1);#elif defined(TARGET_M68K) {TaskState *ts = cpu->opaque; ts->tp_value = arg1; - ret =0 ; -break ; +return 0 ; }#else goto unimplemented_nowarn;@@ -11965,13 +11801,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_get_thread_areacase TARGET_NR_get_thread_area:#if defined(TARGET_I386 ) && defined(TARGET_ABI32 ) - ret =do_get_thread_area (cpu_env, arg1); -break ; +return do_get_thread_area (cpu_env, arg1);#elif defined(TARGET_M68K ) {TaskState *ts = cpu->opaque; - ret = ts->tp_value; -break ; +return ts->tp_value; }#else goto unimplemented_nowarn;@@ -11991,7 +11825,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) { ret =get_errno (clock_settime (arg1, &ts)); } - break; + return ret; }#endif #ifdef TARGET_NR_clock_gettime@@ -12002,7 +11836,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) { ret =host_to_target_timespec (arg2, &ts); } - break; + return ret; }#endif #ifdef TARGET_NR_clock_getres@@ -12013,7 +11847,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) {host_to_target_timespec (arg2, &ts); } - break; + return ret; }#endif #ifdef TARGET_NR_clock_nanosleep@@ -12033,24 +11867,21 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ((CPUPPCState *)cpu_env)->crf[0 ] |=1 ; }#endif -break ; +return ret; }#endif #if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)case TARGET_NR_set_tid_address: - ret =get_errno (set_tid_address ((int *)g2h (arg1))); -break ; +return get_errno (set_tid_address ((int *)g2h (arg1)));#endif case TARGET_NR_tkill: - ret =get_errno (safe_tkill ((int )arg1,target_to_host_signal (arg2))); -break ; +return get_errno (safe_tkill ((int )arg1,target_to_host_signal (arg2)));case TARGET_NR_tgkill: - ret =get_errno (safe_tgkill ((int )arg1, (int )arg2, -target_to_host_signal (arg3))); -break ; +return get_errno (safe_tgkill ((int )arg1, (int )arg2, +target_to_host_signal (arg3)));#ifdef TARGET_NR_set_robust_listcase TARGET_NR_set_robust_list:@@ -12092,18 +11923,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg2, 0); } } -break ; +return ret;#endif case TARGET_NR_futex: - ret =do_futex (arg1, arg2, arg3, arg4, arg5, arg6); -break ; +return do_futex (arg1, arg2, arg3, arg4, arg5, arg6);#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)case TARGET_NR_inotify_init: ret =get_errno (sys_inotify_init ());if (ret >=0 ) {fd_trans_register (ret, &target_inotify_trans); } -break ; +return ret;#endif #ifdef CONFIG_INOTIFY1 #if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1)@@ -12113,7 +11943,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (ret >=0 ) {fd_trans_register (ret, &target_inotify_trans); } -break ; +return ret;#endif #endif #if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch)@@ -12121,12 +11951,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p =lock_user_string (arg2); ret =get_errno (sys_inotify_add_watch (arg1,path (p), arg3));unlock_user (p, arg2,0 ); -break ; +return ret;#endif #if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch)case TARGET_NR_inotify_rm_watch: - ret =get_errno (sys_inotify_rm_watch (arg1, arg2)); -break ; +return get_errno (sys_inotify_rm_watch (arg1, arg2));#endif #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)@@ -12151,17 +11980,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (mq_open (p, host_flags, arg3, pposix_mq_attr));unlock_user (p, arg1,0 ); } -break ; +return ret;case TARGET_NR_mq_unlink: p =lock_user_string (arg1 -1 );if (!p) { - ret = -TARGET_EFAULT ; -break ; +return -TARGET_EFAULT ; } ret =get_errno (mq_unlink (p));unlock_user (p, arg1,0 ); -break ; +return ret;case TARGET_NR_mq_timedsend: {@@ -12177,7 +12005,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }unlock_user (p, arg2, arg3); } -break ; +return ret;case TARGET_NR_mq_timedreceive: {@@ -12198,7 +12026,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg4 !=0 )put_user_u32 (prio, arg4); } -break ; +return ret;/* Not implemented for now... */ /* case TARGET_NR_mq_notify: */ @@ -12219,7 +12047,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, copy_to_user_mq_attr(arg3, &posix_mq_attr_out); } } -break ; +return ret;#endif #ifdef CONFIG_SPLICE @@ -12228,7 +12056,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, { ret =get_errno (tee (arg1,arg2,arg3,arg4)); } -break ; +return ret;#endif #ifdef TARGET_NR_splicecase TARGET_NR_splice:@@ -12259,7 +12087,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } -break ; +return ret;#endif #ifdef TARGET_NR_vmsplicecase TARGET_NR_vmsplice:@@ -12272,7 +12100,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno (errno); } } -break ; +return ret;#endif #endif /* CONFIG_SPLICE */ #ifdef CONFIG_EVENTFD @@ -12282,7 +12110,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (ret >=0 ) {fd_trans_register (ret, &target_eventfd_trans); } -break ; +return ret;#endif #if defined(TARGET_NR_eventfd2)case TARGET_NR_eventfd2:@@ -12298,7 +12126,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (ret >=0 ) {fd_trans_register (ret, &target_eventfd_trans); } -break ; +return ret; }#endif #endif /* CONFIG_EVENTFD */ @@ -12310,7 +12138,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#else ret =get_errno (fallocate (arg1, arg2, arg3, arg4));#endif -break ; +return ret;#endif #if defined(CONFIG_SYNC_FILE_RANGE )#if defined(TARGET_NR_sync_file_range)@@ -12326,7 +12154,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#else ret =get_errno (sync_file_range (arg1, arg2, arg3, arg4));#endif -break ; +return ret;#endif #if defined(TARGET_NR_sync_file_range2)case TARGET_NR_sync_file_range2:@@ -12337,29 +12165,25 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#else ret =get_errno (sync_file_range (arg1, arg3, arg4, arg2));#endif -break ; +return ret;#endif #endif #if defined(TARGET_NR_signalfd4)case TARGET_NR_signalfd4: - ret =do_signalfd4 (arg1, arg2, arg4); -break ; +return do_signalfd4 (arg1, arg2, arg4);#endif #if defined(TARGET_NR_signalfd)case TARGET_NR_signalfd: - ret =do_signalfd4 (arg1, arg2,0 ); -break ; +return do_signalfd4 (arg1, arg2,0 );#endif #if defined(CONFIG_EPOLL )#if defined(TARGET_NR_epoll_create)case TARGET_NR_epoll_create: - ret =get_errno (epoll_create (arg1)); -break ; +return get_errno (epoll_create (arg1));#endif #if defined(TARGET_NR_epoll_create1) && defined(CONFIG_EPOLL_CREATE1 )case TARGET_NR_epoll_create1: - ret =get_errno (epoll_create1 (arg1)); -break ; +return get_errno (epoll_create1 (arg1));#endif #if defined(TARGET_NR_epoll_ctl)case TARGET_NR_epoll_ctl:@@ -12380,8 +12204,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user_struct (target_ep, arg4,0 ); epp = &ep; } - ret =get_errno (epoll_ctl (arg1, arg2, arg3, epp)); -break ; +return get_errno (epoll_ctl (arg1, arg2, arg3, epp)); }#endif @@ -12400,8 +12223,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,int timeout = arg4;if (maxevents <=0 || maxevents >TARGET_EP_MAX_EVENTS ) { - ret = -TARGET_EINVAL ; -break ; +return -TARGET_EINVAL ; } target_ep = lock_user(VERIFY_WRITE, arg2,@@ -12413,8 +12235,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ep = g_try_new(struct epoll_event, maxevents);if (!ep) {unlock_user (target_ep, arg2,0 ); - ret = -TARGET_ENOMEM ; -break ; +return -TARGET_ENOMEM ; }switch (num) {@@ -12444,7 +12265,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (safe_epoll_pwait (epfd, ep, maxevents, timeout, set, SIGSET_T_SIZE)); - break; }#endif #if defined(TARGET_NR_epoll_wait)@@ -12468,7 +12288,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (target_ep, arg2,0 ); }g_free (ep); -break ; +return ret; }#endif #endif @@ -12498,7 +12318,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_rold->rlim_max =tswap64 (rold.rlim_max); unlock_user_struct(target_rold, arg4, 1); } -break ; +return ret; }#endif #ifdef TARGET_NR_gethostname@@ -12511,7 +12331,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } else { ret = -TARGET_EFAULT ; } -break ; +return ret; }#endif #ifdef TARGET_NR_atomic_cmpxchg_32@@ -12532,17 +12352,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }if (mem_value == arg2)put_user_u32 (arg1, arg6); - ret = mem_value; -break ; +return mem_value; }#endif #ifdef TARGET_NR_atomic_barriercase TARGET_NR_atomic_barrier: - { -/* Like the kernel implementation and the qemu arm barrier, no-op this? */ - ret =0 ; -break ; - } +/* Like the kernel implementation and the +qemu arm barrier, no-op this? */ +return 0 ;#endif #ifdef TARGET_NR_timer_create@@ -12564,7 +12381,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, phost_sevp = &host_sevp; ret =target_to_host_sigevent (phost_sevp, arg2);if (ret !=0 ) { -break ; +return ret; } }@@ -12577,7 +12394,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } } } -break ; +return ret; }#endif @@ -12605,7 +12422,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret; }#endif @@ -12628,7 +12445,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = -TARGET_EFAULT; } } -break ; +return ret; }#endif @@ -12645,7 +12462,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret = get_errno(timer_getoverrun(htimer)); }fd_trans_unregister (ret); -break ; +return ret; }#endif @@ -12662,15 +12479,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (timer_delete (htimer)); g_posix_timers[timerid] = 0; } -break ; +return ret; }#endif #if defined(TARGET_NR_timerfd_create) && defined(CONFIG_TIMERFD )case TARGET_NR_timerfd_create: - ret =get_errno (timerfd_create (arg1, -target_to_host_bitmask (arg2, fcntl_flags_tbl))); -break ; +return get_errno (timerfd_create (arg1, +target_to_host_bitmask (arg2, fcntl_flags_tbl)));#endif #if defined(TARGET_NR_timerfd_gettime) && defined(CONFIG_TIMERFD )@@ -12684,7 +12500,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #if defined(TARGET_NR_timerfd_settime) && defined(CONFIG_TIMERFD )@@ -12707,35 +12523,30 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto efault; } } -break ; +return ret;#endif #if defined(TARGET_NR_ioprio_get) && defined(__NR_ioprio_get)case TARGET_NR_ioprio_get: - ret =get_errno (ioprio_get (arg1, arg2)); -break ; +return get_errno (ioprio_get (arg1, arg2));#endif #if defined(TARGET_NR_ioprio_set) && defined(__NR_ioprio_set)case TARGET_NR_ioprio_set: - ret =get_errno (ioprio_set (arg1, arg2, arg3)); -break ; +return get_errno (ioprio_set (arg1, arg2, arg3));#endif #if defined(TARGET_NR_setns) && defined(CONFIG_SETNS )case TARGET_NR_setns: - ret =get_errno (setns (arg1, arg2)); -break ; +return get_errno (setns (arg1, arg2));#endif #if defined(TARGET_NR_unshare) && defined(CONFIG_SETNS )case TARGET_NR_unshare: - ret =get_errno (unshare (arg1)); -break ; +return get_errno (unshare (arg1));#endif #if defined(TARGET_NR_kcmp) && defined(__NR_kcmp)case TARGET_NR_kcmp: - ret =get_errno (kcmp (arg1, arg2, arg3, arg4, arg5)); -break ; +return get_errno (kcmp (arg1, arg2, arg3, arg4, arg5));#endif default :
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 12561
Quoted 9 lines
linux-user/syscall.c +1
-2@@ -12744,8 +12555,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list) unimplemented_nowarn:#endif - ret = -TARGET_ENOSYS ; -break ; +return -TARGET_ENOSYS ; } fail:return ret;
whew!
Re: [Qemu-devel] [PATCH v3 07/19] linux-user: Relax single exit from "break"
In reply to Richard HendersonLe 12/06/2018 à 02:51, Richard Henderson a écrit :
Quoted 14 lines
Transform outermost "break" to "return ret". If the immediately preceeding statement was an assignment to ret, return the value directly.
Reviewed-by Laurent Vivier <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.c | 970 +++++++++++++++++-------------------------- 1 file changed, 390 insertions(+), 580 deletions(-)linux-user/syscall.c +0
-0
...
Quoted 10 lines
linux-user/syscall.c +1
-1@@ -10481,7 +10387,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg4) {unlock_user (target_set, arg4,0 ); } - break; + return ret; }# endif # ifdef TARGET_NR_poll
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 10410
Quoted 9 lines
linux-user/syscall.c +1
-2@@ -10498,8 +10404,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,/* -ve poll() timeout means "infinite" */ pts = NULL; } - ret =get_errno (safe_ppoll (pfd, nfds, pts,NULL ,0 )); -break ; +return get_errno (safe_ppoll (pfd, nfds, pts,NULL ,0 )); }# endif default :
You can't change these breaks by returns because they are in an inner switch() (see the "default:"), that is followed by:
if (!is_error(ret)) {
for(i = 0; i < nfds; i++) {
target_pfd[i].revents = tswap16(pfd[i].revents);
}
}
unlock_user(target_pfd, arg1, sizeof(struct target_pollfd) * nfds);which are needed to copy the result to the target array.
...
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 12447
Quoted 5 lines
linux-user/syscall.c +0
-1@@ -12444,7 +12265,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (safe_epoll_pwait (epfd, ep, maxevents, timeout, set,SIGSET_T_SIZE )); -break ;
You can't remove this break because otherwise it falls through the following case (and you can't put a return because it's in an inner switch())
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 12294
Quoted 12 lines
linux-user/syscall.c +1
-1}#endif #if defined(TARGET_NR_epoll_wait)@@ -12468,7 +12288,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (target_ep, arg2,0 ); }g_free (ep); -break ; +return ret; }#endif #endif
Thanks,
Laurent
PATCH v3 8/19 linux-user: Propagate goto efault to return
In reply to Richard Henderson--- linux-user/syscall.c | 341 ++++++++++++++++++++++--------------------- 1 file changed, 175 insertions(+), 166 deletions(-)
linux-user/syscall.c +175 -166
@@ -8009,7 +8009,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return 0 ; }else {if (!(p =lock_user (VERIFY_WRITE , arg2, arg3,0 ))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (safe_read (arg1, p, arg3));if (ret >=0 &&fd_trans_host_to_target_data (arg1)) {
@@ -8020,7 +8020,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return ret;case TARGET_NR_write:if (!(p =lock_user (VERIFY_READ , arg2, arg3,1 ))) - goto efault; +return -TARGET_EFAULT ;if (fd_trans_target_to_host_data (arg1)) {void *copy =g_malloc (arg3);memcpy (copy, p, arg3);
@@ -8038,7 +8038,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_opencase TARGET_NR_open:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (do_openat (cpu_env,AT_FDCWD , p,target_to_host_bitmask (arg2, fcntl_flags_tbl), arg3));
@@ -8048,7 +8048,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif case TARGET_NR_openat:if (!(p =lock_user_string (arg2))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (do_openat (cpu_env, arg1, p,target_to_host_bitmask (arg3, fcntl_flags_tbl), arg4));
@@ -8083,7 +8083,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (safe_wait4 (arg1, &status, arg3,0 ));if (!is_error (ret) && arg2 && ret &&put_user_s32 (host_to_target_waitstatus (status), arg2)) - goto efault; + return -TARGET_EFAULT; }return ret;#endif
@@ -8095,7 +8095,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (safe_waitid (arg1, arg2, &info, arg4,NULL ));if (!is_error (ret) && arg3 && info.si_pid !=0 ) {if (!(p =lock_user (VERIFY_WRITE , arg3,sizeof (target_siginfo_t),0 ))) - goto efault; +return -TARGET_EFAULT ;host_to_target_siginfo (p, &info);unlock_user (p, arg3,sizeof (target_siginfo_t)); }
@@ -8105,7 +8105,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_creat/* not on alpha */ case TARGET_NR_creat:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (creat (p, arg2));fd_trans_unregister (ret);unlock_user (p, arg1,0 );
@@ -8131,7 +8131,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, {void * p2 =NULL ;if (!arg2 || !arg4) - goto efault; +return -TARGET_EFAULT ; p =lock_user_string (arg2); p2 =lock_user_string (arg4);if (!p || !p2)
@@ -8146,7 +8146,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_unlinkcase TARGET_NR_unlink:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (unlink (p));unlock_user (p, arg1,0 );return ret;
@@ -8154,7 +8154,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_unlinkat)case TARGET_NR_unlinkat:if (!(p =lock_user_string (arg2))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (unlinkat (arg1, p, arg3));unlock_user (p, arg2,0 );return ret;
@@ -8174,7 +8174,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, guest_argp = arg2;for (gp = guest_argp; gp; gp +=sizeof (abi_ulong)) {if (get_user_ual (addr, gp)) - goto efault; +return -TARGET_EFAULT ;if (!addr)break ; argc++;
@@ -8183,7 +8183,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, guest_envp = arg3;for (gp = guest_envp; gp; gp +=sizeof (abi_ulong)) {if (get_user_ual (addr, gp)) - goto efault; +return -TARGET_EFAULT ;if (!addr)break ; envc++;
@@ -8258,7 +8258,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return ret;case TARGET_NR_chdir:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (chdir (p));unlock_user (p, arg1,0 );return ret;
@@ -8270,14 +8270,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret) && arg1 &&put_user_sal (host_time, arg1)) - goto efault; + return -TARGET_EFAULT; }return ret;#endif #ifdef TARGET_NR_mknodcase TARGET_NR_mknod:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (mknod (p, arg2, arg3));unlock_user (p, arg1,0 );return ret;
@@ -8285,7 +8285,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_mknodat)case TARGET_NR_mknodat:if (!(p =lock_user_string (arg2))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (mknodat (arg1, p, arg3, arg4));unlock_user (p, arg2,0 );return ret;
@@ -8293,7 +8293,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_chmodcase TARGET_NR_chmod:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (chmod (p, arg2));unlock_user (p, arg1,0 );return ret;
@@ -8326,7 +8326,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg1) { p =lock_user_string (arg1);if (!p) { - goto efault; +return -TARGET_EFAULT ; } }else { p =NULL ;
@@ -8337,7 +8337,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg1) {unlock_user (p, arg1,0 ); } - goto efault; +return -TARGET_EFAULT ; }if (arg3) {
@@ -8347,7 +8347,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg1,0 ); }unlock_user (p2, arg2,0 ); - goto efault; +return -TARGET_EFAULT ; } }else { p3 =NULL ;
@@ -8376,7 +8376,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_umountcase TARGET_NR_umount:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (umount (p));unlock_user (p, arg1,0 );return ret;
@@ -8386,7 +8386,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, {time_t host_time;if (get_user_sal (host_time, arg1)) - goto efault; +return -TARGET_EFAULT ;return get_errno (stime (&host_time)); }#endif
@@ -8414,7 +8414,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_utimbuf *target_tbuf;if (arg2) {if (!lock_user_struct (VERIFY_READ , target_tbuf, arg2,1 )) - goto efault; +return -TARGET_EFAULT ; tbuf.actime =tswapal (target_tbuf->actime); tbuf.modtime =tswapal (target_tbuf->modtime);unlock_user_struct (target_tbuf, arg2,0 );
@@ -8423,7 +8423,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, host_tbuf =NULL ; }if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (utime (p, host_tbuf));unlock_user (p, arg1,0 ); }
@@ -8437,13 +8437,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (copy_from_user_timeval (&tv[0 ], arg2) ||copy_from_user_timeval (&tv[1 ], arg2 +sizeof (struct target_timeval ))) - goto efault; +return -TARGET_EFAULT ; tvp = tv; }else { tvp =NULL ; }if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (utimes (p, tvp));unlock_user (p, arg1,0 ); }
@@ -8457,13 +8457,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (copy_from_user_timeval (&tv[0 ], arg3) ||copy_from_user_timeval (&tv[1 ], arg3 +sizeof (struct target_timeval ))) - goto efault; +return -TARGET_EFAULT ; tvp = tv; }else { tvp =NULL ; } -if (!(p =lock_user_string (arg2))) - goto efault; +if (!(p =lock_user_string (arg2))) { +return -TARGET_EFAULT ; + } ret =get_errno (futimesat (arg1,path (p), tvp));unlock_user (p, arg2,0 ); }
@@ -8479,16 +8480,18 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_accesscase TARGET_NR_access: -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (access (path (p), arg2));unlock_user (p, arg1,0 );return ret;#endif #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)case TARGET_NR_faccessat: -if (!(p =lock_user_string (arg2))) - goto efault; +if (!(p =lock_user_string (arg2))) { +return -TARGET_EFAULT ; + } ret =get_errno (faccessat (arg1, p, arg3,0 ));unlock_user (p, arg2,0 );return ret;
@@ -8559,7 +8562,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_mkdircase TARGET_NR_mkdir:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (mkdir (p, arg2));unlock_user (p, arg1,0 );return ret;
@@ -8567,7 +8570,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_mkdirat)case TARGET_NR_mkdirat:if (!(p =lock_user_string (arg2))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (mkdirat (arg1, p, arg3));unlock_user (p, arg2,0 );return ret;
@@ -8575,7 +8578,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_rmdircase TARGET_NR_rmdir:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (rmdir (p));unlock_user (p, arg1,0 );return ret;
@@ -8603,7 +8606,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg1) { tmsp =lock_user (VERIFY_WRITE , arg1,sizeof (struct target_tms ),0 );if (!tmsp) - goto efault; +return -TARGET_EFAULT ; tmsp->tms_utime =tswapal (host_to_target_clock_t (tms.tms_utime)); tmsp->tms_stime =tswapal (host_to_target_clock_t (tms.tms_stime)); tmsp->tms_cutime =tswapal (host_to_target_clock_t (tms.tms_cutime));
@@ -8625,8 +8628,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg1 ==0 ) { ret =get_errno (acct (NULL )); }else { -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (acct (path (p)));unlock_user (p, arg1,0 ); }
@@ -8634,7 +8638,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_umount2case TARGET_NR_umount2:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (umount2 (p, arg2));unlock_user (p, arg1,0 );return ret;
@@ -8667,7 +8671,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return get_errno (umask (arg1));case TARGET_NR_chroot:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (chroot (p));unlock_user (p, arg1,0 );return ret;
@@ -8717,7 +8721,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_old_sigaction *old_act;if (arg2) {if (!lock_user_struct (VERIFY_READ , old_act, arg2,1 )) - goto efault; +return -TARGET_EFAULT ; act._sa_handler = old_act->_sa_handler;target_siginitset (&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags;
@@ -8728,7 +8732,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (do_sigaction (arg1, pact, &oact));if (!is_error (ret) && arg3) {if (!lock_user_struct (VERIFY_WRITE , old_act, arg3,0 )) - goto efault; +return -TARGET_EFAULT ; old_act->_sa_handler = oact._sa_handler; old_act->sa_mask = oact.sa_mask.sig[0 ]; old_act->sa_flags = oact.sa_flags;
@@ -8739,7 +8743,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg2) {if (!lock_user_struct (VERIFY_READ , old_act, arg2,1 )) - goto efault; +return -TARGET_EFAULT ; act._sa_handler = old_act->_sa_handler;target_siginitset (&act.sa_mask, old_act->sa_mask.sig[0 ]); act.sa_flags = old_act->sa_flags;
@@ -8753,7 +8757,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret) && arg3) {if (!lock_user_struct (VERIFY_WRITE , old_act, arg3,0 )) - goto efault; +return -TARGET_EFAULT ; old_act->_sa_handler = oact._sa_handler; old_act->sa_flags = oact.sa_flags; old_act->sa_mask.sig[0 ] = oact.sa_mask.sig[0 ];
@@ -8767,7 +8771,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_sigaction act, oact, *pact;if (arg2) {if (!lock_user_struct (VERIFY_READ , old_act, arg2,1 )) - goto efault; +return -TARGET_EFAULT ; act._sa_handler = old_act->_sa_handler;target_siginitset (&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags;
@@ -8783,7 +8787,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (do_sigaction (arg1, pact, &oact));if (!is_error (ret) && arg3) {if (!lock_user_struct (VERIFY_WRITE , old_act, arg3,0 )) - goto efault; +return -TARGET_EFAULT ; old_act->_sa_handler = oact._sa_handler; old_act->sa_mask = oact.sa_mask.sig[0 ]; old_act->sa_flags = oact.sa_flags;
@@ -8813,7 +8817,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }if (arg2) {if (!lock_user_struct (VERIFY_READ , rt_act, arg2,1 )) - goto efault; +return -TARGET_EFAULT ; act._sa_handler = rt_act->_sa_handler; act.sa_mask = rt_act->sa_mask; act.sa_flags = rt_act->sa_flags;
@@ -8824,7 +8828,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (do_sigaction (arg1, pact, &oact));if (!is_error (ret) && arg3) {if (!lock_user_struct (VERIFY_WRITE , rt_act, arg3,0 )) - goto efault; +return -TARGET_EFAULT ; rt_act->_sa_handler = oact._sa_handler; rt_act->sa_mask = oact.sa_mask; rt_act->sa_flags = oact.sa_flags;
@@ -8845,7 +8849,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }if (arg2) {if (!lock_user_struct (VERIFY_READ , act, arg2,1 )) { - goto efault; +return -TARGET_EFAULT ; }#ifdef TARGET_ARCH_HAS_KA_RESTORER act->ka_restorer = restorer;
@@ -8947,7 +8951,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto fail; }if (!(p =lock_user (VERIFY_READ , arg2,sizeof (target_sigset_t),1 ))) - goto efault; +return -TARGET_EFAULT ;target_to_host_old_sigset (&set, p);unlock_user (p, arg2,0 ); set_ptr = &set;
@@ -8958,7 +8962,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =do_sigprocmask (how, set_ptr, &oldset);if (!is_error (ret) && arg3) {if (!(p =lock_user (VERIFY_WRITE , arg3,sizeof (target_sigset_t),0 ))) - goto efault; +return -TARGET_EFAULT ;host_to_target_old_sigset (p, &oldset);unlock_user (p, arg3,sizeof (target_sigset_t)); }
@@ -8991,7 +8995,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto fail; }if (!(p =lock_user (VERIFY_READ , arg2,sizeof (target_sigset_t),1 ))) - goto efault; +return -TARGET_EFAULT ;target_to_host_sigset (&set, p);unlock_user (p, arg2,0 ); set_ptr = &set;
@@ -9002,7 +9006,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =do_sigprocmask (how, set_ptr, &oldset);if (!is_error (ret) && arg3) {if (!(p =lock_user (VERIFY_WRITE , arg3,sizeof (target_sigset_t),0 ))) - goto efault; +return -TARGET_EFAULT ;host_to_target_sigset (p, &oldset);unlock_user (p, arg3,sizeof (target_sigset_t)); }
@@ -9015,7 +9019,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (sigpending (&set));if (!is_error (ret)) {if (!(p =lock_user (VERIFY_WRITE , arg1,sizeof (target_sigset_t),0 ))) - goto efault; +return -TARGET_EFAULT ;host_to_target_old_sigset (p, &set);unlock_user (p, arg1,sizeof (target_sigset_t)); }
@@ -9038,7 +9042,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (sigpending (&set));if (!is_error (ret)) {if (!(p =lock_user (VERIFY_WRITE , arg1,sizeof (target_sigset_t),0 ))) - goto efault; +return -TARGET_EFAULT ;host_to_target_sigset (p, &set);unlock_user (p, arg1,sizeof (target_sigset_t)); }
@@ -9053,7 +9057,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,target_to_host_old_sigset (&ts->sigsuspend_mask, &mask);#else if (!(p =lock_user (VERIFY_READ , arg1,sizeof (target_sigset_t),1 ))) - goto efault; +return -TARGET_EFAULT ;target_to_host_old_sigset (&ts->sigsuspend_mask, p);unlock_user (p, arg1,0 );#endif
@@ -9073,7 +9077,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return -TARGET_EINVAL ; }if (!(p =lock_user (VERIFY_READ , arg1,sizeof (target_sigset_t),1 ))) - goto efault; +return -TARGET_EFAULT ;target_to_host_sigset (&ts->sigsuspend_mask, p);unlock_user (p, arg1,0 ); ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask,
@@ -9094,7 +9098,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }if (!(p =lock_user (VERIFY_READ , arg1,sizeof (target_sigset_t),1 ))) - goto efault; +return -TARGET_EFAULT ;target_to_host_sigset (&set, p);unlock_user (p, arg1,0 );if (arg3) {
@@ -9110,7 +9114,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p =lock_user (VERIFY_WRITE , arg2,sizeof (target_siginfo_t),0 );if (!p) { - goto efault; +return -TARGET_EFAULT ; }host_to_target_siginfo (p, &uinfo);unlock_user (p, arg2,sizeof (target_siginfo_t));
@@ -9125,7 +9129,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p =lock_user (VERIFY_READ , arg3,sizeof (target_siginfo_t),1 );if (!p) { - goto efault; +return -TARGET_EFAULT ; }target_to_host_siginfo (&uinfo, p);unlock_user (p, arg3,0 );
@@ -9138,7 +9142,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p =lock_user (VERIFY_READ , arg4,sizeof (target_siginfo_t),1 );if (!p) { - goto efault; +return -TARGET_EFAULT ; }target_to_host_siginfo (&uinfo, p);unlock_user (p, arg4,0 );
@@ -9162,7 +9166,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }case TARGET_NR_sethostname:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (sethostname (p, arg2));unlock_user (p, arg1,0 );return ret;
@@ -9172,7 +9176,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_rlimit *target_rlim;struct rlimit rlim;if (!lock_user_struct (VERIFY_READ , target_rlim, arg2,1 )) - goto efault; +return -TARGET_EFAULT ; rlim.rlim_cur =target_to_host_rlim (target_rlim->rlim_cur); rlim.rlim_max =target_to_host_rlim (target_rlim->rlim_max);unlock_user_struct (target_rlim, arg2,0 );
@@ -9187,7 +9191,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (getrlimit (resource, &rlim));if (!is_error (ret)) {if (!lock_user_struct (VERIFY_WRITE , target_rlim, arg2,0 )) - goto efault; +return -TARGET_EFAULT ; target_rlim->rlim_cur =host_to_target_rlim (rlim.rlim_cur); target_rlim->rlim_max =host_to_target_rlim (rlim.rlim_max);unlock_user_struct (target_rlim, arg2,1 );
@@ -9209,7 +9213,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (gettimeofday (&tv,NULL ));if (!is_error (ret)) {if (copy_to_user_timeval (arg1, &tv)) - goto efault; +return -TARGET_EFAULT ; } }return ret;
@@ -9220,14 +9224,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg1) {if (copy_from_user_timeval (&tv, arg1)) { - goto efault; +return -TARGET_EFAULT ; } ptv = &tv; }if (arg2) {if (copy_from_user_timezone (&tz, arg2)) { - goto efault; +return -TARGET_EFAULT ; } ptz = &tz; }
@@ -9294,7 +9298,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,*/ if (ts_addr) {if (target_to_host_timespec (&ts, ts_addr)) { - goto efault; +return -TARGET_EFAULT ; } ts_ptr = &ts; }else {
@@ -9308,7 +9312,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg7 =lock_user (VERIFY_READ , arg6,sizeof (*arg7) *2 ,1 );if (!arg7) { - goto efault; +return -TARGET_EFAULT ; } arg_sigset =tswapal (arg7[0 ]); arg_sigsize =tswapal (arg7[1 ]);
@@ -9324,7 +9328,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_sigset =lock_user (VERIFY_READ , arg_sigset,sizeof (*target_sigset),1 );if (!target_sigset) { - goto efault; +return -TARGET_EFAULT ; }target_to_host_sigset (&set, target_sigset);unlock_user (target_sigset, arg_sigset,0 );
@@ -9340,14 +9344,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) {if (rfd_addr &©_to_user_fdset (rfd_addr, &rfds, n)) - goto efault; +return -TARGET_EFAULT ;if (wfd_addr &©_to_user_fdset (wfd_addr, &wfds, n)) - goto efault; +return -TARGET_EFAULT ;if (efd_addr &©_to_user_fdset (efd_addr, &efds, n)) - goto efault; +return -TARGET_EFAULT ;if (ts_addr &&host_to_target_timespec (ts_addr, &ts)) - goto efault; +return -TARGET_EFAULT ; } }return ret;
@@ -9446,7 +9450,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_swaponcase TARGET_NR_swapon:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (swapon (p, arg2));unlock_user (p, arg1,0 );return ret;
@@ -9456,7 +9460,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,/* arg4 must be ignored in all other cases */ p =lock_user_string (arg4);if (!p) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (reboot (arg1, arg2, arg3, p));unlock_user (p, arg4,0 );
@@ -9478,7 +9482,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,abi_ulong *v;abi_ulong v1, v2, v3, v4, v5, v6;if (!(v =lock_user (VERIFY_READ , arg1,6 *sizeof (abi_ulong),1 ))) - goto efault; +return -TARGET_EFAULT ; v1 =tswapal (v[0 ]); v2 =tswapal (v[1 ]); v3 =tswapal (v[2 ]);
@@ -9550,7 +9554,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif case TARGET_NR_truncate:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (truncate (p, arg2));unlock_user (p, arg1,0 );return ret;
@@ -9561,7 +9565,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_fchmodat)case TARGET_NR_fchmodat:if (!(p =lock_user_string (arg2))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (fchmodat (arg1, p, arg3,0 ));unlock_user (p, arg2,0 );return ret;
@@ -9589,8 +9593,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented;#endif case TARGET_NR_statfs: -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (statfs (path (p), &stfs));unlock_user (p, arg1,0 ); convert_statfs:
@@ -9598,7 +9603,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_statfs *target_stfs;if (!lock_user_struct (VERIFY_WRITE , target_stfs, arg2,0 )) - goto efault; +return -TARGET_EFAULT ;__put_user (stfs.f_type, &target_stfs->f_type);__put_user (stfs.f_bsize, &target_stfs->f_bsize);__put_user (stfs.f_blocks, &target_stfs->f_blocks);
@@ -9624,8 +9629,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto convert_statfs;#ifdef TARGET_NR_statfs64case TARGET_NR_statfs64: -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (statfs (path (p), &stfs));unlock_user (p, arg1,0 ); convert_statfs64:
@@ -9633,7 +9639,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_statfs64 *target_stfs;if (!lock_user_struct (VERIFY_WRITE , target_stfs, arg3,0 )) - goto efault; +return -TARGET_EFAULT ;__put_user (stfs.f_type, &target_stfs->f_type);__put_user (stfs.f_bsize, &target_stfs->f_bsize);__put_user (stfs.f_blocks, &target_stfs->f_blocks);
@@ -9731,7 +9737,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,case TARGET_NR_getrandom: p =lock_user (VERIFY_WRITE , arg1, arg2,0 );if (!p) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (getrandom (p, arg2, arg3));unlock_user (p, arg1, ret);
@@ -9799,7 +9805,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (copy_from_user_timeval (&pvalue->it_interval, arg2) ||copy_from_user_timeval (&pvalue->it_value, arg2 +sizeof (struct target_timeval ))) - goto efault; +return -TARGET_EFAULT ; }else { pvalue =NULL ; }
@@ -9809,7 +9815,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, &ovalue.it_interval) ||copy_to_user_timeval (arg3 +sizeof (struct target_timeval ), &ovalue.it_value)) - goto efault; + return -TARGET_EFAULT; } }return ret;
@@ -9823,22 +9829,24 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, &value.it_interval) ||copy_to_user_timeval (arg2 +sizeof (struct target_timeval ), &value.it_value)) - goto efault; + return -TARGET_EFAULT; } }return ret;#ifdef TARGET_NR_statcase TARGET_NR_stat: -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (stat (path (p), &st));unlock_user (p, arg1,0 ); goto do_stat;#endif #ifdef TARGET_NR_lstatcase TARGET_NR_lstat: -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (lstat (path (p), &st));unlock_user (p, arg1,0 ); goto do_stat;
@@ -9853,7 +9861,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_stat *target_st;if (!lock_user_struct (VERIFY_WRITE , target_st, arg2,0 )) - goto efault; +return -TARGET_EFAULT ;memset (target_st,0 ,sizeof (*target_st));__put_user (st.st_dev, &target_st->st_dev);__put_user (st.st_ino, &target_st->st_ino);
@@ -9907,7 +9915,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (status_ptr && ret) { status =host_to_target_waitstatus (status);if (put_user_s32 (status, status_ptr)) - goto efault; +return -TARGET_EFAULT ; }if (target_rusage) { rusage_err =host_to_target_rusage (target_rusage, &rusage);
@@ -9921,7 +9929,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_swapoffcase TARGET_NR_swapoff:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (swapoff (p));unlock_user (p, arg1,0 );return ret;
@@ -9934,7 +9942,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret) && arg1) {if (!lock_user_struct (VERIFY_WRITE , target_value, arg1,0 )) - goto efault; +return -TARGET_EFAULT ;__put_user (value.uptime, &target_value->uptime);__put_user (value.loads[0 ], &target_value->loads[0 ]);__put_user (value.loads[1 ], &target_value->loads[1 ]);
@@ -10031,7 +10039,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif case TARGET_NR_setdomainname:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (setdomainname (p, arg2));unlock_user (p, arg1,0 );return ret;
@@ -10041,7 +10049,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct new_utsname * buf;if (!lock_user_struct (VERIFY_WRITE , buf, arg1,0 )) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (sys_uname (buf));if (!is_error (ret)) {/* Overwrite the native machine name with whatever is being
@@ -10072,12 +10080,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct timex host_buf;if (target_to_host_timex (&host_buf, arg1) !=0 ) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (adjtimex (&host_buf));if (!is_error (ret)) {if (host_to_target_timex (arg1, &host_buf) !=0 ) { - goto efault; +return -TARGET_EFAULT ; } } }
@@ -10088,12 +10096,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct timex htx, *phtx = &htx;if (target_to_host_timex (phtx, arg2) !=0 ) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (clock_adjtime (arg1, phtx));if (!is_error (ret) && phtx) {if (host_to_target_timex (arg2, phtx) !=0 ) { - goto efault; +return -TARGET_EFAULT ; } } }
@@ -10143,7 +10151,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (_llseek (arg1, arg2, arg3, &res, arg5));#endif if ((ret ==0 ) &&put_user_s64 (res, arg4)) { - goto efault; +return -TARGET_EFAULT ; } }return ret;
@@ -10174,7 +10182,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, count1 =0 ; de = dirp;if (!(target_dirp =lock_user (VERIFY_WRITE , arg2, count,0 ))) - goto efault; +return -TARGET_EFAULT ; tde = target_dirp;while (len >0 ) { reclen = de->d_reclen;
@@ -10202,7 +10210,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,abi_long count = arg3;if (!(dirp =lock_user (VERIFY_WRITE , arg2, count,0 ))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (sys_getdents (arg1, dirp, count));if (!is_error (ret)) {struct linux_dirent *de;
@@ -10231,7 +10239,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, dirp =lock_user (VERIFY_WRITE , arg2, count,0 );if (!dirp) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (sys_getdents64 (arg1, dirp, count));if (!is_error (ret)) {
@@ -10286,7 +10294,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct linux_dirent64 *dirp;abi_long count = arg3;if (!(dirp =lock_user (VERIFY_WRITE , arg2, count,0 ))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (sys_getdents64 (arg1, dirp, count));if (!is_error (ret)) {struct linux_dirent64 *de;
@@ -10335,7 +10343,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_pfd =lock_user (VERIFY_WRITE , arg1,sizeof (struct target_pollfd ) * nfds,1 );if (!target_pfd) { - goto efault; +return -TARGET_EFAULT ; } pfd =alloca (sizeof (struct pollfd ) * nfds);
@@ -10356,7 +10364,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg3) {if (target_to_host_timespec (timeout_ts, arg3)) {unlock_user (target_pfd, arg1,0 ); - goto efault; +return -TARGET_EFAULT ; } }else { timeout_ts =NULL ;
@@ -10371,7 +10379,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_set =lock_user (VERIFY_READ , arg4,sizeof (target_sigset_t),1 );if (!target_set) {unlock_user (target_pfd, arg1,0 ); - goto efault; +return -TARGET_EFAULT ; }target_to_host_sigset (set, target_set); }else {
@@ -10525,7 +10533,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }if (host_to_target_cpu_mask (mask, mask_size, arg3, ret)) { - goto efault; +return -TARGET_EFAULT ; } } }
@@ -10562,10 +10570,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto fail; }if (arg1 &&put_user_u32 (cpu, arg1)) { - goto efault; +return -TARGET_EFAULT ; }if (arg2 &&put_user_u32 (node, arg2)) { - goto efault; +return -TARGET_EFAULT ; } }return ret;
@@ -10578,7 +10586,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return -TARGET_EINVAL ; }if (!lock_user_struct (VERIFY_READ , target_schp, arg2,1 )) - goto efault; +return -TARGET_EFAULT ; schp.sched_priority =tswap32 (target_schp->sched_priority);unlock_user_struct (target_schp, arg2,0 );return get_errno (sched_setparam (arg1, &schp));
@@ -10594,7 +10602,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (sched_getparam (arg1, &schp));if (!is_error (ret)) {if (!lock_user_struct (VERIFY_WRITE , target_schp, arg2,0 )) - goto efault; +return -TARGET_EFAULT ; target_schp->sched_priority =tswap32 (schp.sched_priority);unlock_user_struct (target_schp, arg2,1 ); }
@@ -10608,7 +10616,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return -TARGET_EINVAL ; }if (!lock_user_struct (VERIFY_READ , target_schp, arg3,1 )) - goto efault; +return -TARGET_EFAULT ; schp.sched_priority =tswap32 (target_schp->sched_priority);unlock_user_struct (target_schp, arg3,0 );return get_errno (sched_setscheduler (arg1, arg2, &schp));
@@ -10656,7 +10664,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (prctl (arg1, &deathsig, arg3, arg4, arg5));if (!is_error (ret) && arg2 &&put_user_ual (deathsig, arg2)) { - goto efault; +return -TARGET_EFAULT ; }return ret; }
@@ -10665,7 +10673,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, {void *name =lock_user (VERIFY_WRITE , arg2,16 ,1 );if (!name) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (prctl (arg1, (unsigned long )name, arg3, arg4, arg5));
@@ -10676,7 +10684,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, {void *name =lock_user (VERIFY_READ , arg2,16 ,1 );if (!name) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (prctl (arg1, (unsigned long )name, arg3, arg4, arg5));
@@ -10736,7 +10744,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg5 = arg6; }if (!(p =lock_user (VERIFY_WRITE , arg2, arg3,0 ))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (pread64 (arg1, p, arg3,target_offset64 (arg4, arg5)));unlock_user (p, arg2, ret);return ret;
@@ -10746,14 +10754,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg5 = arg6; }if (!(p =lock_user (VERIFY_READ , arg2, arg3,1 ))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (pwrite64 (arg1, p, arg3,target_offset64 (arg4, arg5)));unlock_user (p, arg2,0 );return ret;#endif case TARGET_NR_getcwd:if (!(p =lock_user (VERIFY_WRITE , arg1, arg2,0 ))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (sys_getcwd1 (p, arg2));unlock_user (p, arg1, ret);return ret;
@@ -10769,7 +10777,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,int data_items =1 ;if (!lock_user_struct (VERIFY_WRITE , target_header, arg1,1 )) { - goto efault; +return -TARGET_EFAULT ; } header.version =tswap32 (target_header->version); header.pid =tswap32 (target_header->pid);
@@ -10789,7 +10797,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }if (!target_data) {unlock_user_struct (target_header, arg1,0 ); - goto efault; +return -TARGET_EFAULT ; }if (num == TARGET_NR_capset) {
@@ -10905,7 +10913,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) {struct target_rlimit *target_rlim;if (!lock_user_struct (VERIFY_WRITE , target_rlim, arg2,0 )) - goto efault; +return -TARGET_EFAULT ; target_rlim->rlim_cur =host_to_target_rlim (rlim.rlim_cur); target_rlim->rlim_max =host_to_target_rlim (rlim.rlim_max);unlock_user_struct (target_rlim, arg2,1 );
@@ -10916,7 +10924,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_truncate64case TARGET_NR_truncate64:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =target_truncate64 (cpu_env, p, arg2, arg3, arg4);unlock_user (p, arg1,0 );return ret;
@@ -10927,8 +10935,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_stat64case TARGET_NR_stat64: -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (stat (path (p), &st));unlock_user (p, arg1,0 );if (!is_error (ret))
@@ -10937,8 +10946,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_lstat64case TARGET_NR_lstat64: -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (lstat (path (p), &st));unlock_user (p, arg1,0 );if (!is_error (ret))
@@ -10959,9 +10969,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_newfstatatcase TARGET_NR_newfstatat:#endif -if (!(p =lock_user_string (arg2))) - goto efault; +if (!(p =lock_user_string (arg2))) { +return -TARGET_EFAULT ; + } ret =get_errno (fstatat (arg1,path (p), &st, arg4)); +unlock_user (p, arg2,0 );if (!is_error (ret)) ret =host_to_target_stat64 (cpu_env, arg3, &st);return ret;
@@ -10969,7 +10981,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_lchowncase TARGET_NR_lchown:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (lchown (p,low2highuid (arg2),low2highgid (arg3)));unlock_user (p, arg1,0 );return ret;
@@ -11008,7 +11020,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) { target_grouplist =lock_user (VERIFY_WRITE , arg2, gidsetsize *sizeof (target_id),0 );if (!target_grouplist) - goto efault; +return -TARGET_EFAULT ;for (i =0 ;i < ret; i++) target_grouplist[i] =tswapid (high2lowgid (grouplist[i]));unlock_user (target_grouplist, arg2, gidsetsize *sizeof (target_id));
@@ -11040,7 +11052,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_fchownat)case TARGET_NR_fchownat:if (!(p =lock_user_string (arg2))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (fchownat (arg1, p,low2highuid (arg3),low2highgid (arg4), arg5));unlock_user (p, arg2,0 );
@@ -11061,7 +11073,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (put_user_id (high2lowuid (ruid), arg1) ||put_user_id (high2lowuid (euid), arg2) ||put_user_id (high2lowuid (suid), arg3)) - goto efault; +return -TARGET_EFAULT ; } }return ret;
@@ -11081,7 +11093,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (put_user_id (high2lowgid (rgid), arg1) ||put_user_id (high2lowgid (egid), arg2) ||put_user_id (high2lowgid (sgid), arg3)) - goto efault; +return -TARGET_EFAULT ; } }return ret;
@@ -11089,7 +11101,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_chowncase TARGET_NR_chown:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (chown (p,low2highuid (arg2),low2highgid (arg3)));unlock_user (p, arg1,0 );return ret;
@@ -11106,7 +11118,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_lchown32case TARGET_NR_lchown32:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (lchown (p, arg2, arg3));unlock_user (p, arg1,0 );return ret;
@@ -11157,7 +11169,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, swcr |= (~fpcr >>41 ) &SWCR_TRAP_ENABLE_DNO ;if (put_user_u64 (swcr, arg2)) - goto efault; +return -TARGET_EFAULT ; ret =0 ; }break ;
@@ -11184,7 +11196,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,uint64_t swcr, fpcr, orig_fpcr;if (get_user_u64 (swcr, arg2)) { - goto efault; +return -TARGET_EFAULT ; } orig_fpcr =cpu_alpha_load_fpcr (cpu_env); fpcr = orig_fpcr &FPCR_DYN_MASK ;
@@ -11211,7 +11223,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,int si_code;if (get_user_u64 (exc, arg2)) { - goto efault; +return -TARGET_EFAULT ; } orig_fpcr =cpu_alpha_load_fpcr (cpu_env);
@@ -11380,7 +11392,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (put_user_u32 (ruid, arg1) ||put_user_u32 (euid, arg2) ||put_user_u32 (suid, arg3)) - goto efault; +return -TARGET_EFAULT ; } }return ret;
@@ -11398,7 +11410,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (put_user_u32 (rgid, arg1) ||put_user_u32 (egid, arg2) ||put_user_u32 (sgid, arg3)) - goto efault; +return -TARGET_EFAULT ; } }return ret;
@@ -11406,7 +11418,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_chown32case TARGET_NR_chown32:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (chown (p, arg2, arg3));unlock_user (p, arg1,0 );return ret;
@@ -11969,13 +11981,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, pposix_mq_attr =NULL ;if (arg4) {if (copy_from_user_mq_attr (&posix_mq_attr, arg4) !=0 ) { - goto efault; +return -TARGET_EFAULT ; } pposix_mq_attr = &posix_mq_attr; } p =lock_user_string (arg1 -1 );if (!p) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (mq_open (p, host_flags, arg3, pposix_mq_attr));unlock_user (p, arg1,0 );
@@ -12065,25 +12077,25 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,loff_t *ploff_in =NULL , *ploff_out =NULL ;if (arg2) {if (get_user_u64 (loff_in, arg2)) { - goto efault; +return -TARGET_EFAULT ; } ploff_in = &loff_in; }if (arg4) {if (get_user_u64 (loff_out, arg4)) { - goto efault; +return -TARGET_EFAULT ; } ploff_out = &loff_out; } ret =get_errno (splice (arg1, ploff_in, arg3, ploff_out, arg5, arg6));if (arg2) {if (put_user_u64 (loff_in, arg2)) { - goto efault; +return -TARGET_EFAULT ; } }if (arg4) {if (put_user_u64 (loff_out, arg4)) { - goto efault; +return -TARGET_EFAULT ; } } }
@@ -12193,7 +12205,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg4) {struct target_epoll_event *target_ep;if (!lock_user_struct (VERIFY_READ , target_ep, arg4,1 )) { - goto efault; +return -TARGET_EFAULT ; } ep.events =tswap32 (target_ep->events);/* The epoll_data_t union is just opaque data to the kernel,
@@ -12229,7 +12241,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_ep =lock_user (VERIFY_WRITE , arg2, maxevents *sizeof (struct target_epoll_event ),1 );if (!target_ep) { - goto efault; +return -TARGET_EFAULT ; } ep = g_try_new(struct epoll_event, maxevents);
@@ -12301,7 +12313,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,int resource =target_to_host_resource (arg2);if (arg3) {if (!lock_user_struct (VERIFY_READ , target_rnew, arg3,1 )) { - goto efault; +return -TARGET_EFAULT ; } rnew.rlim_cur =tswap64 (target_rnew->rlim_cur); rnew.rlim_max =tswap64 (target_rnew->rlim_max);
@@ -12312,7 +12324,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (sys_prlimit64 (arg1, resource, rnewp, arg4 ? &rold :0 ));if (!is_error (ret) && arg4) {if (!lock_user_struct (VERIFY_WRITE , target_rold, arg4,1 )) { - goto efault; +return -TARGET_EFAULT ; } target_rold->rlim_cur =tswap64 (rold.rlim_cur); target_rold->rlim_max =tswap64 (rold.rlim_max);
@@ -12390,7 +12402,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, phtimer =NULL ; }else {if (put_user (TIMER_MAGIC | timer_index, arg3, target_timer_t)) { - goto efault; +return -TARGET_EFAULT ; } } }
@@ -12414,12 +12426,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct itimerspec hspec_new = {{0 },}, hspec_old = {{0 },};if (target_to_host_itimerspec (&hspec_new, arg3)) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (timer_settime (htimer, arg2, &hspec_new, &hspec_old));if (arg4 &&host_to_target_itimerspec (arg4, &hspec_old)) { - goto efault; +return -TARGET_EFAULT ; } }return ret;
@@ -12497,7 +12509,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (timerfd_gettime (arg1, &its_curr));if (arg2 &&host_to_target_itimerspec (arg2, &its_curr)) { - goto efault; +return -TARGET_EFAULT ; } }return ret;
@@ -12510,7 +12522,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg3) {if (target_to_host_itimerspec (&its_new, arg3)) { - goto efault; +return -TARGET_EFAULT ; } p_new = &its_new; }else {
@@ -12520,7 +12532,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (timerfd_settime (arg1, arg2, p_new, &its_old));if (arg4 &&host_to_target_itimerspec (arg4, &its_old)) { - goto efault; +return -TARGET_EFAULT ; } }return ret;
@@ -12559,9 +12571,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } fail:return ret; -efault: - ret = -TARGET_EFAULT ; - goto fail; } abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v3 08/19] linux-user: Propagate goto efault to return
Quoted 1,099 lines · Richard Henderson
Reviewed-by Laurent Vivier <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.c | 341 ++++++++++++++++++++++--------------------- 1 file changed, 175 insertions(+), 166 deletions(-)linux-user/syscall.c +142
-132@@ -8009,7 +8009,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return 0 ; }else {if (!(p =lock_user (VERIFY_WRITE , arg2, arg3,0 ))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (safe_read (arg1, p, arg3));if (ret >=0 &&fd_trans_host_to_target_data (arg1)) {@@ -8020,7 +8020,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return ret;case TARGET_NR_write:if (!(p =lock_user (VERIFY_READ , arg2, arg3,1 ))) - goto efault; +return -TARGET_EFAULT ;if (fd_trans_target_to_host_data (arg1)) {void *copy =g_malloc (arg3);memcpy (copy, p, arg3);@@ -8038,7 +8038,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_opencase TARGET_NR_open:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (do_openat (cpu_env,AT_FDCWD , p,target_to_host_bitmask (arg2, fcntl_flags_tbl), arg3));@@ -8048,7 +8048,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif case TARGET_NR_openat:if (!(p =lock_user_string (arg2))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (do_openat (cpu_env, arg1, p,target_to_host_bitmask (arg3, fcntl_flags_tbl), arg4));@@ -8083,7 +8083,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (safe_wait4 (arg1, &status, arg3,0 ));if (!is_error (ret) && arg2 && ret &&put_user_s32 (host_to_target_waitstatus (status), arg2)) - goto efault; + return -TARGET_EFAULT; }return ret;#endif @@ -8095,7 +8095,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (safe_waitid (arg1, arg2, &info, arg4,NULL ));if (!is_error (ret) && arg3 && info.si_pid !=0 ) {if (!(p =lock_user (VERIFY_WRITE , arg3,sizeof (target_siginfo_t),0 ))) - goto efault; +return -TARGET_EFAULT ;host_to_target_siginfo (p, &info);unlock_user (p, arg3,sizeof (target_siginfo_t)); }@@ -8105,7 +8105,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_creat/* not on alpha */ case TARGET_NR_creat:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (creat (p, arg2));fd_trans_unregister (ret);unlock_user (p, arg1,0 );@@ -8131,7 +8131,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, {void * p2 =NULL ;if (!arg2 || !arg4) - goto efault; +return -TARGET_EFAULT ; p =lock_user_string (arg2); p2 =lock_user_string (arg4);if (!p || !p2)@@ -8146,7 +8146,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_unlinkcase TARGET_NR_unlink:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (unlink (p));unlock_user (p, arg1,0 );return ret;@@ -8154,7 +8154,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_unlinkat)case TARGET_NR_unlinkat:if (!(p =lock_user_string (arg2))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (unlinkat (arg1, p, arg3));unlock_user (p, arg2,0 );return ret;@@ -8174,7 +8174,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, guest_argp = arg2;for (gp = guest_argp; gp; gp +=sizeof (abi_ulong)) {if (get_user_ual (addr, gp)) - goto efault; +return -TARGET_EFAULT ;if (!addr)break ; argc++;@@ -8183,7 +8183,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, guest_envp = arg3;for (gp = guest_envp; gp; gp +=sizeof (abi_ulong)) {if (get_user_ual (addr, gp)) - goto efault; +return -TARGET_EFAULT ;if (!addr)break ; envc++;@@ -8258,7 +8258,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return ret;case TARGET_NR_chdir:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (chdir (p));unlock_user (p, arg1,0 );return ret;@@ -8270,14 +8270,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret) && arg1 &&put_user_sal (host_time, arg1)) - goto efault; + return -TARGET_EFAULT; }return ret;#endif #ifdef TARGET_NR_mknodcase TARGET_NR_mknod:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (mknod (p, arg2, arg3));unlock_user (p, arg1,0 );return ret;@@ -8285,7 +8285,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_mknodat)case TARGET_NR_mknodat:if (!(p =lock_user_string (arg2))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (mknodat (arg1, p, arg3, arg4));unlock_user (p, arg2,0 );return ret;@@ -8293,7 +8293,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_chmodcase TARGET_NR_chmod:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (chmod (p, arg2));unlock_user (p, arg1,0 );return ret;@@ -8326,7 +8326,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg1) { p =lock_user_string (arg1);if (!p) { - goto efault; +return -TARGET_EFAULT ; } }else { p =NULL ;@@ -8337,7 +8337,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg1) {unlock_user (p, arg1,0 ); } - goto efault; +return -TARGET_EFAULT ; }if (arg3) {@@ -8347,7 +8347,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,unlock_user (p, arg1,0 ); }unlock_user (p2, arg2,0 ); - goto efault; +return -TARGET_EFAULT ; } }else { p3 =NULL ;@@ -8376,7 +8376,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_umountcase TARGET_NR_umount:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (umount (p));unlock_user (p, arg1,0 );return ret;@@ -8386,7 +8386,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, {time_t host_time;if (get_user_sal (host_time, arg1)) - goto efault; +return -TARGET_EFAULT ;return get_errno (stime (&host_time)); }#endif @@ -8414,7 +8414,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_utimbuf *target_tbuf;if (arg2) {if (!lock_user_struct (VERIFY_READ , target_tbuf, arg2,1 )) - goto efault; +return -TARGET_EFAULT ; tbuf.actime =tswapal (target_tbuf->actime); tbuf.modtime =tswapal (target_tbuf->modtime);unlock_user_struct (target_tbuf, arg2,0 );@@ -8423,7 +8423,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, host_tbuf =NULL ; }if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (utime (p, host_tbuf));unlock_user (p, arg1,0 ); }@@ -8437,13 +8437,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (copy_from_user_timeval (&tv[0 ], arg2) ||copy_from_user_timeval (&tv[1 ], arg2 +sizeof (struct target_timeval ))) - goto efault; +return -TARGET_EFAULT ; tvp = tv; }else { tvp =NULL ; }if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (utimes (p, tvp));unlock_user (p, arg1,0 ); }@@ -8457,13 +8457,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (copy_from_user_timeval (&tv[0 ], arg3) ||copy_from_user_timeval (&tv[1 ], arg3 +sizeof (struct target_timeval ))) - goto efault; +return -TARGET_EFAULT ; tvp = tv; }else { tvp =NULL ; } -if (!(p =lock_user_string (arg2))) - goto efault; +if (!(p =lock_user_string (arg2))) { +return -TARGET_EFAULT ; + } ret =get_errno (futimesat (arg1,path (p), tvp));unlock_user (p, arg2,0 ); }@@ -8479,16 +8480,18 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_accesscase TARGET_NR_access: -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (access (path (p), arg2));unlock_user (p, arg1,0 );return ret;#endif #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)case TARGET_NR_faccessat: -if (!(p =lock_user_string (arg2))) - goto efault; +if (!(p =lock_user_string (arg2))) { +return -TARGET_EFAULT ; + } ret =get_errno (faccessat (arg1, p, arg3,0 ));unlock_user (p, arg2,0 );return ret;@@ -8559,7 +8562,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_mkdircase TARGET_NR_mkdir:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (mkdir (p, arg2));unlock_user (p, arg1,0 );return ret;@@ -8567,7 +8570,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_mkdirat)case TARGET_NR_mkdirat:if (!(p =lock_user_string (arg2))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (mkdirat (arg1, p, arg3));unlock_user (p, arg2,0 );return ret;@@ -8575,7 +8578,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_rmdircase TARGET_NR_rmdir:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (rmdir (p));unlock_user (p, arg1,0 );return ret;@@ -8603,7 +8606,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg1) { tmsp =lock_user (VERIFY_WRITE , arg1,sizeof (struct target_tms ),0 );if (!tmsp) - goto efault; +return -TARGET_EFAULT ; tmsp->tms_utime =tswapal (host_to_target_clock_t (tms.tms_utime)); tmsp->tms_stime =tswapal (host_to_target_clock_t (tms.tms_stime)); tmsp->tms_cutime =tswapal (host_to_target_clock_t (tms.tms_cutime));@@ -8625,8 +8628,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg1 ==0 ) { ret =get_errno (acct (NULL )); }else { -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (acct (path (p)));unlock_user (p, arg1,0 ); }@@ -8634,7 +8638,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_umount2case TARGET_NR_umount2:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (umount2 (p, arg2));unlock_user (p, arg1,0 );return ret;@@ -8667,7 +8671,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return get_errno (umask (arg1));case TARGET_NR_chroot:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (chroot (p));unlock_user (p, arg1,0 );return ret;@@ -8717,7 +8721,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_old_sigaction *old_act;if (arg2) {if (!lock_user_struct (VERIFY_READ , old_act, arg2,1 )) - goto efault; +return -TARGET_EFAULT ; act._sa_handler = old_act->_sa_handler;target_siginitset (&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags;@@ -8728,7 +8732,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (do_sigaction (arg1, pact, &oact));if (!is_error (ret) && arg3) {if (!lock_user_struct (VERIFY_WRITE , old_act, arg3,0 )) - goto efault; +return -TARGET_EFAULT ; old_act->_sa_handler = oact._sa_handler; old_act->sa_mask = oact.sa_mask.sig[0 ]; old_act->sa_flags = oact.sa_flags;@@ -8739,7 +8743,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg2) {if (!lock_user_struct (VERIFY_READ , old_act, arg2,1 )) - goto efault; +return -TARGET_EFAULT ; act._sa_handler = old_act->_sa_handler;target_siginitset (&act.sa_mask, old_act->sa_mask.sig[0 ]); act.sa_flags = old_act->sa_flags;@@ -8753,7 +8757,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret) && arg3) {if (!lock_user_struct (VERIFY_WRITE , old_act, arg3,0 )) - goto efault; +return -TARGET_EFAULT ; old_act->_sa_handler = oact._sa_handler; old_act->sa_flags = oact.sa_flags; old_act->sa_mask.sig[0 ] = oact.sa_mask.sig[0 ];@@ -8767,7 +8771,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_sigaction act, oact, *pact;if (arg2) {if (!lock_user_struct (VERIFY_READ , old_act, arg2,1 )) - goto efault; +return -TARGET_EFAULT ; act._sa_handler = old_act->_sa_handler;target_siginitset (&act.sa_mask, old_act->sa_mask); act.sa_flags = old_act->sa_flags;@@ -8783,7 +8787,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (do_sigaction (arg1, pact, &oact));if (!is_error (ret) && arg3) {if (!lock_user_struct (VERIFY_WRITE , old_act, arg3,0 )) - goto efault; +return -TARGET_EFAULT ; old_act->_sa_handler = oact._sa_handler; old_act->sa_mask = oact.sa_mask.sig[0 ]; old_act->sa_flags = oact.sa_flags;@@ -8813,7 +8817,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }if (arg2) {if (!lock_user_struct (VERIFY_READ , rt_act, arg2,1 )) - goto efault; +return -TARGET_EFAULT ; act._sa_handler = rt_act->_sa_handler; act.sa_mask = rt_act->sa_mask; act.sa_flags = rt_act->sa_flags;@@ -8824,7 +8828,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (do_sigaction (arg1, pact, &oact));if (!is_error (ret) && arg3) {if (!lock_user_struct (VERIFY_WRITE , rt_act, arg3,0 )) - goto efault; +return -TARGET_EFAULT ; rt_act->_sa_handler = oact._sa_handler; rt_act->sa_mask = oact.sa_mask; rt_act->sa_flags = oact.sa_flags;@@ -8845,7 +8849,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }if (arg2) {if (!lock_user_struct (VERIFY_READ , act, arg2,1 )) { - goto efault; +return -TARGET_EFAULT ; }#ifdef TARGET_ARCH_HAS_KA_RESTORER act->ka_restorer = restorer;@@ -8947,7 +8951,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto fail; }if (!(p =lock_user (VERIFY_READ , arg2,sizeof (target_sigset_t),1 ))) - goto efault; +return -TARGET_EFAULT ;target_to_host_old_sigset (&set, p);unlock_user (p, arg2,0 ); set_ptr = &set;@@ -8958,7 +8962,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =do_sigprocmask (how, set_ptr, &oldset);if (!is_error (ret) && arg3) {if (!(p =lock_user (VERIFY_WRITE , arg3,sizeof (target_sigset_t),0 ))) - goto efault; +return -TARGET_EFAULT ;host_to_target_old_sigset (p, &oldset);unlock_user (p, arg3,sizeof (target_sigset_t)); }@@ -8991,7 +8995,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto fail; }if (!(p =lock_user (VERIFY_READ , arg2,sizeof (target_sigset_t),1 ))) - goto efault; +return -TARGET_EFAULT ;target_to_host_sigset (&set, p);unlock_user (p, arg2,0 ); set_ptr = &set;@@ -9002,7 +9006,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =do_sigprocmask (how, set_ptr, &oldset);if (!is_error (ret) && arg3) {if (!(p =lock_user (VERIFY_WRITE , arg3,sizeof (target_sigset_t),0 ))) - goto efault; +return -TARGET_EFAULT ;host_to_target_sigset (p, &oldset);unlock_user (p, arg3,sizeof (target_sigset_t)); }@@ -9015,7 +9019,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (sigpending (&set));if (!is_error (ret)) {if (!(p =lock_user (VERIFY_WRITE , arg1,sizeof (target_sigset_t),0 ))) - goto efault; +return -TARGET_EFAULT ;host_to_target_old_sigset (p, &set);unlock_user (p, arg1,sizeof (target_sigset_t)); }@@ -9038,7 +9042,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (sigpending (&set));if (!is_error (ret)) {if (!(p =lock_user (VERIFY_WRITE , arg1,sizeof (target_sigset_t),0 ))) - goto efault; +return -TARGET_EFAULT ;host_to_target_sigset (p, &set);unlock_user (p, arg1,sizeof (target_sigset_t)); }@@ -9053,7 +9057,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,target_to_host_old_sigset (&ts->sigsuspend_mask, &mask);#else if (!(p =lock_user (VERIFY_READ , arg1,sizeof (target_sigset_t),1 ))) - goto efault; +return -TARGET_EFAULT ;target_to_host_old_sigset (&ts->sigsuspend_mask, p);unlock_user (p, arg1,0 );#endif @@ -9073,7 +9077,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return -TARGET_EINVAL ; }if (!(p =lock_user (VERIFY_READ , arg1,sizeof (target_sigset_t),1 ))) - goto efault; +return -TARGET_EFAULT ;target_to_host_sigset (&ts->sigsuspend_mask, p);unlock_user (p, arg1,0 ); ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask,@@ -9094,7 +9098,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }if (!(p =lock_user (VERIFY_READ , arg1,sizeof (target_sigset_t),1 ))) - goto efault; +return -TARGET_EFAULT ;target_to_host_sigset (&set, p);unlock_user (p, arg1,0 );if (arg3) {@@ -9110,7 +9114,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p =lock_user (VERIFY_WRITE , arg2,sizeof (target_siginfo_t),0 );if (!p) { - goto efault; +return -TARGET_EFAULT ; }host_to_target_siginfo (p, &uinfo);unlock_user (p, arg2,sizeof (target_siginfo_t));@@ -9125,7 +9129,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p =lock_user (VERIFY_READ , arg3,sizeof (target_siginfo_t),1 );if (!p) { - goto efault; +return -TARGET_EFAULT ; }target_to_host_siginfo (&uinfo, p);unlock_user (p, arg3,0 );@@ -9138,7 +9142,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, p =lock_user (VERIFY_READ , arg4,sizeof (target_siginfo_t),1 );if (!p) { - goto efault; +return -TARGET_EFAULT ; }target_to_host_siginfo (&uinfo, p);unlock_user (p, arg4,0 );@@ -9162,7 +9166,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }case TARGET_NR_sethostname:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (sethostname (p, arg2));unlock_user (p, arg1,0 );return ret;@@ -9172,7 +9176,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_rlimit *target_rlim;struct rlimit rlim;if (!lock_user_struct (VERIFY_READ , target_rlim, arg2,1 )) - goto efault; +return -TARGET_EFAULT ; rlim.rlim_cur =target_to_host_rlim (target_rlim->rlim_cur); rlim.rlim_max =target_to_host_rlim (target_rlim->rlim_max);unlock_user_struct (target_rlim, arg2,0 );@@ -9187,7 +9191,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (getrlimit (resource, &rlim));if (!is_error (ret)) {if (!lock_user_struct (VERIFY_WRITE , target_rlim, arg2,0 )) - goto efault; +return -TARGET_EFAULT ; target_rlim->rlim_cur =host_to_target_rlim (rlim.rlim_cur); target_rlim->rlim_max =host_to_target_rlim (rlim.rlim_max);unlock_user_struct (target_rlim, arg2,1 );@@ -9209,7 +9213,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (gettimeofday (&tv,NULL ));if (!is_error (ret)) {if (copy_to_user_timeval (arg1, &tv)) - goto efault; +return -TARGET_EFAULT ; } }return ret;@@ -9220,14 +9224,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg1) {if (copy_from_user_timeval (&tv, arg1)) { - goto efault; +return -TARGET_EFAULT ; } ptv = &tv; }if (arg2) {if (copy_from_user_timezone (&tz, arg2)) { - goto efault; +return -TARGET_EFAULT ; } ptz = &tz; }@@ -9294,7 +9298,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,*/ if (ts_addr) {if (target_to_host_timespec (&ts, ts_addr)) { - goto efault; +return -TARGET_EFAULT ; } ts_ptr = &ts; }else {@@ -9308,7 +9312,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg7 =lock_user (VERIFY_READ , arg6,sizeof (*arg7) *2 ,1 );if (!arg7) { - goto efault; +return -TARGET_EFAULT ; } arg_sigset =tswapal (arg7[0 ]); arg_sigsize =tswapal (arg7[1 ]);@@ -9324,7 +9328,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_sigset =lock_user (VERIFY_READ , arg_sigset,sizeof (*target_sigset),1 );if (!target_sigset) { - goto efault; +return -TARGET_EFAULT ; }target_to_host_sigset (&set, target_sigset);unlock_user (target_sigset, arg_sigset,0 );@@ -9340,14 +9344,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) {if (rfd_addr &©_to_user_fdset (rfd_addr, &rfds, n)) - goto efault; +return -TARGET_EFAULT ;if (wfd_addr &©_to_user_fdset (wfd_addr, &wfds, n)) - goto efault; +return -TARGET_EFAULT ;if (efd_addr &©_to_user_fdset (efd_addr, &efds, n)) - goto efault; +return -TARGET_EFAULT ;if (ts_addr &&host_to_target_timespec (ts_addr, &ts)) - goto efault; +return -TARGET_EFAULT ; } }return ret;@@ -9446,7 +9450,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_swaponcase TARGET_NR_swapon:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (swapon (p, arg2));unlock_user (p, arg1,0 );return ret;@@ -9456,7 +9460,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,/* arg4 must be ignored in all other cases */ p =lock_user_string (arg4);if (!p) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (reboot (arg1, arg2, arg3, p));unlock_user (p, arg4,0 );@@ -9478,7 +9482,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,abi_ulong *v;abi_ulong v1, v2, v3, v4, v5, v6;if (!(v =lock_user (VERIFY_READ , arg1,6 *sizeof (abi_ulong),1 ))) - goto efault; +return -TARGET_EFAULT ; v1 =tswapal (v[0 ]); v2 =tswapal (v[1 ]); v3 =tswapal (v[2 ]);@@ -9550,7 +9554,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif case TARGET_NR_truncate:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (truncate (p, arg2));unlock_user (p, arg1,0 );return ret;@@ -9561,7 +9565,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_fchmodat)case TARGET_NR_fchmodat:if (!(p =lock_user_string (arg2))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (fchmodat (arg1, p, arg3,0 ));unlock_user (p, arg2,0 );return ret;@@ -9589,8 +9593,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto unimplemented;#endif case TARGET_NR_statfs: -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (statfs (path (p), &stfs));unlock_user (p, arg1,0 ); convert_statfs:@@ -9598,7 +9603,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_statfs *target_stfs;if (!lock_user_struct (VERIFY_WRITE , target_stfs, arg2,0 )) - goto efault; +return -TARGET_EFAULT ;__put_user (stfs.f_type, &target_stfs->f_type);__put_user (stfs.f_bsize, &target_stfs->f_bsize);__put_user (stfs.f_blocks, &target_stfs->f_blocks);@@ -9624,8 +9629,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto convert_statfs;#ifdef TARGET_NR_statfs64case TARGET_NR_statfs64: -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (statfs (path (p), &stfs));unlock_user (p, arg1,0 ); convert_statfs64:@@ -9633,7 +9639,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_statfs64 *target_stfs;if (!lock_user_struct (VERIFY_WRITE , target_stfs, arg3,0 )) - goto efault; +return -TARGET_EFAULT ;__put_user (stfs.f_type, &target_stfs->f_type);__put_user (stfs.f_bsize, &target_stfs->f_bsize);__put_user (stfs.f_blocks, &target_stfs->f_blocks);@@ -9731,7 +9737,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,case TARGET_NR_getrandom: p =lock_user (VERIFY_WRITE , arg1, arg2,0 );if (!p) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (getrandom (p, arg2, arg3));unlock_user (p, arg1, ret);@@ -9799,7 +9805,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (copy_from_user_timeval (&pvalue->it_interval, arg2) ||copy_from_user_timeval (&pvalue->it_value, arg2 +sizeof (struct target_timeval ))) - goto efault; +return -TARGET_EFAULT ; }else { pvalue =NULL ; }@@ -9809,7 +9815,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, &ovalue.it_interval) ||copy_to_user_timeval (arg3 +sizeof (struct target_timeval ), &ovalue.it_value)) - goto efault; + return -TARGET_EFAULT; } }return ret;@@ -9823,22 +9829,24 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, &value.it_interval) ||copy_to_user_timeval (arg2 +sizeof (struct target_timeval ), &value.it_value)) - goto efault; + return -TARGET_EFAULT; } }return ret;#ifdef TARGET_NR_statcase TARGET_NR_stat: -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (stat (path (p), &st));unlock_user (p, arg1,0 ); goto do_stat;#endif #ifdef TARGET_NR_lstatcase TARGET_NR_lstat: -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (lstat (path (p), &st));unlock_user (p, arg1,0 ); goto do_stat;@@ -9853,7 +9861,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct target_stat *target_st;if (!lock_user_struct (VERIFY_WRITE , target_st, arg2,0 )) - goto efault; +return -TARGET_EFAULT ;memset (target_st,0 ,sizeof (*target_st));__put_user (st.st_dev, &target_st->st_dev);__put_user (st.st_ino, &target_st->st_ino);@@ -9907,7 +9915,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (status_ptr && ret) { status =host_to_target_waitstatus (status);if (put_user_s32 (status, status_ptr)) - goto efault; +return -TARGET_EFAULT ; }if (target_rusage) { rusage_err =host_to_target_rusage (target_rusage, &rusage);@@ -9921,7 +9929,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_swapoffcase TARGET_NR_swapoff:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (swapoff (p));unlock_user (p, arg1,0 );return ret;@@ -9934,7 +9942,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret) && arg1) {if (!lock_user_struct (VERIFY_WRITE , target_value, arg1,0 )) - goto efault; +return -TARGET_EFAULT ;__put_user (value.uptime, &target_value->uptime);__put_user (value.loads[0 ], &target_value->loads[0 ]);__put_user (value.loads[1 ], &target_value->loads[1 ]);@@ -10031,7 +10039,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif case TARGET_NR_setdomainname:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (setdomainname (p, arg2));unlock_user (p, arg1,0 );return ret;@@ -10041,7 +10049,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct new_utsname * buf;if (!lock_user_struct (VERIFY_WRITE , buf, arg1,0 )) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (sys_uname (buf));if (!is_error (ret)) {/* Overwrite the native machine name with whatever is being @@ -10072,12 +10080,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct timex host_buf;if (target_to_host_timex (&host_buf, arg1) !=0 ) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (adjtimex (&host_buf));if (!is_error (ret)) {if (host_to_target_timex (arg1, &host_buf) !=0 ) { - goto efault; +return -TARGET_EFAULT ; } } }@@ -10088,12 +10096,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct timex htx, *phtx = &htx;if (target_to_host_timex (phtx, arg2) !=0 ) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (clock_adjtime (arg1, phtx));if (!is_error (ret) && phtx) {if (host_to_target_timex (arg2, phtx) !=0 ) { - goto efault; +return -TARGET_EFAULT ; } } }@@ -10143,7 +10151,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (_llseek (arg1, arg2, arg3, &res, arg5));#endif if ((ret ==0 ) &&put_user_s64 (res, arg4)) { - goto efault; +return -TARGET_EFAULT ; } }return ret;@@ -10174,7 +10182,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, count1 =0 ; de = dirp;if (!(target_dirp =lock_user (VERIFY_WRITE , arg2, count,0 ))) - goto efault; +return -TARGET_EFAULT ; tde = target_dirp;while (len >0 ) { reclen = de->d_reclen;@@ -10202,7 +10210,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,abi_long count = arg3;if (!(dirp =lock_user (VERIFY_WRITE , arg2, count,0 ))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (sys_getdents (arg1, dirp, count));if (!is_error (ret)) {struct linux_dirent *de;@@ -10231,7 +10239,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, dirp =lock_user (VERIFY_WRITE , arg2, count,0 );if (!dirp) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (sys_getdents64 (arg1, dirp, count));if (!is_error (ret)) {@@ -10286,7 +10294,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct linux_dirent64 *dirp;abi_long count = arg3;if (!(dirp =lock_user (VERIFY_WRITE , arg2, count,0 ))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (sys_getdents64 (arg1, dirp, count));if (!is_error (ret)) {struct linux_dirent64 *de;@@ -10335,7 +10343,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_pfd =lock_user (VERIFY_WRITE , arg1,sizeof (struct target_pollfd ) * nfds,1 );if (!target_pfd) { - goto efault; +return -TARGET_EFAULT ; } pfd =alloca (sizeof (struct pollfd ) * nfds);@@ -10356,7 +10364,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg3) {if (target_to_host_timespec (timeout_ts, arg3)) {unlock_user (target_pfd, arg1,0 ); - goto efault; +return -TARGET_EFAULT ; } }else { timeout_ts =NULL ;@@ -10371,7 +10379,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_set =lock_user (VERIFY_READ , arg4,sizeof (target_sigset_t),1 );if (!target_set) {unlock_user (target_pfd, arg1,0 ); - goto efault; +return -TARGET_EFAULT ; }target_to_host_sigset (set, target_set); }else {@@ -10525,7 +10533,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }if (host_to_target_cpu_mask (mask, mask_size, arg3, ret)) { - goto efault; +return -TARGET_EFAULT ; } } }@@ -10562,10 +10570,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, goto fail; }if (arg1 &&put_user_u32 (cpu, arg1)) { - goto efault; +return -TARGET_EFAULT ; }if (arg2 &&put_user_u32 (node, arg2)) { - goto efault; +return -TARGET_EFAULT ; } }return ret;@@ -10578,7 +10586,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return -TARGET_EINVAL ; }if (!lock_user_struct (VERIFY_READ , target_schp, arg2,1 )) - goto efault; +return -TARGET_EFAULT ; schp.sched_priority =tswap32 (target_schp->sched_priority);unlock_user_struct (target_schp, arg2,0 );return get_errno (sched_setparam (arg1, &schp));@@ -10594,7 +10602,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (sched_getparam (arg1, &schp));if (!is_error (ret)) {if (!lock_user_struct (VERIFY_WRITE , target_schp, arg2,0 )) - goto efault; +return -TARGET_EFAULT ; target_schp->sched_priority =tswap32 (schp.sched_priority);unlock_user_struct (target_schp, arg2,1 ); }@@ -10608,7 +10616,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return -TARGET_EINVAL ; }if (!lock_user_struct (VERIFY_READ , target_schp, arg3,1 )) - goto efault; +return -TARGET_EFAULT ; schp.sched_priority =tswap32 (target_schp->sched_priority);unlock_user_struct (target_schp, arg3,0 );return get_errno (sched_setscheduler (arg1, arg2, &schp));@@ -10656,7 +10664,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (prctl (arg1, &deathsig, arg3, arg4, arg5));if (!is_error (ret) && arg2 &&put_user_ual (deathsig, arg2)) { - goto efault; +return -TARGET_EFAULT ; }return ret; }@@ -10665,7 +10673,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, {void *name =lock_user (VERIFY_WRITE , arg2,16 ,1 );if (!name) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (prctl (arg1, (unsigned long )name, arg3, arg4, arg5));@@ -10676,7 +10684,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, {void *name =lock_user (VERIFY_READ , arg2,16 ,1 );if (!name) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (prctl (arg1, (unsigned long )name, arg3, arg4, arg5));@@ -10736,7 +10744,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg5 = arg6; }if (!(p =lock_user (VERIFY_WRITE , arg2, arg3,0 ))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (pread64 (arg1, p, arg3,target_offset64 (arg4, arg5)));unlock_user (p, arg2, ret);return ret;@@ -10746,14 +10754,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg5 = arg6; }if (!(p =lock_user (VERIFY_READ , arg2, arg3,1 ))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (pwrite64 (arg1, p, arg3,target_offset64 (arg4, arg5)));unlock_user (p, arg2,0 );return ret;#endif case TARGET_NR_getcwd:if (!(p =lock_user (VERIFY_WRITE , arg1, arg2,0 ))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (sys_getcwd1 (p, arg2));unlock_user (p, arg1, ret);return ret;@@ -10769,7 +10777,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,int data_items =1 ;if (!lock_user_struct (VERIFY_WRITE , target_header, arg1,1 )) { - goto efault; +return -TARGET_EFAULT ; } header.version =tswap32 (target_header->version); header.pid =tswap32 (target_header->pid);@@ -10789,7 +10797,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }if (!target_data) {unlock_user_struct (target_header, arg1,0 ); - goto efault; +return -TARGET_EFAULT ; }if (num == TARGET_NR_capset) {@@ -10905,7 +10913,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) {struct target_rlimit *target_rlim;if (!lock_user_struct (VERIFY_WRITE , target_rlim, arg2,0 )) - goto efault; +return -TARGET_EFAULT ; target_rlim->rlim_cur =host_to_target_rlim (rlim.rlim_cur); target_rlim->rlim_max =host_to_target_rlim (rlim.rlim_max);unlock_user_struct (target_rlim, arg2,1 );@@ -10916,7 +10924,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_truncate64case TARGET_NR_truncate64:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =target_truncate64 (cpu_env, p, arg2, arg3, arg4);unlock_user (p, arg1,0 );return ret;@@ -10927,8 +10935,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_stat64case TARGET_NR_stat64: -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (stat (path (p), &st));unlock_user (p, arg1,0 );if (!is_error (ret))@@ -10937,8 +10946,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif #ifdef TARGET_NR_lstat64case TARGET_NR_lstat64: -if (!(p =lock_user_string (arg1))) - goto efault; +if (!(p =lock_user_string (arg1))) { +return -TARGET_EFAULT ; + } ret =get_errno (lstat (path (p), &st));unlock_user (p, arg1,0 );if (!is_error (ret))
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 10976
Quoted 10 lines
linux-user/syscall.c +4
-2@@ -10959,9 +10969,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_newfstatatcase TARGET_NR_newfstatat:#endif -if (!(p =lock_user_string (arg2))) - goto efault; +if (!(p =lock_user_string (arg2))) { +return -TARGET_EFAULT ; + } ret =get_errno (fstatat (arg1,path (p), &st, arg4)); +unlock_user (p, arg2,0 );
Oh, another bug fixed? Is it worth a separate patch?
Quoted 255 lines
linux-user/syscall.c +29
-29if (!is_error (ret)) ret =host_to_target_stat64 (cpu_env, arg3, &st);return ret;@@ -10969,7 +10981,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_lchowncase TARGET_NR_lchown:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (lchown (p,low2highuid (arg2),low2highgid (arg3)));unlock_user (p, arg1,0 );return ret;@@ -11008,7 +11020,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) { target_grouplist =lock_user (VERIFY_WRITE , arg2, gidsetsize *sizeof (target_id),0 );if (!target_grouplist) - goto efault; +return -TARGET_EFAULT ;for (i =0 ;i < ret; i++) target_grouplist[i] =tswapid (high2lowgid (grouplist[i]));unlock_user (target_grouplist, arg2, gidsetsize *sizeof (target_id));@@ -11040,7 +11052,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_NR_fchownat)case TARGET_NR_fchownat:if (!(p =lock_user_string (arg2))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (fchownat (arg1, p,low2highuid (arg3),low2highgid (arg4), arg5));unlock_user (p, arg2,0 );@@ -11061,7 +11073,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (put_user_id (high2lowuid (ruid), arg1) ||put_user_id (high2lowuid (euid), arg2) ||put_user_id (high2lowuid (suid), arg3)) - goto efault; +return -TARGET_EFAULT ; } }return ret;@@ -11081,7 +11093,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (put_user_id (high2lowgid (rgid), arg1) ||put_user_id (high2lowgid (egid), arg2) ||put_user_id (high2lowgid (sgid), arg3)) - goto efault; +return -TARGET_EFAULT ; } }return ret;@@ -11089,7 +11101,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_chowncase TARGET_NR_chown:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (chown (p,low2highuid (arg2),low2highgid (arg3)));unlock_user (p, arg1,0 );return ret;@@ -11106,7 +11118,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_lchown32case TARGET_NR_lchown32:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (lchown (p, arg2, arg3));unlock_user (p, arg1,0 );return ret;@@ -11157,7 +11169,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, swcr |= (~fpcr >>41 ) &SWCR_TRAP_ENABLE_DNO ;if (put_user_u64 (swcr, arg2)) - goto efault; +return -TARGET_EFAULT ; ret =0 ; }break ;@@ -11184,7 +11196,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,uint64_t swcr, fpcr, orig_fpcr;if (get_user_u64 (swcr, arg2)) { - goto efault; +return -TARGET_EFAULT ; } orig_fpcr =cpu_alpha_load_fpcr (cpu_env); fpcr = orig_fpcr &FPCR_DYN_MASK ;@@ -11211,7 +11223,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,int si_code;if (get_user_u64 (exc, arg2)) { - goto efault; +return -TARGET_EFAULT ; } orig_fpcr =cpu_alpha_load_fpcr (cpu_env);@@ -11380,7 +11392,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (put_user_u32 (ruid, arg1) ||put_user_u32 (euid, arg2) ||put_user_u32 (suid, arg3)) - goto efault; +return -TARGET_EFAULT ; } }return ret;@@ -11398,7 +11410,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (put_user_u32 (rgid, arg1) ||put_user_u32 (egid, arg2) ||put_user_u32 (sgid, arg3)) - goto efault; +return -TARGET_EFAULT ; } }return ret;@@ -11406,7 +11418,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_chown32case TARGET_NR_chown32:if (!(p =lock_user_string (arg1))) - goto efault; +return -TARGET_EFAULT ; ret =get_errno (chown (p, arg2, arg3));unlock_user (p, arg1,0 );return ret;@@ -11969,13 +11981,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, pposix_mq_attr =NULL ;if (arg4) {if (copy_from_user_mq_attr (&posix_mq_attr, arg4) !=0 ) { - goto efault; +return -TARGET_EFAULT ; } pposix_mq_attr = &posix_mq_attr; } p =lock_user_string (arg1 -1 );if (!p) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (mq_open (p, host_flags, arg3, pposix_mq_attr));unlock_user (p, arg1,0 );@@ -12065,25 +12077,25 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,loff_t *ploff_in =NULL , *ploff_out =NULL ;if (arg2) {if (get_user_u64 (loff_in, arg2)) { - goto efault; +return -TARGET_EFAULT ; } ploff_in = &loff_in; }if (arg4) {if (get_user_u64 (loff_out, arg4)) { - goto efault; +return -TARGET_EFAULT ; } ploff_out = &loff_out; } ret =get_errno (splice (arg1, ploff_in, arg3, ploff_out, arg5, arg6));if (arg2) {if (put_user_u64 (loff_in, arg2)) { - goto efault; +return -TARGET_EFAULT ; } }if (arg4) {if (put_user_u64 (loff_out, arg4)) { - goto efault; +return -TARGET_EFAULT ; } } }@@ -12193,7 +12205,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg4) {struct target_epoll_event *target_ep;if (!lock_user_struct (VERIFY_READ , target_ep, arg4,1 )) { - goto efault; +return -TARGET_EFAULT ; } ep.events =tswap32 (target_ep->events);/* The epoll_data_t union is just opaque data to the kernel, @@ -12229,7 +12241,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_ep =lock_user (VERIFY_WRITE , arg2, maxevents *sizeof (struct target_epoll_event ),1 );if (!target_ep) { - goto efault; +return -TARGET_EFAULT ; } ep = g_try_new(struct epoll_event, maxevents);@@ -12301,7 +12313,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,int resource =target_to_host_resource (arg2);if (arg3) {if (!lock_user_struct (VERIFY_READ , target_rnew, arg3,1 )) { - goto efault; +return -TARGET_EFAULT ; } rnew.rlim_cur =tswap64 (target_rnew->rlim_cur); rnew.rlim_max =tswap64 (target_rnew->rlim_max);@@ -12312,7 +12324,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (sys_prlimit64 (arg1, resource, rnewp, arg4 ? &rold :0 ));if (!is_error (ret) && arg4) {if (!lock_user_struct (VERIFY_WRITE , target_rold, arg4,1 )) { - goto efault; +return -TARGET_EFAULT ; } target_rold->rlim_cur =tswap64 (rold.rlim_cur); target_rold->rlim_max =tswap64 (rold.rlim_max);@@ -12390,7 +12402,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, phtimer =NULL ; }else {if (put_user (TIMER_MAGIC | timer_index, arg3, target_timer_t)) { - goto efault; +return -TARGET_EFAULT ; } } }@@ -12414,12 +12426,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,struct itimerspec hspec_new = {{0 },}, hspec_old = {{0 },};if (target_to_host_itimerspec (&hspec_new, arg3)) { - goto efault; +return -TARGET_EFAULT ; } ret =get_errno (timer_settime (htimer, arg2, &hspec_new, &hspec_old));if (arg4 &&host_to_target_itimerspec (arg4, &hspec_old)) { - goto efault; +return -TARGET_EFAULT ; } }return ret;@@ -12497,7 +12509,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (timerfd_gettime (arg1, &its_curr));if (arg2 &&host_to_target_itimerspec (arg2, &its_curr)) { - goto efault; +return -TARGET_EFAULT ; } }return ret;@@ -12510,7 +12522,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (arg3) {if (target_to_host_itimerspec (&its_new, arg3)) { - goto efault; +return -TARGET_EFAULT ; } p_new = &its_new; }else {@@ -12520,7 +12532,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (timerfd_settime (arg1, arg2, p_new, &its_old));if (arg4 &&host_to_target_itimerspec (arg4, &its_old)) { - goto efault; +return -TARGET_EFAULT ; } }return ret;
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, · line 12576
Quoted 9 lines
linux-user/syscall.c +0
-3@@ -12559,9 +12571,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } fail:return ret; -efault: - ret = -TARGET_EFAULT ; - goto fail; } abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
PATCH v3 9/19 linux-user: Propagate goto unimplemented_nowarn to return
In reply to Richard Henderson--- linux-user/syscall.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
linux-user/syscall.c +4 -7
@@ -11807,7 +11807,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return 0 ; }#else - goto unimplemented_nowarn; +return -TARGET_ENOSYS ;#endif #endif #ifdef TARGET_NR_get_thread_area
@@ -11820,12 +11820,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return ts->tp_value; }#else - goto unimplemented_nowarn; +return -TARGET_ENOSYS ;#endif #endif #ifdef TARGET_NR_getdomainnamecase TARGET_NR_getdomainname: - goto unimplemented_nowarn; +return -TARGET_ENOSYS ;#endif #ifdef TARGET_NR_clock_settime
@@ -11910,7 +11910,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,* holding a mutex that is shared with another process via * shared memory). */ - goto unimplemented_nowarn; +return -TARGET_ENOSYS ;#endif #if defined(TARGET_NR_utimensat)
@@ -12564,9 +12564,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,default : unimplemented:gemu_log ("qemu: Unsupported syscall: %d\n" , num); -#if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list) - unimplemented_nowarn: -#endif return -TARGET_ENOSYS ; } fail:
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v3 09/19] linux-user: Propagate goto unimplemented_nowarn to return
Quoted 2 lines · Richard Henderson
Reviewed-by Laurent Vivier <[email protected]>Signed-off-by Richard Henderson <[email protected]>
Quoted 52 lines
--- linux-user/syscall.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)linux-user/syscall.c +4
-7@@ -11807,7 +11807,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return 0 ; }#else - goto unimplemented_nowarn; +return -TARGET_ENOSYS ;#endif #endif #ifdef TARGET_NR_get_thread_area@@ -11820,12 +11820,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return ts->tp_value; }#else - goto unimplemented_nowarn; +return -TARGET_ENOSYS ;#endif #endif #ifdef TARGET_NR_getdomainnamecase TARGET_NR_getdomainname: - goto unimplemented_nowarn; +return -TARGET_ENOSYS ;#endif #ifdef TARGET_NR_clock_settime@@ -11910,7 +11910,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,* holding a mutex that is shared with another process via * shared memory). */ - goto unimplemented_nowarn; +return -TARGET_ENOSYS ;#endif #if defined(TARGET_NR_utimensat)@@ -12564,9 +12564,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,default : unimplemented:gemu_log ("qemu: Unsupported syscall: %d\n" , num); -#if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list) - unimplemented_nowarn: -#endif return -TARGET_ENOSYS ; } fail:
PATCH v3 10/19 linux-user: Propagate goto unimplemented to default
In reply to Richard HendersonThere is no point in listing a syscall if you want the same effect as not listing it. In one less trivial case, the goto was demonstrably not reachable.
--- linux-user/syscall.c | 144 +------------------------------------------ 1 file changed, 1 insertion(+), 143 deletions(-)
linux-user/syscall.c +1 -143
@@ -8297,14 +8297,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (chmod (p, arg2));unlock_user (p, arg1,0 );return ret; -#endif -#ifdef TARGET_NR_break -case TARGET_NR_break: - goto unimplemented; -#endif -#ifdef TARGET_NR_oldstat -case TARGET_NR_oldstat: - goto unimplemented;#endif case TARGET_NR_lseek:return get_errno (lseek (arg1, arg2, arg3));
@@ -8390,16 +8382,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return get_errno (stime (&host_time)); }#endif -case TARGET_NR_ptrace: - goto unimplemented;#ifdef TARGET_NR_alarm/* not on alpha */ case TARGET_NR_alarm:return alarm (arg1);#endif -#ifdef TARGET_NR_oldfstat -case TARGET_NR_oldfstat: - goto unimplemented; -#endif #ifdef TARGET_NR_pause/* not on alpha */ case TARGET_NR_pause:if (!block_signals ()) {
@@ -8470,14 +8456,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }return ret;#endif -#ifdef TARGET_NR_stty -case TARGET_NR_stty: - goto unimplemented; -#endif -#ifdef TARGET_NR_gtty -case TARGET_NR_gtty: - goto unimplemented; -#endif #ifdef TARGET_NR_accesscase TARGET_NR_access:if (!(p =lock_user_string (arg1))) {
@@ -8499,10 +8477,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_nice/* not on alpha */ case TARGET_NR_nice:return get_errno (nice (arg1)); -#endif -#ifdef TARGET_NR_ftime -case TARGET_NR_ftime: - goto unimplemented;#endif case TARGET_NR_sync:sync ();
@@ -8616,14 +8590,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =host_to_target_clock_t (ret); }return ret; -#ifdef TARGET_NR_prof -case TARGET_NR_prof: - goto unimplemented; -#endif -#ifdef TARGET_NR_signal -case TARGET_NR_signal: - goto unimplemented; -#endif case TARGET_NR_acct:if (arg1 ==0 ) { ret =get_errno (acct (NULL ));
@@ -8642,31 +8608,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (umount2 (p, arg2));unlock_user (p, arg1,0 );return ret; -#endif -#ifdef TARGET_NR_lock -case TARGET_NR_lock: - goto unimplemented;#endif case TARGET_NR_ioctl:return do_ioctl (arg1, arg2, arg3);#ifdef TARGET_NR_fcntlcase TARGET_NR_fcntl:return do_fcntl (arg1, arg2, arg3); -#endif -#ifdef TARGET_NR_mpx -case TARGET_NR_mpx: - goto unimplemented;#endif case TARGET_NR_setpgid:return get_errno (setpgid (arg1, arg2)); -#ifdef TARGET_NR_ulimit -case TARGET_NR_ulimit: - goto unimplemented; -#endif -#ifdef TARGET_NR_oldolduname -case TARGET_NR_oldolduname: - goto unimplemented; -#endif case TARGET_NR_umask:return get_errno (umask (arg1));case TARGET_NR_chroot:
@@ -8675,10 +8625,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (chroot (p));unlock_user (p, arg1,0 );return ret; -#ifdef TARGET_NR_ustat -case TARGET_NR_ustat: - goto unimplemented; -#endif #ifdef TARGET_NR_dup2case TARGET_NR_dup2: ret =get_errno (dup2 (arg1, arg2));
@@ -9386,10 +9332,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }return ret;#endif -#ifdef TARGET_NR_oldlstat -case TARGET_NR_oldlstat: - goto unimplemented; -#endif #ifdef TARGET_NR_readlinkcase TARGET_NR_readlink: {
@@ -9443,10 +9385,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }return ret;#endif -#ifdef TARGET_NR_uselib -case TARGET_NR_uselib: - goto unimplemented; -#endif #ifdef TARGET_NR_swaponcase TARGET_NR_swapon:if (!(p =lock_user_string (arg1)))
@@ -9468,10 +9406,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (reboot (arg1, arg2, arg3,NULL )); }return ret; -#ifdef TARGET_NR_readdir -case TARGET_NR_readdir: - goto unimplemented; -#endif #ifdef TARGET_NR_mmapcase TARGET_NR_mmap: #if (defined(TARGET_I386) && defined(TARGET_ABI32)) || \
@@ -9588,10 +9522,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return ret;case TARGET_NR_setpriority:return get_errno (setpriority (arg1, arg2, arg3)); -#ifdef TARGET_NR_profil -case TARGET_NR_profil: - goto unimplemented; -#endif case TARGET_NR_statfs:if (!(p =lock_user_string (arg1))) {return -TARGET_EFAULT ;
@@ -9659,10 +9589,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (fstatfs (arg1, &stfs)); goto convert_statfs64;#endif -#ifdef TARGET_NR_ioperm -case TARGET_NR_ioperm: - goto unimplemented; -#endif #ifdef TARGET_NR_socketcallcase TARGET_NR_socketcall:return do_socketcall (arg1, arg2);
@@ -9880,20 +9806,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } }return ret; -#ifdef TARGET_NR_olduname -case TARGET_NR_olduname: - goto unimplemented; -#endif -#ifdef TARGET_NR_iopl -case TARGET_NR_iopl: - goto unimplemented; -#endif case TARGET_NR_vhangup:return get_errno (vhangup ()); -#ifdef TARGET_NR_idle -case TARGET_NR_idle: - goto unimplemented; -#endif #ifdef TARGET_NR_syscallcase TARGET_NR_syscall: return do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5,
@@ -10069,8 +9983,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,case TARGET_NR_modify_ldt:return do_modify_ldt (cpu_env, arg1, arg2, arg3);#if !defined(TARGET_X86_64 ) -case TARGET_NR_vm86old: - goto unimplemented;case TARGET_NR_vm86:return do_vm86 (cpu_env, arg1, arg2);#endif
@@ -10107,35 +10019,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, }return ret;#endif -#ifdef TARGET_NR_create_module -case TARGET_NR_create_module: -#endif -case TARGET_NR_init_module: -case TARGET_NR_delete_module: -#ifdef TARGET_NR_get_kernel_syms -case TARGET_NR_get_kernel_syms: -#endif - goto unimplemented; -case TARGET_NR_quotactl: - goto unimplemented;case TARGET_NR_getpgid:return get_errno (getpgid (arg1));case TARGET_NR_fchdir:return get_errno (fchdir (arg1)); -#ifdef TARGET_NR_bdflush/* not on x86_64 */ -case TARGET_NR_bdflush: - goto unimplemented; -#endif -#ifdef TARGET_NR_sysfs -case TARGET_NR_sysfs: - goto unimplemented; -#endif case TARGET_NR_personality:return get_errno (personality (arg1)); -#ifdef TARGET_NR_afs_syscall -case TARGET_NR_afs_syscall: - goto unimplemented; -#endif #ifdef TARGET_NR__llseek/* Not on alpha */ case TARGET_NR__llseek: {
@@ -10648,14 +10537,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } }return ret; -#ifdef TARGET_NR_query_module -case TARGET_NR_query_module: - goto unimplemented; -#endif -#ifdef TARGET_NR_nfsservctl -case TARGET_NR_nfsservctl: - goto unimplemented; -#endif case TARGET_NR_prctl:switch (arg1) {case PR_GET_PDEATHSIG :
@@ -10734,7 +10615,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#if defined(TARGET_I386 ) && !defined(TARGET_ABI32 )return do_arch_prctl (cpu_env, arg1, arg2);#else - goto unimplemented; +#error unreachable#endif #endif #ifdef TARGET_NR_pread64
@@ -10882,21 +10763,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return ret; }#endif -#else -case TARGET_NR_sendfile: -#ifdef TARGET_NR_sendfile64 -case TARGET_NR_sendfile64: -#endif - goto unimplemented; -#endif - -#ifdef TARGET_NR_getpmsg -case TARGET_NR_getpmsg: - goto unimplemented; -#endif -#ifdef TARGET_NR_putpmsg -case TARGET_NR_putpmsg: - goto unimplemented;#endif #ifdef TARGET_NR_vforkcase TARGET_NR_vfork:
@@ -11439,9 +11305,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,case TARGET_NR_setfsgid32:return get_errno (setfsgid (arg1));#endif - -case TARGET_NR_pivot_root: - goto unimplemented;#ifdef TARGET_NR_mincorecase TARGET_NR_mincore: {
@@ -11599,10 +11462,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,/* self-modifying code is handled automatically, so nothing needed */ return 0 ;#endif -#ifdef TARGET_NR_security -case TARGET_NR_security: - goto unimplemented; -#endif #ifdef TARGET_NR_getpagesizecase TARGET_NR_getpagesize:return TARGET_PAGE_SIZE ;
@@ -12562,7 +12421,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#endif default : - unimplemented:gemu_log ("qemu: Unsupported syscall: %d\n" , num);return -TARGET_ENOSYS ; }
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v3 10/19] linux-user: Propagate goto unimplemented to default
Quoted 9 lines · Richard Henderson
There is no point in listing a syscall if you want the same effect as not listing it. In one less trivial case, the goto was demonstrably not reachable.
Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.c | 144 +------------------------------------------ 1 file changed, 1 insertion(+), 143 deletions(-)
thanks
-- PMM
PATCH v3 11/19 linux-user: Propagate goto fail to return
In reply to Richard Henderson--- linux-user/syscall.c | 60 ++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 38 deletions(-)
linux-user/syscall.c +22 -38
@@ -8865,8 +8865,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, how =SIG_SETMASK ;break ;default : - ret = -TARGET_EINVAL ; - goto fail; +return -TARGET_EINVAL ; } mask = arg2;target_to_host_old_sigset (&set, &mask);
@@ -8893,8 +8892,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, how =SIG_SETMASK ;break ;default : - ret = -TARGET_EINVAL ; - goto fail; +return -TARGET_EINVAL ; }if (!(p =lock_user (VERIFY_READ , arg2,sizeof (target_sigset_t),1 )))return -TARGET_EFAULT ;
@@ -8937,8 +8935,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, how =SIG_SETMASK ;break ;default : - ret = -TARGET_EINVAL ; - goto fail; +return -TARGET_EINVAL ; }if (!(p =lock_user (VERIFY_READ , arg2,sizeof (target_sigset_t),1 )))return -TARGET_EFAULT ;
@@ -9227,15 +9224,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =copy_from_user_fdset_ptr (&rfds, &rfds_ptr, rfd_addr, n);if (ret) { - goto fail; +return ret; } ret =copy_from_user_fdset_ptr (&wfds, &wfds_ptr, wfd_addr, n);if (ret) { - goto fail; +return ret; } ret =copy_from_user_fdset_ptr (&efds, &efds_ptr, efd_addr, n);if (ret) { - goto fail; +return ret; }/*
@@ -9268,8 +9265,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, sig.set = &set;if (arg_sigsize !=sizeof (*target_sigset)) {/* Like the kernel, we enforce correct size sigsets */ - ret = -TARGET_EINVAL ; - goto fail; +return -TARGET_EINVAL ; } target_sigset =lock_user (VERIFY_READ , arg_sigset,sizeof (*target_sigset),1 );
@@ -9700,17 +9696,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,case TARGET_SYSLOG_ACTION_READ_CLEAR :/* Read/clear msgs */ case TARGET_SYSLOG_ACTION_READ_ALL :/* Read last messages */ { - ret = -TARGET_EINVAL ;if (len <0 ) { - goto fail; +return -TARGET_EINVAL ; }if (len ==0 ) {return 0 ; } p =lock_user (VERIFY_WRITE , arg2, arg3,0 );if (!p) { - ret = -TARGET_EFAULT ; - goto fail; +return -TARGET_EFAULT ; } ret =get_errno (sys_syslog ((int )arg1, p, (int )arg3));unlock_user (p, arg2, arg3);
@@ -10056,8 +10050,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, dirp =g_try_malloc (count);if (!dirp) { - ret = -TARGET_ENOMEM ; - goto fail; +return -TARGET_ENOMEM ; } ret =get_errno (sys_getdents (arg1, dirp, count));
@@ -10456,7 +10449,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, arg2 ? &node :NULL , NULL));if (is_error (ret)) { - goto fail; +return ret; }if (arg1 &&put_user_u32 (cpu, arg1)) {return -TARGET_EFAULT ;
@@ -10903,8 +10896,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, grouplist =alloca (gidsetsize *sizeof (gid_t)); target_grouplist =lock_user (VERIFY_READ , arg2, gidsetsize *sizeof (target_id),1 );if (!target_grouplist) { - ret = -TARGET_EFAULT ; - goto fail; +return -TARGET_EFAULT ; }for (i =0 ; i < gidsetsize; i++) { grouplist[i] =low2highgid (tswapid (target_grouplist[i]));
@@ -11162,8 +11154,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, how =SIG_SETMASK ;break ;default : - ret = -TARGET_EINVAL ; - goto fail; +return -TARGET_EINVAL ; } mask = arg2;target_to_host_old_sigset (&set, &mask);
@@ -11211,8 +11202,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,if (!is_error (ret)) { target_grouplist =lock_user (VERIFY_WRITE , arg2, gidsetsize *4 ,0 );if (!target_grouplist) { - ret = -TARGET_EFAULT ; - goto fail; +return -TARGET_EFAULT ; }for (i =0 ;i < ret; i++) target_grouplist[i] =tswap32 (grouplist[i]);
@@ -11232,8 +11222,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, grouplist =alloca (gidsetsize *sizeof (gid_t)); target_grouplist =lock_user (VERIFY_READ , arg2, gidsetsize *4 ,1 );if (!target_grouplist) { - ret = -TARGET_EFAULT ; - goto fail; +return -TARGET_EFAULT ; }for (i =0 ;i < gidsetsize; i++) grouplist[i] =tswap32 (target_grouplist[i]);
@@ -11308,20 +11297,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#ifdef TARGET_NR_mincorecase TARGET_NR_mincore: { -void *a; - ret = -TARGET_ENOMEM ; - a =lock_user (VERIFY_READ , arg1, arg2,0 ); +void *a =lock_user (VERIFY_READ , arg1, arg2,0 );if (!a) { - goto fail; +return -TARGET_ENOMEM ; } - ret = -TARGET_EFAULT ; p =lock_user_string (arg3);if (!p) { - goto mincore_fail; + ret = -TARGET_EFAULT ; + }else { + ret =get_errno (mincore (a, arg2, p)); +unlock_user (p, arg3, ret); } - ret =get_errno (mincore (a, arg2, p)); -unlock_user (p, arg3, ret); - mincore_fail:unlock_user (a, arg1,0 ); }return ret;
@@ -11787,8 +11773,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, ret =get_errno (sys_utimensat (arg1,NULL , tsp, arg4)); else {if (!(p =lock_user_string (arg2))) { - ret = -TARGET_EFAULT ; - goto fail; +return -TARGET_EFAULT ; } ret =get_errno (sys_utimensat (arg1,path (p), tsp, arg4));unlock_user (p, arg2,0 );
@@ -12424,7 +12409,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,gemu_log ("qemu: Unsupported syscall: %d\n" , num);return -TARGET_ENOSYS ; } -fail:return ret; }
Signature · 1 line
2.17.1
PATCH v3 12/19 linux-user: Setup split syscall infrastructure
In reply to Richard HendersonDefines a unified structure for implementation and strace. Supplies a generator script to build the declarations and the lookup function.
--- linux-user/syscall.h | 178 +++++++++++++++ linux-user/strace.c | 386 ++++++++++++++++++++++++--------- linux-user/syscall.c | 113 ++++------ linux-user/Makefile.objs | 10 + linux-user/gen_syscall_list.py | 82 +++++++ 5 files changed, 595 insertions(+), 174 deletions(-) create mode 100644 linux-user/syscall.h create mode 100644 linux-user/gen_syscall_list.py
linux-user/syscall.h new file +178 -0
@@ -0,0 +1,178 @@ +/* +* Linux syscalls internals +* Copyright (c) 2018 Linaro, Limited. +* +* 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, see <http://www.gnu.org/licenses/>. +*/ + +typedef struct SyscallDef SyscallDef ; + +/* This hook extracts max 6 arguments from max 8 input registers. +* In the process, register pairs that store 64-bit arguments are merged. +* Finally, syscalls are demultipliexed; e.g. the hook for socketcall will +* return the SyscallDef for bind, listen, etc. In the process the hook +* may need to read from guest memory, or otherwise validate operands. +* On failure, set errno (to a host value) and return NULL; +* the (target adjusted) errno will be returned to the guest. +*/ +typedef const SyscallDef *SyscallArgsFn (const SyscallDef *,int64_t out[6 ], +abi_long in[8 ]); + +/* This hook implements the syscall. */ +typedef abi_long SyscallImplFn (CPUArchState *,int64_t ,int64_t ,int64_t , +int64_t ,int64_t ,int64_t ); + +/* This hook prints the arguments to the syscall for strace. */ +typedef void SyscallPrintFn (const SyscallDef *,int64_t arg[6 ]); + +/* This hook print the return value from the syscall for strace. */ +typedef void SyscallPrintRetFn (const SyscallDef *,abi_long ); + +/* These flags describe the arguments for the generic fallback to +* SyscallPrintFn. ARG_NONE indicates that the argument is not present. +*/ +typedef enum { +ARG_NONE =0 , + +/* These print as numbers of abi_long. */ +ARG_DEC , +ARG_HEX , +ARG_OCT , + +/* These print as sets of flags. */ +ARG_ATDIRFD , +ARG_MODEFLAG , +ARG_OPENFLAG , + +/* These are interpreted as pointers. */ +ARG_PTR , +ARG_STR , +ARG_BUF , + +/* For a 32-bit host, force printing as a 64-bit operand. */ +#if TARGET_ABI_BITS ==32 +ARG_DEC64 , +#else +ARG_DEC64 =ARG_DEC , +#endif +}SyscallArgType ; + +struct SyscallDef { +const char *name; +SyscallArgsFn *args; +SyscallImplFn *impl; +SyscallPrintFn *print; +SyscallPrintRetFn *print_ret; +SyscallArgType arg_type[6 ]; +}; + +void print_syscall_def (const SyscallDef *def,int64_t args[6 ]); +void print_syscall_def_ret (const SyscallDef *def,abi_long ret); +void print_syscall_ptr_ret (const SyscallDef *def,abi_long ret); + +/* Emit the signature for a SyscallArgsFn. */ +#define SYSCALL_ARGS (NAME ) \ + static const SyscallDef *args_##NAME(const SyscallDef *def, \ + int64_t out[6], abi_long in[8]) + +/* Emit the signature for a SyscallImplFn. */ +#define SYSCALL_IMPL (NAME ) \ + static abi_long impl_##NAME(CPUArchState *cpu_env, int64_t arg1, \ + int64_t arg2, int64_t arg3, int64_t arg4, \ + int64_t arg5, int64_t arg6) + +/* Emit the definition for a "simple" syscall. Such does not use +* SyscallArgsFn and only uses arg_type for strace. +*/ +#define SYSCALL_DEF (NAME , ...) \ + const SyscallDef def_##NAME = { \ + .name = #NAME, .impl = impl_##NAME, .arg_type = { __VA_ARGS__ } \ + } + +/* Emit the definition for a syscall that also has an args hook, +* and uses arg_type for strace. +*/ +#define SYSCALL_DEF_ARGS (NAME , ...) \ + const SyscallDef def_##NAME = { \ + .name = #NAME, .args = args_##NAME, .impl = impl_##NAME, \ + .arg_type = { __VA_ARGS__ } \ + } + +/* Declarations from the main syscall.c for use in syscall_foo.c, +* or for the moment, vice versa. +*/ + +int host_to_target_errno (int err); + +static inline abi_long get_errno (abi_long ret) +{ +return unlikely (ret ==-1 ) ? -host_to_target_errno (errno) : ret; +} + +static inline int is_error (abi_ulong ret) +{ +return ret >=-4096 ; +} + +/* Declarators for interruptable system calls. */ + +#define safe_syscall0 (type, name) \ +static type safe_##name(void) \ +{ \ + return safe_syscall(__NR_##name); \ +} + +#define safe_syscall1 (type, name, type1, arg1) \ +static type safe_##name(type1 arg1) \ +{ \ + return safe_syscall(__NR_##name, arg1); \ +} + +#define safe_syscall2 (type, name, type1, arg1, type2, arg2) \ +static type safe_##name(type1 arg1, type2 arg2) \ +{ \ + return safe_syscall(__NR_##name, arg1, arg2); \ +} + +#define safe_syscall3 (type, name, type1, arg1, type2, arg2, type3, arg3) \ +static type safe_##name(type1 arg1, type2 arg2, type3 arg3) \ +{ \ + return safe_syscall(__NR_##name, arg1, arg2, arg3); \ +} + +#define safe_syscall4 (type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4) \ +static type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ +{ \ + return safe_syscall(__NR_##name, arg1, arg2, arg3, arg4); \ +} + +#define safe_syscall5 (type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5) \ +static type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ + type5 arg5) \ +{ \ + return safe_syscall(__NR_##name, arg1, arg2, arg3, arg4, arg5); \ +} + +#define safe_syscall6 (type, name, type1, arg1, type2, arg2, type3, arg3, \ + type4, arg4, type5, arg5, type6, arg6) \ +static type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ + type5 arg5, type6 arg6) \ +{ \ + return safe_syscall(__NR_##name, arg1, arg2, arg3, arg4, arg5, arg6); \ +} + +/* Include declarations of syscall definitions. */ +#include "syscall_list.h"
linux-user/strace.c +281 -105
482 lines not on this page · raw message
linux-user/syscall.c +44 -69
157 lines not on this page · raw message
linux-user/Makefile.objs +10 -0
@@ -7,3 +7,13 @@ obj-$(TARGET_HAS_BFLT) += flatload.o obj-$(TARGET_I386) += vm86.o obj-$(TARGET_ARM) += arm/nwfpe/ obj-$(TARGET_M68K) += m68k-sim.o + +GEN_SYSCALL_LIST = $(SRC_PATH)/linux-user/gen_syscall_list.py +SYSCALL_LIST = linux-user/syscall_list.h linux-user/syscall_list.inc.c + +$(SYSCALL_LIST): $(GEN_SYSCALL_LIST) + $(call quiet-command,\ + $(PYTHON) $(GEN_SYSCALL_LIST) $@, "GEN", $(TARGET_DIR)$@) + +linux-user/syscall.o \ +linux-user/strace.o: $(SYSCALL_LIST)
linux-user/gen_syscall_list.py new file +82 -0
82 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v3 12/19] linux-user: Setup split syscall infrastructure
Quoted 34 lines · Richard Henderson
Defines a unified structure for implementation and strace. Supplies a generator script to build the declarations and the lookup function.
Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.h | 178 +++++++++++++++ linux-user/strace.c | 386 ++++++++++++++++++++++++--------- linux-user/syscall.c | 113 ++++------ linux-user/Makefile.objs | 10 + linux-user/gen_syscall_list.py | 82 +++++++ 5 files changed, 595 insertions(+), 174 deletions(-) create mode 100644 linux-user/syscall.h create mode 100644 linux-user/gen_syscall_list.pylinux-user/syscall.h new file +13
-0@@ -0,0 +1,178 @@ +/* +* Linux syscalls internals +* Copyright (c) 2018 Linaro, Limited. +* +* 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.
linux-user/syscall.h line 23
Quoted 10 lines
linux-user/syscall.h new file +10
-0+* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +typedef struct SyscallDef SyscallDef ; + +/* This hook extracts max 6 arguments from max 8 input registers. +* In the process, register pairs that store 64-bit arguments are merged. +* Finally, syscalls are demultipliexed; e.g. the hook for socketcall will
"demultiplexed"
Quoted 43 lines
linux-user/syscall.h new file +43
-0+* return the SyscallDef for bind, listen, etc. In the process the hook +* may need to read from guest memory, or otherwise validate operands. +* On failure, set errno (to a host value) and return NULL; +* the (target adjusted) errno will be returned to the guest. +*/ +typedef const SyscallDef *SyscallArgsFn (const SyscallDef *,int64_t out[6 ], +abi_long in[8 ]); + +/* This hook implements the syscall. */ +typedef abi_long SyscallImplFn (CPUArchState *,int64_t ,int64_t ,int64_t , +int64_t ,int64_t ,int64_t ); + +/* This hook prints the arguments to the syscall for strace. */ +typedef void SyscallPrintFn (const SyscallDef *,int64_t arg[6 ]); + +/* This hook print the return value from the syscall for strace. */ +typedef void SyscallPrintRetFn (const SyscallDef *,abi_long ); + +/* These flags describe the arguments for the generic fallback to +* SyscallPrintFn. ARG_NONE indicates that the argument is not present. +*/ +typedef enum { + ARG_NONE = 0, + + /* These print as numbers of abi_long. */ + ARG_DEC, + ARG_HEX, + ARG_OCT, + + /* These print as sets of flags. */ + ARG_ATDIRFD, + ARG_MODEFLAG, + ARG_OPENFLAG, + + /* These are interpreted as pointers. */ + ARG_PTR, + ARG_STR, + ARG_BUF, + + /* For a 32-bit host, force printing as a 64-bit operand. */ +#if TARGET_ABI_BITS == 32 + ARG_DEC64, +#else
linux-user/syscall.h line 76
Quoted 10 lines
linux-user/syscall.h new file +10
-0+ ARG_DEC64 = ARG_DEC, +#endif +} SyscallArgType; + +struct SyscallDef { +const char *name; +SyscallArgsFn *args; +SyscallImplFn *impl; +SyscallPrintFn *print; +SyscallPrintRetFn *print_ret;
Are all these hook functions mandatory, or can a syscall implementation leave some of them NULL for a default behaviour?
Quoted 106 lines
linux-user/syscall.h new file +35
-0+SyscallArgType arg_type[6 ]; +}; + +void print_syscall_def (const SyscallDef *def,int64_t args[6 ]); +void print_syscall_def_ret (const SyscallDef *def,abi_long ret); +void print_syscall_ptr_ret (const SyscallDef *def,abi_long ret); + +/* Emit the signature for a SyscallArgsFn. */ +#define SYSCALL_ARGS (NAME ) \ + static const SyscallDef *args_##NAME(const SyscallDef *def, \ + int64_t out[6], abi_long in[8]) + +/* Emit the signature for a SyscallImplFn. */ +#define SYSCALL_IMPL (NAME ) \ + static abi_long impl_##NAME(CPUArchState *cpu_env, int64_t arg1, \ + int64_t arg2, int64_t arg3, int64_t arg4, \ + int64_t arg5, int64_t arg6) + +/* Emit the definition for a "simple" syscall. Such does not use +* SyscallArgsFn and only uses arg_type for strace. +*/ +#define SYSCALL_DEF (NAME , ...) \ + const SyscallDef def_##NAME = { \ + .name = #NAME, .impl = impl_##NAME, .arg_type = { __VA_ARGS__ } \ + } + +/* Emit the definition for a syscall that also has an args hook, +* and uses arg_type for strace. +*/ +#define SYSCALL_DEF_ARGS (NAME , ...) \ + const SyscallDef def_##NAME = { \ + .name = #NAME, .args = args_##NAME, .impl = impl_##NAME, \ + .arg_type = { __VA_ARGS__ } \ + } +linux-user/strace.c +32
-3@@ -10,6 +10,7 @@#include <linux/if_packet.h> #include <sched.h> #include "qemu.h" +#include "syscall.h" int do_strace=0 ;@@ -796,7 +797,7 @@ UNUSED static struct flags unlinkat_flags[] = { FLAG_END, }; -UNUSED static struct flags mode_flags[] = { +static struct flags const mode_flags[] = {FLAG_GENERIC (S_IFSOCK ),FLAG_GENERIC (S_IFLNK ),FLAG_GENERIC (S_IFREG ),@@ -807,14 +808,14 @@ UNUSED static struct flags mode_flags[] = { FLAG_END, }; -UNUSED static struct flags open_access_flags[] = { +static struct flags const open_access_flags[] = {FLAG_TARGET (O_RDONLY ),FLAG_TARGET (O_WRONLY ),FLAG_TARGET (O_RDWR ),FLAG_END , }; -UNUSED static struct flags open_flags[] = { +static struct flags const open_flags[] = {FLAG_TARGET (O_APPEND ),FLAG_TARGET (O_CREAT ),FLAG_TARGET (O_DIRECTORY ),@@ -989,84 +990,86 @@ get_comma(int last)return ((last) ?"" :"," ); } +static int add_flags (char *buf,int size,const struct flags *f, +int flags,bool octal) +{ +const char *sep ="" ; +int off =0 ; + +if (flags ==0 && f->f_value ==0 ) { +return snprintf (buf, size,"%s" , f->f_string); + } + +for (; f->f_string !=NULL ; f++) { +if (f->f_value !=0 && (flags & f->f_value) == f->f_value) { + off +=snprintf (buf + off, size - off,"%s%s" , sep, f->f_string); + flags &= ~f->f_value; + sep ="|" ; + } + } + +/* Print rest of the flags as numeric. */ +if (flags) { +if (octal) { + off +=snprintf (buf + off, size - off,"%s%#o" , sep, flags); + }else { + off +=snprintf (buf + off, size - off,"%s%#x" , sep, flags); + } + } +return off; +}
linux-user/strace.c get_comma(int last) · line 1028
Quoted 10 lines
linux-user/strace.c +5
-2+static void print_flags (const struct flags *f,abi_long flags,int last) { -const char *sep ="" ; -int n; +char buf[256 ]; +add_flags (buf,sizeof (buf), f, flags, false); +gemu_log ("%s%s" , buf,get_comma (last)); +}
All this refactoring of the strace functions feels like it should have been in a separate patch...
Quoted 191 lines
linux-user/strace.c +42
-28-if ((flags ==0 ) && (f->f_value ==0 )) { -gemu_log ("%s%s" , f->f_string,get_comma (last)); -return ; - } -for (n =0 ; f->f_string !=NULL ; f++) { -if ((f->f_value !=0 ) && ((flags & f->f_value) == f->f_value)) { -gemu_log ("%s%s" , sep, f->f_string); - flags &= ~f->f_value; - sep ="|" ; - n++; - } - } - -if (n >0 ) { -/* print rest of the flags as numeric */ -if (flags !=0 ) { -gemu_log ("%s%#x%s" , sep, (unsigned int )flags,get_comma (last)); - }else { -gemu_log ("%s" ,get_comma (last)); - }@@ -12412,12 +12353,18 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,return ret; } +/* Include the generated syscall lookup function. */ +#include "syscall_list.inc.c" +abi_long do_syscall (void *cpu_env,int num,abi_long arg1,abi_long arg2,abi_long arg3,abi_long arg4,abi_long arg5,abi_long arg6,abi_long arg7,abi_long arg8) {CPUState *cpu =ENV_GET_CPU (cpu_env); +const SyscallDef *def, *orig_def; +abi_long raw_args[8 ] = { arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 }; +int64_t out_args[6 ] = { arg1, arg2, arg3, arg4, arg5, arg6 };abi_long ret;#ifdef DEBUG_ERESTARTSYS @@ -12437,16 +12384,44 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,trace_guest_user_syscall (cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); -if (unlikely (do_strace)) { -print_syscall (num, arg1, arg2, arg3, arg4, arg5, arg6); - ret =do_syscall1 (cpu_env, num, arg1, arg2, arg3, arg4, - arg5, arg6, arg7, arg8); -print_syscall_ret (num, ret); - }else { - ret =do_syscall1 (cpu_env, num, arg1, arg2, arg3, arg4, - arg5, arg6, arg7, arg8); + orig_def = def =syscall_table (num); +if (def ==NULL ) { +/* Unconverted. */ +if (unlikely (do_strace)) { +print_syscall (num, arg1, arg2, arg3, arg4, arg5, arg6); + ret =do_syscall1 (cpu_env, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); +print_syscall_ret (num, ret); + }else { + ret =do_syscall1 (cpu_env, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); + } + goto fini; } +if (def->args) { + def = def->args (def, out_args, raw_args); +if (unlikely (def ==NULL )) { + ret = -host_to_target_errno (errno); +if (unlikely (do_strace)) { +print_syscall_def (orig_def, out_args); +print_syscall_def_ret (orig_def, ret); + } + goto fini; + } + } + +if (unlikely (do_strace)) { +print_syscall_def (def, out_args); + ret = def->impl (cpu_env, out_args[0 ], out_args[1 ], out_args[2 ], + out_args[3 ], out_args[4 ], out_args[5 ]); +print_syscall_def_ret (def, ret); + }else { + ret = def->impl (cpu_env, out_args[0 ], out_args[1 ], out_args[2 ], + out_args[3 ], out_args[4 ], out_args[5 ]); + } + + fini:trace_guest_user_syscall_ret (cpu, num, ret);return ret; }linux-user/Makefile.objs +10
-0@@ -7,3 +7,13 @@ obj-$(TARGET_HAS_BFLT) += flatload.o obj-$(TARGET_I386) += vm86.o obj-$(TARGET_ARM) += arm/nwfpe/ obj-$(TARGET_M68K) += m68k-sim.o + +GEN_SYSCALL_LIST = $(SRC_PATH)/linux-user/gen_syscall_list.py +SYSCALL_LIST = linux-user/syscall_list.h linux-user/syscall_list.inc.c + +$(SYSCALL_LIST): $(GEN_SYSCALL_LIST) + $(call quiet-command,\ + $(PYTHON) $(GEN_SYSCALL_LIST) $@, "GEN", $(TARGET_DIR)$@) + +linux-user/syscall.o \ +linux-user/strace.o: $(SYSCALL_LIST)linux-user/gen_syscall_list.py new file +72
-0@@ -0,0 +1,82 @@ +# +# Linux syscall table generator +# Copyright (c) 2018 Linaro, Limited. +# +# 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, see <http://www.gnu.org/licenses/>. +# + +from __future__ import print_function +import sys + +# These are sets of all syscalls that have been converted. +# The lists are in collation order with '_' ignored. + +# These syscalls are supported by all targets. +# Avoiding ifdefs for these can diagnose typos in $cpu/syscall_nr.h +unconditional_syscalls = [ +] + +# These syscalls are only supported by some target or abis. +conditional_syscalls = [ +] + + +def header(f): + # Do not ifdef the declarations -- their use may be complicated. + all = unconditional_syscalls + conditional_syscalls + all.sort() + for s in all: + print("extern const SyscallDef def_", s, ";", sep = '', file = f) + + +def def_syscall(s, f): + print(" case TARGET_NR_", s, ": return &def_", s, ";", + sep = '', file = f); + + +def source(f): + print("static const SyscallDef *syscall_table(int num)", + "{", + " switch (num) {", + sep = '\n', file = f) + + for s in unconditional_syscalls: + def_syscall(s, f) + for s in conditional_syscalls: + print("#ifdef TARGET_NR_", s, sep = '', file = f) + def_syscall(s, f) + print("#endif", file = f) + + print(" }", + " return NULL;", + "}", + sep = '\n', file = f); + + +def main(): + p = sys.argv[1] + f = open(p, "w") + + print("/* This file is autogenerated by gensyscall.py. */\n\n", + file = f)
linux-user/gen_syscall_list.py line 82
Quoted 10 lines
linux-user/gen_syscall_list.py new file +10
-0+ + if p[len(p) - 1] == 'h': + header(f) + else: + source(f) + + f.close(); + + +main()
Codegen looks good to me.
thanks
-- PMM
Re: [Qemu-devel] [PATCH v3 12/19] linux-user: Setup split syscall infrastructure
Quoted 9 lines · Peter Maydell
linux-user/syscall.h line 76
Quoted 6 lines
linux-user/syscall.h new file +6
-0+struct SyscallDef { +const char *name; +SyscallArgsFn *args; +SyscallImplFn *impl; +SyscallPrintFn *print; +SyscallPrintRetFn *print_ret;Are all these hook functions mandatory, or can a syscall implementation leave some of them NULL for a default behaviour?
Only impl is mandatory. You're right that there should be more doco here at the structure definition. Here, the docs got split down to the macros that define the most common forms of the structures. Will fix.
Quoted 10 lines
linux-user/strace.c get_comma(int last) · line 1028
Quoted 9 lines
static void
print_flags(const struct flags *f, abi_long flags, int last){linux-user/strace.c +4
-2-const char *sep ="" ; -int n; +char buf[256 ]; +add_flags (buf,sizeof (buf), f, flags, false); +gemu_log ("%s%s" , buf,get_comma (last)); +}
Quoted 2 lines
All this refactoring of the strace functions feels like it should have been in a separate patch...
Fair.
r~
Re: [Qemu-devel] [PATCH v3 12/19] linux-user: Setup split syscall infrastructure
In reply to Richard HendersonLe 12/06/2018 à 02:51, Richard Henderson a écrit :
Quoted 14 lines
Defines a unified structure for implementation and strace. Supplies a generator script to build the declarations and the lookup function.
Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.h | 178 +++++++++++++++ linux-user/strace.c | 386 ++++++++++++++++++++++++--------- linux-user/syscall.c | 113 ++++------ linux-user/Makefile.objs | 10 + linux-user/gen_syscall_list.py | 82 +++++++ 5 files changed, 595 insertions(+), 174 deletions(-) create mode 100644 linux-user/syscall.h create mode 100644 linux-user/gen_syscall_list.py
...
Quoted 97 lines
linux-user/Makefile.objs +10
-0@@ -7,3 +7,13 @@ obj-$(TARGET_HAS_BFLT) += flatload.o obj-$(TARGET_I386) += vm86.o obj-$(TARGET_ARM) += arm/nwfpe/ obj-$(TARGET_M68K) += m68k-sim.o + +GEN_SYSCALL_LIST = $(SRC_PATH)/linux-user/gen_syscall_list.py +SYSCALL_LIST = linux-user/syscall_list.h linux-user/syscall_list.inc.c + +$(SYSCALL_LIST): $(GEN_SYSCALL_LIST) + $(call quiet-command,\ + $(PYTHON) $(GEN_SYSCALL_LIST) $@, "GEN", $(TARGET_DIR)$@) + +linux-user/syscall.o \ +linux-user/strace.o: $(SYSCALL_LIST)linux-user/gen_syscall_list.py new file +72
-0@@ -0,0 +1,82 @@ +# +# Linux syscall table generator +# Copyright (c) 2018 Linaro, Limited. +# +# 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, see <http://www.gnu.org/licenses/>. +# + +from __future__ import print_function +import sys + +# These are sets of all syscalls that have been converted. +# The lists are in collation order with '_' ignored. + +# These syscalls are supported by all targets. +# Avoiding ifdefs for these can diagnose typos in $cpu/syscall_nr.h +unconditional_syscalls = [ +] + +# These syscalls are only supported by some target or abis. +conditional_syscalls = [ +] + + +def header(f): + # Do not ifdef the declarations -- their use may be complicated. + all = unconditional_syscalls + conditional_syscalls + all.sort() + for s in all: + print("extern const SyscallDef def_", s, ";", sep = '', file = f) + + +def def_syscall(s, f): + print(" case TARGET_NR_", s, ": return &def_", s, ";", + sep = '', file = f); + + +def source(f): + print("static const SyscallDef *syscall_table(int num)", + "{", + " switch (num) {", + sep = '\n', file = f) + + for s in unconditional_syscalls: + def_syscall(s, f) + for s in conditional_syscalls: + print("#ifdef TARGET_NR_", s, sep = '', file = f) + def_syscall(s, f) + print("#endif", file = f) + + print(" }", + " return NULL;", + "}", + sep = '\n', file = f); + + +def main(): + p = sys.argv[1] + f = open(p, "w") + + print("/* This file is autogenerated by gensyscall.py. */\n\n", + file = f)
linux-user/gen_syscall_list.py line 82
Quoted 10 lines
linux-user/gen_syscall_list.py new file +10
-0+ + if p[len(p) - 1] == 'h': + header(f) + else: + source(f) + + f.close(); + + +main()
As we can see in patch 19/19 it's easy to forget to update the syscalls lists.
Should it be possible to generate syscalls switch from the macro we already have?
Something like (it should not be as simple as this but...):
#define SYSCALL_DEF(NAME, ...) \
case TARGET_NR_##NAME: return @def_##NAME
static const SyscallDef *syscall_table(int num)
{
switch (num) {
#include "syscall_file.def"
#include "syscall_ipc.def"
#include "syscall_mem.def"
#include "syscall_proc.def"
}
return NULL;
}and in syscall_proc.def:
...SYSCALL_DEF(clone)
#ifdef TARGET_NR_forkSYSCALL_DEF(fork);
#endif
#ifdef TARGET_NR_vforkSYSCALL_DEF(vfork);
#endif
...SYSCALL_DEF(set_tid_address, ARG_PTR);
and in syscall_proc.c:
...SYSCALL_IMPL(set_tid_address)
{
return get_errno(set_tid_address((int *)g2h(arg1)));
}#include "syscall_proc.def".
So compiler will detect any unused references (if SYSCALL_DEF doesn't match SYSCALL_IMPL), the syscall_table has automatically all implemented syscalls, it automatically manage conditional/unconditional syscalls and we don't need generated files per target.
Thanks,
Laurent
Re: [Qemu-devel] [PATCH v3 12/19] linux-user: Setup split syscall infrastructure
Quoted 127 lines · Laurent Vivier
Le 12/06/2018 à 02:51, Richard Henderson a écrit :
Quoted 14 lines
Defines a unified structure for implementation and strace. Supplies a generator script to build the declarations and the lookup function.
Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.h | 178 +++++++++++++++ linux-user/strace.c | 386 ++++++++++++++++++++++++--------- linux-user/syscall.c | 113 ++++------ linux-user/Makefile.objs | 10 + linux-user/gen_syscall_list.py | 82 +++++++ 5 files changed, 595 insertions(+), 174 deletions(-) create mode 100644 linux-user/syscall.h create mode 100644 linux-user/gen_syscall_list.py...
Quoted 97 lines
linux-user/Makefile.objs +10
-0@@ -7,3 +7,13 @@ obj-$(TARGET_HAS_BFLT) += flatload.o obj-$(TARGET_I386) += vm86.o obj-$(TARGET_ARM) += arm/nwfpe/ obj-$(TARGET_M68K) += m68k-sim.o + +GEN_SYSCALL_LIST = $(SRC_PATH)/linux-user/gen_syscall_list.py +SYSCALL_LIST = linux-user/syscall_list.h linux-user/syscall_list.inc.c + +$(SYSCALL_LIST): $(GEN_SYSCALL_LIST) + $(call quiet-command,\ + $(PYTHON) $(GEN_SYSCALL_LIST) $@, "GEN", $(TARGET_DIR)$@) + +linux-user/syscall.o \ +linux-user/strace.o: $(SYSCALL_LIST)linux-user/gen_syscall_list.py new file +72
-0@@ -0,0 +1,82 @@ +# +# Linux syscall table generator +# Copyright (c) 2018 Linaro, Limited. +# +# 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, see <http://www.gnu.org/licenses/>. +# + +from __future__ import print_function +import sys + +# These are sets of all syscalls that have been converted. +# The lists are in collation order with '_' ignored. + +# These syscalls are supported by all targets. +# Avoiding ifdefs for these can diagnose typos in $cpu/syscall_nr.h +unconditional_syscalls = [ +] + +# These syscalls are only supported by some target or abis. +conditional_syscalls = [ +] + + +def header(f): + # Do not ifdef the declarations -- their use may be complicated. + all = unconditional_syscalls + conditional_syscalls + all.sort() + for s in all: + print("extern const SyscallDef def_", s, ";", sep = '', file = f) + + +def def_syscall(s, f): + print(" case TARGET_NR_", s, ": return &def_", s, ";", + sep = '', file = f); + + +def source(f): + print("static const SyscallDef *syscall_table(int num)", + "{", + " switch (num) {", + sep = '\n', file = f) + + for s in unconditional_syscalls: + def_syscall(s, f) + for s in conditional_syscalls: + print("#ifdef TARGET_NR_", s, sep = '', file = f) + def_syscall(s, f) + print("#endif", file = f) + + print(" }", + " return NULL;", + "}", + sep = '\n', file = f); + + +def main(): + p = sys.argv[1] + f = open(p, "w") + + print("/* This file is autogenerated by gensyscall.py. */\n\n", + file = f)linux-user/gen_syscall_list.py line 82
Quoted 10 lines
linux-user/gen_syscall_list.py new file +10
-0+ + if p[len(p) - 1] == 'h': + header(f) + else: + source(f) + + f.close(); + + +main()As we can see in patch 19/19 it's easy to forget to update the syscalls lists.
Quoted 2 lines
Should it be possible to generate syscalls switch from the macro we already have?
I didn't see how, right off.
It was possible when all of the syscalls were still in the same file, as we could get defined-but-unused warnings. With them in different files, we don't get that.
Perhaps there's a way that
Quoted 11 lines
static const SyscallDef *syscall_table(int num)
{ switch (num) { #include "syscall_file.def" #include "syscall_ipc.def" #include "syscall_mem.def" #include "syscall_proc.def" } return NULL; }
Quoted 1 line
and in syscall_proc.def:
something like this achieves that, via missing-prototype warnings.
But if we have a structure like this, I wonder if we're better off with
#include "syscall_file.inc.c"
#include "syscall_ipc.inc.c"
etc and go back to the defined-but-unused warnings, which are simpler to manage. That lets me drop the python script entirely, much like v2.
r~
PATCH v3 13/19 linux-user: Split out close, open, openat, read, write
In reply to Richard Henderson--- linux-user/syscall.h | 51 ++++ linux-user/strace.c | 35 --- linux-user/syscall.c | 402 +------------------------------ linux-user/syscall_file.c | 423 +++++++++++++++++++++++++++++++++ linux-user/Makefile.objs | 3 +- linux-user/gen_syscall_list.py | 5 + linux-user/strace.list | 15 -- 7 files changed, 484 insertions(+), 450 deletions(-) create mode 100644 linux-user/syscall_file.c
linux-user/syscall.h +51 -0
@@ -125,6 +125,57 @@ static inline int is_error(abi_ulong ret)return ret >=-4096 ; } +typedef abi_long (*TargetFdDataFunc )(void *,size_t ); +typedef abi_long (*TargetFdAddrFunc )(void *,abi_ulong ,socklen_t ); +typedef struct TargetFdTrans { +TargetFdDataFunc host_to_target_data; +TargetFdDataFunc target_to_host_data; +TargetFdAddrFunc target_to_host_addr; +}TargetFdTrans ; + +extern TargetFdTrans **target_fd_trans; +extern unsigned int target_fd_max; + +static inline TargetFdDataFunc fd_trans_target_to_host_data (int fd) +{ +if (fd >=0 && fd < target_fd_max && target_fd_trans[fd]) { +return target_fd_trans[fd]->target_to_host_data; + } +return NULL ; +} + +static inline TargetFdDataFunc fd_trans_host_to_target_data (int fd) +{ +if (fd >=0 && fd < target_fd_max && target_fd_trans[fd]) { +return target_fd_trans[fd]->host_to_target_data; + } +return NULL ; +} + +static inline TargetFdAddrFunc fd_trans_target_to_host_addr (int fd) +{ +if (fd >=0 && fd < target_fd_max && target_fd_trans[fd]) { +return target_fd_trans[fd]->target_to_host_addr; + } +return NULL ; +} + +void fd_trans_register (int fd,TargetFdTrans *trans); + +static inline void fd_trans_unregister (int fd) +{ +if (fd >=0 && fd < target_fd_max) { + target_fd_trans[fd] =NULL ; + } +} + +/* Temporary declarations from syscall_foo.c back to main syscall.c. +* These indicate incomplete conversion. +*/ + +int is_proc_myself (const char *filename,const char *entry); +extern bitmask_transtbl const fcntl_flags_tbl[]; +/* Declarators for interruptable system calls. */ #define safe_syscall0 (type, name) \
linux-user/strace.c +0 -35
@@ -2213,41 +2213,6 @@ print_mq_open(const struct syscallname *name, }#endif -#ifdef TARGET_NR_open -static void -print_open (const struct syscallname *name, -abi_long arg0,abi_long arg1,abi_long arg2, -abi_long arg3,abi_long arg4,abi_long arg5) -{ -int is_creat = (arg1 &TARGET_O_CREAT ); - -print_syscall_prologue (name); -print_string (arg0,0 ); -print_open_flags (arg1, (is_creat ==0 )); -if (is_creat) -print_file_mode (arg2,1 ); -print_syscall_epilogue (name); -} -#endif - -#ifdef TARGET_NR_openat -static void -print_openat (const struct syscallname *name, -abi_long arg0,abi_long arg1,abi_long arg2, -abi_long arg3,abi_long arg4,abi_long arg5) -{ -int is_creat = (arg2 &TARGET_O_CREAT ); - -print_syscall_prologue (name); -print_at_dirfd (arg0,0 ); -print_string (arg1,0 ); -print_open_flags (arg2, (is_creat ==0 )); -if (is_creat) -print_file_mode (arg3,1 ); -print_syscall_epilogue (name); -} -#endif -#ifdef TARGET_NR_mq_unlink static void print_mq_unlink(const struct syscallname *name,
linux-user/syscall.c +3 -399
445 lines not on this page · raw message
linux-user/syscall_file.c new file +423 -0
423 lines not on this page · raw message
linux-user/Makefile.objs +2 -1
@@ -1,4 +1,4 @@ -obj-y = main.o syscall.o strace.o mmap.o signal.o \ +obj-y = main.o syscall.o syscall_file.o strace.o mmap.o signal.o \ elfload.o linuxload.o uaccess.o uname.o \ safe-syscall.o $(TARGET_ABI_DIR)/signal.o \ $(TARGET_ABI_DIR)/cpu_loop.o
@@ -16,4 +16,5 @@ $(SYSCALL_LIST): $(GEN_SYSCALL_LIST) $(PYTHON) $(GEN_SYSCALL_LIST) $@, "GEN", $(TARGET_DIR)$@) linux-user/syscall.o \ +linux-user/syscall_file.o \ linux-user/strace.o: $(SYSCALL_LIST)
linux-user/gen_syscall_list.py +5 -0
@@ -25,10 +25,15 @@ import sys # These syscalls are supported by all targets. # Avoiding ifdefs for these can diagnose typos in $cpu/syscall_nr.h unconditional_syscalls = [ + "close", + "openat", + "read", + "write", ] # These syscalls are only supported by some target or abis. conditional_syscalls = [ + "open", ]
linux-user/strace.list +0 -15
@@ -97,9 +97,6 @@ #ifdef TARGET_NR_clone { TARGET_NR_clone, "clone" , NULL, print_clone, NULL }, #endif -#ifdef TARGET_NR_close -{ TARGET_NR_close, "close" , "%s(%d)", NULL, NULL }, -#endif #ifdef TARGET_NR_connect { TARGET_NR_connect, "connect" , "%s(%d,%#x,%d)", NULL, NULL }, #endif
@@ -677,12 +674,6 @@ #ifdef TARGET_NR_olduname { TARGET_NR_olduname, "olduname" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_open -{ TARGET_NR_open, "open" , NULL, print_open, NULL }, -#endif -#ifdef TARGET_NR_openat -{ TARGET_NR_openat, "openat" , NULL, print_openat, NULL }, -#endif #ifdef TARGET_NR_osf_adjtime { TARGET_NR_osf_adjtime, "osf_adjtime" , NULL, NULL, NULL }, #endif
@@ -1076,9 +1067,6 @@ #ifdef TARGET_NR_quotactl { TARGET_NR_quotactl, "quotactl" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_read -{ TARGET_NR_read, "read" , "%s(%d,%#x,%d)", NULL, NULL }, -#endif #ifdef TARGET_NR_readahead { TARGET_NR_readahead, "readahead" , NULL, NULL, NULL }, #endif
@@ -1626,9 +1614,6 @@ #ifdef TARGET_NR_waitpid { TARGET_NR_waitpid, "waitpid" , "%s(%d,%p,%#x)", NULL, NULL }, #endif -#ifdef TARGET_NR_write -{ TARGET_NR_write, "write" , "%s(%d,%#x,%d)", NULL, NULL }, -#endif #ifdef TARGET_NR_writev { TARGET_NR_writev, "writev" , "%s(%d,%p,%#x)", NULL, NULL }, #endif
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v3 13/19] linux-user: Split out close, open, openat, read, write
Quoted 11 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.h | 51 ++++ linux-user/strace.c | 35 --- linux-user/syscall.c | 402 +------------------------------ linux-user/syscall_file.c | 423 +++++++++++++++++++++++++++++++++ linux-user/Makefile.objs | 3 +- linux-user/gen_syscall_list.py | 5 + linux-user/strace.list | 15 -- 7 files changed, 484 insertions(+), 450 deletions(-) create mode 100644 linux-user/syscall_file.c
linux-user/syscall_file.c line 359
Quoted 6 lines
linux-user/syscall_file.c new file +6
-0+SYSCALL_IMPL (close) +{ +fd_trans_unregister (arg1); +return get_errno (close (arg1)); +} +SYSCALL_DEF (close,ARG_DEC );
If in future we wanted to extend the set of information we had for each syscall in the SyscallDef struct, I guess we'd add parameters to the SYSCALL_DEF macro (or have more variant macros)? I can't offhand think of something I'd want to use that for, so it's a bit of an abstract question for the moment.
thanks
-- PMM
Re: [Qemu-devel] [PATCH v3 13/19] linux-user: Split out close, open, openat, read, write
Quoted 5 lines · Peter Maydell
Quoted 5 lines
linux-user/syscall_file.c new file +5
-0+SYSCALL_IMPL (close) +{ +fd_trans_unregister (arg1); +return get_errno (close (arg1)); +}
Quoted 8 lines
Quoted 1 line
+SYSCALL_DEF(close,
ARG_DEC);If in future we wanted to extend the set of information we had for each syscall in the SyscallDef struct, I guess we'd add parameters to the
SYSCALL_DEFmacro (or have more variant macros)? I can't offhand think of something I'd want to use that for, so it's a bit of an abstract question for the moment.
Yes, I imagine we'd extend the SYSCALL_DEF macro(s) in that case.
Another thought I've had is to define variant SYSCALL_IMPL<N> macros that would allow us to put names to arguments, and help make the implementations clearer. E.g.
SYSCALL_IMPL1(close, fd)
{
fd_trans_unregister(fd);
return get_errno(close(fd));
}r~
PATCH v3 14/19 linux-user: Split out preadv, pwritev, readv, writev
In reply to Richard Henderson--- linux-user/syscall.h | 5 ++ linux-user/syscall.c | 85 ++------------------------- linux-user/syscall_file.c | 103 +++++++++++++++++++++++++++++++++ linux-user/gen_syscall_list.py | 4 ++ linux-user/strace.list | 12 ---- 5 files changed, 116 insertions(+), 93 deletions(-)
linux-user/syscall.h +5 -0
@@ -169,6 +169,11 @@ static inline void fd_trans_unregister(int fd) } } +struct iovec *lock_iovec (int type,abi_ulong target_addr, +abi_ulong count,int copy); +void unlock_iovec (struct iovec *vec,abi_ulong target_addr, +abi_ulong count,int copy); +/* Temporary declarations from syscall_foo.c back to main syscall.c. * These indicate incomplete conversion. */
linux-user/syscall.c +4 -81
109 lines not on this page · raw message
linux-user/syscall_file.c +103 -0
126 lines not on this page · raw message
linux-user/gen_syscall_list.py +4 -0
@@ -27,8 +27,12 @@ import sys unconditional_syscalls = [ "close", "openat", + "preadv", + "pwritev", "read", + "readv", "write", + "writev", ] # These syscalls are only supported by some target or abis.
linux-user/strace.list +0 -12
@@ -1028,9 +1028,6 @@ #ifdef TARGET_NR_pread64 { TARGET_NR_pread64, "pread64" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_preadv -{ TARGET_NR_preadv, "preadv" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_prlimit64 { TARGET_NR_prlimit64, "prlimit64" , NULL, NULL, NULL }, #endif
@@ -1058,9 +1055,6 @@ #ifdef TARGET_NR_pwrite64 { TARGET_NR_pwrite64, "pwrite64" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_pwritev -{ TARGET_NR_pwritev, "pwritev" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_query_module { TARGET_NR_query_module, "query_module" , NULL, NULL, NULL }, #endif
@@ -1079,9 +1073,6 @@ #ifdef TARGET_NR_readlinkat { TARGET_NR_readlinkat, "readlinkat" , NULL, print_readlinkat, NULL }, #endif -#ifdef TARGET_NR_readv -{ TARGET_NR_readv, "readv" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_reboot { TARGET_NR_reboot, "reboot" , NULL, NULL, NULL }, #endif
@@ -1614,9 +1605,6 @@ #ifdef TARGET_NR_waitpid { TARGET_NR_waitpid, "waitpid" , "%s(%d,%p,%#x)", NULL, NULL }, #endif -#ifdef TARGET_NR_writev -{ TARGET_NR_writev, "writev" , "%s(%d,%p,%#x)", NULL, NULL }, -#endif #ifdef TARGET_NR_utimensat { TARGET_NR_utimensat, "utimensat", NULL, print_utimensat, NULL }, #endif
Signature · 1 line
2.17.1
PATCH v3 15/19 linux-user: Split out pread64, pwrite64
In reply to Richard Henderson--- linux-user/syscall.h | 44 +++++++++++++++++++++ linux-user/syscall.c | 70 ---------------------------------- linux-user/syscall_file.c | 61 +++++++++++++++++++++++++++-- linux-user/gen_syscall_list.py | 2 + linux-user/strace.list | 6 --- 5 files changed, 104 insertions(+), 79 deletions(-)
linux-user/syscall.h +44 -0
@@ -174,6 +174,50 @@ struct iovec *lock_iovec(int type, abi_ulong target_addr,void unlock_iovec (struct iovec *vec,abi_ulong target_addr,abi_ulong count,int copy); +/* Returns true if syscall NUM expects 64bit types aligned even +* on pairs of registers. +*/ +static inline bool regpairs_aligned (void *cpu_env,int num) +{ +#ifdef TARGET_ARM +return ((CPUARMState *)cpu_env)->eabi; +#elif defined(TARGET_MIPS ) &&TARGET_ABI_BITS ==32 +return true; +#elif defined(TARGET_PPC ) && !defined(TARGET_PPC64 ) +/* SysV AVI for PPC32 expects 64bit parameters to be passed on +* odd/even pairs of registers which translates to the same as +* we start with r3 as arg1 +*/ +return true; +#elif defined(TARGET_SH4 ) +/* SH4 doesn't align register pairs, except for p{read,write}64 */ +switch (num) { +case TARGET_NR_pread64: +case TARGET_NR_pwrite64: +return true; +default : +return false; + } +#elif defined(TARGET_XTENSA ) +return true; +#else +return false; +#endif +} + +static inline uint64_t target_offset64 (abi_ulong word0,abi_ulong word1) +{ +#if TARGET_ABI_BITS ==32 +# ifdef TARGET_WORDS_BIGENDIAN +return ((uint64_t )word0 <<32 ) | word1; +# else +return ((uint64_t )word1 <<32 ) | word0; +# endif +#else +return word0; +#endif +} +/* Temporary declarations from syscall_foo.c back to main syscall.c. * These indicate incomplete conversion. */
linux-user/syscall.c +0 -70
88 lines not on this page · raw message
linux-user/syscall_file.c +58 -3
73 lines not on this page · raw message
linux-user/gen_syscall_list.py +2 -0
@@ -27,7 +27,9 @@ import sys unconditional_syscalls = [ "close", "openat", + "pread64", "preadv", + "pwrite64", "pwritev", "read", "readv",
linux-user/strace.list +0 -6
@@ -1025,9 +1025,6 @@ #ifdef TARGET_NR_prctl { TARGET_NR_prctl, "prctl" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_pread64 -{ TARGET_NR_pread64, "pread64" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_prlimit64 { TARGET_NR_prlimit64, "prlimit64" , NULL, NULL, NULL }, #endif
@@ -1052,9 +1049,6 @@ #ifdef TARGET_NR_putpmsg { TARGET_NR_putpmsg, "putpmsg" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_pwrite64 -{ TARGET_NR_pwrite64, "pwrite64" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_query_module { TARGET_NR_query_module, "query_module" , NULL, NULL, NULL }, #endif
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v3 15/19] linux-user: Split out pread64, pwrite64
Hi Richard,
Quoted 224 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.h | 44 +++++++++++++++++++++ linux-user/syscall.c | 70 ---------------------------------- linux-user/syscall_file.c | 61 +++++++++++++++++++++++++++-- linux-user/gen_syscall_list.py | 2 + linux-user/strace.list | 6 --- 5 files changed, 104 insertions(+), 79 deletions(-)linux-user/syscall.h +44
-0@@ -174,6 +174,50 @@ struct iovec *lock_iovec(int type, abi_ulong target_addr,void unlock_iovec (struct iovec *vec,abi_ulong target_addr,abi_ulong count,int copy); +/* Returns true if syscall NUM expects 64bit types aligned even +* on pairs of registers. +*/ +static inline bool regpairs_aligned (void *cpu_env,int num) +{ +#ifdef TARGET_ARM +return ((CPUARMState *)cpu_env)->eabi; +#elif defined(TARGET_MIPS ) &&TARGET_ABI_BITS ==32 +return true; +#elif defined(TARGET_PPC ) && !defined(TARGET_PPC64 ) +/* SysV AVI for PPC32 expects 64bit parameters to be passed on +* odd/even pairs of registers which translates to the same as +* we start with r3 as arg1 +*/ +return true; +#elif defined(TARGET_SH4 ) +/* SH4 doesn't align register pairs, except for p{read,write}64 */ +switch (num) { +case TARGET_NR_pread64: +case TARGET_NR_pwrite64: +return true; +default : +return false; + } +#elif defined(TARGET_XTENSA ) +return true; +#else +return false; +#endif +} + +static inline uint64_t target_offset64 (abi_ulong word0,abi_ulong word1) +{ +#if TARGET_ABI_BITS ==32 +# ifdef TARGET_WORDS_BIGENDIAN +return ((uint64_t )word0 <<32 ) | word1; +# else +return ((uint64_t )word1 <<32 ) | word0; +# endif +#else +return word0; +#endif +} +/* Temporary declarations from syscall_foo.c back to main syscall.c. * These indicate incomplete conversion. */ linux-user/syscall.c +0
-70@@ -642,38 +642,6 @@ static inline int next_free_host_timer(void) }#endif -/* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */ -#ifdef TARGET_ARM -static inline int regpairs_aligned (void *cpu_env,int num) -{ -return ((((CPUARMState *)cpu_env)->eabi) ==1 ) ; -} -#elif defined(TARGET_MIPS ) && (TARGET_ABI_BITS ==32 ) -static inline int regpairs_aligned (void *cpu_env,int num) {return 1 ; } -#elif defined(TARGET_PPC ) && !defined(TARGET_PPC64 ) -/* SysV AVI for PPC32 expects 64bit parameters to be passed on odd/even pairs -* of registers which translates to the same as ARM/MIPS, because we start with -* r3 as arg1 */ -static inline int regpairs_aligned (void *cpu_env,int num) {return 1 ; } -#elif defined(TARGET_SH4 ) -/* SH4 doesn't align register pairs, except for p{read,write}64 */ -static inline int regpairs_aligned (void *cpu_env,int num) -{ -switch (num) { -case TARGET_NR_pread64: -case TARGET_NR_pwrite64: -return 1 ; - -default : -return 0 ; - } -} -#elif defined(TARGET_XTENSA ) -static inline int regpairs_aligned (void *cpu_env,int num) {return 1 ; } -#else -static inline int regpairs_aligned (void *cpu_env,int num) {return 0 ; } -#endif -#define ERRNO_TABLE_SIZE 1200/* target_to_host_errno_table[] is initialized from @@ -6864,22 +6832,6 @@ void syscall_init(void) } } -#if TARGET_ABI_BITS ==32 -static inline uint64_t target_offset64 (uint32_t word0,uint32_t word1) -{ -#ifdef TARGET_WORDS_BIGENDIAN -return ((uint64_t )word0 <<32 ) | word1; -#else -return ((uint64_t )word1 <<32 ) | word0; -#endif -} -#else /* TARGET_ABI_BITS == 32 */ -static inline uint64_t target_offset64 (uint64_t word0,uint64_t word1) -{ -return word0; -} -#endif /* TARGET_ABI_BITS != 32 */ -#ifdef TARGET_NR_truncate64 static inline abi_long target_truncate64(void *cpu_env, const char *arg1, abi_long arg2,@@ -10078,28 +10030,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,#else #error unreachable#endif -#endif -#ifdef TARGET_NR_pread64 -case TARGET_NR_pread64: -if (regpairs_aligned (cpu_env, num)) { - arg4 = arg5; - arg5 = arg6; - } -if (!(p =lock_user (VERIFY_WRITE , arg2, arg3,0 ))) -return -TARGET_EFAULT ; - ret =get_errno (pread64 (arg1, p, arg3,target_offset64 (arg4, arg5))); -unlock_user (p, arg2, ret); -return ret; -case TARGET_NR_pwrite64: -if (regpairs_aligned (cpu_env, num)) { - arg4 = arg5; - arg5 = arg6; - } -if (!(p =lock_user (VERIFY_READ , arg2, arg3,1 ))) -return -TARGET_EFAULT ; - ret =get_errno (pwrite64 (arg1, p, arg3,target_offset64 (arg4, arg5))); -unlock_user (p, arg2,0 ); -return ret;#endif case TARGET_NR_getcwd:if (!(p =lock_user (VERIFY_WRITE , arg1, arg2,0 )))linux-user/syscall_file.c +55
-0@@ -378,15 +378,70 @@ SYSCALL_IMPL(openat) }SYSCALL_DEF (openat,ARG_ATDIRFD ,ARG_STR ,ARG_OPENFLAG ,ARG_MODEFLAG ); +/* Both pread64 and pwrite64 merge args into a 64-bit offset, +* but the input registers and ordering are target specific. +*/ +#if TARGET_ABI_BITS ==32 +SYSCALL_ARGS (pread64_pwrite64) +{ +/* We have already assigned out[0-2]. */ +int off =regpairs_aligned (cpu_env, TARGET_NR_pread64); + out[3 ] =target_offset64 (in[3 + off], in[4 + off]); +return def; +} +#else +#define args_pread64_pwrite64 NULL +#endif + +SYSCALL_IMPL (pread64) +{ +void *p =lock_user (VERIFY_WRITE , arg2, arg3,0 ); +abi_long ret; + +if (!p) { +return -TARGET_EFAULT ; + } + ret =get_errno (pread64 (arg1, p, arg3, arg4)); +unlock_user (p, arg2, ret); +return ret; +} + +const SyscallDef def_pread64 = { + .name ="pread64" , + .args = args_pread64_pwrite64, + .impl = impl_pread64, + .arg_type = {ARG_DEC ,ARG_PTR ,ARG_DEC ,ARG_DEC64 } +}; + +SYSCALL_IMPL (pwrite64) +{ +void *p =lock_user (VERIFY_READ , arg2, arg3,0 ); +abi_long ret; + +if (!p) { +return -TARGET_EFAULT ; + } + ret =get_errno (pwrite64 (arg1, p, arg3, arg4)); +unlock_user (p, arg2,0 ); +return ret; +} + +const SyscallDef def_pwrite64 = { + .name ="pwrite64" , + .args = args_pread64_pwrite64, + .impl = impl_pwrite64, + .arg_type = {ARG_DEC ,ARG_PTR ,ARG_DEC ,ARG_DEC64 } +}; +/* Both preadv and pwritev merge args 4/5 into a 64-bit offset. * Moreover, the parts are *always* in little-endian order.
linux-user/syscall_file.c SYSCALL_IMPL(openat) · line 444
Quoted 10 lines
linux-user/syscall_file.c +3
-3*/ #if TARGET_ABI_BITS ==32 SYSCALL_ARGS (preadv_pwritev) { -/* We have already assigned out[0-3]. */ -abi_ulong lo = in[4 ], hi = in[5 ]; - out[4 ] = ((hi << (TARGET_ABI_BITS -1 )) <<1 ) | lo; +/* We have already assigned out[0-2]. */ +abi_ulong lo = in[3 ], hi = in[4 ]; + out[3 ] = ((hi << (TARGET_ABI_BITS -1 )) <<1 ) | lo;
Why this change? If correct, can you update the comment? Also this seems related to your previous patch #14: "Split out preadv, pwritev, readv, writev", not this one.
Quoted 42 lines
linux-user/syscall_file.c +0
-0return def; }#else linux-user/gen_syscall_list.py +2
-0@@ -27,7 +27,9 @@ import sys unconditional_syscalls = [ "close", "openat", + "pread64", "preadv", + "pwrite64", "pwritev", "read", "readv",linux-user/strace.list +0
-6@@ -1025,9 +1025,6 @@ #ifdef TARGET_NR_prctl { TARGET_NR_prctl, "prctl" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_pread64 -{ TARGET_NR_pread64, "pread64" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_prlimit64 { TARGET_NR_prlimit64, "prlimit64" , NULL, NULL, NULL }, #endif@@ -1052,9 +1049,6 @@ #ifdef TARGET_NR_putpmsg { TARGET_NR_putpmsg, "putpmsg" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_pwrite64 -{ TARGET_NR_pwrite64, "pwrite64" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_query_module { TARGET_NR_query_module, "query_module" , NULL, NULL, NULL }, #endif
Re: [Qemu-devel] [PATCH v3 15/19] linux-user: Split out pread64, pwrite64
Quoted 12 lines · Philippe Mathieu-Daudé
linux-user/syscall_file.c SYSCALL_IMPL(openat) · line 444
Quoted 12 lines
/* Both preadv and pwritev merge args 4/5 into a 64-bit offset.
* Moreover, the parts are *always* in little-endian order. */
#ifTARGET_ABI_BITS== 32SYSCALL_ARGS(preadv_pwritev)
{linux-user/syscall_file.c +3
-3-/* We have already assigned out[0-3]. */ -abi_ulong lo = in[4 ], hi = in[5 ]; - out[4 ] = ((hi << (TARGET_ABI_BITS -1 )) <<1 ) | lo; +/* We have already assigned out[0-2]. */ +abi_ulong lo = in[3 ], hi = in[4 ]; + out[3 ] = ((hi << (TARGET_ABI_BITS -1 )) <<1 ) | lo;
Quoted 4 lines
Why this change? If correct, can you update the comment? Also this seems related to your previous patch #14: "Split out preadv, pwritev, readv, writev", not this one.
You're right, this hunk should be folded back into the previous patch.
r~
Philippe Mathieu-Daudé
Reviewed-byRe: [Qemu-devel] [PATCH v3 15/19] linux-user: Split out pread64, pwrite64
Quoted 13 lines · Richard Henderson
Quoted 12 lines · Philippe Mathieu-Daudé
Quoted 12 lines
/* Both preadv and pwritev merge args 4/5 into a 64-bit offset.
* Moreover, the parts are *always* in little-endian order. */
#ifTARGET_ABI_BITS== 32SYSCALL_ARGS(preadv_pwritev)
{linux-user/syscall_file.c +3
-3-/* We have already assigned out[0-3]. */ -abi_ulong lo = in[4 ], hi = in[5 ]; - out[4 ] = ((hi << (TARGET_ABI_BITS -1 )) <<1 ) | lo; +/* We have already assigned out[0-2]. */ +abi_ulong lo = in[3 ], hi = in[4 ]; + out[3 ] = ((hi << (TARGET_ABI_BITS -1 )) <<1 ) | lo;
Quoted 6 lines
Quoted 4 lines
Why this change? If correct, can you update the comment? Also this seems related to your previous patch #14: "Split out preadv, pwritev, readv, writev", not this one.
You're right, this hunk should be folded back into the previous patch.
So for this patch without this hunk:
PATCH v3 16/19 linux-user: Split out name_to_handle_at, open_by_handle_at
In reply to Richard Henderson--- linux-user/syscall.h | 1 + linux-user/strace.c | 5 +- linux-user/syscall.c | 98 ---------------------------------- linux-user/syscall_file.c | 88 ++++++++++++++++++++++++++++++ linux-user/gen_syscall_list.py | 2 + linux-user/strace.list | 3 -- 6 files changed, 95 insertions(+), 102 deletions(-)
linux-user/syscall.h +1 -0
@@ -52,6 +52,7 @@ typedef enum {/* These print as sets of flags. */ ARG_ATDIRFD , +ARG_ATFLAG ,ARG_MODEFLAG , ARG_OPENFLAG,
linux-user/strace.c +4 -1
@@ -780,7 +780,7 @@ UNUSED static struct flags access_flags[] = { FLAG_END, }; -UNUSED static struct flags at_file_flags[] = { +static struct flags const at_file_flags[] = { #ifdef AT_EACCESSFLAG_GENERIC (AT_EACCESS ), #endif
@@ -2693,6 +2693,9 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6])case ARG_ATDIRFD : len =add_atdirfd (b, rest, arg);break ; +case ARG_ATFLAG : + len =add_flags (b, rest, at_file_flags, arg, false); +break ;case ARG_MODEFLAG : len =add_flags (b, rest, mode_flags, arg, true);break ;
linux-user/syscall.c +0 -98
110 lines not on this page · raw message
linux-user/syscall_file.c +88 -0
102 lines not on this page · raw message
linux-user/gen_syscall_list.py +2 -0
@@ -26,7 +26,9 @@ import sys # Avoiding ifdefs for these can diagnose typos in $cpu/syscall_nr.h unconditional_syscalls = [ "close", + "name_to_handle_at", "openat", + "open_by_handle_at", "pread64", "preadv", "pwrite64",
linux-user/strace.list +0 -3
@@ -635,9 +635,6 @@ #ifdef TARGET_NR_munmap { TARGET_NR_munmap, "munmap" , NULL, print_munmap, NULL }, #endif -#ifdef TARGET_NR_name_to_handle_at -{ TARGET_NR_name_to_handle_at, "name_to_handle_at" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_nanosleep { TARGET_NR_nanosleep, "nanosleep" , NULL, NULL, NULL }, #endif
Signature · 1 line
2.17.1
PATCH v3 17/19 linux-user: Split out ipc syscalls
In reply to Richard HendersonGiven that these are all intertwined via TARGET_NR_ipc, we must move them all to the new file all at once.
--- linux-user/strace.c | 83 --- linux-user/syscall.c | 973 ---------------------------- linux-user/syscall_ipc.c | 1095 ++++++++++++++++++++++++++++++++ linux-user/Makefile.objs | 4 +- linux-user/gen_syscall_list.py | 12 + linux-user/strace.list | 42 -- 6 files changed, 1110 insertions(+), 1099 deletions(-) create mode 100644 linux-user/syscall_ipc.c
linux-user/strace.c +0 -83
@@ -1,8 +1,4 @@#include "qemu/osdep.h" -#include <sys/ipc.h> -#include <sys/msg.h> -#include <sys/sem.h> -#include <sys/shm.h> #include <sys/select.h> #include <sys/mount.h> #include <arpa/inet.h>
@@ -74,54 +70,6 @@ UNUSED static void print_socket_protocol(int domain, int type, int protocol);/* * Utility functions */ -static void -print_ipc_cmd (int cmd) -{ -#define output_cmd (val) \ -if( cmd == val ) { \ - gemu_log(#val); \ - return; \ -} - - cmd &=0xff ; - -/* General IPC commands */ -output_cmd (IPC_RMID ); -output_cmd (IPC_SET ); -output_cmd (IPC_STAT ); -output_cmd (IPC_INFO ); -/* msgctl() commands */ -output_cmd (MSG_STAT ); -output_cmd (MSG_INFO ); -/* shmctl() commands */ -output_cmd (SHM_LOCK ); -output_cmd (SHM_UNLOCK ); -output_cmd (SHM_STAT ); -output_cmd (SHM_INFO ); -/* semctl() commands */ -output_cmd (GETPID ); -output_cmd (GETVAL ); -output_cmd (GETALL ); -output_cmd (GETNCNT ); -output_cmd (GETZCNT ); -output_cmd (SETVAL ); -output_cmd (SETALL ); -output_cmd (SEM_STAT ); -output_cmd (SEM_INFO ); -output_cmd (IPC_RMID ); -output_cmd (IPC_RMID ); -output_cmd (IPC_RMID ); -output_cmd (IPC_RMID ); -output_cmd (IPC_RMID ); -output_cmd (IPC_RMID ); -output_cmd (IPC_RMID ); -output_cmd (IPC_RMID ); -output_cmd (IPC_RMID ); - -/* Some value we don't recognize */ -gemu_log ("%d" ,cmd); -} -static void print_signal (abi_ulong arg,int last) {
@@ -620,18 +568,6 @@ print_newselect(const struct syscallname *name, }#endif -#ifdef TARGET_NR_semctl -static void -print_semctl (const struct syscallname *name, -abi_long arg1,abi_long arg2,abi_long arg3, -abi_long arg4,abi_long arg5,abi_long arg6) -{ -gemu_log ("%s(" TARGET_ABI_FMT_ld"," TARGET_ABI_FMT_ld"," , name->name, arg1, arg2); -print_ipc_cmd (arg3); -gemu_log (",0x" TARGET_ABI_FMT_lx")" , arg4); -} -#endif - static void print_execve(const struct syscallname *name, abi_long arg1, abi_long arg2, abi_long arg3,
@@ -664,25 +600,6 @@ print_execve(const struct syscallname *name,gemu_log ("NULL})" ); } -#ifdef TARGET_NR_ipc -static void -print_ipc (const struct syscallname *name, -abi_long arg1,abi_long arg2,abi_long arg3, -abi_long arg4,abi_long arg5,abi_long arg6) -{ -switch (arg1) { -case IPCOP_semctl: -gemu_log ("semctl(" TARGET_ABI_FMT_ld"," TARGET_ABI_FMT_ld"," , arg1, arg2); -print_ipc_cmd (arg3); -gemu_log (",0x" TARGET_ABI_FMT_lx")" , arg4); -break ; -default : -gemu_log ("%s(" TARGET_ABI_FMT_ld"," TARGET_ABI_FMT_ld"," TARGET_ABI_FMT_ld"," TARGET_ABI_FMT_ld")" , - name->name, arg1, arg2, arg3, arg4); - } -} -#endif -/* * Variants for the return value output function */
linux-user/syscall.c +0 -973
1,003 lines not on this page · raw message
linux-user/syscall_ipc.c new file +1095 -0
1,095 lines not on this page · raw message
linux-user/Makefile.objs +3 -1
@@ -1,4 +1,5 @@ -obj-y = main.o syscall.o syscall_file.o strace.o mmap.o signal.o \ +obj-y = main.o syscall.o syscall_file.o syscall_ipc.o \ + strace.o mmap.o signal.o \ elfload.o linuxload.o uaccess.o uname.o \ safe-syscall.o $(TARGET_ABI_DIR)/signal.o \ $(TARGET_ABI_DIR)/cpu_loop.o
@@ -17,4 +18,5 @@ $(SYSCALL_LIST): $(GEN_SYSCALL_LIST) linux-user/syscall.o \ linux-user/syscall_file.o \ +linux-user/syscall_ipc.o \ linux-user/strace.o: $(SYSCALL_LIST)
linux-user/gen_syscall_list.py +12 -0
@@ -41,7 +41,19 @@ unconditional_syscalls = [ # These syscalls are only supported by some target or abis. conditional_syscalls = [ + "ipc", + "msgctl", + "msgget", + "msgrcv", + "msgsnd", "open", + "semctl", + "semget", + "semop", + "shmat", + "shmctl", + "shmdt", + "shmget", ]
linux-user/strace.list +0 -42
72 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 18/19 linux-user: Split out memory syscalls
In reply to Richard HendersonThis includes mmap, mmap2, munmap, mlock, mlockall, munlock, munlockall, mprotect, mremap, msync.
--- linux-user/syscall.h | 2 + linux-user/strace.c | 55 ++-------- linux-user/syscall.c | 118 -------------------- linux-user/syscall_mem.c | 190 +++++++++++++++++++++++++++++++++ linux-user/Makefile.objs | 3 +- linux-user/gen_syscall_list.py | 10 ++ linux-user/strace.list | 33 ------ 7 files changed, 212 insertions(+), 199 deletions(-) create mode 100644 linux-user/syscall_mem.c
linux-user/syscall.h +2 -0
@@ -53,6 +53,8 @@ typedef enum {/* These print as sets of flags. */ ARG_ATDIRFD ,ARG_ATFLAG , +ARG_MMAPFLAG , +ARG_MMAPPROT ,ARG_MODEFLAG , ARG_OPENFLAG,
linux-user/strace.c +8 -47
79 lines not on this page · raw message
linux-user/syscall.c +0 -118
136 lines not on this page · raw message
linux-user/syscall_mem.c new file +190 -0
190 lines not on this page · raw message
linux-user/Makefile.objs +2 -1
@@ -1,4 +1,4 @@ -obj-y = main.o syscall.o syscall_file.o syscall_ipc.o \ +obj-y = main.o syscall.o syscall_file.o syscall_ipc.o syscall_mem.o \ strace.o mmap.o signal.o \ elfload.o linuxload.o uaccess.o uname.o \ safe-syscall.o $(TARGET_ABI_DIR)/signal.o \
@@ -18,5 +18,6 @@ $(SYSCALL_LIST): $(GEN_SYSCALL_LIST) linux-user/syscall.o \ linux-user/syscall_file.o \ +linux-user/syscall_mem.o \ linux-user/syscall_ipc.o \ linux-user/strace.o: $(SYSCALL_LIST)
linux-user/gen_syscall_list.py +10 -0
@@ -26,6 +26,14 @@ import sys # Avoiding ifdefs for these can diagnose typos in $cpu/syscall_nr.h unconditional_syscalls = [ "close", + "mlock", + "mlockall", + "mprotect", + "mremap", + "msync", + "munlock", + "munlockall", + "munmap", "name_to_handle_at", "openat", "open_by_handle_at",
@@ -42,6 +50,8 @@ unconditional_syscalls = [ # These syscalls are only supported by some target or abis. conditional_syscalls = [ "ipc", + "mmap", + "mmap2", "msgctl", "msgget", "msgrcv",
linux-user/strace.list +0 -33
@@ -554,21 +554,6 @@ #ifdef TARGET_NR_mknodat { TARGET_NR_mknodat, "mknodat" , NULL, print_mknodat, NULL }, #endif -#ifdef TARGET_NR_mlock -{ TARGET_NR_mlock, "mlock" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_mlock2 -{ TARGET_NR_mlock2, "mlock2" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_mlockall -{ TARGET_NR_mlockall, "mlockall" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_mmap -{ TARGET_NR_mmap, "mmap" , NULL, print_mmap, print_syscall_ret_addr }, -#endif -#ifdef TARGET_NR_mmap2 -{ TARGET_NR_mmap2, "mmap2" , NULL, print_mmap2, print_syscall_ret_addr }, -#endif #ifdef TARGET_NR_modify_ldt { TARGET_NR_modify_ldt, "modify_ldt" , NULL, NULL, NULL }, #endif
@@ -578,9 +563,6 @@ #ifdef TARGET_NR_move_pages { TARGET_NR_move_pages, "move_pages" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_mprotect -{ TARGET_NR_mprotect, "mprotect" , NULL, print_mprotect, NULL }, -#endif #ifdef TARGET_NR_mpx { TARGET_NR_mpx, "mpx" , NULL, NULL, NULL }, #endif
@@ -602,24 +584,9 @@ #ifdef TARGET_NR_mq_unlink { TARGET_NR_mq_unlink, "mq_unlink" , NULL, print_mq_unlink, NULL }, #endif -#ifdef TARGET_NR_mremap -{ TARGET_NR_mremap, "mremap" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_msync -{ TARGET_NR_msync, "msync" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_multiplexer { TARGET_NR_multiplexer, "multiplexer" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_munlock -{ TARGET_NR_munlock, "munlock" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_munlockall -{ TARGET_NR_munlockall, "munlockall" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_munmap -{ TARGET_NR_munmap, "munmap" , NULL, print_munmap, NULL }, -#endif #ifdef TARGET_NR_nanosleep { TARGET_NR_nanosleep, "nanosleep" , NULL, NULL, NULL }, #endif
Signature · 1 line
2.17.1
PATCH v3 19/19 linux-user: Split out some process syscalls
In reply to Richard HendersonThis includes clone, getgroups, gettid, setfsgid, setfsuid, setgroups, setsid, setuid, fork, getegid, getegid32, geteuid, geteuid32, getgid, getgid32, getgroups32, getpgrp, getpid, getppid, getresgid, getresgid32, getresuid, getresuid32, getuid, getuid32, getxgid, getxpid, getxuid, setfsgid32, setgsuid32, setgid32, setgroups32, setregid, setregid32, setresgid, setresgid32, setresuid, setresuid32, setreuid, setreuid32, setuid32, vfork.
--- linux-user/syscall.h | 108 ++++ linux-user/strace.c | 36 +- linux-user/syscall.c | 799 ---------------------------- linux-user/syscall_proc.c | 914 +++++++++++++++++++++++++++++++++ linux-user/Makefile.objs | 5 +- linux-user/gen_syscall_list.py | 43 ++ linux-user/strace.list | 144 ------ 7 files changed, 1072 insertions(+), 977 deletions(-) create mode 100644 linux-user/syscall_proc.c
linux-user/syscall.h +108 -0
@@ -53,6 +53,7 @@ typedef enum {/* These print as sets of flags. */ ARG_ATDIRFD ,ARG_ATFLAG , +ARG_CLONEFLAG ,ARG_MMAPFLAG ,ARG_MMAPPROT , ARG_MODEFLAG,
@@ -221,6 +222,61 @@ static inline uint64_t target_offset64(abi_ulong word0, abi_ulong word1)#endif } +#ifdef USE_UID16 +static inline int high2lowuid (int uid) +{ +return uid >65535 ?65534 : uid; +} + +static inline int high2lowgid (int gid) +{ +return gid >65535 ?65534 : gid; +} + +static inline int low2highuid (int uid) +{ +return (int16_t )uid ==-1 ?-1 : uid; +} + +static inline int low2highgid (int gid) +{ +return (int16_t )gid ==-1 ?-1 : gid; +} +static inline int tswapid (int id) +{ +return tswap16 (id); +} + +#define put_user_id (x, gaddr) put_user_u16(x, gaddr) +#else /* !USE_UID16 */ +static inline int high2lowuid (int uid) +{ +return uid; +} + +static inline int high2lowgid (int gid) +{ +return gid; +} + +static inline int low2highuid (int uid) +{ +return uid; +} + +static inline int low2highgid (int gid) +{ +return gid; +} + +static inline int tswapid (int id) +{ +return tswap32 (id); +} + +#define put_user_id (x, gaddr) put_user_u32(x, gaddr) +#endif /* USE_UID16 */ +/* Temporary declarations from syscall_foo.c back to main syscall.c. * These indicate incomplete conversion. */
@@ -277,5 +333,57 @@ static type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ return safe_syscall(__NR_##name, arg1, arg2, arg3, arg4, arg5, arg6); \ } +/* Declarators for non-interruptable system calls. */ + +#undef _syscall0 +#undef _syscall1 +#undef _syscall2 +#undef _syscall3 +#undef _syscall4 +#undef _syscall5 +#undef _syscall6 + +#define _syscall0 (type, name) \ + static type name(void) \ + { \ + return syscall(__NR_##name); \ + } + +#define _syscall1 (T0 , name,T1 ,A1 ) \ + static T0 name(T1 A1) \ + { \ + return syscall(__NR_##name, A1); \ + } + +#define _syscall2 (T0 , name,T1 ,A1 ,T2 ,A2 ) \ + static T0 name(T1 A1, T2 A2) \ + { \ + return syscall(__NR_##name, A1, A2); \ + } + +#define _syscall3 (T0 , name,T1 ,A1 ,T2 ,A2 ,T3 ,A3 ) \ + static T0 name(T1 A1, T2 A2, T3 A3) \ + { \ + return syscall(__NR_##name, A1, A2, A3); \ + } + +#define _syscall4 (T0 , name,T1 ,A1 ,T2 ,A2 ,T3 ,A3 ,T4 ,A4 ) \ + static T0 name(T1 A1, T2 A2, T3 A3, T4 A4) \ + { \ + return syscall(__NR_##name, A1, A2, A3, A4); \ + } + +#define _syscall5 (T0 , name,T1 ,A1 ,T2 ,A2 ,T3 ,A3 ,T4 ,A4 ,T5 ,A5 ) \ + static T0 name(T1 A1, T2 A2, T3 A3, T4 A4, T5 A5) \ + { \ + return syscall(__NR_##name, A1, A2, A3, A4, A5); \ + } + +#define _syscall6 (T0 , name,T1 ,A1 ,T2 ,A2 ,T3 ,A3 ,T4 ,A4 ,T5 ,A5 ,T6 ,A6 ) \ + static T0 name(T1 A1, T2 A2, T3 A3, T4 A4, T5 A5, T6 A6) \ + { \ + return syscall(__NR_##name, A1, A2, A3, A4, A5, A6); \ + } +/* Include declarations of syscall definitions. */ #include "syscall_list.h"
linux-user/strace.c +4 -32
@@ -836,7 +836,7 @@ static struct flags const mmap_flags[] = { FLAG_END, }; -UNUSED static struct flags clone_flags[] = { +static struct flags const clone_flags[] = {FLAG_GENERIC (CLONE_VM ),FLAG_GENERIC (CLONE_FS ),FLAG_GENERIC (CLONE_FILES ),
@@ -1218,37 +1218,6 @@ print_clock_adjtime(const struct syscallname *name, }#endif -#ifdef TARGET_NR_clone -static void do_print_clone (unsigned int flags,abi_ulong newsp, -abi_ulong parent_tidptr,target_ulong newtls, -abi_ulong child_tidptr) -{ -print_flags (clone_flags, flags,0 ); -print_raw_param ("child_stack=0x" TARGET_ABI_FMT_lx, newsp,0 ); -print_raw_param ("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr,0 ); -print_raw_param ("tls=0x" TARGET_ABI_FMT_lx, newtls,0 ); -print_raw_param ("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr,1 ); -} - -static void -print_clone (const struct syscallname *name, -abi_long arg1,abi_long arg2,abi_long arg3, -abi_long arg4,abi_long arg5,abi_long arg6) -{ -print_syscall_prologue (name); -#if defined(TARGET_MICROBLAZE ) -do_print_clone (arg1, arg2, arg4, arg6, arg5); -#elif defined(TARGET_CLONE_BACKWARDS ) -do_print_clone (arg1, arg2, arg3, arg4, arg5); -#elif defined(TARGET_CLONE_BACKWARDS2 ) -do_print_clone (arg2, arg1, arg3, arg5, arg4); -#else -do_print_clone (arg1, arg2, arg3, arg5, arg4); -#endif -print_syscall_epilogue (name); -} -#endif -#ifdef TARGET_NR_creat static void print_creat(const struct syscallname *name,
@@ -2568,6 +2537,9 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6])case ARG_ATFLAG : len =add_flags (b, rest, at_file_flags, arg, false);break ; +case ARG_CLONEFLAG : + len =add_flags (b, rest, clone_flags, arg, false); +break ;case ARG_MMAPFLAG : len =add_flags (b, rest, mmap_flags, arg, false);break ;
linux-user/syscall.c +0 -799
938 lines not on this page · raw message
linux-user/syscall_proc.c new file +914 -0
914 lines not on this page · raw message
linux-user/Makefile.objs +3 -2
@@ -1,5 +1,5 @@ obj-y = main.o syscall.o syscall_file.o syscall_ipc.o syscall_mem.o \ - strace.o mmap.o signal.o \ + syscall_proc.o strace.o mmap.o signal.o \ elfload.o linuxload.o uaccess.o uname.o \ safe-syscall.o $(TARGET_ABI_DIR)/signal.o \ $(TARGET_ABI_DIR)/cpu_loop.o
@@ -18,6 +18,7 @@ $(SYSCALL_LIST): $(GEN_SYSCALL_LIST) linux-user/syscall.o \ linux-user/syscall_file.o \ -linux-user/syscall_mem.o \ linux-user/syscall_ipc.o \ +linux-user/syscall_mem.o \ +linux-user/syscall_proc.o \ linux-user/strace.o: $(SYSCALL_LIST)
linux-user/gen_syscall_list.py +43 -0
72 lines not on this page · raw message
linux-user/strace.list +0 -144
234 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v3 19/19] linux-user: Split out some process syscalls
Le 12/06/2018 à 02:51, Richard Henderson a écrit :
Quoted 21 lines
This includes clone, getgroups, gettid, setfsgid, setfsuid, setgroups, setsid, setuid, fork, getegid, getegid32, geteuid, geteuid32, getgid, getgid32, getgroups32, getpgrp, getpid, getppid, getresgid, getresgid32, getresuid, getresuid32, getuid, getuid32, getxgid, getxpid, getxuid, setfsgid32, setgsuid32, setgid32, setgroups32, setregid, setregid32, setresgid, setresgid32, setresuid, setresuid32, setreuid, setreuid32, setuid32, vfork.
Signed-off-by Richard Henderson <[email protected]>--- linux-user/syscall.h | 108 ++++ linux-user/strace.c | 36 +- linux-user/syscall.c | 799 ---------------------------- linux-user/syscall_proc.c | 914 +++++++++++++++++++++++++++++++++ linux-user/Makefile.objs | 5 +- linux-user/gen_syscall_list.py | 43 ++ linux-user/strace.list | 144 ------ 7 files changed, 1072 insertions(+), 977 deletions(-) create mode 100644 linux-user/syscall_proc.c
...
Quoted 4 lines
linux-user/gen_syscall_list.py +0
-0
...
Quoted 51 lines
linux-user/gen_syscall_list.py +26
-0@@ -43,12 +46,38 @@ unconditional_syscalls = [ "pwritev", "read", "readv", + "setfsgid", + "setfsuid", + "setgid", + "setgroups", + "setsid", + "setuid", "write", "writev", ] # These syscalls are only supported by some target or abis. conditional_syscalls = [ + "fork", + "getegid", + "getegid32", + "geteuid", + "geteuid32", + "getgid", + "getgid32", + "getgroups32", + "getpgrp", + "getpid", + "getppid", + "getresgid", + "getresgid32", + "getresuid", + "getresuid32", + "getuid", + "getuid32", + "getxgid", + "getxpid", + "getxuid", "ipc", "mmap", "mmap2"> @@ -60,10 +89,24 @@ conditional_syscalls = ["semctl", "semget", "semop",linux-user/gen_syscall_list.py +9
-0+ "setfsgid32", + "setfsuid32", + "setgid32", + "setgroups32", + "setregid", + "setregid32", + "setresgid", + "setresgid32", + "setresuid",
linux-user/gen_syscall_list.py conditional_syscalls = [ · line 110
Quoted 10 lines
linux-user/gen_syscall_list.py +5
-0+ "setresuid32", + "setreuid", + "setreuid32", + "setuid32", "shmat", "shmctl", "shmdt", "shmget", + "vfork", ]
At least the following syscalls are missing in the list:
get_thread_area, set_thread_area, set_tid_address, ...
Thanks,
Laurent
This series seems to have some coding style problems. See output below for more information:
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH v3 00/19] linux-user: Split do_syscall
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'41150e125a linux-user: Split out some process syscalls fb226d75f3 linux-user: Split out memory syscalls a1be98d2de linux-user: Split out ipc syscalls4ed2df106e linux-user: Split out name_to_handle_at, open_by_handle_at aa14b5dcfe linux-user: Split out pread64, pwrite64 856ddcb6c5 linux-user: Split out preadv, pwritev, readv, writev 4b6c6ec7c9 linux-user: Split out close, open, openat, read, write 796e07dce5 linux-user: Setup split syscall infrastructure 67e916d5d7 linux-user: Propagate goto fail to return 209fad0642 linux-user: Propagate goto unimplemented to default df63822df8 linux-user: Propagate goto unimplemented_nowarn to return 6211190a92 linux-user: Propagate goto efault to return daed129053 linux-user: Relax single exit from "break" 850a3c73a6 linux-user: Split out do_syscall1
1344862476 linux-user: Remove DEBUGd4c997503b linux-user/sparc64: Add inotify_rm_watch and tee syscalls 57b7c2976f linux-user/microblaze: Fix typo in accept4 syscall ca160b0d28 linux-user/hppa: Fix typo in mknodat syscall 2fd6a8234f linux-user/alpha: Fix epoll syscalls
=== OUTPUT BEGIN ===
Checking PATCH 1/19: linux-user/alpha: Fix epoll syscalls...
ERROR: code indent should never use tabs
#23: FILE: linux-user/alpha/syscall_nr.h:346:
+#define TARGET_NR_epoll_create^I^I407$
ERROR: code indent should never use tabs
#24: FILE: linux-user/alpha/syscall_nr.h:347:
+#define TARGET_NR_epoll_ctl^I^I408$
ERROR: code indent should never use tabs
#25: FILE: linux-user/alpha/syscall_nr.h:348:
+#define TARGET_NR_epoll_wait^I^I409$
total: 3 errors, 0 warnings, 27 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 2/19: linux-user/hppa: Fix typo in mknodat syscall... Checking PATCH 3/19: linux-user/microblaze: Fix typo in accept4 syscall...
ERROR: code indent should never use tabs
#23: FILE: linux-user/microblaze/syscall_nr.h:366:
+#define TARGET_NR_accept4^I^I362 /* new */$
total: 1 errors, 0 warnings, 8 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 4/19: linux-user/sparc64: Add inotify_rm_watch and tee syscalls...
WARNING: line over 80 characters
#19: FILE: linux-user/sparc64/syscall_nr.h:157:
+#define TARGET_NR_inotify_rm_watch 156 /* Linux specific */
total: 0 errors, 1 warnings, 16 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 5/19: linux-user: Remove DEBUG...
Checking PATCH 6/19: linux-user: Split out do_syscall1... Checking PATCH 7/19: linux-user: Relax single exit from "break"... Checking PATCH 8/19: linux-user: Propagate goto efault to return...
ERROR: do not use assignment in if condition
#257: FILE: linux-user/syscall.c:8465:
+ if (!(p = lock_user_string(arg2))) {
ERROR: do not use assignment in if condition
#269: FILE: linux-user/syscall.c:8483:
+ if (!(p = lock_user_string(arg1))) {
ERROR: do not use assignment in if condition
#280: FILE: linux-user/syscall.c:8492:
+ if (!(p = lock_user_string(arg2))) {
ERROR: do not use assignment in if condition
#328: FILE: linux-user/syscall.c:8631:
+ if (!(p = lock_user_string(arg1))) {
ERROR: suspect code indent for conditional statements (11, 15) #652: FILE: linux-user/syscall.c:9462:
if (!p) {+ return -TARGET_EFAULT;
ERROR: do not use assignment in if condition
#691: FILE: linux-user/syscall.c:9596:
+ if (!(p = lock_user_string(arg1))) {
ERROR: do not use assignment in if condition
#712: FILE: linux-user/syscall.c:9632:
+ if (!(p = lock_user_string(arg1))) {
ERROR: do not use assignment in if condition
#767: FILE: linux-user/syscall.c:9838:
+ if (!(p = lock_user_string(arg1))) {
ERROR: do not use assignment in if condition
#778: FILE: linux-user/syscall.c:9847:
+ if (!(p = lock_user_string(arg1))) {
ERROR: do not use assignment in if condition
#1084: FILE: linux-user/syscall.c:10938:
+ if (!(p = lock_user_string(arg1))) {
ERROR: do not use assignment in if condition
#1096: FILE: linux-user/syscall.c:10949:
+ if (!(p = lock_user_string(arg1))) {
ERROR: do not use assignment in if condition
#1108: FILE: linux-user/syscall.c:10972:
+ if (!(p = lock_user_string(arg2))) {
total: 12 errors, 0 warnings, 1228 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 9/19: linux-user: Propagate goto unimplemented_nowarn to return... Checking PATCH 10/19: linux-user: Propagate goto unimplemented to default... Checking PATCH 11/19: linux-user: Propagate goto fail to return... Checking PATCH 12/19: linux-user: Setup split syscall infrastructure...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #32:
new file mode 100644
total: 0 errors, 1 warnings, 912 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 13/19: linux-user: Split out close, open, openat, read, write...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #657:
new file mode 100644
total: 0 errors, 1 warnings, 1030 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 14/19: linux-user: Split out preadv, pwritev, readv, writev... Checking PATCH 15/19: linux-user: Split out pread64, pwrite64... Checking PATCH 16/19: linux-user: Split out name_to_handle_at, open_by_handle_at... Checking PATCH 17/19: linux-user: Split out ipc syscalls...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #1260:
new file mode 100644
WARNING: architecture specific defines should be avoided #1294: FILE: linux-user/syscall_ipc.c:30:
+#ifdef __NR_msgsnd
total: 0 errors, 2 warnings, 2305 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 18/19: linux-user: Split out memory syscalls...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #362:
new file mode 100644
total: 0 errors, 1 warnings, 500 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 19/19: linux-user: Split out some process syscalls...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #1524:
new file mode 100644
WARNING: architecture specific defines should be avoided #1564: FILE: linux-user/syscall_proc.c:36:
+#ifdef __NR_setuid32
WARNING: architecture specific defines should be avoided #1569: FILE: linux-user/syscall_proc.c:41:
+#ifdef __NR_setgid32
WARNING: architecture specific defines should be avoided #1574: FILE: linux-user/syscall_proc.c:46:
+#ifdef __NR_setresuid32
WARNING: architecture specific defines should be avoided #1579: FILE: linux-user/syscall_proc.c:51:
+#ifdef __NR_setresgid32
WARNING: architecture specific defines should be avoided #1590: FILE: linux-user/syscall_proc.c:62:
+#ifndef __NR_gettid
WARNING: architecture specific defines should be avoided #1595: FILE: linux-user/syscall_proc.c:67:
+#ifndef __NR_set_tid_address
total: 0 errors, 7 warnings, 2351 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Le 12/06/2018 à 02:51, Richard Henderson a écrit :
Quoted 2 lines
Version 3 does not attempt the whole thing in one go, and does attempt to incorporate strace into the reorg.
I've included your first four patches in my last linux-user pull-request.
Thanks,
Laurent
Quoted 4 lines · Richard Henderson
Version 3 does not attempt the whole thing in one go, and does attempt to incorporate strace into the reorg.
Thoughts?
This approach works for me. I won't bother to review the rest of the patchset for the moment, until Laurent weighs in on whether he likes the structure or not...
thanks
-- PMM