From 26b746db49ab0dcaaf5a700d0fc055e5188dcc70 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 9 Sep 2011 19:31:17 +0200 Subject: linux-user: fix TARGET_RLIM_INFINITY declaration Signed-off-by: Matthias Braun Signed-off-by: Riku Voipio --- linux-user/syscall_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 15c44d45a8..1bc54c7480 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -690,7 +690,7 @@ struct target_rlimit { #elif defined(TARGET_MIPS) || defined(TARGET_SPARC) #define TARGET_RLIM_INFINITY 0x7fffffffUL #else -#define TARGET_RLIM_INFINITY ((target_ulong)~0UL) +#define TARGET_RLIM_INFINITY ((abi_ulong)-1) #endif #if defined(TARGET_MIPS) -- cgit v1.2.1 From 6cafd027be3a6cad710d99bde4a2b3b662869e5d Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 9 Sep 2011 19:30:25 +0200 Subject: linux-user: fix rlimit syscalls on sparc(64) Signed-off-by: Matthias Braun Signed-off-by: Riku Voipio --- linux-user/syscall_defs.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 1bc54c7480..5fd4c9ce45 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -687,7 +687,7 @@ struct target_rlimit { #if defined(TARGET_ALPHA) #define TARGET_RLIM_INFINITY 0x7fffffffffffffffull -#elif defined(TARGET_MIPS) || defined(TARGET_SPARC) +#elif defined(TARGET_MIPS) || (defined(TARGET_SPARC) && TARGET_ABI_BITS == 32) #define TARGET_RLIM_INFINITY 0x7fffffffUL #else #define TARGET_RLIM_INFINITY ((abi_ulong)-1) @@ -716,8 +716,13 @@ struct target_rlimit { #define TARGET_RLIMIT_STACK 3 #define TARGET_RLIMIT_CORE 4 #define TARGET_RLIMIT_RSS 5 +#if defined(TARGET_SPARC) +#define TARGET_RLIMIT_NOFILE 6 +#define TARGET_RLIMIT_NPROC 7 +#else #define TARGET_RLIMIT_NPROC 6 #define TARGET_RLIMIT_NOFILE 7 +#endif #define TARGET_RLIMIT_MEMLOCK 8 #define TARGET_RLIMIT_AS 9 #define TARGET_RLIMIT_LOCKS 10 -- cgit v1.2.1 From cbb21eed186647716b9e8404a9e90d3fc5c6c467 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 12 Aug 2011 19:57:41 +0200 Subject: linux-user: fix abi_(u)long, target_ulong mismatch abi_(u)long might be different from target_ulong, so don't use tswapl but introduce a new tswapal Signed-off-by: Matthias Braun Signed-off-by: Riku Voipio --- linux-user/qemu-types.h | 12 +++ linux-user/signal.c | 22 ++-- linux-user/strace.c | 4 +- linux-user/syscall.c | 250 +++++++++++++++++++++++----------------------- linux-user/syscall_defs.h | 8 +- linux-user/vm86.c | 4 +- 6 files changed, 157 insertions(+), 143 deletions(-) diff --git a/linux-user/qemu-types.h b/linux-user/qemu-types.h index 1adda9fbdb..fe7f6624f9 100644 --- a/linux-user/qemu-types.h +++ b/linux-user/qemu-types.h @@ -9,6 +9,12 @@ typedef int32_t abi_long; #define TARGET_ABI_FMT_ld "%d" #define TARGET_ABI_FMT_lu "%u" #define TARGET_ABI_BITS 32 + +static inline abi_ulong tswapal(abi_ulong v) +{ + return tswap32(v); +} + #else typedef target_ulong abi_ulong; typedef target_long abi_long; @@ -20,5 +26,11 @@ typedef target_long abi_long; #if TARGET_ABI_BITS == 32 #define TARGET_ABI32 1 #endif + +static inline abi_ulong tswapal(abi_ulong v) +{ + return tswapl(v); +} + #endif #endif diff --git a/linux-user/signal.c b/linux-user/signal.c index 40c5eb1846..e4addcdd53 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -152,7 +152,7 @@ void host_to_target_sigset(target_sigset_t *d, const sigset_t *s) host_to_target_sigset_internal(&d1, s); for(i = 0;i < TARGET_NSIG_WORDS; i++) - d->sig[i] = tswapl(d1.sig[i]); + d->sig[i] = tswapal(d1.sig[i]); } static void target_to_host_sigset_internal(sigset_t *d, @@ -173,7 +173,7 @@ void target_to_host_sigset(sigset_t *d, const target_sigset_t *s) int i; for(i = 0;i < TARGET_NSIG_WORDS; i++) - s1.sig[i] = tswapl(s->sig[i]); + s1.sig[i] = tswapal(s->sig[i]); target_to_host_sigset_internal(d, &s1); } @@ -234,14 +234,14 @@ static void tswap_siginfo(target_siginfo_t *tinfo, if (sig == SIGILL || sig == SIGFPE || sig == SIGSEGV || sig == SIGBUS || sig == SIGTRAP) { tinfo->_sifields._sigfault._addr = - tswapl(info->_sifields._sigfault._addr); + tswapal(info->_sifields._sigfault._addr); } else if (sig == SIGIO) { tinfo->_sifields._sigpoll._fd = tswap32(info->_sifields._sigpoll._fd); } else if (sig >= TARGET_SIGRTMIN) { tinfo->_sifields._rt._pid = tswap32(info->_sifields._rt._pid); tinfo->_sifields._rt._uid = tswap32(info->_sifields._rt._uid); tinfo->_sifields._rt._sigval.sival_ptr = - tswapl(info->_sifields._rt._sigval.sival_ptr); + tswapal(info->_sifields._rt._sigval.sival_ptr); } } @@ -262,7 +262,7 @@ void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo) info->si_pid = tswap32(tinfo->_sifields._rt._pid); info->si_uid = tswap32(tinfo->_sifields._rt._uid); info->si_value.sival_ptr = - (void *)(long)tswapl(tinfo->_sifields._rt._sigval.sival_ptr); + (void *)(long)tswapal(tinfo->_sifields._rt._sigval.sival_ptr); } static int fatal_signal (int sig) @@ -586,19 +586,19 @@ int do_sigaction(int sig, const struct target_sigaction *act, sig, act, oact); #endif if (oact) { - oact->_sa_handler = tswapl(k->_sa_handler); - oact->sa_flags = tswapl(k->sa_flags); + oact->_sa_handler = tswapal(k->_sa_handler); + oact->sa_flags = tswapal(k->sa_flags); #if !defined(TARGET_MIPS) - oact->sa_restorer = tswapl(k->sa_restorer); + oact->sa_restorer = tswapal(k->sa_restorer); #endif oact->sa_mask = k->sa_mask; } if (act) { /* FIXME: This is not threadsafe. */ - k->_sa_handler = tswapl(act->_sa_handler); - k->sa_flags = tswapl(act->sa_flags); + k->_sa_handler = tswapal(act->_sa_handler); + k->sa_flags = tswapal(act->sa_flags); #if !defined(TARGET_MIPS) - k->sa_restorer = tswapl(act->sa_restorer); + k->sa_restorer = tswapal(act->sa_restorer); #endif k->sa_mask = act->sa_mask; diff --git a/linux-user/strace.c b/linux-user/strace.c index fe9326aa73..90027a1106 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -169,7 +169,7 @@ print_fdset(int n, abi_ulong target_fds_addr) return; for (i=n; i>=0; i--) { - if ((tswapl(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_ABI_BITS - 1))) & 1) + if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_ABI_BITS - 1))) & 1) gemu_log("%d,", i ); } unlock_user(target_fds, target_fds_addr, 0); @@ -245,7 +245,7 @@ print_execve(const struct syscallname *name, arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1); if (!arg_ptr) return; - arg_addr = tswapl(*arg_ptr); + arg_addr = tswapal(*arg_ptr); unlock_user(arg_ptr, arg_ptr_addr, 0); if (!arg_addr) break; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7735008d6a..9a633571a7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -931,53 +931,55 @@ static inline abi_long host_to_target_rusage(abi_ulong target_addr, if (!lock_user_struct(VERIFY_WRITE, target_rusage, target_addr, 0)) return -TARGET_EFAULT; - target_rusage->ru_utime.tv_sec = tswapl(rusage->ru_utime.tv_sec); - target_rusage->ru_utime.tv_usec = tswapl(rusage->ru_utime.tv_usec); - target_rusage->ru_stime.tv_sec = tswapl(rusage->ru_stime.tv_sec); - target_rusage->ru_stime.tv_usec = tswapl(rusage->ru_stime.tv_usec); - target_rusage->ru_maxrss = tswapl(rusage->ru_maxrss); - target_rusage->ru_ixrss = tswapl(rusage->ru_ixrss); - target_rusage->ru_idrss = tswapl(rusage->ru_idrss); - target_rusage->ru_isrss = tswapl(rusage->ru_isrss); - target_rusage->ru_minflt = tswapl(rusage->ru_minflt); - target_rusage->ru_majflt = tswapl(rusage->ru_majflt); - target_rusage->ru_nswap = tswapl(rusage->ru_nswap); - target_rusage->ru_inblock = tswapl(rusage->ru_inblock); - target_rusage->ru_oublock = tswapl(rusage->ru_oublock); - target_rusage->ru_msgsnd = tswapl(rusage->ru_msgsnd); - target_rusage->ru_msgrcv = tswapl(rusage->ru_msgrcv); - target_rusage->ru_nsignals = tswapl(rusage->ru_nsignals); - target_rusage->ru_nvcsw = tswapl(rusage->ru_nvcsw); - target_rusage->ru_nivcsw = tswapl(rusage->ru_nivcsw); + target_rusage->ru_utime.tv_sec = tswapal(rusage->ru_utime.tv_sec); + target_rusage->ru_utime.tv_usec = tswapal(rusage->ru_utime.tv_usec); + target_rusage->ru_stime.tv_sec = tswapal(rusage->ru_stime.tv_sec); + target_rusage->ru_stime.tv_usec = tswapal(rusage->ru_stime.tv_usec); + target_rusage->ru_maxrss = tswapal(rusage->ru_maxrss); + target_rusage->ru_ixrss = tswapal(rusage->ru_ixrss); + target_rusage->ru_idrss = tswapal(rusage->ru_idrss); + target_rusage->ru_isrss = tswapal(rusage->ru_isrss); + target_rusage->ru_minflt = tswapal(rusage->ru_minflt); + target_rusage->ru_majflt = tswapal(rusage->ru_majflt); + target_rusage->ru_nswap = tswapal(rusage->ru_nswap); + target_rusage->ru_inblock = tswapal(rusage->ru_inblock); + target_rusage->ru_oublock = tswapal(rusage->ru_oublock); + target_rusage->ru_msgsnd = tswapal(rusage->ru_msgsnd); + target_rusage->ru_msgrcv = tswapal(rusage->ru_msgrcv); + target_rusage->ru_nsignals = tswapal(rusage->ru_nsignals); + target_rusage->ru_nvcsw = tswapal(rusage->ru_nvcsw); + target_rusage->ru_nivcsw = tswapal(rusage->ru_nivcsw); unlock_user_struct(target_rusage, target_addr, 1); return 0; } -static inline rlim_t target_to_host_rlim(target_ulong target_rlim) +static inline rlim_t target_to_host_rlim(abi_ulong target_rlim) { - target_ulong target_rlim_swap; + abi_ulong target_rlim_swap; rlim_t result; - target_rlim_swap = tswapl(target_rlim); - if (target_rlim_swap == TARGET_RLIM_INFINITY || target_rlim_swap != (rlim_t)target_rlim_swap) - result = RLIM_INFINITY; - else - result = target_rlim_swap; + target_rlim_swap = tswapal(target_rlim); + if (target_rlim_swap == TARGET_RLIM_INFINITY) + return RLIM_INFINITY; + + result = target_rlim_swap; + if (target_rlim_swap != (rlim_t)result) + return RLIM_INFINITY; return result; } -static inline target_ulong host_to_target_rlim(rlim_t rlim) +static inline abi_ulong host_to_target_rlim(rlim_t rlim) { - target_ulong target_rlim_swap; - target_ulong result; + abi_ulong target_rlim_swap; + abi_ulong result; - if (rlim == RLIM_INFINITY || rlim != (target_long)rlim) + if (rlim == RLIM_INFINITY || rlim != (abi_long)rlim) target_rlim_swap = TARGET_RLIM_INFINITY; else target_rlim_swap = rlim; - result = tswapl(target_rlim_swap); + result = tswapal(target_rlim_swap); return result; } @@ -1196,7 +1198,7 @@ static inline abi_long target_to_host_ip_mreq(struct ip_mreqn *mreqn, mreqn->imr_multiaddr.s_addr = target_smreqn->imr_multiaddr.s_addr; mreqn->imr_address.s_addr = target_smreqn->imr_address.s_addr; if (len == sizeof(struct target_ip_mreqn)) - mreqn->imr_ifindex = tswapl(target_smreqn->imr_ifindex); + mreqn->imr_ifindex = tswapal(target_smreqn->imr_ifindex); unlock_user(target_smreqn, target_addr, 0); return 0; @@ -1268,10 +1270,10 @@ static inline abi_long target_to_host_cmsg(struct msghdr *msgh, struct target_cmsghdr *target_cmsg; socklen_t space = 0; - msg_controllen = tswapl(target_msgh->msg_controllen); + msg_controllen = tswapal(target_msgh->msg_controllen); if (msg_controllen < sizeof (struct target_cmsghdr)) goto the_end; - target_cmsg_addr = tswapl(target_msgh->msg_control); + target_cmsg_addr = tswapal(target_msgh->msg_control); target_cmsg = lock_user(VERIFY_READ, target_cmsg_addr, msg_controllen, 1); if (!target_cmsg) return -TARGET_EFAULT; @@ -1280,7 +1282,7 @@ static inline abi_long target_to_host_cmsg(struct msghdr *msgh, void *data = CMSG_DATA(cmsg); void *target_data = TARGET_CMSG_DATA(target_cmsg); - int len = tswapl(target_cmsg->cmsg_len) + int len = tswapal(target_cmsg->cmsg_len) - TARGET_CMSG_ALIGN(sizeof (struct target_cmsghdr)); space += CMSG_SPACE(len); @@ -1325,10 +1327,10 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh, struct target_cmsghdr *target_cmsg; socklen_t space = 0; - msg_controllen = tswapl(target_msgh->msg_controllen); + msg_controllen = tswapal(target_msgh->msg_controllen); if (msg_controllen < sizeof (struct target_cmsghdr)) goto the_end; - target_cmsg_addr = tswapl(target_msgh->msg_control); + target_cmsg_addr = tswapal(target_msgh->msg_control); target_cmsg = lock_user(VERIFY_WRITE, target_cmsg_addr, msg_controllen, 0); if (!target_cmsg) return -TARGET_EFAULT; @@ -1348,7 +1350,7 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh, target_cmsg->cmsg_level = tswap32(cmsg->cmsg_level); target_cmsg->cmsg_type = tswap32(cmsg->cmsg_type); - target_cmsg->cmsg_len = tswapl(TARGET_CMSG_LEN(len)); + target_cmsg->cmsg_len = tswapal(TARGET_CMSG_LEN(len)); if (cmsg->cmsg_level != TARGET_SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) { gemu_log("Unsupported ancillary data: %d/%d\n", cmsg->cmsg_level, cmsg->cmsg_type); @@ -1367,7 +1369,7 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh, } unlock_user(target_cmsg, target_cmsg_addr, space); the_end: - target_msgh->msg_controllen = tswapl(space); + target_msgh->msg_controllen = tswapal(space); return 0; } @@ -1687,8 +1689,8 @@ static abi_long lock_iovec(int type, struct iovec *vec, abi_ulong target_addr, if (!target_vec) return -TARGET_EFAULT; for(i = 0;i < count; i++) { - base = tswapl(target_vec[i].iov_base); - vec[i].iov_len = tswapl(target_vec[i].iov_len); + base = tswapal(target_vec[i].iov_base); + vec[i].iov_len = tswapal(target_vec[i].iov_len); if (vec[i].iov_len != 0) { vec[i].iov_base = lock_user(type, base, vec[i].iov_len, copy); /* Don't check lock_user return value. We must call writev even @@ -1714,7 +1716,7 @@ static abi_long unlock_iovec(struct iovec *vec, abi_ulong target_addr, return -TARGET_EFAULT; for(i = 0;i < count; i++) { if (target_vec[i].iov_base) { - base = tswapl(target_vec[i].iov_base); + base = tswapal(target_vec[i].iov_base); unlock_user(vec[i].iov_base, base, copy ? vec[i].iov_len : 0); } } @@ -1813,7 +1815,7 @@ static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg, if (msgp->msg_name) { msg.msg_namelen = tswap32(msgp->msg_namelen); msg.msg_name = alloca(msg.msg_namelen); - ret = target_to_host_sockaddr(msg.msg_name, tswapl(msgp->msg_name), + ret = target_to_host_sockaddr(msg.msg_name, tswapal(msgp->msg_name), msg.msg_namelen); if (ret) { unlock_user_struct(msgp, target_msg, send ? 0 : 1); @@ -1823,13 +1825,13 @@ static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg, msg.msg_name = NULL; msg.msg_namelen = 0; } - msg.msg_controllen = 2 * tswapl(msgp->msg_controllen); + msg.msg_controllen = 2 * tswapal(msgp->msg_controllen); msg.msg_control = alloca(msg.msg_controllen); msg.msg_flags = tswap32(msgp->msg_flags); - count = tswapl(msgp->msg_iovlen); + count = tswapal(msgp->msg_iovlen); vec = alloca(count * sizeof(struct iovec)); - target_vec = tswapl(msgp->msg_iov); + target_vec = tswapal(msgp->msg_iov); lock_iovec(send ? VERIFY_READ : VERIFY_WRITE, vec, target_vec, count, send); msg.msg_iovlen = count; msg.msg_iov = vec; @@ -2332,12 +2334,12 @@ static inline abi_long target_to_host_ipc_perm(struct ipc_perm *host_ip, if (!lock_user_struct(VERIFY_READ, target_sd, target_addr, 1)) return -TARGET_EFAULT; target_ip = &(target_sd->sem_perm); - host_ip->__key = tswapl(target_ip->__key); - host_ip->uid = tswapl(target_ip->uid); - host_ip->gid = tswapl(target_ip->gid); - host_ip->cuid = tswapl(target_ip->cuid); - host_ip->cgid = tswapl(target_ip->cgid); - host_ip->mode = tswapl(target_ip->mode); + host_ip->__key = tswapal(target_ip->__key); + host_ip->uid = tswapal(target_ip->uid); + host_ip->gid = tswapal(target_ip->gid); + host_ip->cuid = tswapal(target_ip->cuid); + host_ip->cgid = tswapal(target_ip->cgid); + host_ip->mode = tswap16(target_ip->mode); unlock_user_struct(target_sd, target_addr, 0); return 0; } @@ -2351,12 +2353,12 @@ static inline abi_long host_to_target_ipc_perm(abi_ulong target_addr, if (!lock_user_struct(VERIFY_WRITE, target_sd, target_addr, 0)) return -TARGET_EFAULT; target_ip = &(target_sd->sem_perm); - target_ip->__key = tswapl(host_ip->__key); - target_ip->uid = tswapl(host_ip->uid); - target_ip->gid = tswapl(host_ip->gid); - target_ip->cuid = tswapl(host_ip->cuid); - target_ip->cgid = tswapl(host_ip->cgid); - target_ip->mode = tswapl(host_ip->mode); + target_ip->__key = tswapal(host_ip->__key); + target_ip->uid = tswapal(host_ip->uid); + target_ip->gid = tswapal(host_ip->gid); + target_ip->cuid = tswapal(host_ip->cuid); + target_ip->cgid = tswapal(host_ip->cgid); + target_ip->mode = tswap16(host_ip->mode); unlock_user_struct(target_sd, target_addr, 1); return 0; } @@ -2370,9 +2372,9 @@ static inline abi_long target_to_host_semid_ds(struct semid_ds *host_sd, return -TARGET_EFAULT; if (target_to_host_ipc_perm(&(host_sd->sem_perm),target_addr)) return -TARGET_EFAULT; - host_sd->sem_nsems = tswapl(target_sd->sem_nsems); - host_sd->sem_otime = tswapl(target_sd->sem_otime); - host_sd->sem_ctime = tswapl(target_sd->sem_ctime); + host_sd->sem_nsems = tswapal(target_sd->sem_nsems); + host_sd->sem_otime = tswapal(target_sd->sem_otime); + host_sd->sem_ctime = tswapal(target_sd->sem_ctime); unlock_user_struct(target_sd, target_addr, 0); return 0; } @@ -2386,9 +2388,9 @@ static inline abi_long host_to_target_semid_ds(abi_ulong target_addr, return -TARGET_EFAULT; if (host_to_target_ipc_perm(target_addr,&(host_sd->sem_perm))) return -TARGET_EFAULT;; - target_sd->sem_nsems = tswapl(host_sd->sem_nsems); - target_sd->sem_otime = tswapl(host_sd->sem_otime); - target_sd->sem_ctime = tswapl(host_sd->sem_ctime); + target_sd->sem_nsems = tswapal(host_sd->sem_nsems); + target_sd->sem_otime = tswapal(host_sd->sem_otime); + target_sd->sem_ctime = tswapal(host_sd->sem_ctime); unlock_user_struct(target_sd, target_addr, 1); return 0; } @@ -2516,9 +2518,9 @@ static inline abi_long do_semctl(int semid, int semnum, int cmd, switch( cmd ) { case GETVAL: case SETVAL: - arg.val = tswapl(target_su.val); + arg.val = tswap32(target_su.val); ret = get_errno(semctl(semid, semnum, cmd, arg)); - target_su.val = tswapl(arg.val); + target_su.val = tswap32(arg.val); break; case GETALL: case SETALL: @@ -2634,14 +2636,14 @@ static inline abi_long target_to_host_msqid_ds(struct msqid_ds *host_md, return -TARGET_EFAULT; if (target_to_host_ipc_perm(&(host_md->msg_perm),target_addr)) return -TARGET_EFAULT; - host_md->msg_stime = tswapl(target_md->msg_stime); - host_md->msg_rtime = tswapl(target_md->msg_rtime); - host_md->msg_ctime = tswapl(target_md->msg_ctime); - host_md->__msg_cbytes = tswapl(target_md->__msg_cbytes); - host_md->msg_qnum = tswapl(target_md->msg_qnum); - host_md->msg_qbytes = tswapl(target_md->msg_qbytes); - host_md->msg_lspid = tswapl(target_md->msg_lspid); - host_md->msg_lrpid = tswapl(target_md->msg_lrpid); + host_md->msg_stime = tswapal(target_md->msg_stime); + host_md->msg_rtime = tswapal(target_md->msg_rtime); + host_md->msg_ctime = tswapal(target_md->msg_ctime); + host_md->__msg_cbytes = tswapal(target_md->__msg_cbytes); + host_md->msg_qnum = tswapal(target_md->msg_qnum); + host_md->msg_qbytes = tswapal(target_md->msg_qbytes); + host_md->msg_lspid = tswapal(target_md->msg_lspid); + host_md->msg_lrpid = tswapal(target_md->msg_lrpid); unlock_user_struct(target_md, target_addr, 0); return 0; } @@ -2655,14 +2657,14 @@ static inline abi_long host_to_target_msqid_ds(abi_ulong target_addr, return -TARGET_EFAULT; if (host_to_target_ipc_perm(target_addr,&(host_md->msg_perm))) return -TARGET_EFAULT; - target_md->msg_stime = tswapl(host_md->msg_stime); - target_md->msg_rtime = tswapl(host_md->msg_rtime); - target_md->msg_ctime = tswapl(host_md->msg_ctime); - target_md->__msg_cbytes = tswapl(host_md->__msg_cbytes); - target_md->msg_qnum = tswapl(host_md->msg_qnum); - target_md->msg_qbytes = tswapl(host_md->msg_qbytes); - target_md->msg_lspid = tswapl(host_md->msg_lspid); - target_md->msg_lrpid = tswapl(host_md->msg_lrpid); + target_md->msg_stime = tswapal(host_md->msg_stime); + target_md->msg_rtime = tswapal(host_md->msg_rtime); + target_md->msg_ctime = tswapal(host_md->msg_ctime); + target_md->__msg_cbytes = tswapal(host_md->__msg_cbytes); + target_md->msg_qnum = tswapal(host_md->msg_qnum); + target_md->msg_qbytes = tswapal(host_md->msg_qbytes); + target_md->msg_lspid = tswapal(host_md->msg_lspid); + target_md->msg_lrpid = tswapal(host_md->msg_lrpid); unlock_user_struct(target_md, target_addr, 1); return 0; } @@ -2743,7 +2745,7 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp, if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0)) return -TARGET_EFAULT; host_mb = malloc(msgsz+sizeof(long)); - host_mb->mtype = (abi_long) tswapl(target_mb->mtype); + host_mb->mtype = (abi_long) tswapal(target_mb->mtype); memcpy(host_mb->mtext, target_mb->mtext, msgsz); ret = get_errno(msgsnd(msqid, host_mb, msgsz, msgflg)); free(host_mb); @@ -2765,7 +2767,7 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp, return -TARGET_EFAULT; host_mb = malloc(msgsz+sizeof(long)); - ret = get_errno(msgrcv(msqid, host_mb, msgsz, tswapl(msgtyp), msgflg)); + ret = get_errno(msgrcv(msqid, host_mb, msgsz, tswapal(msgtyp), msgflg)); if (ret > 0) { abi_ulong target_mtext_addr = msgp + sizeof(abi_ulong); @@ -2778,7 +2780,7 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp, unlock_user(target_mtext, target_mtext_addr, ret); } - target_mb->mtype = tswapl(host_mb->mtype); + target_mb->mtype = tswapal(host_mb->mtype); free(host_mb); end: @@ -3649,7 +3651,7 @@ static abi_long write_ldt(CPUX86State *env, if (!lock_user_struct(VERIFY_READ, target_ldt_info, ptr, 1)) return -TARGET_EFAULT; ldt_info.entry_number = tswap32(target_ldt_info->entry_number); - ldt_info.base_addr = tswapl(target_ldt_info->base_addr); + ldt_info.base_addr = tswapal(target_ldt_info->base_addr); ldt_info.limit = tswap32(target_ldt_info->limit); ldt_info.flags = tswap32(target_ldt_info->flags); unlock_user_struct(target_ldt_info, ptr, 0); @@ -3764,7 +3766,7 @@ static abi_long do_set_thread_area(CPUX86State *env, abi_ulong ptr) if (!target_ldt_info) return -TARGET_EFAULT; ldt_info.entry_number = tswap32(target_ldt_info->entry_number); - ldt_info.base_addr = tswapl(target_ldt_info->base_addr); + ldt_info.base_addr = tswapal(target_ldt_info->base_addr); ldt_info.limit = tswap32(target_ldt_info->limit); ldt_info.flags = tswap32(target_ldt_info->flags); if (ldt_info.entry_number == -1) { @@ -3875,7 +3877,7 @@ static abi_long do_get_thread_area(CPUX86State *env, abi_ulong ptr) base_addr = (entry_1 >> 16) | (entry_2 & 0xff000000) | ((entry_2 & 0xff) << 16); - target_ldt_info->base_addr = tswapl(base_addr); + target_ldt_info->base_addr = tswapal(base_addr); target_ldt_info->limit = tswap32(limit); target_ldt_info->flags = tswap32(flags); unlock_user_struct(target_ldt_info, ptr, 1); @@ -4175,8 +4177,8 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) return -TARGET_EFAULT; fl.l_type = tswap16(target_fl->l_type); fl.l_whence = tswap16(target_fl->l_whence); - fl.l_start = tswapl(target_fl->l_start); - fl.l_len = tswapl(target_fl->l_len); + fl.l_start = tswapal(target_fl->l_start); + fl.l_len = tswapal(target_fl->l_len); fl.l_pid = tswap32(target_fl->l_pid); unlock_user_struct(target_fl, arg, 0); ret = get_errno(fcntl(fd, host_cmd, &fl)); @@ -4185,8 +4187,8 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) return -TARGET_EFAULT; target_fl->l_type = tswap16(fl.l_type); target_fl->l_whence = tswap16(fl.l_whence); - target_fl->l_start = tswapl(fl.l_start); - target_fl->l_len = tswapl(fl.l_len); + target_fl->l_start = tswapal(fl.l_start); + target_fl->l_len = tswapal(fl.l_len); target_fl->l_pid = tswap32(fl.l_pid); unlock_user_struct(target_fl, arg, 1); } @@ -4198,8 +4200,8 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) return -TARGET_EFAULT; fl.l_type = tswap16(target_fl->l_type); fl.l_whence = tswap16(target_fl->l_whence); - fl.l_start = tswapl(target_fl->l_start); - fl.l_len = tswapl(target_fl->l_len); + fl.l_start = tswapal(target_fl->l_start); + fl.l_len = tswapal(target_fl->l_len); fl.l_pid = tswap32(target_fl->l_pid); unlock_user_struct(target_fl, arg, 0); ret = get_errno(fcntl(fd, host_cmd, &fl)); @@ -4210,8 +4212,8 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) return -TARGET_EFAULT; fl64.l_type = tswap16(target_fl64->l_type) >> 1; fl64.l_whence = tswap16(target_fl64->l_whence); - fl64.l_start = tswapl(target_fl64->l_start); - fl64.l_len = tswapl(target_fl64->l_len); + fl64.l_start = tswap64(target_fl64->l_start); + fl64.l_len = tswap64(target_fl64->l_len); fl64.l_pid = tswap32(target_fl64->l_pid); unlock_user_struct(target_fl64, arg, 0); ret = get_errno(fcntl(fd, host_cmd, &fl64)); @@ -4220,8 +4222,8 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) return -TARGET_EFAULT; target_fl64->l_type = tswap16(fl64.l_type) >> 1; target_fl64->l_whence = tswap16(fl64.l_whence); - target_fl64->l_start = tswapl(fl64.l_start); - target_fl64->l_len = tswapl(fl64.l_len); + target_fl64->l_start = tswap64(fl64.l_start); + target_fl64->l_len = tswap64(fl64.l_len); target_fl64->l_pid = tswap32(fl64.l_pid); unlock_user_struct(target_fl64, arg, 1); } @@ -4232,8 +4234,8 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg) return -TARGET_EFAULT; fl64.l_type = tswap16(target_fl64->l_type) >> 1; fl64.l_whence = tswap16(target_fl64->l_whence); - fl64.l_start = tswapl(target_fl64->l_start); - fl64.l_len = tswapl(target_fl64->l_len); + fl64.l_start = tswap64(target_fl64->l_start); + fl64.l_len = tswap64(target_fl64->l_len); fl64.l_pid = tswap32(target_fl64->l_pid); unlock_user_struct(target_fl64, arg, 0); ret = get_errno(fcntl(fd, host_cmd, &fl64)); @@ -4426,8 +4428,8 @@ static inline abi_long target_to_host_timespec(struct timespec *host_ts, if (!lock_user_struct(VERIFY_READ, target_ts, target_addr, 1)) return -TARGET_EFAULT; - host_ts->tv_sec = tswapl(target_ts->tv_sec); - host_ts->tv_nsec = tswapl(target_ts->tv_nsec); + host_ts->tv_sec = tswapal(target_ts->tv_sec); + host_ts->tv_nsec = tswapal(target_ts->tv_nsec); unlock_user_struct(target_ts, target_addr, 0); return 0; } @@ -4439,8 +4441,8 @@ static inline abi_long host_to_target_timespec(abi_ulong target_addr, if (!lock_user_struct(VERIFY_WRITE, target_ts, target_addr, 0)) return -TARGET_EFAULT; - target_ts->tv_sec = tswapl(host_ts->tv_sec); - target_ts->tv_nsec = tswapl(host_ts->tv_nsec); + target_ts->tv_sec = tswapal(host_ts->tv_sec); + target_ts->tv_nsec = tswapal(host_ts->tv_nsec); unlock_user_struct(target_ts, target_addr, 1); return 0; } @@ -5004,8 +5006,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, if (arg2) { if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1)) goto efault; - tbuf.actime = tswapl(target_tbuf->actime); - tbuf.modtime = tswapl(target_tbuf->modtime); + tbuf.actime = tswapal(target_tbuf->actime); + tbuf.modtime = tswapal(target_tbuf->modtime); unlock_user_struct(target_tbuf, arg2, 0); host_tbuf = &tbuf; } else { @@ -5162,10 +5164,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, tmsp = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0); if (!tmsp) goto efault; - tmsp->tms_utime = tswapl(host_to_target_clock_t(tms.tms_utime)); - tmsp->tms_stime = tswapl(host_to_target_clock_t(tms.tms_stime)); - tmsp->tms_cutime = tswapl(host_to_target_clock_t(tms.tms_cutime)); - tmsp->tms_cstime = tswapl(host_to_target_clock_t(tms.tms_cstime)); + 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)); + tmsp->tms_cstime = tswapal(host_to_target_clock_t(tms.tms_cstime)); } if (!is_error(ret)) ret = host_to_target_clock_t(ret); @@ -5687,11 +5689,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, if (!lock_user_struct(VERIFY_READ, sel, arg1, 1)) goto efault; - nsel = tswapl(sel->n); - inp = tswapl(sel->inp); - outp = tswapl(sel->outp); - exp = tswapl(sel->exp); - tvp = tswapl(sel->tvp); + nsel = tswapal(sel->n); + inp = tswapal(sel->inp); + outp = tswapal(sel->outp); + exp = tswapal(sel->exp); + tvp = tswapal(sel->tvp); unlock_user_struct(sel, arg1, 0); ret = do_select(nsel, inp, outp, exp, tvp); } @@ -5759,8 +5761,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, if (!arg7) { goto efault; } - arg_sigset = tswapl(arg7[0]); - arg_sigsize = tswapl(arg7[1]); + arg_sigset = tswapal(arg7[0]); + arg_sigsize = tswapal(arg7[1]); unlock_user(arg7, arg6, 0); if (arg_sigset) { @@ -5897,12 +5899,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, abi_ulong v1, v2, v3, v4, v5, v6; if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1))) goto efault; - v1 = tswapl(v[0]); - v2 = tswapl(v[1]); - v3 = tswapl(v[2]); - v4 = tswapl(v[3]); - v5 = tswapl(v[4]); - v6 = tswapl(v[5]); + v1 = tswapal(v[0]); + v2 = tswapal(v[1]); + v3 = tswapal(v[2]); + v4 = tswapal(v[3]); + v5 = tswapal(v[4]); + v6 = tswapal(v[5]); unlock_user(v, arg1, 0); ret = get_errno(target_mmap(v1, v2, v3, target_to_host_bitmask(v4, mmap_flags_tbl), @@ -6525,8 +6527,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, reclen = de->d_reclen; treclen = reclen - (2 * (sizeof(long) - sizeof(abi_long))); tde->d_reclen = tswap16(treclen); - tde->d_ino = tswapl(de->d_ino); - tde->d_off = tswapl(de->d_off); + tde->d_ino = tswapal(de->d_ino); + tde->d_off = tswapal(de->d_off); tnamelen = treclen - (2 * sizeof(abi_long) + 2); if (tnamelen > 256) tnamelen = 256; diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 5fd4c9ce45..9dd1b8e4cf 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -209,9 +209,9 @@ __target_cmsg_nxthdr (struct target_msghdr *__mhdr, struct target_cmsghdr *__cms struct target_cmsghdr *__ptr; __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg - + TARGET_CMSG_ALIGN (tswapl(__cmsg->cmsg_len))); - if ((unsigned long)((char *)(__ptr+1) - (char *)(size_t)tswapl(__mhdr->msg_control)) - > tswapl(__mhdr->msg_controllen)) + + TARGET_CMSG_ALIGN (tswapal(__cmsg->cmsg_len))); + if ((unsigned long)((char *)(__ptr+1) - (char *)(size_t)tswapal(__mhdr->msg_control)) + > tswapal(__mhdr->msg_controllen)) /* No more entries. */ return (struct target_cmsghdr *)0; return __cmsg; @@ -292,7 +292,7 @@ static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s) { int i; for(i = 0;i < TARGET_NSIG_WORDS; i++) - d->sig[i] = tswapl(s->sig[i]); + d->sig[i] = tswapal(s->sig[i]); } #else static inline void tswap_sigset(target_sigset_t *d, const target_sigset_t *s) diff --git a/linux-user/vm86.c b/linux-user/vm86.c index 0b2439dfa3..2c4ffeb551 100644 --- a/linux-user/vm86.c +++ b/linux-user/vm86.c @@ -432,7 +432,7 @@ int do_vm86(CPUX86State *env, long subfunction, abi_ulong vm86_addr) env->eflags = (env->eflags & ~SAFE_MASK) | (tswap32(target_v86->regs.eflags) & SAFE_MASK) | VM_MASK; - ts->vm86plus.cpu_type = tswapl(target_v86->cpu_type); + ts->vm86plus.cpu_type = tswapal(target_v86->cpu_type); switch (ts->vm86plus.cpu_type) { case TARGET_CPU_286: ts->v86mask = 0; @@ -468,7 +468,7 @@ int do_vm86(CPUX86State *env, long subfunction, abi_ulong vm86_addr) &target_v86->int_revectored, 32); memcpy(&ts->vm86plus.int21_revectored, &target_v86->int21_revectored, 32); - ts->vm86plus.vm86plus.flags = tswapl(target_v86->vm86plus.flags); + ts->vm86plus.vm86plus.flags = tswapal(target_v86->vm86plus.flags); memcpy(&ts->vm86plus.vm86plus.vm86dbg_intxxtab, target_v86->vm86plus.vm86dbg_intxxtab, 32); unlock_user_struct(target_v86, vm86_addr, 0); -- cgit v1.2.1 From f4c690101c74afcc58deead71f6302fe343718b7 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Sun, 25 Sep 2011 06:25:35 +0200 Subject: linux-user: fix openat When running openat using qemu-arm, we stumbled over invalid permissions on the created files. The reason for this is that the mode parameter gets treates as an O_... flag, which it isn't - it's a permission bitmask. This patch removes the needless translation of the mode parameter, rendering permission passing of openat() to work with linux-user. Reported-by: Dirk Mueller Signed-off-by: Alexander Graf Signed-off-by: Riku Voipio --- linux-user/syscall.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9a633571a7..615957120c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -379,25 +379,13 @@ static int sys_mknodat(int dirfd, const char *pathname, mode_t mode, } #endif #ifdef TARGET_NR_openat -static int sys_openat(int dirfd, const char *pathname, int flags, ...) +static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode) { /* * open(2) has extra parameter 'mode' when called with * flag O_CREAT. */ if ((flags & O_CREAT) != 0) { - va_list ap; - mode_t mode; - - /* - * Get the 'mode' parameter and translate it to - * host bits. - */ - va_start(ap, flags); - mode = va_arg(ap, mode_t); - mode = target_to_host_bitmask(mode, fcntl_flags_tbl); - va_end(ap); - return (openat(dirfd, pathname, flags, mode)); } return (openat(dirfd, pathname, flags)); -- cgit v1.2.1 From 0f6b4d21121bec70b383b4a3bc1c46d9c83f8692 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Tue, 27 Sep 2011 14:39:42 +0200 Subject: linux-user: implement reboot syscall For OBS, we're running a full cross-guest inside of a VM. When a build is done there, we reboot the guest as shutdown mechanism. Unfortunately, reboot is not implemented in linux-user. So this mechanism fails, spilling unpretty warnings. This patch implements sys_reboot() emulation. Signed-off-by: Alexander Graf Signed-off-by: Riku Voipio --- linux-user/syscall.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 615957120c..9f5da36021 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -248,6 +248,8 @@ _syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len, #define __NR_sys_sched_setaffinity __NR_sched_setaffinity _syscall3(int, sys_sched_setaffinity, pid_t, pid, unsigned int, len, unsigned long *, user_mask_ptr); +_syscall4(int, reboot, int, magic1, int, magic2, unsigned int, cmd, + void *, arg); static bitmask_transtbl fcntl_flags_tbl[] = { { TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, }, @@ -5872,7 +5874,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; #endif case TARGET_NR_reboot: - goto unimplemented; + if (!(p = lock_user_string(arg4))) + goto efault; + ret = reboot(arg1, arg2, arg3, p); + unlock_user(p, arg4, 0); + break; #ifdef TARGET_NR_readdir case TARGET_NR_readdir: goto unimplemented; -- cgit v1.2.1 From 75f22e4e69aa4e6d58f52c1863910b3245acc719 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 25 Oct 2011 10:34:06 -0700 Subject: sparc-linux-user: Handle SIGILL. Signed-off-by: Richard Henderson Signed-off-by: Riku Voipio --- linux-user/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/linux-user/main.c b/linux-user/main.c index e7dad547b8..2bc10ed860 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -1191,6 +1191,15 @@ void cpu_loop (CPUSPARCState *env) case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ break; + case TT_ILL_INSN: + { + info.si_signo = TARGET_SIGILL; + info.si_errno = 0; + info.si_code = TARGET_ILL_ILLOPC; + info._sifields._sigfault._addr = env->pc; + queue_signal(env, info.si_signo, &info); + } + break; case EXCP_DEBUG: { int sig; -- cgit v1.2.1 From 59f7182f945ca9a0a689ab60bfcd7e37c25fc4cb Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 25 Oct 2011 10:34:07 -0700 Subject: sparc-linux-user: Fixup sending SIGSEGV Signed-off-by: Richard Henderson Signed-off-by: Riku Voipio --- linux-user/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 2bc10ed860..c36a8afc04 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -1148,7 +1148,7 @@ void cpu_loop (CPUSPARCState *env) case TT_TFAULT: case TT_DFAULT: { - info.si_signo = SIGSEGV; + info.si_signo = TARGET_SIGSEGV; info.si_errno = 0; /* XXX: check env->error_code */ info.si_code = TARGET_SEGV_MAPERR; @@ -1166,7 +1166,7 @@ void cpu_loop (CPUSPARCState *env) case TT_TFAULT: case TT_DFAULT: { - info.si_signo = SIGSEGV; + info.si_signo = TARGET_SIGSEGV; info.si_errno = 0; /* XXX: check env->error_code */ info.si_code = TARGET_SEGV_MAPERR; -- cgit v1.2.1 From 7cd393ac1db87a5268173ce2286a4283c9e7a4a9 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 25 Oct 2011 10:34:08 -0700 Subject: sparc-linux-user: Add some missing syscall numbers Signed-off-by: Richard Henderson Signed-off-by: Riku Voipio --- linux-user/sparc/syscall_nr.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linux-user/sparc/syscall_nr.h b/linux-user/sparc/syscall_nr.h index be503f23dd..f201f9f788 100644 --- a/linux-user/sparc/syscall_nr.h +++ b/linux-user/sparc/syscall_nr.h @@ -136,6 +136,7 @@ #define TARGET_NR_utimes 138 /* SunOS Specific */ #define TARGET_NR_stat64 139 /* Linux sparc32 Specific */ #define TARGET_NR_getpeername 141 /* Common */ +#define TARGET_NR_futex 142 /* gethostid under SunOS */ #define TARGET_NR_gettid 143 /* ENOSYS under SunOS */ #define TARGET_NR_getrlimit 144 /* Common */ #define TARGET_NR_setrlimit 145 /* Common */ @@ -153,6 +154,7 @@ #define TARGET_NR_getdomainname 162 /* SunOS Specific */ #define TARGET_NR_setdomainname 163 /* Common */ #define TARGET_NR_quotactl 165 /* Common */ +#define TARGET_NR_set_tid_address 166 /* Linux specific, exportfs under SunOS */ #define TARGET_NR_mount 167 /* Common */ #define TARGET_NR_ustat 168 /* Common */ #define TARGET_NR_getdents 174 /* Common */ @@ -177,6 +179,7 @@ #define TARGET_NR_readahead 205 /* Linux Specific */ #define TARGET_NR_socketcall 206 /* Linux Specific */ #define TARGET_NR_syslog 207 /* Linux Specific */ +#define TARGET_NR_tgkill 211 /* Linux Specific */ #define TARGET_NR_waitpid 212 /* Linux Specific */ #define TARGET_NR_swapoff 213 /* Linux Specific */ #define TARGET_NR_sysinfo 214 /* Linux Specific */ -- cgit v1.2.1 From 8e78064e9d95094b7db8e82e57fa6d57fd38b333 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 26 Oct 2011 09:59:17 -0700 Subject: ppc64-linux-user: Properly interpret the entry function descriptor. Don't confuse the load address with the load bias. They're equal for ET_DYN objects (i.e. ld.so) but different for ET_EXEC objects (i.e. statically linked). Signed-off-by: Richard Henderson Signed-off-by: Riku Voipio --- linux-user/elfload.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 8677bba0d8..a4139763f4 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -618,8 +618,8 @@ static inline void init_thread(struct target_pt_regs *_regs, struct image_info * { _regs->gpr[1] = infop->start_stack; #if defined(TARGET_PPC64) && !defined(TARGET_ABI32) - _regs->gpr[2] = ldq_raw(infop->entry + 8) + infop->load_addr; - infop->entry = ldq_raw(infop->entry) + infop->load_addr; + _regs->gpr[2] = ldq_raw(infop->entry + 8) + infop->load_bias; + infop->entry = ldq_raw(infop->entry) + infop->load_bias; #endif _regs->nip = infop->entry; } @@ -1884,11 +1884,11 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, info->start_stack = bprm->p; /* If we have an interpreter, set that as the program's entry point. - Copy the load_addr as well, to help PPC64 interpret the entry + Copy the load_bias as well, to help PPC64 interpret the entry point as a function descriptor. Do this after creating elf tables so that we copy the original program entry point into the AUXV. */ if (elf_interpreter) { - info->load_addr = interp_info.load_addr; + info->load_bias = interp_info.load_bias; info->entry = interp_info.entry; free(elf_interpreter); } -- cgit v1.2.1 From 9e0e2f967b17fc88cd288963e9cb1187d4b3841b Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 26 Oct 2011 09:59:18 -0700 Subject: ppc64-linux-user: Fix syscall return type. Use target_ulong instead of hard-coded uint32_t. Remove the disabled printf's that are redundant with -strace. Signed-off-by: Richard Henderson Signed-off-by: Riku Voipio --- linux-user/main.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index c36a8afc04..d1bbc577e5 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -1341,7 +1341,7 @@ void cpu_loop(CPUPPCState *env) { target_siginfo_t info; int trapnr; - uint32_t ret; + target_ulong ret; for(;;) { cpu_exec_start(env); @@ -1704,27 +1704,20 @@ void cpu_loop(CPUPPCState *env) * PPC ABI uses overflow flag in cr0 to signal an error * in syscalls. */ -#if 0 - printf("syscall %d 0x%08x 0x%08x 0x%08x 0x%08x\n", env->gpr[0], - env->gpr[3], env->gpr[4], env->gpr[5], env->gpr[6]); -#endif env->crf[0] &= ~0x1; ret = do_syscall(env, env->gpr[0], env->gpr[3], env->gpr[4], env->gpr[5], env->gpr[6], env->gpr[7], env->gpr[8], 0, 0); - if (ret == (uint32_t)(-TARGET_QEMU_ESIGRETURN)) { + if (ret == (target_ulong)(-TARGET_QEMU_ESIGRETURN)) { /* Returning from a successful sigreturn syscall. Avoid corrupting register state. */ break; } - if (ret > (uint32_t)(-515)) { + if (ret > (target_ulong)(-515)) { env->crf[0] |= 0x1; ret = -ret; } env->gpr[3] = ret; -#if 0 - printf("syscall returned 0x%08x (%d)\n", ret, ret); -#endif break; case POWERPC_EXCP_STCX: if (do_store_exclusive(env)) { -- cgit v1.2.1