Lines Matching +full:cross +full:- +full:i386 +full:- +full:system

28 #include "exec/page-protection.h"
29 #include "exec/mmap-lock.h"
30 #include "exec/tb-flush.h"
31 #include "exec/translation-block.h"
115 #include <linux/dm-ioctl.h>
136 #include "user-internals.h"
138 #include "signal-common.h"
140 #include "user-mmap.h"
141 #include "user/page-protection.h"
142 #include "user/safe-syscall.h"
144 #include "qemu/guest-random.h"
146 #include "user/syscall-trace.h"
147 #include "special-errno.h"
149 #include "fd-trans.h"
306 /* For the 64-bit guest on 32-bit host case we must emulate
461 /* Don't terminate the list prematurely on 64-bit host+guest. */
479 return -1;
497 return -1;
514 # define __NR_prlimit64 -1
542 return -1; in next_free_host_timer()
575 if (ret == -1) in get_errno()
576 return -host_to_target_errno(errno); in get_errno()
602 return -TARGET_EFAULT; in check_zeroed_user()
613 * backwards-compatibility for struct syscall arguments.
620 size_t rest = MAX(ksize, usize) - size; in copy_struct_from_user()
628 return ret ?: -TARGET_E2BIG; in copy_struct_from_user()
633 return -TARGET_EFAULT; in copy_struct_from_user()
800 * we should be using the 64-bit structures automatically. in safe_syscall3()
872 target_munmap(new_brk, old_brk - new_brk); in do_brk()
878 mapped_addr = target_mmap(old_brk, new_brk - old_brk, in do_brk()
881 -1, 0); in do_brk()
891 return -TARGET_ENOMEM; in do_brk()
911 return -TARGET_EFAULT; in copy_from_user_fdset()
937 return -TARGET_EFAULT; in copy_from_user_fdset_ptr()
958 return -TARGET_EFAULT; in copy_to_user_fdset()
997 return -TARGET_EFAULT; in host_to_target_rusage()
998 target_rusage->ru_utime.tv_sec = tswapal(rusage->ru_utime.tv_sec); in host_to_target_rusage()
999 target_rusage->ru_utime.tv_usec = tswapal(rusage->ru_utime.tv_usec); in host_to_target_rusage()
1000 target_rusage->ru_stime.tv_sec = tswapal(rusage->ru_stime.tv_sec); in host_to_target_rusage()
1001 target_rusage->ru_stime.tv_usec = tswapal(rusage->ru_stime.tv_usec); in host_to_target_rusage()
1002 target_rusage->ru_maxrss = tswapal(rusage->ru_maxrss); in host_to_target_rusage()
1003 target_rusage->ru_ixrss = tswapal(rusage->ru_ixrss); in host_to_target_rusage()
1004 target_rusage->ru_idrss = tswapal(rusage->ru_idrss); in host_to_target_rusage()
1005 target_rusage->ru_isrss = tswapal(rusage->ru_isrss); in host_to_target_rusage()
1006 target_rusage->ru_minflt = tswapal(rusage->ru_minflt); in host_to_target_rusage()
1007 target_rusage->ru_majflt = tswapal(rusage->ru_majflt); in host_to_target_rusage()
1008 target_rusage->ru_nswap = tswapal(rusage->ru_nswap); in host_to_target_rusage()
1009 target_rusage->ru_inblock = tswapal(rusage->ru_inblock); in host_to_target_rusage()
1010 target_rusage->ru_oublock = tswapal(rusage->ru_oublock); in host_to_target_rusage()
1011 target_rusage->ru_msgsnd = tswapal(rusage->ru_msgsnd); in host_to_target_rusage()
1012 target_rusage->ru_msgrcv = tswapal(rusage->ru_msgrcv); in host_to_target_rusage()
1013 target_rusage->ru_nsignals = tswapal(rusage->ru_nsignals); in host_to_target_rusage()
1014 target_rusage->ru_nvcsw = tswapal(rusage->ru_nvcsw); in host_to_target_rusage()
1015 target_rusage->ru_nivcsw = tswapal(rusage->ru_nivcsw); in host_to_target_rusage()
1103 return -TARGET_EFAULT; in copy_from_user_timeval()
1106 __get_user(tv->tv_sec, &target_tv->tv_sec); in copy_from_user_timeval()
1107 __get_user(tv->tv_usec, &target_tv->tv_usec); in copy_from_user_timeval()
1120 return -TARGET_EFAULT; in copy_to_user_timeval()
1123 __put_user(tv->tv_sec, &target_tv->tv_sec); in copy_to_user_timeval()
1124 __put_user(tv->tv_usec, &target_tv->tv_usec); in copy_to_user_timeval()
1138 return -TARGET_EFAULT; in copy_from_user_timeval64()
1141 __get_user(tv->tv_sec, &target_tv->tv_sec); in copy_from_user_timeval64()
1142 __get_user(tv->tv_usec, &target_tv->tv_usec); in copy_from_user_timeval64()
1156 return -TARGET_EFAULT; in copy_to_user_timeval64()
1159 __put_user(tv->tv_sec, &target_tv->tv_sec); in copy_to_user_timeval64()
1160 __put_user(tv->tv_usec, &target_tv->tv_usec); in copy_to_user_timeval64()
1182 return -TARGET_EFAULT; in target_to_host_timespec()
1184 __get_user(host_ts->tv_sec, &target_ts->tv_sec); in target_to_host_timespec()
1185 __get_user(host_ts->tv_nsec, &target_ts->tv_nsec); in target_to_host_timespec()
1208 return -TARGET_EFAULT; in target_to_host_timespec64()
1210 __get_user(host_ts->tv_sec, &target_ts->tv_sec); in target_to_host_timespec64()
1211 __get_user(host_ts->tv_nsec, &target_ts->tv_nsec); in target_to_host_timespec64()
1213 host_ts->tv_nsec = (long)(abi_long)host_ts->tv_nsec; in target_to_host_timespec64()
1225 return -TARGET_EFAULT; in host_to_target_timespec()
1227 __put_user(host_ts->tv_sec, &target_ts->tv_sec); in host_to_target_timespec()
1228 __put_user(host_ts->tv_nsec, &target_ts->tv_nsec); in host_to_target_timespec()
1239 return -TARGET_EFAULT; in host_to_target_timespec64()
1241 __put_user(host_ts->tv_sec, &target_ts->tv_sec); in host_to_target_timespec64()
1242 __put_user(host_ts->tv_nsec, &target_ts->tv_nsec); in host_to_target_timespec64()
1254 return -TARGET_EFAULT; in copy_to_user_timezone()
1257 __put_user(tz->tz_minuteswest, &target_tz->tz_minuteswest); in copy_to_user_timezone()
1258 __put_user(tz->tz_dsttime, &target_tz->tz_dsttime); in copy_to_user_timezone()
1273 return -TARGET_EFAULT; in copy_from_user_timezone()
1276 __get_user(tz->tz_minuteswest, &target_tz->tz_minuteswest); in copy_from_user_timezone()
1277 __get_user(tz->tz_dsttime, &target_tz->tz_dsttime); in copy_from_user_timezone()
1295 return -TARGET_EFAULT; in copy_from_user_mq_attr()
1297 __get_user(attr->mq_flags, &target_mq_attr->mq_flags); in copy_from_user_mq_attr()
1298 __get_user(attr->mq_maxmsg, &target_mq_attr->mq_maxmsg); in copy_from_user_mq_attr()
1299 __get_user(attr->mq_msgsize, &target_mq_attr->mq_msgsize); in copy_from_user_mq_attr()
1300 __get_user(attr->mq_curmsgs, &target_mq_attr->mq_curmsgs); in copy_from_user_mq_attr()
1314 return -TARGET_EFAULT; in copy_to_user_mq_attr()
1316 __put_user(attr->mq_flags, &target_mq_attr->mq_flags); in copy_to_user_mq_attr()
1317 __put_user(attr->mq_maxmsg, &target_mq_attr->mq_maxmsg); in copy_to_user_mq_attr()
1318 __put_user(attr->mq_msgsize, &target_mq_attr->mq_msgsize); in copy_to_user_mq_attr()
1319 __put_user(attr->mq_curmsgs, &target_mq_attr->mq_curmsgs); in copy_to_user_mq_attr()
1354 return -TARGET_EFAULT; in do_select()
1367 return -TARGET_EFAULT; in do_select()
1369 return -TARGET_EFAULT; in do_select()
1371 return -TARGET_EFAULT; in do_select()
1377 return -TARGET_EFAULT; in do_select()
1393 return -TARGET_EFAULT; in do_old_select()
1396 nsel = tswapal(sel->n); in do_old_select()
1397 inp = tswapal(sel->inp); in do_old_select()
1398 outp = tswapal(sel->outp); in do_old_select()
1399 exp = tswapal(sel->exp); in do_old_select()
1400 tvp = tswapal(sel->tvp); in do_old_select()
1457 return -TARGET_EFAULT; in do_pselect6()
1461 return -TARGET_EFAULT; in do_pselect6()
1474 return -TARGET_EFAULT; in do_pselect6()
1499 return -TARGET_EFAULT; in do_pselect6()
1502 return -TARGET_EFAULT; in do_pselect6()
1505 return -TARGET_EFAULT; in do_pselect6()
1509 return -TARGET_EFAULT; in do_pselect6()
1513 return -TARGET_EFAULT; in do_pselect6()
1536 return -TARGET_EINVAL; in do_ppoll()
1541 return -TARGET_EFAULT; in do_ppoll()
1558 return -TARGET_EFAULT; in do_ppoll()
1563 return -TARGET_EFAULT; in do_ppoll()
1587 return -TARGET_EFAULT; in do_ppoll()
1591 return -TARGET_EFAULT; in do_ppoll()
1604 /* -ve poll() timeout means "infinite" */ in do_ppoll()
1634 cpu_env->ir[IR_A4] = host_pipe[1]; in do_pipe()
1637 cpu_env->active_tc.gpr[3] = host_pipe[1]; in do_pipe()
1640 cpu_env->gregs[1] = host_pipe[1]; in do_pipe()
1643 cpu_env->regwptr[1] = host_pipe[1]; in do_pipe()
1650 return -TARGET_EFAULT; in do_pipe()
1668 return -TARGET_EFAULT; in target_to_host_sockaddr()
1670 sa_family = tswap16(target_saddr->sa_family); in target_to_host_sockaddr()
1675 * length as "strlen(x->sun_path)" while it should be in target_to_host_sockaddr()
1684 if ( cp[len-1] && !cp[len] ) in target_to_host_sockaddr()
1692 addr->sa_family = sa_family; in target_to_host_sockaddr()
1697 nladdr->nl_pid = tswap32(nladdr->nl_pid); in target_to_host_sockaddr()
1698 nladdr->nl_groups = tswap32(nladdr->nl_groups); in target_to_host_sockaddr()
1703 lladdr->sll_ifindex = tswap32(lladdr->sll_ifindex); in target_to_host_sockaddr()
1704 lladdr->sll_hatype = tswap16(lladdr->sll_hatype); in target_to_host_sockaddr()
1709 in6addr->sin6_scope_id = tswap32(in6addr->sin6_scope_id); in target_to_host_sockaddr()
1729 return -TARGET_EFAULT; in host_to_target_sockaddr()
1732 sizeof(target_saddr->sa_family)) { in host_to_target_sockaddr()
1733 target_saddr->sa_family = tswap16(addr->sa_family); in host_to_target_sockaddr()
1735 if (addr->sa_family == AF_NETLINK && in host_to_target_sockaddr()
1739 target_nl->nl_pid = tswap32(target_nl->nl_pid); in host_to_target_sockaddr()
1740 target_nl->nl_groups = tswap32(target_nl->nl_groups); in host_to_target_sockaddr()
1741 } else if (addr->sa_family == AF_PACKET) { in host_to_target_sockaddr()
1743 target_ll->sll_ifindex = tswap32(target_ll->sll_ifindex); in host_to_target_sockaddr()
1744 target_ll->sll_hatype = tswap16(target_ll->sll_hatype); in host_to_target_sockaddr()
1745 } else if (addr->sa_family == AF_INET6 && in host_to_target_sockaddr()
1749 target_in6->sin6_scope_id = tswap16(target_in6->sin6_scope_id); in host_to_target_sockaddr()
1765 msg_controllen = tswapal(target_msgh->msg_controllen); in target_to_host_cmsg()
1768 target_cmsg_addr = tswapal(target_msgh->msg_control); in target_to_host_cmsg()
1772 return -TARGET_EFAULT; in target_to_host_cmsg()
1778 int len = tswapal(target_cmsg->cmsg_len) in target_to_host_cmsg()
1779 - sizeof(struct target_cmsghdr); in target_to_host_cmsg()
1782 if (space > msgh->msg_controllen) { in target_to_host_cmsg()
1783 space -= CMSG_SPACE(len); in target_to_host_cmsg()
1785 * area ourselves (unlike overflow in host-to-target in target_to_host_cmsg()
1796 tswap32(target_cmsg->cmsg_level), in target_to_host_cmsg()
1797 tswap32(target_cmsg->cmsg_type)); in target_to_host_cmsg()
1801 if (tswap32(target_cmsg->cmsg_level) == TARGET_SOL_SOCKET) { in target_to_host_cmsg()
1802 cmsg->cmsg_level = SOL_SOCKET; in target_to_host_cmsg()
1804 cmsg->cmsg_level = tswap32(target_cmsg->cmsg_level); in target_to_host_cmsg()
1806 cmsg->cmsg_type = tswap32(target_cmsg->cmsg_type); in target_to_host_cmsg()
1807 cmsg->cmsg_len = CMSG_LEN(len); in target_to_host_cmsg()
1809 if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { in target_to_host_cmsg()
1817 } else if (cmsg->cmsg_level == SOL_SOCKET in target_to_host_cmsg()
1818 && cmsg->cmsg_type == SCM_CREDENTIALS) { in target_to_host_cmsg()
1823 __get_user(cred->pid, &target_cred->pid); in target_to_host_cmsg()
1824 __get_user(cred->uid, &target_cred->uid); in target_to_host_cmsg()
1825 __get_user(cred->gid, &target_cred->gid); in target_to_host_cmsg()
1826 } else if (cmsg->cmsg_level == SOL_ALG) { in target_to_host_cmsg()
1830 /* fix endianness of first 32-bit word */ in target_to_host_cmsg()
1836 cmsg->cmsg_level, cmsg->cmsg_type); in target_to_host_cmsg()
1846 msgh->msg_controllen = space; in target_to_host_cmsg()
1859 msg_controllen = tswapal(target_msgh->msg_controllen); in host_to_target_cmsg()
1862 target_cmsg_addr = tswapal(target_msgh->msg_control); in host_to_target_cmsg()
1866 return -TARGET_EFAULT; in host_to_target_cmsg()
1872 int len = cmsg->cmsg_len - sizeof(struct cmsghdr); in host_to_target_cmsg()
1875 /* We never copy a half-header but may copy half-data; in host_to_target_cmsg()
1882 target_msgh->msg_flags |= tswap32(MSG_CTRUNC); in host_to_target_cmsg()
1886 if (cmsg->cmsg_level == SOL_SOCKET) { in host_to_target_cmsg()
1887 target_cmsg->cmsg_level = tswap32(TARGET_SOL_SOCKET); in host_to_target_cmsg()
1889 target_cmsg->cmsg_level = tswap32(cmsg->cmsg_level); in host_to_target_cmsg()
1891 target_cmsg->cmsg_type = tswap32(cmsg->cmsg_type); in host_to_target_cmsg()
1897 switch (cmsg->cmsg_level) { in host_to_target_cmsg()
1899 switch (cmsg->cmsg_type) { in host_to_target_cmsg()
1912 target_msgh->msg_flags |= tswap32(MSG_CTRUNC); in host_to_target_cmsg()
1913 tgt_len = msg_controllen - sizeof(struct target_cmsghdr); in host_to_target_cmsg()
1916 /* We must now copy-and-convert len bytes of payload in host_to_target_cmsg()
1921 switch (cmsg->cmsg_level) { in host_to_target_cmsg()
1923 switch (cmsg->cmsg_type) { in host_to_target_cmsg()
1947 __put_user(tv->tv_sec, &target_tv->tv_sec); in host_to_target_cmsg()
1948 __put_user(tv->tv_usec, &target_tv->tv_usec); in host_to_target_cmsg()
1957 __put_user(cred->pid, &target_cred->pid); in host_to_target_cmsg()
1958 __put_user(cred->uid, &target_cred->uid); in host_to_target_cmsg()
1959 __put_user(cred->gid, &target_cred->gid); in host_to_target_cmsg()
1968 switch (cmsg->cmsg_type) { in host_to_target_cmsg()
1995 __put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno); in host_to_target_cmsg()
1996 __put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin); in host_to_target_cmsg()
1997 __put_user(errh->ee.ee_type, &target_errh->ee.ee_type); in host_to_target_cmsg()
1998 __put_user(errh->ee.ee_code, &target_errh->ee.ee_code); in host_to_target_cmsg()
1999 __put_user(errh->ee.ee_pad, &target_errh->ee.ee_pad); in host_to_target_cmsg()
2000 __put_user(errh->ee.ee_info, &target_errh->ee.ee_info); in host_to_target_cmsg()
2001 __put_user(errh->ee.ee_data, &target_errh->ee.ee_data); in host_to_target_cmsg()
2002 host_to_target_sockaddr((unsigned long) &target_errh->offender, in host_to_target_cmsg()
2003 (void *) &errh->offender, sizeof(errh->offender)); in host_to_target_cmsg()
2011 __put_user(pkti->ipi_ifindex, &target_pi->ipi_ifindex); in host_to_target_cmsg()
2012 target_pi->ipi_spec_dst.s_addr = pkti->ipi_spec_dst.s_addr; in host_to_target_cmsg()
2013 target_pi->ipi_addr.s_addr = pkti->ipi_addr.s_addr; in host_to_target_cmsg()
2022 switch (cmsg->cmsg_type) { in host_to_target_cmsg()
2049 __put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno); in host_to_target_cmsg()
2050 __put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin); in host_to_target_cmsg()
2051 __put_user(errh->ee.ee_type, &target_errh->ee.ee_type); in host_to_target_cmsg()
2052 __put_user(errh->ee.ee_code, &target_errh->ee.ee_code); in host_to_target_cmsg()
2053 __put_user(errh->ee.ee_pad, &target_errh->ee.ee_pad); in host_to_target_cmsg()
2054 __put_user(errh->ee.ee_info, &target_errh->ee.ee_info); in host_to_target_cmsg()
2055 __put_user(errh->ee.ee_data, &target_errh->ee.ee_data); in host_to_target_cmsg()
2056 host_to_target_sockaddr((unsigned long) &target_errh->offender, in host_to_target_cmsg()
2057 (void *) &errh->offender, sizeof(errh->offender)); in host_to_target_cmsg()
2068 cmsg->cmsg_level, cmsg->cmsg_type); in host_to_target_cmsg()
2071 memset(target_data + len, 0, tgt_len - len); in host_to_target_cmsg()
2075 target_cmsg->cmsg_len = tswapal(TARGET_CMSG_LEN(tgt_len)); in host_to_target_cmsg()
2080 msg_controllen -= tgt_space; in host_to_target_cmsg()
2088 target_msgh->msg_controllen = tswapal(space); in host_to_target_cmsg()
2104 return -TARGET_EINVAL; in do_setsockopt()
2107 return -TARGET_EFAULT; in do_setsockopt()
2131 return -TARGET_EFAULT; in do_setsockopt()
2134 return -TARGET_EFAULT; in do_setsockopt()
2156 return -TARGET_EINVAL; in do_setsockopt()
2161 return -TARGET_EFAULT; in do_setsockopt()
2163 ip_mreq.imr_multiaddr.s_addr = target_smreqn->imr_multiaddr.s_addr; in do_setsockopt()
2165 ip_mreq.imr_address.s_addr = target_smreqn->imr_address.s_addr; in do_setsockopt()
2167 __put_user(target_smreqn->imr_ifindex, &ip_mreq.imr_ifindex); in do_setsockopt()
2183 return -TARGET_EINVAL; in do_setsockopt()
2187 return -TARGET_EFAULT; in do_setsockopt()
2235 return -TARGET_EINVAL; in do_setsockopt()
2238 return -TARGET_EFAULT; in do_setsockopt()
2248 return -TARGET_EINVAL; in do_setsockopt()
2252 return -TARGET_EFAULT; in do_setsockopt()
2267 return -TARGET_EINVAL; in do_setsockopt()
2271 return -TARGET_EFAULT; in do_setsockopt()
2295 return -TARGET_EFAULT; in do_setsockopt()
2316 return -TARGET_EINVAL; in do_setsockopt()
2320 return -TARGET_EFAULT; in do_setsockopt()
2337 return -TARGET_EFAULT; in do_setsockopt()
2363 return -TARGET_EINVAL; in do_setsockopt()
2367 return -TARGET_EFAULT; in do_setsockopt()
2385 return -TARGET_EINVAL; in do_setsockopt()
2388 return -TARGET_EFAULT; in do_setsockopt()
2391 tswapal(tfprog->filter), 0)) { in do_setsockopt()
2393 return -TARGET_EFAULT; in do_setsockopt()
2396 fprog.len = tswap16(tfprog->len); in do_setsockopt()
2399 unlock_user_struct(tfilter, tfprog->filter, 1); in do_setsockopt()
2401 return -TARGET_ENOMEM; in do_setsockopt()
2415 unlock_user_struct(tfilter, tfprog->filter, 1); in do_setsockopt()
2423 if (optlen > IFNAMSIZ - 1) { in do_setsockopt()
2424 optlen = IFNAMSIZ - 1; in do_setsockopt()
2428 return -TARGET_EFAULT; in do_setsockopt()
2445 return -TARGET_EINVAL; in do_setsockopt()
2448 return -TARGET_EFAULT; in do_setsockopt()
2450 __get_user(lg.l_onoff, &tlg->l_onoff); in do_setsockopt()
2451 __get_user(lg.l_linger, &tlg->l_linger); in do_setsockopt()
2526 return -TARGET_EINVAL; in do_setsockopt()
2529 return -TARGET_EFAULT; in do_setsockopt()
2556 return -TARGET_EINVAL; in do_setsockopt()
2559 return -TARGET_EFAULT; in do_setsockopt()
2569 ret = -TARGET_ENOPROTOOPT; in do_setsockopt()
2597 return -TARGET_EFAULT; in do_getsockopt()
2600 return -TARGET_EINVAL; in do_getsockopt()
2613 return -TARGET_EFAULT; in do_getsockopt()
2616 return -TARGET_EFAULT; in do_getsockopt()
2629 return -TARGET_EFAULT; in do_getsockopt()
2632 return -TARGET_EINVAL; in do_getsockopt()
2645 return -TARGET_EFAULT; in do_getsockopt()
2647 __put_user(cr.pid, &tcr->pid); in do_getsockopt()
2648 __put_user(cr.uid, &tcr->uid); in do_getsockopt()
2649 __put_user(cr.gid, &tcr->gid); in do_getsockopt()
2652 return -TARGET_EFAULT; in do_getsockopt()
2660 return -TARGET_EFAULT; in do_getsockopt()
2663 return -TARGET_EINVAL; in do_getsockopt()
2667 return -TARGET_EFAULT; in do_getsockopt()
2673 ret = -TARGET_EFAULT; in do_getsockopt()
2685 return -TARGET_EFAULT; in do_getsockopt()
2688 return -TARGET_EINVAL; in do_getsockopt()
2701 return -TARGET_EFAULT; in do_getsockopt()
2703 __put_user(lg.l_onoff, &tlg->l_onoff); in do_getsockopt()
2704 __put_user(lg.l_linger, &tlg->l_linger); in do_getsockopt()
2707 return -TARGET_EFAULT; in do_getsockopt()
2785 return -TARGET_EFAULT; in do_getsockopt()
2787 return -TARGET_EINVAL; in do_getsockopt()
2804 return -TARGET_EFAULT; in do_getsockopt()
2807 return -TARGET_EFAULT; in do_getsockopt()
2810 return -TARGET_EFAULT; in do_getsockopt()
2830 return -TARGET_EFAULT; in do_getsockopt()
2832 return -TARGET_EINVAL; in do_getsockopt()
2841 return -TARGET_EFAULT; in do_getsockopt()
2847 return -TARGET_EFAULT; in do_getsockopt()
2851 ret = -TARGET_ENOPROTOOPT; in do_getsockopt()
2892 return -TARGET_EFAULT; in do_getsockopt()
2894 return -TARGET_EINVAL; in do_getsockopt()
2903 return -TARGET_EFAULT; in do_getsockopt()
2909 return -TARGET_EFAULT; in do_getsockopt()
2913 ret = -TARGET_ENOPROTOOPT; in do_getsockopt()
2934 return -TARGET_EFAULT; in do_getsockopt()
2937 return -TARGET_EINVAL; in do_getsockopt()
2946 return -TARGET_EFAULT; in do_getsockopt()
2955 return -TARGET_EFAULT; in do_getsockopt()
2958 return -TARGET_EINVAL; in do_getsockopt()
2962 return -TARGET_EFAULT; in do_getsockopt()
2975 return -TARGET_EFAULT; in do_getsockopt()
2991 ret = -TARGET_EOPNOTSUPP; in do_getsockopt()
3078 if (len > max_len - total_len) { in lock_iovec()
3079 len = max_len - total_len; in lock_iovec()
3090 while (--i >= 0) { in lock_iovec()
3145 return -TARGET_EINVAL; in target_to_host_sock_type()
3152 return -TARGET_EINVAL; in target_to_host_sock_type()
3165 if (fcntl(fd, F_SETFL, O_NONBLOCK | flags) == -1) { in sock_flags_fixup()
3167 return -TARGET_EINVAL; in sock_flags_fixup()
3191 return -TARGET_EPROTONOSUPPORT; in do_socket()
3236 return -TARGET_EINVAL; in do_bind()
3256 return -TARGET_EINVAL; in do_connect()
3278 if (msgp->msg_name) { in do_sendrecvmsg_locked()
3279 msg.msg_namelen = tswap32(msgp->msg_namelen); in do_sendrecvmsg_locked()
3282 tswapal(msgp->msg_name), in do_sendrecvmsg_locked()
3284 if (ret == -TARGET_EFAULT) { in do_sendrecvmsg_locked()
3290 msg.msg_name = (void *)-1; in do_sendrecvmsg_locked()
3298 msg.msg_controllen = 2 * tswapal(msgp->msg_controllen); in do_sendrecvmsg_locked()
3302 msg.msg_flags = tswap32(msgp->msg_flags); in do_sendrecvmsg_locked()
3304 count = tswapal(msgp->msg_iovlen); in do_sendrecvmsg_locked()
3305 target_vec = tswapal(msgp->msg_iov); in do_sendrecvmsg_locked()
3311 ret = -TARGET_EMSGSIZE; in do_sendrecvmsg_locked()
3318 ret = -host_to_target_errno(errno); in do_sendrecvmsg_locked()
3331 host_msg = g_malloc(msg.msg_iov->iov_len); in do_sendrecvmsg_locked()
3332 memcpy(host_msg, msg.msg_iov->iov_base, msg.msg_iov->iov_len); in do_sendrecvmsg_locked()
3334 msg.msg_iov->iov_len); in do_sendrecvmsg_locked()
3336 msg.msg_iov->iov_base = host_msg; in do_sendrecvmsg_locked()
3351 ret = fd_trans_host_to_target_data(fd)(msg.msg_iov->iov_base, in do_sendrecvmsg_locked()
3352 MIN(msg.msg_iov->iov_len, len)); in do_sendrecvmsg_locked()
3358 msgp->msg_namelen = tswap32(msg.msg_namelen); in do_sendrecvmsg_locked()
3359 msgp->msg_flags = tswap32(msg.msg_flags); in do_sendrecvmsg_locked()
3360 if (msg.msg_name != NULL && msg.msg_name != (void *)-1) { in do_sendrecvmsg_locked()
3361 ret = host_to_target_sockaddr(tswapal(msgp->msg_name), in do_sendrecvmsg_locked()
3391 return -TARGET_EFAULT; in do_sendrecvmsg()
3399 * so it might not have this *mmsg-specific flag either.
3419 return -TARGET_EFAULT; in do_sendrecvmmsg()
3455 return -TARGET_EINVAL; in do_accept4()
3472 return -TARGET_EFAULT; in do_accept4()
3475 return -TARGET_EINVAL; in do_accept4()
3479 return -TARGET_EFAULT; in do_accept4()
3489 ret = -TARGET_EFAULT; in do_accept4()
3504 return -TARGET_EFAULT; in do_getpeername()
3507 return -TARGET_EINVAL; in do_getpeername()
3511 return -TARGET_EFAULT; in do_getpeername()
3521 ret = -TARGET_EFAULT; in do_getpeername()
3536 return -TARGET_EFAULT; in do_getsockname()
3539 return -TARGET_EINVAL; in do_getsockname()
3543 return -TARGET_EFAULT; in do_getsockname()
3553 ret = -TARGET_EFAULT; in do_getsockname()
3572 ret = -TARGET_EFAULT; in do_socketpair()
3587 return -TARGET_EINVAL; in do_sendto()
3592 return -TARGET_EFAULT; in do_sendto()
3636 return -TARGET_EFAULT; in do_recvfrom()
3641 ret = -TARGET_EFAULT; in do_recvfrom()
3645 ret = -TARGET_EINVAL; in do_recvfrom()
3670 ret = -TARGET_EFAULT; in do_recvfrom()
3714 return -TARGET_EINVAL; in do_socketcall()
3718 return -TARGET_EINVAL; in do_socketcall()
3723 return -TARGET_EFAULT; in do_socketcall()
3770 return -TARGET_EINVAL; in do_socketcall()
3776 /* asm-generic version of this struct */
3801 return -TARGET_EFAULT; in target_to_host_ipc_perm()
3802 target_ip = &(target_sd->sem_perm); in target_to_host_ipc_perm()
3803 host_ip->__key = tswap32(target_ip->__key); in target_to_host_ipc_perm()
3804 host_ip->uid = tswap32(target_ip->uid); in target_to_host_ipc_perm()
3805 host_ip->gid = tswap32(target_ip->gid); in target_to_host_ipc_perm()
3806 host_ip->cuid = tswap32(target_ip->cuid); in target_to_host_ipc_perm()
3807 host_ip->cgid = tswap32(target_ip->cgid); in target_to_host_ipc_perm()
3809 host_ip->mode = tswap32(target_ip->mode); in target_to_host_ipc_perm()
3811 host_ip->mode = tswap16(target_ip->mode); in target_to_host_ipc_perm()
3814 host_ip->__seq = tswap32(target_ip->__seq); in target_to_host_ipc_perm()
3816 host_ip->__seq = tswap16(target_ip->__seq); in target_to_host_ipc_perm()
3829 return -TARGET_EFAULT; in host_to_target_ipc_perm()
3830 target_ip = &(target_sd->sem_perm); in host_to_target_ipc_perm()
3831 target_ip->__key = tswap32(host_ip->__key); in host_to_target_ipc_perm()
3832 target_ip->uid = tswap32(host_ip->uid); in host_to_target_ipc_perm()
3833 target_ip->gid = tswap32(host_ip->gid); in host_to_target_ipc_perm()
3834 target_ip->cuid = tswap32(host_ip->cuid); in host_to_target_ipc_perm()
3835 target_ip->cgid = tswap32(host_ip->cgid); in host_to_target_ipc_perm()
3837 target_ip->mode = tswap32(host_ip->mode); in host_to_target_ipc_perm()
3839 target_ip->mode = tswap16(host_ip->mode); in host_to_target_ipc_perm()
3842 target_ip->__seq = tswap32(host_ip->__seq); in host_to_target_ipc_perm()
3844 target_ip->__seq = tswap16(host_ip->__seq); in host_to_target_ipc_perm()
3856 return -TARGET_EFAULT; in target_to_host_semid_ds()
3857 if (target_to_host_ipc_perm(&(host_sd->sem_perm),target_addr)) in target_to_host_semid_ds()
3858 return -TARGET_EFAULT; in target_to_host_semid_ds()
3859 host_sd->sem_nsems = tswapal(target_sd->sem_nsems); in target_to_host_semid_ds()
3860 host_sd->sem_otime = tswapal(target_sd->sem_otime); in target_to_host_semid_ds()
3861 host_sd->sem_ctime = tswapal(target_sd->sem_ctime); in target_to_host_semid_ds()
3872 return -TARGET_EFAULT; in host_to_target_semid_ds()
3873 if (host_to_target_ipc_perm(target_addr,&(host_sd->sem_perm))) in host_to_target_semid_ds()
3874 return -TARGET_EFAULT; in host_to_target_semid_ds()
3875 target_sd->sem_nsems = tswapal(host_sd->sem_nsems); in host_to_target_semid_ds()
3876 target_sd->sem_otime = tswapal(host_sd->sem_otime); in host_to_target_semid_ds()
3877 target_sd->sem_ctime = tswapal(host_sd->sem_ctime); in host_to_target_semid_ds()
3900 return -TARGET_EFAULT; in host_to_target_seminfo()
3901 __put_user(host_seminfo->semmap, &target_seminfo->semmap); in host_to_target_seminfo()
3902 __put_user(host_seminfo->semmni, &target_seminfo->semmni); in host_to_target_seminfo()
3903 __put_user(host_seminfo->semmns, &target_seminfo->semmns); in host_to_target_seminfo()
3904 __put_user(host_seminfo->semmnu, &target_seminfo->semmnu); in host_to_target_seminfo()
3905 __put_user(host_seminfo->semmsl, &target_seminfo->semmsl); in host_to_target_seminfo()
3906 __put_user(host_seminfo->semopm, &target_seminfo->semopm); in host_to_target_seminfo()
3907 __put_user(host_seminfo->semume, &target_seminfo->semume); in host_to_target_seminfo()
3908 __put_user(host_seminfo->semusz, &target_seminfo->semusz); in host_to_target_seminfo()
3909 __put_user(host_seminfo->semvmx, &target_seminfo->semvmx); in host_to_target_seminfo()
3910 __put_user(host_seminfo->semaem, &target_seminfo->semaem); in host_to_target_seminfo()
3941 if (ret == -1) in target_to_host_semarray()
3948 return -TARGET_ENOMEM; in target_to_host_semarray()
3954 return -TARGET_EFAULT; in target_to_host_semarray()
3977 if (ret == -1) in host_to_target_semarray()
3985 return -TARGET_EFAULT; in host_to_target_semarray()
4004 abi_long ret = -TARGET_EINVAL; in do_semctl()
4011 /* In 64 bit cross-endian situations, we will erroneously pick up in do_semctl()
4013 * this, the entire 8-byte structure is byteswapped, followed by in do_semctl()
4082 return -TARGET_EFAULT; in target_to_host_sembuf()
4123 return -TARGET_EFAULT; in do_semtimedop()
4127 return -TARGET_EFAULT; in do_semtimedop()
4133 return -TARGET_E2BIG; in do_semtimedop()
4140 return -TARGET_EFAULT; in do_semtimedop()
4143 ret = -TARGET_ENOSYS; in do_semtimedop()
4148 if (ret == -TARGET_ENOSYS) { in do_semtimedop()
4188 return -TARGET_EFAULT; in target_to_host_msqid_ds()
4189 if (target_to_host_ipc_perm(&(host_md->msg_perm),target_addr)) in target_to_host_msqid_ds()
4190 return -TARGET_EFAULT; in target_to_host_msqid_ds()
4191 host_md->msg_stime = tswapal(target_md->msg_stime); in target_to_host_msqid_ds()
4192 host_md->msg_rtime = tswapal(target_md->msg_rtime); in target_to_host_msqid_ds()
4193 host_md->msg_ctime = tswapal(target_md->msg_ctime); in target_to_host_msqid_ds()
4194 host_md->__msg_cbytes = tswapal(target_md->__msg_cbytes); in target_to_host_msqid_ds()
4195 host_md->msg_qnum = tswapal(target_md->msg_qnum); in target_to_host_msqid_ds()
4196 host_md->msg_qbytes = tswapal(target_md->msg_qbytes); in target_to_host_msqid_ds()
4197 host_md->msg_lspid = tswapal(target_md->msg_lspid); in target_to_host_msqid_ds()
4198 host_md->msg_lrpid = tswapal(target_md->msg_lrpid); in target_to_host_msqid_ds()
4209 return -TARGET_EFAULT; in host_to_target_msqid_ds()
4210 if (host_to_target_ipc_perm(target_addr,&(host_md->msg_perm))) in host_to_target_msqid_ds()
4211 return -TARGET_EFAULT; in host_to_target_msqid_ds()
4212 target_md->msg_stime = tswapal(host_md->msg_stime); in host_to_target_msqid_ds()
4213 target_md->msg_rtime = tswapal(host_md->msg_rtime); in host_to_target_msqid_ds()
4214 target_md->msg_ctime = tswapal(host_md->msg_ctime); in host_to_target_msqid_ds()
4215 target_md->__msg_cbytes = tswapal(host_md->__msg_cbytes); in host_to_target_msqid_ds()
4216 target_md->msg_qnum = tswapal(host_md->msg_qnum); in host_to_target_msqid_ds()
4217 target_md->msg_qbytes = tswapal(host_md->msg_qbytes); in host_to_target_msqid_ds()
4218 target_md->msg_lspid = tswapal(host_md->msg_lspid); in host_to_target_msqid_ds()
4219 target_md->msg_lrpid = tswapal(host_md->msg_lrpid); in host_to_target_msqid_ds()
4240 return -TARGET_EFAULT; in host_to_target_msginfo()
4241 __put_user(host_msginfo->msgpool, &target_msginfo->msgpool); in host_to_target_msginfo()
4242 __put_user(host_msginfo->msgmap, &target_msginfo->msgmap); in host_to_target_msginfo()
4243 __put_user(host_msginfo->msgmax, &target_msginfo->msgmax); in host_to_target_msginfo()
4244 __put_user(host_msginfo->msgmnb, &target_msginfo->msgmnb); in host_to_target_msginfo()
4245 __put_user(host_msginfo->msgmni, &target_msginfo->msgmni); in host_to_target_msginfo()
4246 __put_user(host_msginfo->msgssz, &target_msginfo->msgssz); in host_to_target_msginfo()
4247 __put_user(host_msginfo->msgtql, &target_msginfo->msgtql); in host_to_target_msginfo()
4248 __put_user(host_msginfo->msgseg, &target_msginfo->msgseg); in host_to_target_msginfo()
4257 abi_long ret = -TARGET_EINVAL; in do_msgctl()
4266 return -TARGET_EFAULT; in do_msgctl()
4269 return -TARGET_EFAULT; in do_msgctl()
4278 return -TARGET_EFAULT; in do_msgctl()
4298 return -TARGET_EINVAL; in do_msgsnd()
4302 return -TARGET_EFAULT; in do_msgsnd()
4306 return -TARGET_ENOMEM; in do_msgsnd()
4308 host_mb->mtype = (abi_long) tswapal(target_mb->mtype); in do_msgsnd()
4309 memcpy(host_mb->mtext, target_mb->mtext, msgsz); in do_msgsnd()
4310 ret = -TARGET_ENOSYS; in do_msgsnd()
4315 if (ret == -TARGET_ENOSYS) { in do_msgsnd()
4355 return -TARGET_EINVAL; in do_msgrcv()
4359 return -TARGET_EFAULT; in do_msgrcv()
4363 ret = -TARGET_ENOMEM; in do_msgrcv()
4366 ret = -TARGET_ENOSYS; in do_msgrcv()
4371 if (ret == -TARGET_ENOSYS) { in do_msgrcv()
4381 ret = -TARGET_EFAULT; in do_msgrcv()
4384 memcpy(target_mb->mtext, host_mb->mtext, ret); in do_msgrcv()
4388 target_mb->mtype = tswapal(host_mb->mtype); in do_msgrcv()
4403 return -TARGET_EFAULT; in target_to_host_shmid_ds()
4404 if (target_to_host_ipc_perm(&(host_sd->shm_perm), target_addr)) in target_to_host_shmid_ds()
4405 return -TARGET_EFAULT; in target_to_host_shmid_ds()
4406 __get_user(host_sd->shm_segsz, &target_sd->shm_segsz); in target_to_host_shmid_ds()
4407 __get_user(host_sd->shm_atime, &target_sd->shm_atime); in target_to_host_shmid_ds()
4408 __get_user(host_sd->shm_dtime, &target_sd->shm_dtime); in target_to_host_shmid_ds()
4409 __get_user(host_sd->shm_ctime, &target_sd->shm_ctime); in target_to_host_shmid_ds()
4410 __get_user(host_sd->shm_cpid, &target_sd->shm_cpid); in target_to_host_shmid_ds()
4411 __get_user(host_sd->shm_lpid, &target_sd->shm_lpid); in target_to_host_shmid_ds()
4412 __get_user(host_sd->shm_nattch, &target_sd->shm_nattch); in target_to_host_shmid_ds()
4423 return -TARGET_EFAULT; in host_to_target_shmid_ds()
4424 if (host_to_target_ipc_perm(target_addr, &(host_sd->shm_perm))) in host_to_target_shmid_ds()
4425 return -TARGET_EFAULT; in host_to_target_shmid_ds()
4426 __put_user(host_sd->shm_segsz, &target_sd->shm_segsz); in host_to_target_shmid_ds()
4427 __put_user(host_sd->shm_atime, &target_sd->shm_atime); in host_to_target_shmid_ds()
4428 __put_user(host_sd->shm_dtime, &target_sd->shm_dtime); in host_to_target_shmid_ds()
4429 __put_user(host_sd->shm_ctime, &target_sd->shm_ctime); in host_to_target_shmid_ds()
4430 __put_user(host_sd->shm_cpid, &target_sd->shm_cpid); in host_to_target_shmid_ds()
4431 __put_user(host_sd->shm_lpid, &target_sd->shm_lpid); in host_to_target_shmid_ds()
4432 __put_user(host_sd->shm_nattch, &target_sd->shm_nattch); in host_to_target_shmid_ds()
4450 return -TARGET_EFAULT; in host_to_target_shminfo()
4451 __put_user(host_shminfo->shmmax, &target_shminfo->shmmax); in host_to_target_shminfo()
4452 __put_user(host_shminfo->shmmin, &target_shminfo->shmmin); in host_to_target_shminfo()
4453 __put_user(host_shminfo->shmmni, &target_shminfo->shmmni); in host_to_target_shminfo()
4454 __put_user(host_shminfo->shmseg, &target_shminfo->shmseg); in host_to_target_shminfo()
4455 __put_user(host_shminfo->shmall, &target_shminfo->shmall); in host_to_target_shminfo()
4474 return -TARGET_EFAULT; in host_to_target_shm_info()
4475 __put_user(host_shm_info->used_ids, &target_shm_info->used_ids); in host_to_target_shm_info()
4476 __put_user(host_shm_info->shm_tot, &target_shm_info->shm_tot); in host_to_target_shm_info()
4477 __put_user(host_shm_info->shm_rss, &target_shm_info->shm_rss); in host_to_target_shm_info()
4478 __put_user(host_shm_info->shm_swp, &target_shm_info->shm_swp); in host_to_target_shm_info()
4479 __put_user(host_shm_info->swap_attempts, &target_shm_info->swap_attempts); in host_to_target_shm_info()
4480 __put_user(host_shm_info->swap_successes, &target_shm_info->swap_successes); in host_to_target_shm_info()
4490 abi_long ret = -TARGET_EINVAL; in do_shmctl()
4499 return -TARGET_EFAULT; in do_shmctl()
4502 return -TARGET_EFAULT; in do_shmctl()
4507 return -TARGET_EFAULT; in do_shmctl()
4512 return -TARGET_EFAULT; in do_shmctl()
4591 ret = -TARGET_EFAULT; in do_ipc()
4595 ret = do_msgrcv(first, tswapal(tmp->msgp), second, tswapal(tmp->msgtyp), third); in do_ipc()
4614 return -TARGET_EFAULT; in do_ipc()
4618 ret = -TARGET_EINVAL; in do_ipc()
4638 ret = -TARGET_ENOSYS; in do_ipc()
4669 #define FIEMAP_MAX_EXTENTS ((UINT_MAX - sizeof(struct fiemap)) \
4677 * in fiemap->fm_extent_count. The array is filled in by the in do_ioctl_fs_ioc_fiemap()
4682 const argtype *arg_type = ie->arg_type; in do_ioctl_fs_ioc_fiemap()
4691 assert(ie->access == IOC_RW); in do_ioctl_fs_ioc_fiemap()
4696 return -TARGET_EFAULT; in do_ioctl_fs_ioc_fiemap()
4701 if (fm->fm_extent_count > FIEMAP_MAX_EXTENTS) { in do_ioctl_fs_ioc_fiemap()
4702 return -TARGET_EINVAL; in do_ioctl_fs_ioc_fiemap()
4706 (sizeof(struct fiemap_extent) * fm->fm_extent_count); in do_ioctl_fs_ioc_fiemap()
4714 return -TARGET_ENOMEM; in do_ioctl_fs_ioc_fiemap()
4719 ret = get_errno(safe_ioctl(fd, ie->host_cmd, fm)); in do_ioctl_fs_ioc_fiemap()
4725 if (fm->fm_extent_count != 0) { in do_ioctl_fs_ioc_fiemap()
4726 target_size_out += fm->fm_mapped_extents * extent_size; in do_ioctl_fs_ioc_fiemap()
4730 ret = -TARGET_EFAULT; in do_ioctl_fs_ioc_fiemap()
4734 if (fm->fm_extent_count != 0) { in do_ioctl_fs_ioc_fiemap()
4737 for (i = 0; i < fm->fm_mapped_extents; i++) { in do_ioctl_fs_ioc_fiemap()
4738 thunk_convert(p, &fm->fm_extents[i], extent_arg_type, in do_ioctl_fs_ioc_fiemap()
4756 const argtype *arg_type = ie->arg_type; in do_ioctl_ifconf()
4774 assert(ie->access == IOC_RW); in do_ioctl_ifconf()
4781 return -TARGET_EFAULT; in do_ioctl_ifconf()
4786 target_ifc_buf = (abi_long)(unsigned long)host_ifconf->ifc_buf; in do_ioctl_ifconf()
4790 target_ifc_len = host_ifconf->ifc_len; in do_ioctl_ifconf()
4802 return -TARGET_ENOMEM; in do_ioctl_ifconf()
4809 host_ifconf->ifc_len = host_ifc_len; in do_ioctl_ifconf()
4813 host_ifconf->ifc_buf = host_ifc_buf; in do_ioctl_ifconf()
4815 ret = get_errno(safe_ioctl(fd, ie->host_cmd, host_ifconf)); in do_ioctl_ifconf()
4819 nb_ifreq = host_ifconf->ifc_len / sizeof(struct ifreq); in do_ioctl_ifconf()
4821 host_ifconf->ifc_len = target_ifc_len; in do_ioctl_ifconf()
4825 host_ifconf->ifc_buf = (char *)(unsigned long)target_ifc_buf; in do_ioctl_ifconf()
4831 return -TARGET_EFAULT; in do_ioctl_ifconf()
4909 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl_usbdevfs_reapurb()
4915 lurb = (void *)((uintptr_t)hurb - offsetof(struct live_urb, host_urb)); in do_ioctl_usbdevfs_reapurb()
4916 if (!lurb->target_urb_adr) { in do_ioctl_usbdevfs_reapurb()
4917 return -TARGET_EFAULT; in do_ioctl_usbdevfs_reapurb()
4920 unlock_user(lurb->target_buf_ptr, lurb->target_buf_adr, in do_ioctl_usbdevfs_reapurb()
4921 lurb->host_urb.buffer_length); in do_ioctl_usbdevfs_reapurb()
4922 lurb->target_buf_ptr = NULL; in do_ioctl_usbdevfs_reapurb()
4925 lurb->host_urb.buffer = (void *)(uintptr_t)lurb->target_buf_adr; in do_ioctl_usbdevfs_reapurb()
4928 argptr = lock_user(VERIFY_WRITE, lurb->target_urb_adr, target_size, 0); in do_ioctl_usbdevfs_reapurb()
4931 return -TARGET_EFAULT; in do_ioctl_usbdevfs_reapurb()
4933 thunk_convert(argptr, &lurb->host_urb, usbfsurb_arg_type, THUNK_TARGET); in do_ioctl_usbdevfs_reapurb()
4934 unlock_user(argptr, lurb->target_urb_adr, target_size); in do_ioctl_usbdevfs_reapurb()
4941 return -TARGET_EFAULT; in do_ioctl_usbdevfs_reapurb()
4944 /* GHashTable uses 64-bit keys but thunk_convert expects uintptr_t */ in do_ioctl_usbdevfs_reapurb()
4945 target_urb_adr = lurb->target_urb_adr; in do_ioctl_usbdevfs_reapurb()
4963 return -TARGET_EFAULT; in do_ioctl_usbdevfs_discardurb()
4965 return get_errno(safe_ioctl(fd, ie->host_cmd, &lurb->host_urb)); in do_ioctl_usbdevfs_discardurb()
4972 const argtype *arg_type = ie->arg_type; in do_ioctl_usbdevfs_submiturb()
4991 return -TARGET_ENOMEM; in do_ioctl_usbdevfs_submiturb()
4997 return -TARGET_EFAULT; in do_ioctl_usbdevfs_submiturb()
4999 thunk_convert(&lurb->host_urb, argptr, arg_type, THUNK_HOST); in do_ioctl_usbdevfs_submiturb()
5002 lurb->target_urb_adr = arg; in do_ioctl_usbdevfs_submiturb()
5003 lurb->target_buf_adr = (uintptr_t)lurb->host_urb.buffer; in do_ioctl_usbdevfs_submiturb()
5007 rw_dir = lurb->host_urb.endpoint & USB_DIR_IN ? VERIFY_WRITE : VERIFY_READ; in do_ioctl_usbdevfs_submiturb()
5008 lurb->target_buf_ptr = lock_user(rw_dir, lurb->target_buf_adr, in do_ioctl_usbdevfs_submiturb()
5009 lurb->host_urb.buffer_length, 1); in do_ioctl_usbdevfs_submiturb()
5010 if (lurb->target_buf_ptr == NULL) { in do_ioctl_usbdevfs_submiturb()
5012 return -TARGET_EFAULT; in do_ioctl_usbdevfs_submiturb()
5016 lurb->host_urb.buffer = lurb->target_buf_ptr; in do_ioctl_usbdevfs_submiturb()
5018 ret = get_errno(safe_ioctl(fd, ie->host_cmd, &lurb->host_urb)); in do_ioctl_usbdevfs_submiturb()
5020 unlock_user(lurb->target_buf_ptr, lurb->target_buf_adr, 0); in do_ioctl_usbdevfs_submiturb()
5038 const argtype *arg_type = ie->arg_type; in do_ioctl_dm()
5047 ret = -TARGET_EFAULT; in do_ioctl_dm()
5054 big_buf = g_malloc0(((struct dm_ioctl*)buf_temp)->data_size * 2); in do_ioctl_dm()
5059 guest_data = arg + host_dm->data_start; in do_ioctl_dm()
5060 if ((guest_data - arg) < 0) { in do_ioctl_dm()
5061 ret = -TARGET_EINVAL; in do_ioctl_dm()
5064 guest_data_size = host_dm->data_size - host_dm->data_start; in do_ioctl_dm()
5065 host_data = (char*)host_dm + host_dm->data_start; in do_ioctl_dm()
5069 ret = -TARGET_EFAULT; in do_ioctl_dm()
5073 switch (ie->host_cmd) { in do_ioctl_dm()
5104 for (i = 0; i < host_dm->target_count; i++) { in do_ioctl_dm()
5111 next = spec->next; in do_ioctl_dm()
5112 spec->next = sizeof(*spec) + slen; in do_ioctl_dm()
5115 cur_data += spec->next; in do_ioctl_dm()
5120 ret = -TARGET_EINVAL; in do_ioctl_dm()
5126 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl_dm()
5128 guest_data = arg + host_dm->data_start; in do_ioctl_dm()
5129 guest_data_size = host_dm->data_size - host_dm->data_start; in do_ioctl_dm()
5131 switch (ie->host_cmd) { in do_ioctl_dm()
5146 struct dm_name_list *nl = (void*)host_dm + host_dm->data_start; in do_ioctl_dm()
5153 uint32_t next = nl->next; in do_ioctl_dm()
5155 nl->next = nl_size + (strlen(nl->name) + 1); in do_ioctl_dm()
5157 if (remaining_data < nl->next) { in do_ioctl_dm()
5158 host_dm->flags |= DM_BUFFER_FULL_FLAG; in do_ioctl_dm()
5162 strcpy(cur_data + nl_size, nl->name); in do_ioctl_dm()
5163 cur_data += nl->next; in do_ioctl_dm()
5164 remaining_data -= nl->next; in do_ioctl_dm()
5175 struct dm_target_spec *spec = (void*)host_dm + host_dm->data_start; in do_ioctl_dm()
5181 for (i = 0; i < host_dm->target_count; i++) { in do_ioctl_dm()
5182 uint32_t next = spec->next; in do_ioctl_dm()
5184 spec->next = (cur_data - argptr) + spec_size + slen; in do_ioctl_dm()
5185 if (guest_data_size < spec->next) { in do_ioctl_dm()
5186 host_dm->flags |= DM_BUFFER_FULL_FLAG; in do_ioctl_dm()
5191 cur_data = argptr + spec->next; in do_ioctl_dm()
5192 spec = (void*)host_dm + host_dm->data_start + next; in do_ioctl_dm()
5198 void *hdata = (void*)host_dm + host_dm->data_start; in do_ioctl_dm()
5214 struct dm_target_versions *vers = (void*)host_dm + host_dm->data_start; in do_ioctl_dm()
5221 uint32_t next = vers->next; in do_ioctl_dm()
5223 vers->next = vers_size + (strlen(vers->name) + 1); in do_ioctl_dm()
5225 if (remaining_data < vers->next) { in do_ioctl_dm()
5226 host_dm->flags |= DM_BUFFER_FULL_FLAG; in do_ioctl_dm()
5230 strcpy(cur_data + vers_size, vers->name); in do_ioctl_dm()
5231 cur_data += vers->next; in do_ioctl_dm()
5232 remaining_data -= vers->next; in do_ioctl_dm()
5242 ret = -TARGET_EINVAL; in do_ioctl_dm()
5249 ret = -TARGET_EFAULT; in do_ioctl_dm()
5265 const argtype *arg_type = ie->arg_type; in do_ioctl_blkpg()
5277 ret = -TARGET_EFAULT; in do_ioctl_blkpg()
5283 switch (host_blkpg->op) { in do_ioctl_blkpg()
5290 ret = -TARGET_EINVAL; in do_ioctl_blkpg()
5294 /* Read and convert blkpg->data */ in do_ioctl_blkpg()
5295 arg = (abi_long)(uintptr_t)host_blkpg->data; in do_ioctl_blkpg()
5299 ret = -TARGET_EFAULT; in do_ioctl_blkpg()
5306 host_blkpg->data = &host_part; in do_ioctl_blkpg()
5307 ret = get_errno(safe_ioctl(fd, ie->host_cmd, host_blkpg)); in do_ioctl_blkpg()
5316 const argtype *arg_type = ie->arg_type; in do_ioctl_rt()
5327 assert(ie->access == IOC_W); in do_ioctl_rt()
5334 return -TARGET_EFAULT; in do_ioctl_rt()
5339 assert(se->convert[0] == NULL); in do_ioctl_rt()
5341 field_types = se->field_types; in do_ioctl_rt()
5342 dst_offsets = se->field_offsets[THUNK_HOST]; in do_ioctl_rt()
5343 src_offsets = se->field_offsets[THUNK_TARGET]; in do_ioctl_rt()
5344 for (i = 0; i < se->nb_fields; i++) { in do_ioctl_rt()
5354 return -TARGET_EFAULT; in do_ioctl_rt()
5368 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl_rt()
5383 return get_errno(safe_ioctl(fd, ie->host_cmd, sig)); in do_ioctl_kdsigaccept()
5399 return -TARGET_EFAULT; in do_ioctl_SIOCGSTAMP()
5403 return -TARGET_EFAULT; in do_ioctl_SIOCGSTAMP()
5423 return -TARGET_EFAULT; in do_ioctl_SIOCGSTAMPNS()
5427 return -TARGET_EFAULT; in do_ioctl_SIOCGSTAMPNS()
5439 return get_errno(safe_ioctl(fd, ie->host_cmd, flags)); in do_ioctl_tiocgptpeer()
5449 unlock_user(host_ver->name, target_ver->name, in unlock_drm_version()
5450 copy ? host_ver->name_len : 0); in unlock_drm_version()
5451 unlock_user(host_ver->date, target_ver->date, in unlock_drm_version()
5452 copy ? host_ver->date_len : 0); in unlock_drm_version()
5453 unlock_user(host_ver->desc, target_ver->desc, in unlock_drm_version()
5454 copy ? host_ver->desc_len : 0); in unlock_drm_version()
5462 __get_user(host_ver->name_len, &target_ver->name_len); in target_to_host_drmversion()
5463 if (host_ver->name_len) { in target_to_host_drmversion()
5464 host_ver->name = lock_user(VERIFY_WRITE, target_ver->name, in target_to_host_drmversion()
5465 target_ver->name_len, 0); in target_to_host_drmversion()
5466 if (!host_ver->name) { in target_to_host_drmversion()
5467 return -EFAULT; in target_to_host_drmversion()
5471 __get_user(host_ver->date_len, &target_ver->date_len); in target_to_host_drmversion()
5472 if (host_ver->date_len) { in target_to_host_drmversion()
5473 host_ver->date = lock_user(VERIFY_WRITE, target_ver->date, in target_to_host_drmversion()
5474 target_ver->date_len, 0); in target_to_host_drmversion()
5475 if (!host_ver->date) { in target_to_host_drmversion()
5480 __get_user(host_ver->desc_len, &target_ver->desc_len); in target_to_host_drmversion()
5481 if (host_ver->desc_len) { in target_to_host_drmversion()
5482 host_ver->desc = lock_user(VERIFY_WRITE, target_ver->desc, in target_to_host_drmversion()
5483 target_ver->desc_len, 0); in target_to_host_drmversion()
5484 if (!host_ver->desc) { in target_to_host_drmversion()
5492 return -EFAULT; in target_to_host_drmversion()
5499 __put_user(host_ver->version_major, &target_ver->version_major); in host_to_target_drmversion()
5500 __put_user(host_ver->version_minor, &target_ver->version_minor); in host_to_target_drmversion()
5501 __put_user(host_ver->version_patchlevel, &target_ver->version_patchlevel); in host_to_target_drmversion()
5502 __put_user(host_ver->name_len, &target_ver->name_len); in host_to_target_drmversion()
5503 __put_user(host_ver->date_len, &target_ver->date_len); in host_to_target_drmversion()
5504 __put_user(host_ver->desc_len, &target_ver->desc_len); in host_to_target_drmversion()
5515 switch (ie->host_cmd) { in do_ioctl_drm()
5518 return -TARGET_EFAULT; in do_ioctl_drm()
5523 ret = get_errno(safe_ioctl(fd, ie->host_cmd, ver)); in do_ioctl_drm()
5533 return -TARGET_ENOSYS; in do_ioctl_drm()
5545 return -TARGET_EFAULT; in do_ioctl_drm_i915_getparam()
5548 __get_user(gparam->param, &target_gparam->param); in do_ioctl_drm_i915_getparam()
5549 gparam->value = &value; in do_ioctl_drm_i915_getparam()
5550 ret = get_errno(safe_ioctl(fd, ie->host_cmd, gparam)); in do_ioctl_drm_i915_getparam()
5551 put_user_s32(value, target_gparam->value); in do_ioctl_drm_i915_getparam()
5560 switch (ie->host_cmd) { in do_ioctl_drm_i915()
5566 return -TARGET_ENOSYS; in do_ioctl_drm_i915()
5579 assert(ie->access == IOC_W); in do_ioctl_TUNSETTXFILTER()
5583 return -TARGET_EFAULT; in do_ioctl_TUNSETTXFILTER()
5585 filter->flags = tswap16(target_filter->flags); in do_ioctl_TUNSETTXFILTER()
5586 filter->count = tswap16(target_filter->count); in do_ioctl_TUNSETTXFILTER()
5589 if (filter->count) { in do_ioctl_TUNSETTXFILTER()
5590 if (offsetof(struct tun_filter, addr) + filter->count * ETH_ALEN > in do_ioctl_TUNSETTXFILTER()
5592 return -TARGET_EFAULT; in do_ioctl_TUNSETTXFILTER()
5597 filter->count * ETH_ALEN, 1); in do_ioctl_TUNSETTXFILTER()
5599 return -TARGET_EFAULT; in do_ioctl_TUNSETTXFILTER()
5601 memcpy(filter->addr, target_addr, filter->count * ETH_ALEN); in do_ioctl_TUNSETTXFILTER()
5605 return get_errno(safe_ioctl(fd, ie->host_cmd, filter)); in do_ioctl_TUNSETTXFILTER()
5632 if (ie->target_cmd == 0) { in do_ioctl()
5635 return -TARGET_ENOTTY; in do_ioctl()
5637 if (ie->target_cmd == cmd) in do_ioctl()
5641 arg_type = ie->arg_type; in do_ioctl()
5642 if (ie->do_ioctl) { in do_ioctl()
5643 return ie->do_ioctl(ie, buf_temp, fd, cmd, arg); in do_ioctl()
5644 } else if (!ie->host_cmd) { in do_ioctl()
5647 return -TARGET_ENOTTY; in do_ioctl()
5653 ret = get_errno(safe_ioctl(fd, ie->host_cmd)); in do_ioctl()
5659 ret = get_errno(safe_ioctl(fd, ie->host_cmd, arg)); in do_ioctl()
5664 switch(ie->access) { in do_ioctl()
5666 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl()
5670 return -TARGET_EFAULT; in do_ioctl()
5678 return -TARGET_EFAULT; in do_ioctl()
5681 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl()
5687 return -TARGET_EFAULT; in do_ioctl()
5690 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl()
5694 return -TARGET_EFAULT; in do_ioctl()
5705 ret = -TARGET_ENOTTY; in do_ioctl()
5814 host->c_iflag = in target_to_host_termios()
5815 target_to_host_bitmask(tswap32(target->c_iflag), iflag_tbl); in target_to_host_termios()
5816 host->c_oflag = in target_to_host_termios()
5817 target_to_host_bitmask(tswap32(target->c_oflag), oflag_tbl); in target_to_host_termios()
5818 host->c_cflag = in target_to_host_termios()
5819 target_to_host_bitmask(tswap32(target->c_cflag), cflag_tbl); in target_to_host_termios()
5820 host->c_lflag = in target_to_host_termios()
5821 target_to_host_bitmask(tswap32(target->c_lflag), lflag_tbl); in target_to_host_termios()
5822 host->c_line = target->c_line; in target_to_host_termios()
5824 memset(host->c_cc, 0, sizeof(host->c_cc)); in target_to_host_termios()
5825 host->c_cc[VINTR] = target->c_cc[TARGET_VINTR]; in target_to_host_termios()
5826 host->c_cc[VQUIT] = target->c_cc[TARGET_VQUIT]; in target_to_host_termios()
5827 host->c_cc[VERASE] = target->c_cc[TARGET_VERASE]; in target_to_host_termios()
5828 host->c_cc[VKILL] = target->c_cc[TARGET_VKILL]; in target_to_host_termios()
5829 host->c_cc[VEOF] = target->c_cc[TARGET_VEOF]; in target_to_host_termios()
5830 host->c_cc[VTIME] = target->c_cc[TARGET_VTIME]; in target_to_host_termios()
5831 host->c_cc[VMIN] = target->c_cc[TARGET_VMIN]; in target_to_host_termios()
5832 host->c_cc[VSWTC] = target->c_cc[TARGET_VSWTC]; in target_to_host_termios()
5833 host->c_cc[VSTART] = target->c_cc[TARGET_VSTART]; in target_to_host_termios()
5834 host->c_cc[VSTOP] = target->c_cc[TARGET_VSTOP]; in target_to_host_termios()
5835 host->c_cc[VSUSP] = target->c_cc[TARGET_VSUSP]; in target_to_host_termios()
5836 host->c_cc[VEOL] = target->c_cc[TARGET_VEOL]; in target_to_host_termios()
5837 host->c_cc[VREPRINT] = target->c_cc[TARGET_VREPRINT]; in target_to_host_termios()
5838 host->c_cc[VDISCARD] = target->c_cc[TARGET_VDISCARD]; in target_to_host_termios()
5839 host->c_cc[VWERASE] = target->c_cc[TARGET_VWERASE]; in target_to_host_termios()
5840 host->c_cc[VLNEXT] = target->c_cc[TARGET_VLNEXT]; in target_to_host_termios()
5841 host->c_cc[VEOL2] = target->c_cc[TARGET_VEOL2]; in target_to_host_termios()
5849 target->c_iflag = in host_to_target_termios()
5850 tswap32(host_to_target_bitmask(host->c_iflag, iflag_tbl)); in host_to_target_termios()
5851 target->c_oflag = in host_to_target_termios()
5852 tswap32(host_to_target_bitmask(host->c_oflag, oflag_tbl)); in host_to_target_termios()
5853 target->c_cflag = in host_to_target_termios()
5854 tswap32(host_to_target_bitmask(host->c_cflag, cflag_tbl)); in host_to_target_termios()
5855 target->c_lflag = in host_to_target_termios()
5856 tswap32(host_to_target_bitmask(host->c_lflag, lflag_tbl)); in host_to_target_termios()
5857 target->c_line = host->c_line; in host_to_target_termios()
5859 memset(target->c_cc, 0, sizeof(target->c_cc)); in host_to_target_termios()
5860 target->c_cc[TARGET_VINTR] = host->c_cc[VINTR]; in host_to_target_termios()
5861 target->c_cc[TARGET_VQUIT] = host->c_cc[VQUIT]; in host_to_target_termios()
5862 target->c_cc[TARGET_VERASE] = host->c_cc[VERASE]; in host_to_target_termios()
5863 target->c_cc[TARGET_VKILL] = host->c_cc[VKILL]; in host_to_target_termios()
5864 target->c_cc[TARGET_VEOF] = host->c_cc[VEOF]; in host_to_target_termios()
5865 target->c_cc[TARGET_VTIME] = host->c_cc[VTIME]; in host_to_target_termios()
5866 target->c_cc[TARGET_VMIN] = host->c_cc[VMIN]; in host_to_target_termios()
5867 target->c_cc[TARGET_VSWTC] = host->c_cc[VSWTC]; in host_to_target_termios()
5868 target->c_cc[TARGET_VSTART] = host->c_cc[VSTART]; in host_to_target_termios()
5869 target->c_cc[TARGET_VSTOP] = host->c_cc[VSTOP]; in host_to_target_termios()
5870 target->c_cc[TARGET_VSUSP] = host->c_cc[VSUSP]; in host_to_target_termios()
5871 target->c_cc[TARGET_VEOL] = host->c_cc[VEOL]; in host_to_target_termios()
5872 target->c_cc[TARGET_VREPRINT] = host->c_cc[VREPRINT]; in host_to_target_termios()
5873 target->c_cc[TARGET_VDISCARD] = host->c_cc[VDISCARD]; in host_to_target_termios()
5874 target->c_cc[TARGET_VWERASE] = host->c_cc[VWERASE]; in host_to_target_termios()
5875 target->c_cc[TARGET_VLNEXT] = host->c_cc[VLNEXT]; in host_to_target_termios()
5876 target->c_cc[TARGET_VEOL2] = host->c_cc[VEOL2]; in host_to_target_termios()
5974 return -TARGET_EOPNOTSUPP; in do_mmap()
5982 return -TARGET_EINVAL; in do_mmap()
6010 return -TARGET_EFAULT; in read_ldt()
6028 return -TARGET_EINVAL; in write_ldt()
6030 return -TARGET_EFAULT; in write_ldt()
6031 ldt_info.entry_number = tswap32(target_ldt_info->entry_number); in write_ldt()
6032 ldt_info.base_addr = tswapal(target_ldt_info->base_addr); in write_ldt()
6033 ldt_info.limit = tswap32(target_ldt_info->limit); in write_ldt()
6034 ldt_info.flags = tswap32(target_ldt_info->flags); in write_ldt()
6038 return -TARGET_EINVAL; in write_ldt()
6052 return -TARGET_EINVAL; in write_ldt()
6054 return -TARGET_EINVAL; in write_ldt()
6058 env->ldt.base = target_mmap(0, in write_ldt()
6061 MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); in write_ldt()
6062 if (env->ldt.base == -1) in write_ldt()
6063 return -TARGET_ENOMEM; in write_ldt()
6064 memset(g2h_untagged(env->ldt.base), 0, in write_ldt()
6066 env->ldt.limit = 0xffff; in write_ldt()
6067 ldt_table = g2h_untagged(env->ldt.base); in write_ldt()
6109 /* specific and weird i386 syscalls */
6126 ret = -TARGET_ENOSYS; in do_modify_ldt()
6135 uint64_t *gdt_table = g2h_untagged(env->gdt.base); in do_set_thread_area()
6145 return -TARGET_EFAULT; in do_set_thread_area()
6146 ldt_info.entry_number = tswap32(target_ldt_info->entry_number); in do_set_thread_area()
6147 ldt_info.base_addr = tswapal(target_ldt_info->base_addr); in do_set_thread_area()
6148 ldt_info.limit = tswap32(target_ldt_info->limit); in do_set_thread_area()
6149 ldt_info.flags = tswap32(target_ldt_info->flags); in do_set_thread_area()
6150 if (ldt_info.entry_number == -1) { in do_set_thread_area()
6154 target_ldt_info->entry_number = tswap32(i); in do_set_thread_area()
6163 return -TARGET_EINVAL; in do_set_thread_area()
6178 return -TARGET_EINVAL; in do_set_thread_area()
6221 uint64_t *gdt_table = g2h_untagged(env->gdt.base); in do_get_thread_area()
6229 return -TARGET_EFAULT; in do_get_thread_area()
6230 idx = tswap32(target_ldt_info->entry_number); in do_get_thread_area()
6234 return -TARGET_EINVAL; in do_get_thread_area()
6258 target_ldt_info->base_addr = tswapal(base_addr); in do_get_thread_area()
6259 target_ldt_info->limit = tswap32(limit); in do_get_thread_area()
6260 target_ldt_info->flags = tswap32(flags); in do_get_thread_area()
6267 return -TARGET_ENOSYS; in do_arch_prctl()
6284 env->segs[idx].base = addr; in do_arch_prctl()
6292 val = env->segs[idx].base; in do_arch_prctl()
6294 ret = -TARGET_EFAULT; in do_arch_prctl()
6297 ret = -TARGET_EINVAL; in do_arch_prctl()
6355 return -TARGET_EINVAL; in do_prctl_inval0()
6360 return -TARGET_EINVAL; in do_prctl_inval1()
6410 return -TARGET_EFAULT; in do_prctl()
6421 return -TARGET_EFAULT; in do_prctl()
6432 return -TARGET_EFAULT; in do_prctl()
6453 return -TARGET_EINVAL; in do_prctl()
6458 return -TARGET_EINVAL; in do_prctl()
6463 return -TARGET_EINVAL; in do_prctl()
6503 return -TARGET_EFAULT; in do_prctl()
6511 return put_user_ual(ts->child_tidptr, arg2); in do_prctl()
6517 return -TARGET_EINVAL; in do_prctl()
6532 return -TARGET_EINVAL; in do_prctl()
6537 return -TARGET_EINVAL; in do_prctl()
6565 env = info->env; in clone_func()
6569 info->tid = sys_gettid(); in clone_func()
6571 if (info->child_tidptr) in clone_func()
6572 put_user_u32(info->tid, info->child_tidptr); in clone_func()
6573 if (info->parent_tidptr) in clone_func()
6574 put_user_u32(info->tid, info->parent_tidptr); in clone_func()
6575 qemu_guest_random_seed_thread_part2(cpu->random_seed); in clone_func()
6577 sigprocmask(SIG_SETMASK, &info->sigmask, NULL); in clone_func()
6579 pthread_mutex_lock(&info->mutex); in clone_func()
6580 pthread_cond_broadcast(&info->cond); in clone_func()
6581 pthread_mutex_unlock(&info->mutex); in clone_func()
6616 return -TARGET_EINVAL; in do_fork()
6641 new_cpu->opaque = ts; in do_fork()
6642 ts->bprm = parent_ts->bprm; in do_fork()
6643 ts->info = parent_ts->info; in do_fork()
6644 ts->signal_mask = parent_ts->signal_mask; in do_fork()
6647 ts->child_tidptr = child_tidptr; in do_fork()
6673 cpu->random_seed = qemu_guest_random_seed_thread_part1(); in do_fork()
6685 ret = -1; in do_fork()
6694 return -TARGET_EINVAL; in do_fork()
6699 return -TARGET_EINVAL; in do_fork()
6704 return -TARGET_EINVAL; in do_fork()
6710 return -TARGET_EINVAL; in do_fork()
6714 return -QEMU_ERESTARTSYS; in do_fork()
6737 ts->child_tidptr = child_tidptr; in do_fork()
6850 ret = -TARGET_EINVAL; in target_to_host_fcntl_cmd()
6861 ret -= F_GETLK - 5; in target_to_host_fcntl_cmd()
6880 return -TARGET_EINVAL; in target_to_host_flock()
6889 * from the host we copy to the target field as-is in host_to_target_flock()
6901 return -TARGET_EFAULT; in copy_from_user_flock()
6904 __get_user(l_type, &target_fl->l_type); in copy_from_user_flock()
6909 fl->l_type = l_type; in copy_from_user_flock()
6910 __get_user(fl->l_whence, &target_fl->l_whence); in copy_from_user_flock()
6911 __get_user(fl->l_start, &target_fl->l_start); in copy_from_user_flock()
6912 __get_user(fl->l_len, &target_fl->l_len); in copy_from_user_flock()
6913 __get_user(fl->l_pid, &target_fl->l_pid); in copy_from_user_flock()
6925 return -TARGET_EFAULT; in copy_to_user_flock()
6928 l_type = host_to_target_flock(fl->l_type); in copy_to_user_flock()
6929 __put_user(l_type, &target_fl->l_type); in copy_to_user_flock()
6930 __put_user(fl->l_whence, &target_fl->l_whence); in copy_to_user_flock()
6931 __put_user(fl->l_start, &target_fl->l_start); in copy_to_user_flock()
6932 __put_user(fl->l_len, &target_fl->l_len); in copy_to_user_flock()
6933 __put_user(fl->l_pid, &target_fl->l_pid); in copy_to_user_flock()
6957 return -TARGET_EFAULT; in copy_from_user_oabi_flock64()
6960 __get_user(l_type, &target_fl->l_type); in copy_from_user_oabi_flock64()
6965 fl->l_type = l_type; in copy_from_user_oabi_flock64()
6966 __get_user(fl->l_whence, &target_fl->l_whence); in copy_from_user_oabi_flock64()
6967 __get_user(fl->l_start, &target_fl->l_start); in copy_from_user_oabi_flock64()
6968 __get_user(fl->l_len, &target_fl->l_len); in copy_from_user_oabi_flock64()
6969 __get_user(fl->l_pid, &target_fl->l_pid); in copy_from_user_oabi_flock64()
6981 return -TARGET_EFAULT; in copy_to_user_oabi_flock64()
6984 l_type = host_to_target_flock(fl->l_type); in copy_to_user_oabi_flock64()
6985 __put_user(l_type, &target_fl->l_type); in copy_to_user_oabi_flock64()
6986 __put_user(fl->l_whence, &target_fl->l_whence); in copy_to_user_oabi_flock64()
6987 __put_user(fl->l_start, &target_fl->l_start); in copy_to_user_oabi_flock64()
6988 __put_user(fl->l_len, &target_fl->l_len); in copy_to_user_oabi_flock64()
6989 __put_user(fl->l_pid, &target_fl->l_pid); in copy_to_user_oabi_flock64()
7002 return -TARGET_EFAULT; in copy_from_user_flock64()
7005 __get_user(l_type, &target_fl->l_type); in copy_from_user_flock64()
7010 fl->l_type = l_type; in copy_from_user_flock64()
7011 __get_user(fl->l_whence, &target_fl->l_whence); in copy_from_user_flock64()
7012 __get_user(fl->l_start, &target_fl->l_start); in copy_from_user_flock64()
7013 __get_user(fl->l_len, &target_fl->l_len); in copy_from_user_flock64()
7014 __get_user(fl->l_pid, &target_fl->l_pid); in copy_from_user_flock64()
7026 return -TARGET_EFAULT; in copy_to_user_flock64()
7029 l_type = host_to_target_flock(fl->l_type); in copy_to_user_flock64()
7030 __put_user(l_type, &target_fl->l_type); in copy_to_user_flock64()
7031 __put_user(fl->l_whence, &target_fl->l_whence); in copy_to_user_flock64()
7032 __put_user(fl->l_start, &target_fl->l_start); in copy_to_user_flock64()
7033 __put_user(fl->l_len, &target_fl->l_len); in copy_to_user_flock64()
7034 __put_user(fl->l_pid, &target_fl->l_pid); in copy_to_user_flock64()
7049 if (host_cmd == -TARGET_EINVAL) in do_fcntl()
7099 /* tell 32-bit guests it uses largefile on 64-bit hosts: */ in do_fcntl()
7117 return -TARGET_EFAULT; in do_fcntl()
7118 target_fox->type = tswap32(fox.type); in do_fcntl()
7119 target_fox->pid = tswap32(fox.pid); in do_fcntl()
7128 return -TARGET_EFAULT; in do_fcntl()
7129 fox.type = tswap32(target_fox->type); in do_fcntl()
7130 fox.pid = tswap32(target_fox->pid); in do_fcntl()
7182 if ((int16_t)uid == -1) in low2highuid()
7183 return -1; in low2highuid()
7190 if ((int16_t)gid == -1) in low2highgid()
7191 return -1; in low2highgid()
7229 * implement the Linux system call semantics of "change only for this thread",
7232 * We use the 32-bit version of the syscalls if present; if it is not
7233 * then either the host architecture supports 32-bit UIDs natively with
7234 * the standard syscall, or the 16-bit UID is the best we can do.
7297 while (ie->target_cmd != 0) { in syscall_init()
7298 if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) == in syscall_init()
7300 arg_type = ie->arg_type; in syscall_init()
7303 ie->target_cmd); in syscall_init()
7308 ie->target_cmd = (ie->target_cmd & in syscall_init()
7316 if (unlikely(ie->target_cmd != ie->host_cmd)) { in syscall_init()
7318 ie->name, ie->target_cmd, ie->host_cmd); in syscall_init()
7358 if (target_to_host_timespec(&host_its->it_interval, target_addr + in target_to_host_itimerspec()
7361 target_to_host_timespec(&host_its->it_value, target_addr + in target_to_host_itimerspec()
7364 return -TARGET_EFAULT; in target_to_host_itimerspec()
7376 if (target_to_host_timespec64(&host_its->it_interval, target_addr + in target_to_host_itimerspec64()
7379 target_to_host_timespec64(&host_its->it_value, target_addr + in target_to_host_itimerspec64()
7382 return -TARGET_EFAULT; in target_to_host_itimerspec64()
7397 &host_its->it_interval) || in host_to_target_itimerspec()
7400 &host_its->it_value)) { in host_to_target_itimerspec()
7401 return -TARGET_EFAULT; in host_to_target_itimerspec()
7416 &host_its->it_interval) || in host_to_target_itimerspec64()
7420 &host_its->it_value)) { in host_to_target_itimerspec64()
7421 return -TARGET_EFAULT; in host_to_target_itimerspec64()
7435 return -TARGET_EFAULT; in target_to_host_timex()
7438 __get_user(host_tx->modes, &target_tx->modes); in target_to_host_timex()
7439 __get_user(host_tx->offset, &target_tx->offset); in target_to_host_timex()
7440 __get_user(host_tx->freq, &target_tx->freq); in target_to_host_timex()
7441 __get_user(host_tx->maxerror, &target_tx->maxerror); in target_to_host_timex()
7442 __get_user(host_tx->esterror, &target_tx->esterror); in target_to_host_timex()
7443 __get_user(host_tx->status, &target_tx->status); in target_to_host_timex()
7444 __get_user(host_tx->constant, &target_tx->constant); in target_to_host_timex()
7445 __get_user(host_tx->precision, &target_tx->precision); in target_to_host_timex()
7446 __get_user(host_tx->tolerance, &target_tx->tolerance); in target_to_host_timex()
7447 __get_user(host_tx->time.tv_sec, &target_tx->time.tv_sec); in target_to_host_timex()
7448 __get_user(host_tx->time.tv_usec, &target_tx->time.tv_usec); in target_to_host_timex()
7449 __get_user(host_tx->tick, &target_tx->tick); in target_to_host_timex()
7450 __get_user(host_tx->ppsfreq, &target_tx->ppsfreq); in target_to_host_timex()
7451 __get_user(host_tx->jitter, &target_tx->jitter); in target_to_host_timex()
7452 __get_user(host_tx->shift, &target_tx->shift); in target_to_host_timex()
7453 __get_user(host_tx->stabil, &target_tx->stabil); in target_to_host_timex()
7454 __get_user(host_tx->jitcnt, &target_tx->jitcnt); in target_to_host_timex()
7455 __get_user(host_tx->calcnt, &target_tx->calcnt); in target_to_host_timex()
7456 __get_user(host_tx->errcnt, &target_tx->errcnt); in target_to_host_timex()
7457 __get_user(host_tx->stbcnt, &target_tx->stbcnt); in target_to_host_timex()
7458 __get_user(host_tx->tai, &target_tx->tai); in target_to_host_timex()
7470 return -TARGET_EFAULT; in host_to_target_timex()
7473 __put_user(host_tx->modes, &target_tx->modes); in host_to_target_timex()
7474 __put_user(host_tx->offset, &target_tx->offset); in host_to_target_timex()
7475 __put_user(host_tx->freq, &target_tx->freq); in host_to_target_timex()
7476 __put_user(host_tx->maxerror, &target_tx->maxerror); in host_to_target_timex()
7477 __put_user(host_tx->esterror, &target_tx->esterror); in host_to_target_timex()
7478 __put_user(host_tx->status, &target_tx->status); in host_to_target_timex()
7479 __put_user(host_tx->constant, &target_tx->constant); in host_to_target_timex()
7480 __put_user(host_tx->precision, &target_tx->precision); in host_to_target_timex()
7481 __put_user(host_tx->tolerance, &target_tx->tolerance); in host_to_target_timex()
7482 __put_user(host_tx->time.tv_sec, &target_tx->time.tv_sec); in host_to_target_timex()
7483 __put_user(host_tx->time.tv_usec, &target_tx->time.tv_usec); in host_to_target_timex()
7484 __put_user(host_tx->tick, &target_tx->tick); in host_to_target_timex()
7485 __put_user(host_tx->ppsfreq, &target_tx->ppsfreq); in host_to_target_timex()
7486 __put_user(host_tx->jitter, &target_tx->jitter); in host_to_target_timex()
7487 __put_user(host_tx->shift, &target_tx->shift); in host_to_target_timex()
7488 __put_user(host_tx->stabil, &target_tx->stabil); in host_to_target_timex()
7489 __put_user(host_tx->jitcnt, &target_tx->jitcnt); in host_to_target_timex()
7490 __put_user(host_tx->calcnt, &target_tx->calcnt); in host_to_target_timex()
7491 __put_user(host_tx->errcnt, &target_tx->errcnt); in host_to_target_timex()
7492 __put_user(host_tx->stbcnt, &target_tx->stbcnt); in host_to_target_timex()
7493 __put_user(host_tx->tai, &target_tx->tai); in host_to_target_timex()
7507 if (copy_from_user_timeval64(&host_tx->time, target_addr + in target_to_host_timex64()
7510 return -TARGET_EFAULT; in target_to_host_timex64()
7514 return -TARGET_EFAULT; in target_to_host_timex64()
7517 __get_user(host_tx->modes, &target_tx->modes); in target_to_host_timex64()
7518 __get_user(host_tx->offset, &target_tx->offset); in target_to_host_timex64()
7519 __get_user(host_tx->freq, &target_tx->freq); in target_to_host_timex64()
7520 __get_user(host_tx->maxerror, &target_tx->maxerror); in target_to_host_timex64()
7521 __get_user(host_tx->esterror, &target_tx->esterror); in target_to_host_timex64()
7522 __get_user(host_tx->status, &target_tx->status); in target_to_host_timex64()
7523 __get_user(host_tx->constant, &target_tx->constant); in target_to_host_timex64()
7524 __get_user(host_tx->precision, &target_tx->precision); in target_to_host_timex64()
7525 __get_user(host_tx->tolerance, &target_tx->tolerance); in target_to_host_timex64()
7526 __get_user(host_tx->tick, &target_tx->tick); in target_to_host_timex64()
7527 __get_user(host_tx->ppsfreq, &target_tx->ppsfreq); in target_to_host_timex64()
7528 __get_user(host_tx->jitter, &target_tx->jitter); in target_to_host_timex64()
7529 __get_user(host_tx->shift, &target_tx->shift); in target_to_host_timex64()
7530 __get_user(host_tx->stabil, &target_tx->stabil); in target_to_host_timex64()
7531 __get_user(host_tx->jitcnt, &target_tx->jitcnt); in target_to_host_timex64()
7532 __get_user(host_tx->calcnt, &target_tx->calcnt); in target_to_host_timex64()
7533 __get_user(host_tx->errcnt, &target_tx->errcnt); in target_to_host_timex64()
7534 __get_user(host_tx->stbcnt, &target_tx->stbcnt); in target_to_host_timex64()
7535 __get_user(host_tx->tai, &target_tx->tai); in target_to_host_timex64()
7548 &host_tx->time)) { in host_to_target_timex64()
7549 return -TARGET_EFAULT; in host_to_target_timex64()
7553 return -TARGET_EFAULT; in host_to_target_timex64()
7556 __put_user(host_tx->modes, &target_tx->modes); in host_to_target_timex64()
7557 __put_user(host_tx->offset, &target_tx->offset); in host_to_target_timex64()
7558 __put_user(host_tx->freq, &target_tx->freq); in host_to_target_timex64()
7559 __put_user(host_tx->maxerror, &target_tx->maxerror); in host_to_target_timex64()
7560 __put_user(host_tx->esterror, &target_tx->esterror); in host_to_target_timex64()
7561 __put_user(host_tx->status, &target_tx->status); in host_to_target_timex64()
7562 __put_user(host_tx->constant, &target_tx->constant); in host_to_target_timex64()
7563 __put_user(host_tx->precision, &target_tx->precision); in host_to_target_timex64()
7564 __put_user(host_tx->tolerance, &target_tx->tolerance); in host_to_target_timex64()
7565 __put_user(host_tx->tick, &target_tx->tick); in host_to_target_timex64()
7566 __put_user(host_tx->ppsfreq, &target_tx->ppsfreq); in host_to_target_timex64()
7567 __put_user(host_tx->jitter, &target_tx->jitter); in host_to_target_timex64()
7568 __put_user(host_tx->shift, &target_tx->shift); in host_to_target_timex64()
7569 __put_user(host_tx->stabil, &target_tx->stabil); in host_to_target_timex64()
7570 __put_user(host_tx->jitcnt, &target_tx->jitcnt); in host_to_target_timex64()
7571 __put_user(host_tx->calcnt, &target_tx->calcnt); in host_to_target_timex64()
7572 __put_user(host_tx->errcnt, &target_tx->errcnt); in host_to_target_timex64()
7573 __put_user(host_tx->stbcnt, &target_tx->stbcnt); in host_to_target_timex64()
7574 __put_user(host_tx->tai, &target_tx->tai); in host_to_target_timex64()
7591 return -TARGET_EFAULT; in target_to_host_sigevent()
7600 host_sevp->sigev_value.sival_ptr = in target_to_host_sigevent()
7601 (void *)(uintptr_t)tswapal(target_sevp->sigev_value.sival_ptr); in target_to_host_sigevent()
7602 host_sevp->sigev_signo = in target_to_host_sigevent()
7603 target_to_host_signal(tswap32(target_sevp->sigev_signo)); in target_to_host_sigevent()
7604 host_sevp->sigev_notify = tswap32(target_sevp->sigev_notify); in target_to_host_sigevent()
7605 host_sevp->sigev_notify_thread_id = tswap32(target_sevp->_sigev_un._tid); in target_to_host_sigevent()
7648 if (cpu_env->eabi) { in host_to_target_stat64()
7652 return -TARGET_EFAULT; in host_to_target_stat64()
7654 __put_user(host_st->st_dev, &target_st->st_dev); in host_to_target_stat64()
7655 __put_user(host_st->st_ino, &target_st->st_ino); in host_to_target_stat64()
7657 __put_user(host_st->st_ino, &target_st->__st_ino); in host_to_target_stat64()
7659 __put_user(host_st->st_mode, &target_st->st_mode); in host_to_target_stat64()
7660 __put_user(host_st->st_nlink, &target_st->st_nlink); in host_to_target_stat64()
7661 __put_user(host_st->st_uid, &target_st->st_uid); in host_to_target_stat64()
7662 __put_user(host_st->st_gid, &target_st->st_gid); in host_to_target_stat64()
7663 __put_user(host_st->st_rdev, &target_st->st_rdev); in host_to_target_stat64()
7664 __put_user(host_st->st_size, &target_st->st_size); in host_to_target_stat64()
7665 __put_user(host_st->st_blksize, &target_st->st_blksize); in host_to_target_stat64()
7666 __put_user(host_st->st_blocks, &target_st->st_blocks); in host_to_target_stat64()
7667 __put_user(host_st->st_atime, &target_st->target_st_atime); in host_to_target_stat64()
7668 __put_user(host_st->st_mtime, &target_st->target_st_mtime); in host_to_target_stat64()
7669 __put_user(host_st->st_ctime, &target_st->target_st_ctime); in host_to_target_stat64()
7671 __put_user(host_st->st_atim.tv_nsec, &target_st->target_st_atime_nsec); in host_to_target_stat64()
7672 __put_user(host_st->st_mtim.tv_nsec, &target_st->target_st_mtime_nsec); in host_to_target_stat64()
7673 __put_user(host_st->st_ctim.tv_nsec, &target_st->target_st_ctime_nsec); in host_to_target_stat64()
7686 return -TARGET_EFAULT; in host_to_target_stat64()
7688 __put_user(host_st->st_dev, &target_st->st_dev); in host_to_target_stat64()
7689 __put_user(host_st->st_ino, &target_st->st_ino); in host_to_target_stat64()
7691 __put_user(host_st->st_ino, &target_st->__st_ino); in host_to_target_stat64()
7693 __put_user(host_st->st_mode, &target_st->st_mode); in host_to_target_stat64()
7694 __put_user(host_st->st_nlink, &target_st->st_nlink); in host_to_target_stat64()
7695 __put_user(host_st->st_uid, &target_st->st_uid); in host_to_target_stat64()
7696 __put_user(host_st->st_gid, &target_st->st_gid); in host_to_target_stat64()
7697 __put_user(host_st->st_rdev, &target_st->st_rdev); in host_to_target_stat64()
7699 __put_user(host_st->st_size, &target_st->st_size); in host_to_target_stat64()
7700 __put_user(host_st->st_blksize, &target_st->st_blksize); in host_to_target_stat64()
7701 __put_user(host_st->st_blocks, &target_st->st_blocks); in host_to_target_stat64()
7702 __put_user(host_st->st_atime, &target_st->target_st_atime); in host_to_target_stat64()
7703 __put_user(host_st->st_mtime, &target_st->target_st_mtime); in host_to_target_stat64()
7704 __put_user(host_st->st_ctime, &target_st->target_st_ctime); in host_to_target_stat64()
7706 __put_user(host_st->st_atim.tv_nsec, &target_st->target_st_atime_nsec); in host_to_target_stat64()
7707 __put_user(host_st->st_mtim.tv_nsec, &target_st->target_st_mtime_nsec); in host_to_target_stat64()
7708 __put_user(host_st->st_ctim.tv_nsec, &target_st->target_st_ctime_nsec); in host_to_target_stat64()
7724 return -TARGET_EFAULT; in host_to_target_statx()
7728 __put_user(host_stx->stx_mask, &target_stx->stx_mask); in host_to_target_statx()
7729 __put_user(host_stx->stx_blksize, &target_stx->stx_blksize); in host_to_target_statx()
7730 __put_user(host_stx->stx_attributes, &target_stx->stx_attributes); in host_to_target_statx()
7731 __put_user(host_stx->stx_nlink, &target_stx->stx_nlink); in host_to_target_statx()
7732 __put_user(host_stx->stx_uid, &target_stx->stx_uid); in host_to_target_statx()
7733 __put_user(host_stx->stx_gid, &target_stx->stx_gid); in host_to_target_statx()
7734 __put_user(host_stx->stx_mode, &target_stx->stx_mode); in host_to_target_statx()
7735 __put_user(host_stx->stx_ino, &target_stx->stx_ino); in host_to_target_statx()
7736 __put_user(host_stx->stx_size, &target_stx->stx_size); in host_to_target_statx()
7737 __put_user(host_stx->stx_blocks, &target_stx->stx_blocks); in host_to_target_statx()
7738 __put_user(host_stx->stx_attributes_mask, &target_stx->stx_attributes_mask); in host_to_target_statx()
7739 __put_user(host_stx->stx_atime.tv_sec, &target_stx->stx_atime.tv_sec); in host_to_target_statx()
7740 __put_user(host_stx->stx_atime.tv_nsec, &target_stx->stx_atime.tv_nsec); in host_to_target_statx()
7741 __put_user(host_stx->stx_btime.tv_sec, &target_stx->stx_btime.tv_sec); in host_to_target_statx()
7742 __put_user(host_stx->stx_btime.tv_nsec, &target_stx->stx_btime.tv_nsec); in host_to_target_statx()
7743 __put_user(host_stx->stx_ctime.tv_sec, &target_stx->stx_ctime.tv_sec); in host_to_target_statx()
7744 __put_user(host_stx->stx_ctime.tv_nsec, &target_stx->stx_ctime.tv_nsec); in host_to_target_statx()
7745 __put_user(host_stx->stx_mtime.tv_sec, &target_stx->stx_mtime.tv_sec); in host_to_target_statx()
7746 __put_user(host_stx->stx_mtime.tv_nsec, &target_stx->stx_mtime.tv_nsec); in host_to_target_statx()
7747 __put_user(host_stx->stx_rdev_major, &target_stx->stx_rdev_major); in host_to_target_statx()
7748 __put_user(host_stx->stx_rdev_minor, &target_stx->stx_rdev_minor); in host_to_target_statx()
7749 __put_user(host_stx->stx_dev_major, &target_stx->stx_dev_major); in host_to_target_statx()
7750 __put_user(host_stx->stx_dev_minor, &target_stx->stx_dev_minor); in host_to_target_statx()
7764 /* always a 64-bit time_t, it doesn't define _time64 version */ in do_sys_futex()
7770 if (sizeof(timeout->tv_sec) == 8) { in do_sys_futex()
7789 /* always a 64-bit time_t, it doesn't define _time64 version */ in do_safe_futex()
7794 if (sizeof(timeout->tv_sec) == 8) { in do_safe_futex()
7805 return -TARGET_ENOSYS; in do_safe_futex()
7867 return -TARGET_ENOSYS; in do_futex()
7874 return -TARGET_EFAULT; in do_futex()
7894 return -TARGET_EFAULT; in do_name_to_handle_at()
7899 return -TARGET_EFAULT; in do_name_to_handle_at()
7906 return -TARGET_EFAULT; in do_name_to_handle_at()
7910 fh->handle_bytes = size; in do_name_to_handle_at()
7921 target_fh->handle_bytes = tswap32(fh->handle_bytes); in do_name_to_handle_at()
7922 target_fh->handle_type = tswap32(fh->handle_type); in do_name_to_handle_at()
7927 return -TARGET_EFAULT; in do_name_to_handle_at()
7945 return -TARGET_EFAULT; in do_open_by_handle_at()
7951 return -TARGET_EFAULT; in do_open_by_handle_at()
7955 fh->handle_bytes = size; in do_open_by_handle_at()
7956 fh->handle_type = tswap32(target_fh->handle_type); in do_open_by_handle_at()
7979 return -TARGET_EINVAL; in do_signalfd4()
7982 return -TARGET_EFAULT; in do_signalfd4()
8017 struct linux_binprm *bprm = get_task_state(cpu)->bprm; in open_self_cmdline()
8020 for (i = 0; i < bprm->argc; i++) { in open_self_cmdline()
8021 size_t len = strlen(bprm->argv[i]) + 1; in open_self_cmdline()
8023 if (write(fd, bprm->argv[i], len) != len) { in open_self_cmdline()
8024 return -1; in open_self_cmdline()
8053 const struct image_info *info = d->ts->info; in open_self_maps_4()
8054 const char *path = mi->path; in open_self_maps_4()
8056 int fd = d->fd; in open_self_maps_4()
8059 if (test_stack(start, end, info->stack_limit)) { in open_self_maps_4()
8061 } else if (start == info->brk) { in open_self_maps_4()
8063 } else if (start == info->vdso) { in open_self_maps_4()
8072 offset = mi->offset; in open_self_maps_4()
8073 if (mi->dev) { in open_self_maps_4()
8075 offset += hstart - mi->itree.start; in open_self_maps_4()
8078 count = dprintf(fd, TARGET_ABI_FMT_ptr "-" TARGET_ABI_FMT_ptr in open_self_maps_4()
8081 (flags & PAGE_READ) ? 'r' : '-', in open_self_maps_4()
8082 (flags & PAGE_WRITE_ORG) ? 'w' : '-', in open_self_maps_4()
8083 (flags & PAGE_EXEC) ? 'x' : '-', in open_self_maps_4()
8084 mi->is_priv ? 'p' : 's', in open_self_maps_4()
8085 offset, major(mi->dev), minor(mi->dev), in open_self_maps_4()
8086 (uint64_t)mi->inode); in open_self_maps_4()
8088 dprintf(fd, "%*s%s\n", 73 - count, "", path); in open_self_maps_4()
8093 if (d->smaps) { in open_self_maps_4()
8094 unsigned long size = end - start; in open_self_maps_4()
8126 mi->is_priv ? "" : " sh", in open_self_maps_4()
8130 mi->is_priv ? "" : " ms"); in open_self_maps_4()
8136 * Proceed without the benefit of host /proc/self/maps cross-check.
8155 uintptr_t host_last = (uintptr_t)g2h_untagged(guest_end - 1); in open_self_maps_2()
8171 interval_tree_iter_first(d->host_maps, host_start, host_start); in open_self_maps_2()
8173 uintptr_t this_hlast = MIN(host_last, n->last); in open_self_maps_2()
8229 gchar *bin = g_strrstr(ts->bprm->argv[0], "/"); in open_self_stat()
8230 bin = bin ? bin + 1 : ts->bprm->argv[0]; in open_self_stat()
8253 g_string_printf(buf, "%" PRIu64 " ", ts->start_boottime); in open_self_stat()
8256 g_string_printf(buf, TARGET_ABI_FMT_ld " ", ts->info->start_stack); in open_self_stat()
8262 if (write(fd, buf->str, buf->len) != buf->len) { in open_self_stat()
8263 return -1; in open_self_stat()
8274 abi_ulong auxv = ts->info->saved_auxv; in open_self_auxv()
8275 abi_ulong len = ts->info->auxv_len; in open_self_auxv()
8290 len -= r; in open_self_auxv()
8372 return -1; in open_net_route()
8382 while ((read = getline(&line, &len, fp)) != -1) { in open_net_route()
8450 return -1; in maybe_do_fake_open()
8459 for (fake_open = fakes; fake_open->filename; fake_open++) { in maybe_do_fake_open()
8460 if (fake_open->cmp(pathname, fake_open->filename)) { in maybe_do_fake_open()
8465 if (fake_open->filename) { in maybe_do_fake_open()
8470 fd = memfd_create("qemu-open", 0); in maybe_do_fake_open()
8479 snprintf(filename, sizeof(filename), "%s/qemu-open.XXXXXX", tmpdir); in maybe_do_fake_open()
8487 if ((r = fake_open->fill(cpu_env, fd))) { in maybe_do_fake_open()
8498 return -2; in maybe_do_fake_open()
8505 if (fd > -2) { in do_guest_openat()
8526 return -TARGET_EINVAL; in do_openat2()
8530 if (ret == -TARGET_E2BIG) { in do_openat2()
8539 return -TARGET_EFAULT; in do_openat2()
8547 if (fd > -2) { in do_openat2()
8565 return -1; in do_guest_readlink()
8571 return -1; in do_guest_readlink()
8605 return -TARGET_EFAULT; in do_execv()
8615 return -TARGET_EFAULT; in do_execv()
8684 ret = -TARGET_EFAULT; in do_execv()
8714 return -TARGET_EINVAL; in get_timer_id()
8720 return -TARGET_EINVAL; in get_timer_id()
8740 return -TARGET_EFAULT; in target_to_host_cpu_mask()
8774 return -TARGET_EFAULT; in host_to_target_cpu_mask()
8804 return -TARGET_ENOMEM; in do_getdents()
8820 return -TARGET_EFAULT; in do_getdents()
8833 namelen = strlen(hde->d_name); in do_getdents()
8834 hreclen = hde->d_reclen; in do_getdents()
8846 toff = -TARGET_EINVAL; /* result buffer is too small */ in do_getdents()
8857 prev_diroff = hde->d_off; in do_getdents()
8858 tde->d_ino = tswapal(hde->d_ino); in do_getdents()
8859 tde->d_off = tswapal(hde->d_off); in do_getdents()
8860 tde->d_reclen = tswap16(treclen); in do_getdents()
8861 memcpy(tde->d_name, hde->d_name, namelen + 1); in do_getdents()
8868 type = *((uint8_t *)hde + hreclen - 1); in do_getdents()
8870 type = hde->d_type; in do_getdents()
8872 *((uint8_t *)tde + treclen - 1) = type; in do_getdents()
8891 return -TARGET_ENOMEM; in do_getdents64()
8901 return -TARGET_EFAULT; in do_getdents64()
8909 namelen = strlen(hde->d_name) + 1; in do_getdents64()
8910 hreclen = hde->d_reclen; in do_getdents64()
8922 toff = -TARGET_EINVAL; /* result buffer is too small */ in do_getdents64()
8933 prev_diroff = hde->d_off; in do_getdents64()
8934 tde->d_ino = tswap64(hde->d_ino); in do_getdents64()
8935 tde->d_off = tswap64(hde->d_off); in do_getdents64()
8936 tde->d_reclen = tswap16(treclen); in do_getdents64()
8937 tde->d_type = hde->d_type; in do_getdents64()
8938 memcpy(tde->d_name, hde->d_name, namelen); in do_getdents64()
9014 for (; pair_count > 0; pair_count--, pair++) { in risc_hwprobe_fill_pairs()
9017 __put_user(0, &pair->value); in risc_hwprobe_fill_pairs()
9018 __get_user(key, &pair->key); in risc_hwprobe_fill_pairs()
9021 __put_user(cfg->mvendorid, &pair->value); in risc_hwprobe_fill_pairs()
9024 __put_user(cfg->marchid, &pair->value); in risc_hwprobe_fill_pairs()
9027 __put_user(cfg->mimpid, &pair->value); in risc_hwprobe_fill_pairs()
9034 __put_user(value, &pair->value); in risc_hwprobe_fill_pairs()
9044 value |= cfg->ext_zba ? in risc_hwprobe_fill_pairs()
9046 value |= cfg->ext_zbb ? in risc_hwprobe_fill_pairs()
9048 value |= cfg->ext_zbs ? in risc_hwprobe_fill_pairs()
9050 value |= cfg->ext_zicboz ? in risc_hwprobe_fill_pairs()
9052 value |= cfg->ext_zbc ? in risc_hwprobe_fill_pairs()
9054 value |= cfg->ext_zbkb ? in risc_hwprobe_fill_pairs()
9056 value |= cfg->ext_zbkc ? in risc_hwprobe_fill_pairs()
9058 value |= cfg->ext_zbkx ? in risc_hwprobe_fill_pairs()
9060 value |= cfg->ext_zknd ? in risc_hwprobe_fill_pairs()
9062 value |= cfg->ext_zkne ? in risc_hwprobe_fill_pairs()
9064 value |= cfg->ext_zknh ? in risc_hwprobe_fill_pairs()
9066 value |= cfg->ext_zksed ? in risc_hwprobe_fill_pairs()
9068 value |= cfg->ext_zksh ? in risc_hwprobe_fill_pairs()
9070 value |= cfg->ext_zkt ? in risc_hwprobe_fill_pairs()
9072 value |= cfg->ext_zvbb ? in risc_hwprobe_fill_pairs()
9074 value |= cfg->ext_zvbc ? in risc_hwprobe_fill_pairs()
9076 value |= cfg->ext_zvkb ? in risc_hwprobe_fill_pairs()
9078 value |= cfg->ext_zvkg ? in risc_hwprobe_fill_pairs()
9080 value |= cfg->ext_zvkned ? in risc_hwprobe_fill_pairs()
9082 value |= cfg->ext_zvknha ? in risc_hwprobe_fill_pairs()
9084 value |= cfg->ext_zvknhb ? in risc_hwprobe_fill_pairs()
9086 value |= cfg->ext_zvksed ? in risc_hwprobe_fill_pairs()
9088 value |= cfg->ext_zvksh ? in risc_hwprobe_fill_pairs()
9090 value |= cfg->ext_zvkt ? in risc_hwprobe_fill_pairs()
9092 value |= cfg->ext_zfh ? in risc_hwprobe_fill_pairs()
9094 value |= cfg->ext_zfhmin ? in risc_hwprobe_fill_pairs()
9096 value |= cfg->ext_zihintntl ? in risc_hwprobe_fill_pairs()
9098 value |= cfg->ext_zvfh ? in risc_hwprobe_fill_pairs()
9100 value |= cfg->ext_zvfhmin ? in risc_hwprobe_fill_pairs()
9102 value |= cfg->ext_zfa ? in risc_hwprobe_fill_pairs()
9104 value |= cfg->ext_ztso ? in risc_hwprobe_fill_pairs()
9106 value |= cfg->ext_zacas ? in risc_hwprobe_fill_pairs()
9108 value |= cfg->ext_zicond ? in risc_hwprobe_fill_pairs()
9110 __put_user(value, &pair->value); in risc_hwprobe_fill_pairs()
9113 __put_user(RISCV_HWPROBE_MISALIGNED_FAST, &pair->value); in risc_hwprobe_fill_pairs()
9116 value = cfg->ext_zicboz ? cfg->cboz_blocksize : 0; in risc_hwprobe_fill_pairs()
9117 __put_user(value, &pair->value); in risc_hwprobe_fill_pairs()
9120 __put_user(-1, &pair->key); in risc_hwprobe_fill_pairs()
9127 * If the cpumask_t of (target_cpus, cpusetsize) cannot be read: -EFAULT.
9128 * If the cpumast_t has no bits set: -EINVAL.
9136 int ret = -TARGET_EFAULT; in nonempty_cpu_set()
9139 ret = -TARGET_EINVAL; in nonempty_cpu_set()
9141 * Since we only care about the empty/non-empty state of the cpumask_t in nonempty_cpu_set()
9169 return -TARGET_EINVAL; in do_riscv_hwprobe()
9179 return -TARGET_EINVAL; in do_riscv_hwprobe()
9190 return -TARGET_EFAULT; in do_riscv_hwprobe()
9217 * All errnos that do_syscall() returns must be -TARGET_<errcode>. in _syscall2()
9246 return -QEMU_ERESTARTSYS; in _syscall2()
9254 if (ts->child_tidptr) { in _syscall2()
9255 put_user_u32(0, ts->child_tidptr); in _syscall2()
9256 do_sys_futex(g2h(cpu, ts->child_tidptr), in _syscall2()
9264 * from cpu lists. We can clean-up the rest of the thread in _syscall2()
9285 return -TARGET_EFAULT; in _syscall2()
9299 return -TARGET_EFAULT; in _syscall2()
9317 return -TARGET_EFAULT; in _syscall2()
9327 return -TARGET_EFAULT; in _syscall2()
9360 return -TARGET_EFAULT; in _syscall2()
9406 return -TARGET_EFAULT; in _syscall2()
9423 return -TARGET_EFAULT; in _syscall2()
9429 return -TARGET_EFAULT; in _syscall2()
9438 return -TARGET_EFAULT; in _syscall2()
9451 ret = -TARGET_EFAULT; in _syscall2()
9464 return -TARGET_EFAULT; in _syscall2()
9468 ret = -TARGET_EFAULT; in _syscall2()
9479 return -TARGET_EFAULT; in _syscall2()
9487 return -TARGET_EFAULT; in _syscall2()
9498 return -TARGET_EFAULT; in _syscall2()
9510 return -TARGET_EFAULT; in _syscall2()
9517 return -TARGET_EFAULT; in _syscall2()
9525 return -TARGET_EFAULT; in _syscall2()
9533 return -TARGET_EFAULT; in _syscall2()
9545 cpu_env->ir[IR_A4] = getppid(); in _syscall2()
9560 return -TARGET_EFAULT; in _syscall2()
9571 return -TARGET_EFAULT; in _syscall2()
9581 return -TARGET_EFAULT; in _syscall2()
9587 /* FIXME - arg5 should be locked, but it isn't clear how to in _syscall2()
9588 * do that since it's not guaranteed to be a NULL-terminated in _syscall2()
9615 return -TARGET_EFAULT; in _syscall2()
9626 return -TARGET_EFAULT; in _syscall2()
9631 return -TARGET_EFAULT; in _syscall2()
9637 return -TARGET_EFAULT; in _syscall2()
9654 return -TARGET_EFAULT; in _syscall2()
9659 return -TARGET_EFAULT; in _syscall2()
9680 return -TARGET_EFAULT; in _syscall2()
9692 sigsuspend(&get_task_state(cpu)->signal_mask); in _syscall2()
9694 return -TARGET_EINTR; in _syscall2()
9703 return -TARGET_EFAULT; in _syscall2()
9704 tbuf.actime = tswapal(target_tbuf->actime); in _syscall2()
9705 tbuf.modtime = tswapal(target_tbuf->modtime); in _syscall2()
9712 return -TARGET_EFAULT; in _syscall2()
9726 return -TARGET_EFAULT; in _syscall2()
9732 return -TARGET_EFAULT; in _syscall2()
9746 return -TARGET_EFAULT; in _syscall2()
9752 return -TARGET_EFAULT; in _syscall2()
9762 return -TARGET_EFAULT; in _syscall2()
9771 return -TARGET_EFAULT; in _syscall2()
9780 return -TARGET_EFAULT; in _syscall2()
9806 ret = -TARGET_EFAULT; in _syscall2()
9821 ret = -TARGET_EFAULT; in _syscall2()
9836 ret = -TARGET_EFAULT; in _syscall2()
9848 return -TARGET_EFAULT; in _syscall2()
9856 return -TARGET_EFAULT; in _syscall2()
9864 return -TARGET_EFAULT; in _syscall2()
9892 return -TARGET_EFAULT; in _syscall2()
9893 tmsp->tms_utime = tswapal(host_to_target_clock_t(tms.tms_utime)); in _syscall2()
9894 tmsp->tms_stime = tswapal(host_to_target_clock_t(tms.tms_stime)); in _syscall2()
9895 tmsp->tms_cutime = tswapal(host_to_target_clock_t(tms.tms_cutime)); in _syscall2()
9896 tmsp->tms_cstime = tswapal(host_to_target_clock_t(tms.tms_cstime)); in _syscall2()
9907 return -TARGET_EFAULT; in _syscall2()
9916 return -TARGET_EFAULT; in _syscall2()
9933 return -TARGET_EFAULT; in _syscall2()
9951 return -EINVAL; in _syscall2()
9979 return -TARGET_EFAULT; in _syscall2()
9980 act._sa_handler = old_act->_sa_handler; in _syscall2()
9981 target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]); in _syscall2()
9982 act.sa_flags = old_act->sa_flags; in _syscall2()
9993 return -TARGET_EFAULT; in _syscall2()
9994 old_act->_sa_handler = oact._sa_handler; in _syscall2()
9995 old_act->sa_flags = oact.sa_flags; in _syscall2()
9996 old_act->sa_mask.sig[0] = oact.sa_mask.sig[0]; in _syscall2()
9997 old_act->sa_mask.sig[1] = 0; in _syscall2()
9998 old_act->sa_mask.sig[2] = 0; in _syscall2()
9999 old_act->sa_mask.sig[3] = 0; in _syscall2()
10007 return -TARGET_EFAULT; in _syscall2()
10008 act._sa_handler = old_act->_sa_handler; in _syscall2()
10009 target_siginitset(&act.sa_mask, old_act->sa_mask); in _syscall2()
10010 act.sa_flags = old_act->sa_flags; in _syscall2()
10012 act.sa_restorer = old_act->sa_restorer; in _syscall2()
10022 return -TARGET_EFAULT; in _syscall2()
10023 old_act->_sa_handler = oact._sa_handler; in _syscall2()
10024 old_act->sa_mask = oact.sa_mask.sig[0]; in _syscall2()
10025 old_act->sa_flags = oact.sa_flags; in _syscall2()
10027 old_act->sa_restorer = oact.sa_restorer; in _syscall2()
10058 return -TARGET_EINVAL; in _syscall2()
10061 return -TARGET_EFAULT; in _syscall2()
10064 ret = -TARGET_EFAULT; in _syscall2()
10122 return -TARGET_EINVAL; in _syscall2()
10131 cpu_env->ir[IR_V0] = 0; /* force no error */ in _syscall2()
10140 return -TARGET_EFAULT; in _syscall2()
10156 return -TARGET_EINVAL; in _syscall2()
10165 return -TARGET_EFAULT; in _syscall2()
10179 return -TARGET_EINVAL; in _syscall2()
10185 return -TARGET_EFAULT; in _syscall2()
10201 return -TARGET_EINVAL; in _syscall2()
10210 return -TARGET_EFAULT; in _syscall2()
10223 return -TARGET_EFAULT; in _syscall2()
10240 return -TARGET_EINVAL; in _syscall2()
10246 return -TARGET_EFAULT; in _syscall2()
10261 set = &ts->sigsuspend_mask; in _syscall2()
10294 return -TARGET_EINVAL; in _syscall2()
10298 return -TARGET_EFAULT; in _syscall2()
10304 return -TARGET_EFAULT; in _syscall2()
10316 return -TARGET_EFAULT; in _syscall2()
10334 return -TARGET_EINVAL; in _syscall2()
10339 return -TARGET_EFAULT; in _syscall2()
10346 return -TARGET_EFAULT; in _syscall2()
10358 return -TARGET_EFAULT; in _syscall2()
10374 return -TARGET_EFAULT; in _syscall2()
10387 return -TARGET_EFAULT; in _syscall2()
10397 return -QEMU_ERESTARTSYS; in _syscall2()
10403 return -QEMU_ERESTARTSYS; in _syscall2()
10408 return -TARGET_EFAULT; in _syscall2()
10419 return -TARGET_EFAULT; in _syscall2()
10420 rlim.rlim_cur = target_to_host_rlim(target_rlim->rlim_cur); in _syscall2()
10421 rlim.rlim_max = target_to_host_rlim(target_rlim->rlim_max); in _syscall2()
10450 return -TARGET_EFAULT; in _syscall2()
10451 target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); in _syscall2()
10452 target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); in _syscall2()
10476 return -TARGET_EFAULT; in _syscall2()
10479 return -TARGET_EFAULT; in _syscall2()
10493 return -TARGET_EFAULT; in _syscall2()
10500 return -TARGET_EFAULT; in _syscall2()
10514 ret = -TARGET_ENOSYS; in _syscall2()
10537 ret = -TARGET_EFAULT; in _syscall2()
10552 ret = -TARGET_EFAULT; in _syscall2()
10579 ret = -TARGET_EFAULT; in _syscall2()
10582 ret = -TARGET_EINVAL; in _syscall2()
10602 return -TARGET_EFAULT; in _syscall2()
10612 return -TARGET_EFAULT; in _syscall2()
10627 return -TARGET_EFAULT; in _syscall2()
10659 && arg1 >= ts->info->stack_limit in _syscall2()
10660 && arg1 <= ts->info->start_stack) { in _syscall2()
10662 arg2 = arg2 + arg1 - ts->info->stack_limit; in _syscall2()
10663 arg1 = ts->info->stack_limit; in _syscall2()
10698 return -TARGET_EFAULT; in _syscall2()
10712 return -TARGET_EFAULT; in _syscall2()
10722 if (ret == -1 && errno != 0) { in _syscall2()
10723 return -host_to_target_errno(errno); in _syscall2()
10727 cpu_env->ir[IR_V0] = 0; in _syscall2()
10730 ret = 20 - ret; in _syscall2()
10738 return -TARGET_EFAULT; in _syscall2()
10747 return -TARGET_EFAULT; in _syscall2()
10748 __put_user(stfs.f_type, &target_stfs->f_type); in _syscall2()
10749 __put_user(stfs.f_bsize, &target_stfs->f_bsize); in _syscall2()
10750 __put_user(stfs.f_blocks, &target_stfs->f_blocks); in _syscall2()
10751 __put_user(stfs.f_bfree, &target_stfs->f_bfree); in _syscall2()
10752 __put_user(stfs.f_bavail, &target_stfs->f_bavail); in _syscall2()
10753 __put_user(stfs.f_files, &target_stfs->f_files); in _syscall2()
10754 __put_user(stfs.f_ffree, &target_stfs->f_ffree); in _syscall2()
10755 __put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]); in _syscall2()
10756 __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]); in _syscall2()
10757 __put_user(stfs.f_namelen, &target_stfs->f_namelen); in _syscall2()
10758 __put_user(stfs.f_frsize, &target_stfs->f_frsize); in _syscall2()
10760 __put_user(stfs.f_flags, &target_stfs->f_flags); in _syscall2()
10762 __put_user(0, &target_stfs->f_flags); in _syscall2()
10764 memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); in _syscall2()
10777 return -TARGET_EFAULT; in _syscall2()
10786 return -TARGET_EFAULT; in _syscall2()
10787 __put_user(stfs.f_type, &target_stfs->f_type); in _syscall2()
10788 __put_user(stfs.f_bsize, &target_stfs->f_bsize); in _syscall2()
10789 __put_user(stfs.f_blocks, &target_stfs->f_blocks); in _syscall2()
10790 __put_user(stfs.f_bfree, &target_stfs->f_bfree); in _syscall2()
10791 __put_user(stfs.f_bavail, &target_stfs->f_bavail); in _syscall2()
10792 __put_user(stfs.f_files, &target_stfs->f_files); in _syscall2()
10793 __put_user(stfs.f_ffree, &target_stfs->f_ffree); in _syscall2()
10794 __put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]); in _syscall2()
10795 __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]); in _syscall2()
10796 __put_user(stfs.f_namelen, &target_stfs->f_namelen); in _syscall2()
10797 __put_user(stfs.f_frsize, &target_stfs->f_frsize); in _syscall2()
10799 __put_user(stfs.f_flags, &target_stfs->f_flags); in _syscall2()
10801 __put_user(0, &target_stfs->f_flags); in _syscall2()
10803 memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); in _syscall2()
10887 return -TARGET_EFAULT; in _syscall2()
10925 return -TARGET_EINVAL; in _syscall2()
10932 return -TARGET_EFAULT; in _syscall2()
10939 return -TARGET_EINVAL; in _syscall2()
10950 if (copy_from_user_timeval(&pvalue->it_interval, arg2) in _syscall2()
10951 || copy_from_user_timeval(&pvalue->it_value, in _syscall2()
10953 return -TARGET_EFAULT; in _syscall2()
10963 return -TARGET_EFAULT; in _syscall2()
10977 return -TARGET_EFAULT; in _syscall2()
10984 return -TARGET_EFAULT; in _syscall2()
10993 return -TARGET_EFAULT; in _syscall2()
11010 return -TARGET_EFAULT; in _syscall2()
11012 __put_user(st.st_dev, &target_st->st_dev); in _syscall2()
11013 __put_user(st.st_ino, &target_st->st_ino); in _syscall2()
11014 __put_user(st.st_mode, &target_st->st_mode); in _syscall2()
11015 __put_user(st.st_uid, &target_st->st_uid); in _syscall2()
11016 __put_user(st.st_gid, &target_st->st_gid); in _syscall2()
11017 __put_user(st.st_nlink, &target_st->st_nlink); in _syscall2()
11018 __put_user(st.st_rdev, &target_st->st_rdev); in _syscall2()
11019 __put_user(st.st_size, &target_st->st_size); in _syscall2()
11020 __put_user(st.st_blksize, &target_st->st_blksize); in _syscall2()
11021 __put_user(st.st_blocks, &target_st->st_blocks); in _syscall2()
11022 __put_user(st.st_atime, &target_st->target_st_atime); in _syscall2()
11023 __put_user(st.st_mtime, &target_st->target_st_mtime); in _syscall2()
11024 __put_user(st.st_ctime, &target_st->target_st_ctime); in _syscall2()
11027 &target_st->target_st_atime_nsec); in _syscall2()
11029 &target_st->target_st_mtime_nsec); in _syscall2()
11031 &target_st->target_st_ctime_nsec); in _syscall2()
11062 return -TARGET_EFAULT; in _syscall2()
11077 return -TARGET_EFAULT; in _syscall2()
11090 return -TARGET_EFAULT; in _syscall2()
11091 __put_user(value.uptime, &target_value->uptime); in _syscall2()
11092 __put_user(value.loads[0], &target_value->loads[0]); in _syscall2()
11093 __put_user(value.loads[1], &target_value->loads[1]); in _syscall2()
11094 __put_user(value.loads[2], &target_value->loads[2]); in _syscall2()
11095 __put_user(value.totalram, &target_value->totalram); in _syscall2()
11096 __put_user(value.freeram, &target_value->freeram); in _syscall2()
11097 __put_user(value.sharedram, &target_value->sharedram); in _syscall2()
11098 __put_user(value.bufferram, &target_value->bufferram); in _syscall2()
11099 __put_user(value.totalswap, &target_value->totalswap); in _syscall2()
11100 __put_user(value.freeswap, &target_value->freeswap); in _syscall2()
11101 __put_user(value.procs, &target_value->procs); in _syscall2()
11102 __put_user(value.totalhigh, &target_value->totalhigh); in _syscall2()
11103 __put_user(value.freehigh, &target_value->freehigh); in _syscall2()
11104 __put_user(value.mem_unit, &target_value->mem_unit); in _syscall2()
11192 return -TARGET_EFAULT; in _syscall2()
11202 return -TARGET_EFAULT; in _syscall2()
11207 g_strlcpy(buf->machine, cpu_to_uname_machine(cpu_env), in _syscall2()
11208 sizeof(buf->machine)); in _syscall2()
11211 g_strlcpy(buf->release, qemu_uname_release, in _syscall2()
11212 sizeof(buf->release)); in _syscall2()
11232 return -TARGET_EFAULT; in _syscall2()
11237 return -TARGET_EFAULT; in _syscall2()
11249 return -TARGET_EFAULT; in _syscall2()
11253 return -TARGET_EFAULT; in _syscall2()
11264 return -TARGET_EFAULT; in _syscall2()
11268 return -TARGET_EFAULT; in _syscall2()
11285 if (res == -1) { in _syscall2()
11294 return -TARGET_EFAULT; in _syscall2()
11334 ret = -host_to_target_errno(errno); in _syscall2()
11345 ret = -host_to_target_errno(errno); in _syscall2()
11360 ret = -host_to_target_errno(errno); in _syscall2()
11376 ret = -host_to_target_errno(errno); in _syscall2()
11396 if (arg2 & (sizeof(abi_ulong) - 1)) { in _syscall2()
11397 return -TARGET_EINVAL; in _syscall2()
11399 mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1); in _syscall2()
11416 return -TARGET_EINVAL; in _syscall2()
11422 return -TARGET_EFAULT; in _syscall2()
11436 if (arg2 & (sizeof(abi_ulong) - 1)) { in _syscall2()
11437 return -TARGET_EINVAL; in _syscall2()
11439 mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1); in _syscall2()
11459 return -TARGET_EFAULT; in _syscall2()
11462 return -TARGET_EFAULT; in _syscall2()
11472 return -TARGET_EINVAL; in _syscall2()
11475 return -TARGET_EFAULT; in _syscall2()
11477 schp.sched_priority = tswap32(target_schp->sched_priority); in _syscall2()
11487 return -TARGET_EINVAL; in _syscall2()
11492 return -TARGET_EFAULT; in _syscall2()
11494 target_schp->sched_priority = tswap32(schp.sched_priority); in _syscall2()
11504 return -TARGET_EINVAL; in _syscall2()
11507 return -TARGET_EFAULT; in _syscall2()
11509 schp.sched_priority = tswap32(target_schp->sched_priority); in _syscall2()
11520 return -TARGET_EINVAL; in _syscall2()
11529 return -TARGET_EFAULT; in _syscall2()
11531 target_scha->size = tswap32(scha.size); in _syscall2()
11532 target_scha->sched_policy = tswap32(scha.sched_policy); in _syscall2()
11533 target_scha->sched_flags = tswap64(scha.sched_flags); in _syscall2()
11534 target_scha->sched_nice = tswap32(scha.sched_nice); in _syscall2()
11535 target_scha->sched_priority = tswap32(scha.sched_priority); in _syscall2()
11536 target_scha->sched_runtime = tswap64(scha.sched_runtime); in _syscall2()
11537 target_scha->sched_deadline = tswap64(scha.sched_deadline); in _syscall2()
11538 target_scha->sched_period = tswap64(scha.sched_period); in _syscall2()
11540 target_scha->sched_util_min = tswap32(scha.sched_util_min); in _syscall2()
11541 target_scha->sched_util_max = tswap32(scha.sched_util_max); in _syscall2()
11554 return -TARGET_EINVAL; in _syscall2()
11557 return -TARGET_EFAULT; in _syscall2()
11564 return -TARGET_EFAULT; in _syscall2()
11566 return -TARGET_E2BIG; in _syscall2()
11574 return -TARGET_EFAULT; in _syscall2()
11576 return -TARGET_E2BIG; in _syscall2()
11584 return -TARGET_EFAULT; in _syscall2()
11587 scha.sched_policy = tswap32(target_scha->sched_policy); in _syscall2()
11588 scha.sched_flags = tswap64(target_scha->sched_flags); in _syscall2()
11589 scha.sched_nice = tswap32(target_scha->sched_nice); in _syscall2()
11590 scha.sched_priority = tswap32(target_scha->sched_priority); in _syscall2()
11591 scha.sched_runtime = tswap64(target_scha->sched_runtime); in _syscall2()
11592 scha.sched_deadline = tswap64(target_scha->sched_deadline); in _syscall2()
11593 scha.sched_period = tswap64(target_scha->sched_period); in _syscall2()
11595 scha.sched_util_min = tswap32(target_scha->sched_util_min); in _syscall2()
11596 scha.sched_util_max = tswap32(target_scha->sched_util_max); in _syscall2()
11655 /* Special-case NULL buffer and zero length, which should succeed */ in _syscall2()
11660 return -TARGET_EFAULT; in _syscall2()
11672 /* Special-case NULL buffer and zero length, which should succeed */ in _syscall2()
11677 return -TARGET_EFAULT; in _syscall2()
11686 return -TARGET_EFAULT; in _syscall2()
11702 return -TARGET_EFAULT; in _syscall2()
11704 header.version = tswap32(target_header->version); in _syscall2()
11705 header.pid = tswap32(target_header->pid); in _syscall2()
11722 return -TARGET_EFAULT; in _syscall2()
11743 target_header->version = tswap32(header.version); in _syscall2()
11824 return -TARGET_EFAULT; in _syscall2()
11825 target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); in _syscall2()
11826 target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); in _syscall2()
11835 return -TARGET_EFAULT; in _syscall2()
11847 return -TARGET_EFAULT; in _syscall2()
11858 return -TARGET_EFAULT; in _syscall2()
11881 return -TARGET_EFAULT; in _syscall2()
11898 return -TARGET_EFAULT; in _syscall2()
11912 return -TARGET_EFAULT; in _syscall2()
11916 if (ret != -TARGET_ENOSYS) { in _syscall2()
11927 return -TARGET_EFAULT; in _syscall2()
11930 __put_user(major(st.st_dev), &target_stx->stx_dev_major); in _syscall2()
11931 __put_user(minor(st.st_dev), &target_stx->stx_dev_minor); in _syscall2()
11932 __put_user(st.st_ino, &target_stx->stx_ino); in _syscall2()
11933 __put_user(st.st_mode, &target_stx->stx_mode); in _syscall2()
11934 __put_user(st.st_uid, &target_stx->stx_uid); in _syscall2()
11935 __put_user(st.st_gid, &target_stx->stx_gid); in _syscall2()
11936 __put_user(st.st_nlink, &target_stx->stx_nlink); in _syscall2()
11937 __put_user(major(st.st_rdev), &target_stx->stx_rdev_major); in _syscall2()
11938 __put_user(minor(st.st_rdev), &target_stx->stx_rdev_minor); in _syscall2()
11939 __put_user(st.st_size, &target_stx->stx_size); in _syscall2()
11940 __put_user(st.st_blksize, &target_stx->stx_blksize); in _syscall2()
11941 __put_user(st.st_blocks, &target_stx->stx_blocks); in _syscall2()
11942 __put_user(st.st_atime, &target_stx->stx_atime.tv_sec); in _syscall2()
11943 __put_user(st.st_mtime, &target_stx->stx_mtime.tv_sec); in _syscall2()
11944 __put_user(st.st_ctime, &target_stx->stx_ctime.tv_sec); in _syscall2()
11953 return -TARGET_EFAULT; in _syscall2()
11986 return -TARGET_EINVAL; in _syscall2()
11991 return -TARGET_ENOMEM; in _syscall2()
11999 return -TARGET_EFAULT; in _syscall2()
12017 return -TARGET_EINVAL; in _syscall2()
12022 return -TARGET_ENOMEM; in _syscall2()
12027 return -TARGET_EFAULT; in _syscall2()
12042 return -TARGET_EFAULT; in _syscall2()
12063 return -TARGET_EFAULT; in _syscall2()
12083 return -TARGET_EFAULT; in _syscall2()
12091 return -TARGET_EFAULT; in _syscall2()
12108 return -TARGET_EFAULT; in _syscall2()
12124 cpu_env->ir[IR_A4]=euid; in _syscall2()
12134 cpu_env->ir[IR_A4]=egid; in _syscall2()
12141 ret = -TARGET_EOPNOTSUPP; in _syscall2()
12146 uint64_t swcr = cpu_env->swcr; in _syscall2()
12152 return -TARGET_EFAULT; in _syscall2()
12158 -- Not implemented in linux kernel. in _syscall2()
12160 -- Retrieves current unaligned access state; not much used. in _syscall2()
12162 -- Retrieves implver information; surely not used. in _syscall2()
12164 -- Grabs a copy of the HWRPB; surely not used. in _syscall2()
12172 ret = -TARGET_EOPNOTSUPP; in _syscall2()
12179 return -TARGET_EFAULT; in _syscall2()
12188 cpu_env->swcr = swcr & (SWCR_TRAP_ENABLE_MASK | SWCR_MAP_MASK); in _syscall2()
12203 return -TARGET_EFAULT; in _syscall2()
12212 fex &= (cpu_env)->swcr; in _syscall2()
12244 info._sifields._sigfault._addr = (cpu_env)->pc; in _syscall2()
12253 -- Used with SSIN_UACPROC to enable unaligned accesses. in _syscall2()
12256 -- Not implemented in linux kernel in _syscall2()
12280 return -TARGET_EINVAL; in _syscall2()
12322 return -TARGET_EINVAL; in _syscall2()
12327 return -TARGET_ENOMEM; in _syscall2()
12335 return -TARGET_EFAULT; in _syscall2()
12354 return -TARGET_EINVAL; in _syscall2()
12359 return -TARGET_ENOMEM; in _syscall2()
12364 return -TARGET_EFAULT; in _syscall2()
12391 return -TARGET_EFAULT; in _syscall2()
12409 return -TARGET_EFAULT; in _syscall2()
12417 return -TARGET_EFAULT; in _syscall2()
12443 return -TARGET_ENOMEM; in _syscall2()
12447 ret = -TARGET_EFAULT; in _syscall2()
12461 * Note that offset and len are both 64-bit so appear as in _syscall2()
12462 * pairs of 32-bit registers. in _syscall2()
12466 return -host_to_target_errno(ret); in _syscall2()
12494 return -host_to_target_errno(ret); in _syscall2()
12508 return -host_to_target_errno(ret); in _syscall2()
12511 #else /* not a 32-bit ABI */ in _syscall2()
12528 return -host_to_target_errno(posix_fadvise(arg1, arg2, arg3, arg4)); in _syscall2()
12530 #endif /* end of 64-bit ABI fadvise handling */ in _syscall2()
12545 if (!cpu_env->eabi) { in _syscall2()
12552 if (cmd == -TARGET_EINVAL) { in _syscall2()
12585 /* self-modifying code is handled automatically, so nothing needed */ in _syscall2()
12617 return -TARGET_EFAULT; in _syscall2()
12628 ret = -TARGET_EFAULT; in _syscall2()
12640 return -TARGET_EFAULT; in _syscall2()
12654 return -TARGET_EFAULT; in _syscall2()
12666 ret = -TARGET_EFAULT; in _syscall2()
12679 return -TARGET_EFAULT; in _syscall2()
12686 ret = -TARGET_EFAULT; in _syscall2()
12699 return -TARGET_EFAULT; in _syscall2()
12711 ret = -TARGET_EFAULT; in _syscall2()
12724 return -TARGET_EFAULT; in _syscall2()
12731 ret = -TARGET_EFAULT; in _syscall2()
12750 ret = -TARGET_EFAULT; in _syscall2()
12763 ret = -TARGET_EFAULT; in _syscall2()
12773 cpu_env->active_tc.CP0_UserLocal = arg1; in _syscall2()
12780 ts->tp_value = arg1; in _syscall2()
12784 return -TARGET_ENOSYS; in _syscall2()
12794 return ts->tp_value; in _syscall2()
12797 return -TARGET_ENOSYS; in _syscall2()
12802 return -TARGET_ENOSYS; in _syscall2()
12878 return -TARGET_EFAULT; in _syscall2()
12884 * with error -TARGET_EINTR and if arg4 is not NULL and arg2 is not in _syscall2()
12887 if (ret == -TARGET_EINTR && arg4 && arg2 != TIMER_ABSTIME && in _syscall2()
12889 return -TARGET_EFAULT; in _syscall2()
12901 return -TARGET_EFAULT; in _syscall2()
12907 if (ret == -TARGET_EINTR && arg4 && arg2 != TIMER_ABSTIME && in _syscall2()
12909 return -TARGET_EFAULT; in _syscall2()
12919 ts->child_tidptr = arg1; in _syscall2()
12940 * no way to reliably intercept the thread-death event, we can't in _syscall2()
12942 * falls back to a non-robust futex implementation (which should in _syscall2()
12947 return -TARGET_ENOSYS; in _syscall2()
12958 return -TARGET_EFAULT; in _syscall2()
12962 return -TARGET_EFAULT; in _syscall2()
12970 return -TARGET_EFAULT; in _syscall2()
12986 return -TARGET_EFAULT; in _syscall2()
12990 return -TARGET_EFAULT; in _syscall2()
12999 return -TARGET_EFAULT; in _syscall2()
13057 return -TARGET_EFAULT; in _syscall2()
13061 p = lock_user_string(arg1 - 1); in _syscall2()
13063 return -TARGET_EFAULT; in _syscall2()
13071 p = lock_user_string(arg1 - 1); in _syscall2()
13073 return -TARGET_EFAULT; in _syscall2()
13087 return -TARGET_EFAULT; in _syscall2()
13091 return -TARGET_EFAULT; in _syscall2()
13108 return -TARGET_EFAULT; in _syscall2()
13112 return -TARGET_EFAULT; in _syscall2()
13131 return -TARGET_EFAULT; in _syscall2()
13136 return -TARGET_EFAULT; in _syscall2()
13157 return -TARGET_EFAULT; in _syscall2()
13162 return -TARGET_EFAULT; in _syscall2()
13213 return -TARGET_EFAULT; in _syscall2()
13219 return -TARGET_EFAULT; in _syscall2()
13226 return -TARGET_EFAULT; in _syscall2()
13231 return -TARGET_EFAULT; in _syscall2()
13245 ret = -host_to_target_errno(errno); in _syscall2()
13348 return -TARGET_EFAULT; in _syscall2()
13350 ep.events = tswap32(target_ep->events); in _syscall2()
13356 ep.data.u64 = tswap64(target_ep->data.u64); in _syscall2()
13361 * non-null pointer, even though this argument is ignored. in _syscall2()
13385 return -TARGET_EINVAL; in _syscall2()
13391 return -TARGET_EFAULT; in _syscall2()
13397 return -TARGET_ENOMEM; in _syscall2()
13429 ret = -TARGET_ENOSYS; in _syscall2()
13459 return -TARGET_EFAULT; in _syscall2()
13461 __get_user(rnew.rlim_cur, &target_rnew->rlim_cur); in _syscall2()
13462 __get_user(rnew.rlim_max, &target_rnew->rlim_max); in _syscall2()
13470 return -TARGET_EFAULT; in _syscall2()
13472 __put_user(rold.rlim_cur, &target_rold->rlim_cur); in _syscall2()
13473 __put_user(rold.rlim_max, &target_rold->rlim_max); in _syscall2()
13487 ret = -TARGET_EFAULT; in _syscall2()
13515 qemu arm barrier, no-op this? */ in _syscall2()
13530 ret = -TARGET_EAGAIN; in _syscall2()
13550 return -TARGET_EFAULT; in _syscall2()
13568 ret = -TARGET_EINVAL; in _syscall2()
13574 return -TARGET_EFAULT; in _syscall2()
13579 return -TARGET_EFAULT; in _syscall2()
13594 ret = -TARGET_EINVAL; in _syscall2()
13600 return -TARGET_EFAULT; in _syscall2()
13605 return -TARGET_EFAULT; in _syscall2()
13621 ret = -TARGET_EFAULT; in _syscall2()
13628 ret = -TARGET_EFAULT; in _syscall2()
13644 ret = -TARGET_EFAULT; in _syscall2()
13651 ret = -TARGET_EFAULT; in _syscall2()
13709 return -TARGET_EFAULT; in _syscall2()
13723 return -TARGET_EFAULT; in _syscall2()
13736 return -TARGET_EFAULT; in _syscall2()
13746 return -TARGET_EFAULT; in _syscall2()
13759 return -TARGET_EFAULT; in _syscall2()
13769 return -TARGET_EFAULT; in _syscall2()
13806 return -TARGET_EFAULT; in _syscall2()
13826 return -TARGET_EFAULT; in _syscall2()
13832 return -TARGET_EFAULT; in _syscall2()
13836 /* Do not sign-extend the count parameter. */ in _syscall2()
13842 return -TARGET_EFAULT; in _syscall2()
13847 return -TARGET_EFAULT; in _syscall2()
13862 ret = -TARGET_EFAULT; in _syscall2()
13879 return -TARGET_ENOSYS; in _syscall2()
13893 /* Debug-only code for exercising the syscall-restart code paths in do_syscall()
13894 * in the per-architecture cpu main loops: restart every syscall in do_syscall()
13901 return -QEMU_ERESTARTSYS; in do_syscall()