X-Git-Url: https://repo.jachan.dev/qemu.git/blobdiff_plain/fe54b24930f94bdfbc3d38eccd7adedf35f2f26f..0429a9719551a4aa794051aeb8c7b42658902c27:/linux-user/syscall.c diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a9ce6ba11c..ffc11de4b7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -107,6 +107,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #include #include #include +#include #include "linux_loop.h" #include "cpu-uname.h" @@ -1707,6 +1708,7 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr, struct iovec *vec; abi_ulong total_len, max_len; int i; + int err = 0; if (count == 0) { errno = 0; @@ -1726,7 +1728,7 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr, target_vec = lock_user(VERIFY_READ, target_addr, count * sizeof(struct target_iovec), 1); if (target_vec == NULL) { - errno = EFAULT; + err = EFAULT; goto fail2; } @@ -1740,7 +1742,7 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr, abi_long len = tswapal(target_vec[i].iov_len); if (len < 0) { - errno = EINVAL; + err = EINVAL; goto fail; } else if (len == 0) { /* Zero length pointer is ignored. */ @@ -1748,7 +1750,7 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr, } else { vec[i].iov_base = lock_user(type, base, len, copy); if (!vec[i].iov_base) { - errno = EFAULT; + err = EFAULT; goto fail; } if (len > max_len - total_len) { @@ -1763,9 +1765,10 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr, return vec; fail: - free(vec); - fail2: unlock_user(target_vec, target_addr, 0); + fail2: + free(vec); + errno = err; return NULL; } @@ -1901,23 +1904,16 @@ static abi_long do_connect(int sockfd, abi_ulong target_addr, return get_errno(connect(sockfd, addr, addrlen)); } -/* do_sendrecvmsg() Must return target values and target errnos. */ -static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg, - int flags, int send) +/* do_sendrecvmsg_locked() Must return target values and target errnos. */ +static abi_long do_sendrecvmsg_locked(int fd, struct target_msghdr *msgp, + int flags, int send) { abi_long ret, len; - struct target_msghdr *msgp; struct msghdr msg; int count; struct iovec *vec; abi_ulong target_vec; - /* FIXME */ - if (!lock_user_struct(send ? VERIFY_READ : VERIFY_WRITE, - msgp, - target_msg, - send ? 1 : 0)) - return -TARGET_EFAULT; if (msgp->msg_name) { msg.msg_namelen = tswap32(msgp->msg_namelen); msg.msg_name = alloca(msg.msg_namelen); @@ -1972,10 +1968,75 @@ static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg, out: unlock_iovec(vec, target_vec, count, !send); out2: + return ret; +} + +static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg, + int flags, int send) +{ + abi_long ret; + struct target_msghdr *msgp; + + if (!lock_user_struct(send ? VERIFY_READ : VERIFY_WRITE, + msgp, + target_msg, + send ? 1 : 0)) { + return -TARGET_EFAULT; + } + ret = do_sendrecvmsg_locked(fd, msgp, flags, send); unlock_user_struct(msgp, target_msg, send ? 0 : 1); return ret; } +#ifdef TARGET_NR_sendmmsg +/* We don't rely on the C library to have sendmmsg/recvmmsg support, + * so it might not have this *mmsg-specific flag either. + */ +#ifndef MSG_WAITFORONE +#define MSG_WAITFORONE 0x10000 +#endif + +static abi_long do_sendrecvmmsg(int fd, abi_ulong target_msgvec, + unsigned int vlen, unsigned int flags, + int send) +{ + struct target_mmsghdr *mmsgp; + abi_long ret = 0; + int i; + + if (vlen > UIO_MAXIOV) { + vlen = UIO_MAXIOV; + } + + mmsgp = lock_user(VERIFY_WRITE, target_msgvec, sizeof(*mmsgp) * vlen, 1); + if (!mmsgp) { + return -TARGET_EFAULT; + } + + for (i = 0; i < vlen; i++) { + ret = do_sendrecvmsg_locked(fd, &mmsgp[i].msg_hdr, flags, send); + if (is_error(ret)) { + break; + } + mmsgp[i].msg_len = tswap32(ret); + /* MSG_WAITFORONE turns on MSG_DONTWAIT after one packet */ + if (flags & MSG_WAITFORONE) { + flags |= MSG_DONTWAIT; + } + } + + unlock_user(mmsgp, target_msgvec, sizeof(*mmsgp) * i); + + /* Return number of datagrams sent if we sent any at all; + * otherwise return the error. + */ + if (i) { + return i; + } + return ret; +} +#endif + /* If we don't have a system accept4() then just call accept. * The callsites to do_accept4() will ensure that they don't * pass a non-zero flags argument in this config. @@ -2177,271 +2238,81 @@ fail: /* do_socketcall() Must return target values and target errnos. */ static abi_long do_socketcall(int num, abi_ulong vptr) { - abi_long ret; - const int n = sizeof(abi_ulong); - - switch(num) { - case SOCKOP_socket: - { - abi_ulong domain, type, protocol; - - if (get_user_ual(domain, vptr) - || get_user_ual(type, vptr + n) - || get_user_ual(protocol, vptr + 2 * n)) - return -TARGET_EFAULT; - - ret = do_socket(domain, type, protocol); - } - break; - case SOCKOP_bind: - { - abi_ulong sockfd; - abi_ulong target_addr; - socklen_t addrlen; - - if (get_user_ual(sockfd, vptr) - || get_user_ual(target_addr, vptr + n) - || get_user_ual(addrlen, vptr + 2 * n)) - return -TARGET_EFAULT; - - ret = do_bind(sockfd, target_addr, addrlen); - } - break; - case SOCKOP_connect: - { - abi_ulong sockfd; - abi_ulong target_addr; - socklen_t addrlen; - - if (get_user_ual(sockfd, vptr) - || get_user_ual(target_addr, vptr + n) - || get_user_ual(addrlen, vptr + 2 * n)) - return -TARGET_EFAULT; - - ret = do_connect(sockfd, target_addr, addrlen); - } - break; - case SOCKOP_listen: - { - abi_ulong sockfd, backlog; - - if (get_user_ual(sockfd, vptr) - || get_user_ual(backlog, vptr + n)) - return -TARGET_EFAULT; - - ret = get_errno(listen(sockfd, backlog)); - } - break; - case SOCKOP_accept: - { - abi_ulong sockfd; - abi_ulong target_addr, target_addrlen; - - if (get_user_ual(sockfd, vptr) - || get_user_ual(target_addr, vptr + n) - || get_user_ual(target_addrlen, vptr + 2 * n)) - return -TARGET_EFAULT; - - ret = do_accept4(sockfd, target_addr, target_addrlen, 0); - } - break; - case SOCKOP_accept4: - { - abi_ulong sockfd; - abi_ulong target_addr, target_addrlen; - abi_ulong flags; - - if (get_user_ual(sockfd, vptr) - || get_user_ual(target_addr, vptr + n) - || get_user_ual(target_addrlen, vptr + 2 * n) - || get_user_ual(flags, vptr + 3 * n)) { + static const unsigned ac[] = { /* number of arguments per call */ + [SOCKOP_socket] = 3, /* domain, type, protocol */ + [SOCKOP_bind] = 3, /* sockfd, addr, addrlen */ + [SOCKOP_connect] = 3, /* sockfd, addr, addrlen */ + [SOCKOP_listen] = 2, /* sockfd, backlog */ + [SOCKOP_accept] = 3, /* sockfd, addr, addrlen */ + [SOCKOP_accept4] = 4, /* sockfd, addr, addrlen, flags */ + [SOCKOP_getsockname] = 3, /* sockfd, addr, addrlen */ + [SOCKOP_getpeername] = 3, /* sockfd, addr, addrlen */ + [SOCKOP_socketpair] = 4, /* domain, type, protocol, tab */ + [SOCKOP_send] = 4, /* sockfd, msg, len, flags */ + [SOCKOP_recv] = 4, /* sockfd, msg, len, flags */ + [SOCKOP_sendto] = 6, /* sockfd, msg, len, flags, addr, addrlen */ + [SOCKOP_recvfrom] = 6, /* sockfd, msg, len, flags, addr, addrlen */ + [SOCKOP_shutdown] = 2, /* sockfd, how */ + [SOCKOP_sendmsg] = 3, /* sockfd, msg, flags */ + [SOCKOP_recvmsg] = 3, /* sockfd, msg, flags */ + [SOCKOP_setsockopt] = 5, /* sockfd, level, optname, optval, optlen */ + [SOCKOP_getsockopt] = 5, /* sockfd, level, optname, optval, optlen */ + }; + abi_long a[6]; /* max 6 args */ + + /* first, collect the arguments in a[] according to ac[] */ + if (num >= 0 && num < ARRAY_SIZE(ac)) { + unsigned i; + assert(ARRAY_SIZE(a) >= ac[num]); /* ensure we have space for args */ + for (i = 0; i < ac[num]; ++i) { + if (get_user_ual(a[i], vptr + i * sizeof(abi_long)) != 0) { return -TARGET_EFAULT; } - - ret = do_accept4(sockfd, target_addr, target_addrlen, flags); - } - break; - case SOCKOP_getsockname: - { - abi_ulong sockfd; - abi_ulong target_addr, target_addrlen; - - if (get_user_ual(sockfd, vptr) - || get_user_ual(target_addr, vptr + n) - || get_user_ual(target_addrlen, vptr + 2 * n)) - return -TARGET_EFAULT; - - ret = do_getsockname(sockfd, target_addr, target_addrlen); - } - break; - case SOCKOP_getpeername: - { - abi_ulong sockfd; - abi_ulong target_addr, target_addrlen; - - if (get_user_ual(sockfd, vptr) - || get_user_ual(target_addr, vptr + n) - || get_user_ual(target_addrlen, vptr + 2 * n)) - return -TARGET_EFAULT; - - ret = do_getpeername(sockfd, target_addr, target_addrlen); - } - break; - case SOCKOP_socketpair: - { - abi_ulong domain, type, protocol; - abi_ulong tab; - - if (get_user_ual(domain, vptr) - || get_user_ual(type, vptr + n) - || get_user_ual(protocol, vptr + 2 * n) - || get_user_ual(tab, vptr + 3 * n)) - return -TARGET_EFAULT; - - ret = do_socketpair(domain, type, protocol, tab); - } - break; - case SOCKOP_send: - { - abi_ulong sockfd; - abi_ulong msg; - size_t len; - abi_ulong flags; - - if (get_user_ual(sockfd, vptr) - || get_user_ual(msg, vptr + n) - || get_user_ual(len, vptr + 2 * n) - || get_user_ual(flags, vptr + 3 * n)) - return -TARGET_EFAULT; - - ret = do_sendto(sockfd, msg, len, flags, 0, 0); - } - break; - case SOCKOP_recv: - { - abi_ulong sockfd; - abi_ulong msg; - size_t len; - abi_ulong flags; - - if (get_user_ual(sockfd, vptr) - || get_user_ual(msg, vptr + n) - || get_user_ual(len, vptr + 2 * n) - || get_user_ual(flags, vptr + 3 * n)) - return -TARGET_EFAULT; - - ret = do_recvfrom(sockfd, msg, len, flags, 0, 0); - } - break; - case SOCKOP_sendto: - { - abi_ulong sockfd; - abi_ulong msg; - size_t len; - abi_ulong flags; - abi_ulong addr; - socklen_t addrlen; - - if (get_user_ual(sockfd, vptr) - || get_user_ual(msg, vptr + n) - || get_user_ual(len, vptr + 2 * n) - || get_user_ual(flags, vptr + 3 * n) - || get_user_ual(addr, vptr + 4 * n) - || get_user_ual(addrlen, vptr + 5 * n)) - return -TARGET_EFAULT; - - ret = do_sendto(sockfd, msg, len, flags, addr, addrlen); - } - break; - case SOCKOP_recvfrom: - { - abi_ulong sockfd; - abi_ulong msg; - size_t len; - abi_ulong flags; - abi_ulong addr; - socklen_t addrlen; - - if (get_user_ual(sockfd, vptr) - || get_user_ual(msg, vptr + n) - || get_user_ual(len, vptr + 2 * n) - || get_user_ual(flags, vptr + 3 * n) - || get_user_ual(addr, vptr + 4 * n) - || get_user_ual(addrlen, vptr + 5 * n)) - return -TARGET_EFAULT; - - ret = do_recvfrom(sockfd, msg, len, flags, addr, addrlen); - } - break; - case SOCKOP_shutdown: - { - abi_ulong sockfd, how; - - if (get_user_ual(sockfd, vptr) - || get_user_ual(how, vptr + n)) - return -TARGET_EFAULT; - - ret = get_errno(shutdown(sockfd, how)); - } - break; - case SOCKOP_sendmsg: - case SOCKOP_recvmsg: - { - abi_ulong fd; - abi_ulong target_msg; - abi_ulong flags; - - if (get_user_ual(fd, vptr) - || get_user_ual(target_msg, vptr + n) - || get_user_ual(flags, vptr + 2 * n)) - return -TARGET_EFAULT; - - ret = do_sendrecvmsg(fd, target_msg, flags, - (num == SOCKOP_sendmsg)); } - break; - case SOCKOP_setsockopt: - { - abi_ulong sockfd; - abi_ulong level; - abi_ulong optname; - abi_ulong optval; - abi_ulong optlen; - - if (get_user_ual(sockfd, vptr) - || get_user_ual(level, vptr + n) - || get_user_ual(optname, vptr + 2 * n) - || get_user_ual(optval, vptr + 3 * n) - || get_user_ual(optlen, vptr + 4 * n)) - return -TARGET_EFAULT; - - ret = do_setsockopt(sockfd, level, optname, optval, optlen); - } - break; - case SOCKOP_getsockopt: - { - abi_ulong sockfd; - abi_ulong level; - abi_ulong optname; - abi_ulong optval; - socklen_t optlen; - - if (get_user_ual(sockfd, vptr) - || get_user_ual(level, vptr + n) - || get_user_ual(optname, vptr + 2 * n) - || get_user_ual(optval, vptr + 3 * n) - || get_user_ual(optlen, vptr + 4 * n)) - return -TARGET_EFAULT; + } - ret = do_getsockopt(sockfd, level, optname, optval, optlen); - } - break; + /* now when we have the args, actually handle the call */ + switch (num) { + case SOCKOP_socket: /* domain, type, protocol */ + return do_socket(a[0], a[1], a[2]); + case SOCKOP_bind: /* sockfd, addr, addrlen */ + return do_bind(a[0], a[1], a[2]); + case SOCKOP_connect: /* sockfd, addr, addrlen */ + return do_connect(a[0], a[1], a[2]); + case SOCKOP_listen: /* sockfd, backlog */ + return get_errno(listen(a[0], a[1])); + case SOCKOP_accept: /* sockfd, addr, addrlen */ + return do_accept4(a[0], a[1], a[2], 0); + case SOCKOP_accept4: /* sockfd, addr, addrlen, flags */ + return do_accept4(a[0], a[1], a[2], a[3]); + case SOCKOP_getsockname: /* sockfd, addr, addrlen */ + return do_getsockname(a[0], a[1], a[2]); + case SOCKOP_getpeername: /* sockfd, addr, addrlen */ + return do_getpeername(a[0], a[1], a[2]); + case SOCKOP_socketpair: /* domain, type, protocol, tab */ + return do_socketpair(a[0], a[1], a[2], a[3]); + case SOCKOP_send: /* sockfd, msg, len, flags */ + return do_sendto(a[0], a[1], a[2], a[3], 0, 0); + case SOCKOP_recv: /* sockfd, msg, len, flags */ + return do_recvfrom(a[0], a[1], a[2], a[3], 0, 0); + case SOCKOP_sendto: /* sockfd, msg, len, flags, addr, addrlen */ + return do_sendto(a[0], a[1], a[2], a[3], a[4], a[5]); + case SOCKOP_recvfrom: /* sockfd, msg, len, flags, addr, addrlen */ + return do_recvfrom(a[0], a[1], a[2], a[3], a[4], a[5]); + case SOCKOP_shutdown: /* sockfd, how */ + return get_errno(shutdown(a[0], a[1])); + case SOCKOP_sendmsg: /* sockfd, msg, flags */ + return do_sendrecvmsg(a[0], a[1], a[2], 1); + case SOCKOP_recvmsg: /* sockfd, msg, flags */ + return do_sendrecvmsg(a[0], a[1], a[2], 0); + case SOCKOP_setsockopt: /* sockfd, level, optname, optval, optlen */ + return do_setsockopt(a[0], a[1], a[2], a[3], a[4]); + case SOCKOP_getsockopt: /* sockfd, level, optname, optval, optlen */ + return do_getsockopt(a[0], a[1], a[2], a[3], a[4]); default: gemu_log("Unsupported socketcall: %d\n", num); - ret = -TARGET_ENOSYS; - break; + return -TARGET_ENOSYS; } - return ret; } #endif @@ -2617,10 +2488,15 @@ static inline abi_long target_to_host_semarray(int semid, unsigned short **host_ nsems = semid_ds.sem_nsems; *host_array = malloc(nsems*sizeof(unsigned short)); + if (!*host_array) { + return -TARGET_ENOMEM; + } array = lock_user(VERIFY_READ, target_addr, nsems*sizeof(unsigned short), 1); - if (!array) + if (!array) { + free(*host_array); return -TARGET_EFAULT; + } for(i=0; ienv; cpu = ENV_GET_CPU(env); thread_cpu = cpu; - ts = (TaskState *)env->opaque; + ts = (TaskState *)cpu->opaque; info->tid = gettid(); cpu->host_tid = info->tid; task_settid(ts); @@ -4395,8 +4271,10 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, abi_ulong parent_tidptr, target_ulong newtls, abi_ulong child_tidptr) { + CPUState *cpu = ENV_GET_CPU(env); int ret; TaskState *ts; + CPUState *new_cpu; CPUArchState *new_env; unsigned int nptl_flags; sigset_t sigmask; @@ -4406,7 +4284,7 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, flags &= ~(CLONE_VFORK | CLONE_VM); if (flags & CLONE_VM) { - TaskState *parent_ts = (TaskState *)env->opaque; + TaskState *parent_ts = (TaskState *)cpu->opaque; new_thread_info info; pthread_attr_t attr; @@ -4416,7 +4294,8 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, new_env = cpu_copy(env); /* Init regs that differ from the parent. */ cpu_clone_regs(new_env, newsp); - new_env->opaque = ts; + new_cpu = ENV_GET_CPU(new_env); + new_cpu->opaque = ts; ts->bprm = parent_ts->bprm; ts->info = parent_ts->info; nptl_flags = flags; @@ -4488,7 +4367,7 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, put_user_u32(gettid(), child_tidptr); if (flags & CLONE_PARENT_SETTID) put_user_u32(gettid(), parent_tidptr); - ts = (TaskState *)env->opaque; + ts = (TaskState *)cpu->opaque; if (flags & CLONE_SETTLS) cpu_set_tls (env, newtls); if (flags & CLONE_CHILD_CLEARTID) @@ -4710,6 +4589,9 @@ 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) { @@ -4731,6 +4613,9 @@ static inline int tswapid(int id) { return tswap32(id); } + +#define put_user_id(x, gaddr) put_user_u32(x, gaddr) + #endif /* USE_UID16 */ void syscall_init(void) @@ -5092,7 +4977,8 @@ void init_qemu_uname_release(void) static int open_self_maps(void *cpu_env, int fd) { #if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32) - TaskState *ts = ((CPUArchState *)cpu_env)->opaque; + CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env); + TaskState *ts = cpu->opaque; #endif FILE *fp; char *line = NULL; @@ -5144,7 +5030,8 @@ static int open_self_maps(void *cpu_env, int fd) static int open_self_stat(void *cpu_env, int fd) { - TaskState *ts = ((CPUArchState *)cpu_env)->opaque; + CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env); + TaskState *ts = cpu->opaque; abi_ulong start_stack = ts->info->start_stack; int i; @@ -5180,7 +5067,8 @@ static int open_self_stat(void *cpu_env, int fd) static int open_self_auxv(void *cpu_env, int fd) { - TaskState *ts = ((CPUArchState *)cpu_env)->opaque; + CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env); + TaskState *ts = cpu->opaque; abi_ulong auxv = ts->info->saved_auxv; abi_ulong len = ts->info->auxv_len; char *ptr; @@ -5362,14 +5250,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, /* Remove the CPU from the list. */ QTAILQ_REMOVE(&cpus, cpu, node); cpu_list_unlock(); - ts = ((CPUArchState *)cpu_env)->opaque; + ts = cpu->opaque; if (ts->child_tidptr) { put_user_u32(0, ts->child_tidptr); sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX, NULL, NULL, 0); } thread_cpu = NULL; - object_unref(OBJECT(ENV_GET_CPU(cpu_env))); + object_unref(OBJECT(cpu)); g_free(ts); pthread_exit(NULL); } @@ -6303,11 +6191,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, puts = NULL; } ret = get_errno(sigtimedwait(&set, &uinfo, puts)); - if (!is_error(ret) && arg2) { - if (!(p = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), 0))) - goto efault; - host_to_target_siginfo(p, &uinfo); - unlock_user(p, arg2, sizeof(target_siginfo_t)); + if (!is_error(ret)) { + if (arg2) { + p = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), + 0); + if (!p) { + goto efault; + } + host_to_target_siginfo(p, &uinfo); + unlock_user(p, arg2, sizeof(target_siginfo_t)); + } + ret = host_to_target_signal(ret); } } break; @@ -6667,7 +6561,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; case TARGET_NR_mprotect: { - TaskState *ts = ((CPUArchState *)cpu_env)->opaque; + TaskState *ts = cpu->opaque; /* Special hack to detect libc making the stack executable. */ if ((arg3 & PROT_GROWSDOWN) && arg1 >= ts->info->stack_limit @@ -6892,6 +6786,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = do_sendrecvmsg(arg1, arg2, arg3, 1); break; #endif +#ifdef TARGET_NR_sendmmsg + case TARGET_NR_sendmmsg: + ret = do_sendrecvmmsg(arg1, arg2, arg3, arg4, 1); + break; + case TARGET_NR_recvmmsg: + ret = do_sendrecvmmsg(arg1, arg2, arg3, arg4, 0); + break; +#endif #ifdef TARGET_NR_sendto case TARGET_NR_sendto: ret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6); @@ -7987,9 +7889,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, uid_t ruid, euid, suid; ret = get_errno(getresuid(&ruid, &euid, &suid)); if (!is_error(ret)) { - if (put_user_u16(high2lowuid(ruid), arg1) - || put_user_u16(high2lowuid(euid), arg2) - || put_user_u16(high2lowuid(suid), arg3)) + if (put_user_id(high2lowuid(ruid), arg1) + || put_user_id(high2lowuid(euid), arg2) + || put_user_id(high2lowuid(suid), arg3)) goto efault; } } @@ -8008,9 +7910,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, gid_t rgid, egid, sgid; ret = get_errno(getresgid(&rgid, &egid, &sgid)); if (!is_error(ret)) { - if (put_user_u16(high2lowgid(rgid), arg1) - || put_user_u16(high2lowgid(egid), arg2) - || put_user_u16(high2lowgid(sgid), arg3)) + if (put_user_id(high2lowgid(rgid), arg1) + || put_user_id(high2lowgid(egid), arg2) + || put_user_id(high2lowgid(sgid), arg3)) goto efault; } } @@ -8751,7 +8653,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; #elif defined(TARGET_M68K) { - TaskState *ts = ((CPUArchState *)cpu_env)->opaque; + TaskState *ts = cpu->opaque; ts->tp_value = arg1; ret = 0; break; @@ -8767,7 +8669,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; #elif defined(TARGET_M68K) { - TaskState *ts = ((CPUArchState *)cpu_env)->opaque; + TaskState *ts = cpu->opaque; ret = ts->tp_value; break; }