Lines Matching +full:build +full:- +full:some +full:- +full:softmmu
28 #include "exec/page-protection.h"
112 #include <linux/dm-ioctl.h>
133 #include "user-internals.h"
135 #include "signal-common.h"
137 #include "user-mmap.h"
138 #include "user/safe-syscall.h"
139 #include "qemu/guest-random.h"
141 #include "user/syscall-trace.h"
142 #include "special-errno.h"
144 #include "fd-trans.h"
145 #include "cpu_loop-common.h"
293 /* some platforms need to mask more bits than just TARGET_O_NONBLOCK */
301 /* For the 64-bit guest on 32-bit host case we must emulate
454 /* Don't terminate the list prematurely on 64-bit host+guest. */
472 return -1;
490 return -1;
507 # define __NR_prlimit64 -1
535 return -1; in next_free_host_timer()
568 if (ret == -1) in get_errno()
569 return -host_to_target_errno(errno); in get_errno()
595 return -TARGET_EFAULT; in check_zeroed_user()
606 * backwards-compatibility for struct syscall arguments.
613 size_t rest = MAX(ksize, usize) - size; in copy_struct_from_user()
621 return ret ?: -TARGET_E2BIG; in copy_struct_from_user()
626 return -TARGET_EFAULT; in copy_struct_from_user()
792 /* Similarly for fcntl. Since we always build with LFS enabled, in safe_syscall3()
793 * we should be using the 64-bit structures automatically. in safe_syscall3()
865 target_munmap(new_brk, old_brk - new_brk); in do_brk()
871 mapped_addr = target_mmap(old_brk, new_brk - old_brk, in do_brk()
874 -1, 0); in do_brk()
884 return -TARGET_ENOMEM; in do_brk()
904 return -TARGET_EFAULT; in copy_from_user_fdset()
930 return -TARGET_EFAULT; in copy_from_user_fdset_ptr()
951 return -TARGET_EFAULT; in copy_to_user_fdset()
990 return -TARGET_EFAULT; in host_to_target_rusage()
991 target_rusage->ru_utime.tv_sec = tswapal(rusage->ru_utime.tv_sec); in host_to_target_rusage()
992 target_rusage->ru_utime.tv_usec = tswapal(rusage->ru_utime.tv_usec); in host_to_target_rusage()
993 target_rusage->ru_stime.tv_sec = tswapal(rusage->ru_stime.tv_sec); in host_to_target_rusage()
994 target_rusage->ru_stime.tv_usec = tswapal(rusage->ru_stime.tv_usec); in host_to_target_rusage()
995 target_rusage->ru_maxrss = tswapal(rusage->ru_maxrss); in host_to_target_rusage()
996 target_rusage->ru_ixrss = tswapal(rusage->ru_ixrss); in host_to_target_rusage()
997 target_rusage->ru_idrss = tswapal(rusage->ru_idrss); in host_to_target_rusage()
998 target_rusage->ru_isrss = tswapal(rusage->ru_isrss); in host_to_target_rusage()
999 target_rusage->ru_minflt = tswapal(rusage->ru_minflt); in host_to_target_rusage()
1000 target_rusage->ru_majflt = tswapal(rusage->ru_majflt); in host_to_target_rusage()
1001 target_rusage->ru_nswap = tswapal(rusage->ru_nswap); in host_to_target_rusage()
1002 target_rusage->ru_inblock = tswapal(rusage->ru_inblock); in host_to_target_rusage()
1003 target_rusage->ru_oublock = tswapal(rusage->ru_oublock); in host_to_target_rusage()
1004 target_rusage->ru_msgsnd = tswapal(rusage->ru_msgsnd); in host_to_target_rusage()
1005 target_rusage->ru_msgrcv = tswapal(rusage->ru_msgrcv); in host_to_target_rusage()
1006 target_rusage->ru_nsignals = tswapal(rusage->ru_nsignals); in host_to_target_rusage()
1007 target_rusage->ru_nvcsw = tswapal(rusage->ru_nvcsw); in host_to_target_rusage()
1008 target_rusage->ru_nivcsw = tswapal(rusage->ru_nivcsw); in host_to_target_rusage()
1096 return -TARGET_EFAULT; in copy_from_user_timeval()
1099 __get_user(tv->tv_sec, &target_tv->tv_sec); in copy_from_user_timeval()
1100 __get_user(tv->tv_usec, &target_tv->tv_usec); in copy_from_user_timeval()
1113 return -TARGET_EFAULT; in copy_to_user_timeval()
1116 __put_user(tv->tv_sec, &target_tv->tv_sec); in copy_to_user_timeval()
1117 __put_user(tv->tv_usec, &target_tv->tv_usec); in copy_to_user_timeval()
1131 return -TARGET_EFAULT; in copy_from_user_timeval64()
1134 __get_user(tv->tv_sec, &target_tv->tv_sec); in copy_from_user_timeval64()
1135 __get_user(tv->tv_usec, &target_tv->tv_usec); in copy_from_user_timeval64()
1149 return -TARGET_EFAULT; in copy_to_user_timeval64()
1152 __put_user(tv->tv_sec, &target_tv->tv_sec); in copy_to_user_timeval64()
1153 __put_user(tv->tv_usec, &target_tv->tv_usec); in copy_to_user_timeval64()
1175 return -TARGET_EFAULT; in target_to_host_timespec()
1177 __get_user(host_ts->tv_sec, &target_ts->tv_sec); in target_to_host_timespec()
1178 __get_user(host_ts->tv_nsec, &target_ts->tv_nsec); in target_to_host_timespec()
1201 return -TARGET_EFAULT; in target_to_host_timespec64()
1203 __get_user(host_ts->tv_sec, &target_ts->tv_sec); in target_to_host_timespec64()
1204 __get_user(host_ts->tv_nsec, &target_ts->tv_nsec); in target_to_host_timespec64()
1206 host_ts->tv_nsec = (long)(abi_long)host_ts->tv_nsec; in target_to_host_timespec64()
1218 return -TARGET_EFAULT; in host_to_target_timespec()
1220 __put_user(host_ts->tv_sec, &target_ts->tv_sec); in host_to_target_timespec()
1221 __put_user(host_ts->tv_nsec, &target_ts->tv_nsec); in host_to_target_timespec()
1232 return -TARGET_EFAULT; in host_to_target_timespec64()
1234 __put_user(host_ts->tv_sec, &target_ts->tv_sec); in host_to_target_timespec64()
1235 __put_user(host_ts->tv_nsec, &target_ts->tv_nsec); in host_to_target_timespec64()
1247 return -TARGET_EFAULT; in copy_to_user_timezone()
1250 __put_user(tz->tz_minuteswest, &target_tz->tz_minuteswest); in copy_to_user_timezone()
1251 __put_user(tz->tz_dsttime, &target_tz->tz_dsttime); in copy_to_user_timezone()
1266 return -TARGET_EFAULT; in copy_from_user_timezone()
1269 __get_user(tz->tz_minuteswest, &target_tz->tz_minuteswest); in copy_from_user_timezone()
1270 __get_user(tz->tz_dsttime, &target_tz->tz_dsttime); in copy_from_user_timezone()
1288 return -TARGET_EFAULT; in copy_from_user_mq_attr()
1290 __get_user(attr->mq_flags, &target_mq_attr->mq_flags); in copy_from_user_mq_attr()
1291 __get_user(attr->mq_maxmsg, &target_mq_attr->mq_maxmsg); in copy_from_user_mq_attr()
1292 __get_user(attr->mq_msgsize, &target_mq_attr->mq_msgsize); in copy_from_user_mq_attr()
1293 __get_user(attr->mq_curmsgs, &target_mq_attr->mq_curmsgs); in copy_from_user_mq_attr()
1307 return -TARGET_EFAULT; in copy_to_user_mq_attr()
1309 __put_user(attr->mq_flags, &target_mq_attr->mq_flags); in copy_to_user_mq_attr()
1310 __put_user(attr->mq_maxmsg, &target_mq_attr->mq_maxmsg); in copy_to_user_mq_attr()
1311 __put_user(attr->mq_msgsize, &target_mq_attr->mq_msgsize); in copy_to_user_mq_attr()
1312 __put_user(attr->mq_curmsgs, &target_mq_attr->mq_curmsgs); in copy_to_user_mq_attr()
1347 return -TARGET_EFAULT; in do_select()
1360 return -TARGET_EFAULT; in do_select()
1362 return -TARGET_EFAULT; in do_select()
1364 return -TARGET_EFAULT; in do_select()
1370 return -TARGET_EFAULT; in do_select()
1386 return -TARGET_EFAULT; in do_old_select()
1389 nsel = tswapal(sel->n); in do_old_select()
1390 inp = tswapal(sel->inp); in do_old_select()
1391 outp = tswapal(sel->outp); in do_old_select()
1392 exp = tswapal(sel->exp); in do_old_select()
1393 tvp = tswapal(sel->tvp); in do_old_select()
1450 return -TARGET_EFAULT; in do_pselect6()
1454 return -TARGET_EFAULT; in do_pselect6()
1467 return -TARGET_EFAULT; in do_pselect6()
1492 return -TARGET_EFAULT; in do_pselect6()
1495 return -TARGET_EFAULT; in do_pselect6()
1498 return -TARGET_EFAULT; in do_pselect6()
1502 return -TARGET_EFAULT; in do_pselect6()
1506 return -TARGET_EFAULT; in do_pselect6()
1529 return -TARGET_EINVAL; in do_ppoll()
1534 return -TARGET_EFAULT; in do_ppoll()
1551 return -TARGET_EFAULT; in do_ppoll()
1556 return -TARGET_EFAULT; in do_ppoll()
1580 return -TARGET_EFAULT; in do_ppoll()
1584 return -TARGET_EFAULT; in do_ppoll()
1597 /* -ve poll() timeout means "infinite" */ in do_ppoll()
1627 cpu_env->ir[IR_A4] = host_pipe[1]; in do_pipe()
1630 cpu_env->active_tc.gpr[3] = host_pipe[1]; in do_pipe()
1633 cpu_env->gregs[1] = host_pipe[1]; in do_pipe()
1636 cpu_env->regwptr[1] = host_pipe[1]; in do_pipe()
1643 return -TARGET_EFAULT; in do_pipe()
1661 return -TARGET_EFAULT; in target_to_host_sockaddr()
1663 sa_family = tswap16(target_saddr->sa_family); in target_to_host_sockaddr()
1668 * length as "strlen(x->sun_path)" while it should be in target_to_host_sockaddr()
1677 if ( cp[len-1] && !cp[len] ) in target_to_host_sockaddr()
1685 addr->sa_family = sa_family; in target_to_host_sockaddr()
1690 nladdr->nl_pid = tswap32(nladdr->nl_pid); in target_to_host_sockaddr()
1691 nladdr->nl_groups = tswap32(nladdr->nl_groups); in target_to_host_sockaddr()
1696 lladdr->sll_ifindex = tswap32(lladdr->sll_ifindex); in target_to_host_sockaddr()
1697 lladdr->sll_hatype = tswap16(lladdr->sll_hatype); in target_to_host_sockaddr()
1702 in6addr->sin6_scope_id = tswap32(in6addr->sin6_scope_id); in target_to_host_sockaddr()
1722 return -TARGET_EFAULT; in host_to_target_sockaddr()
1725 sizeof(target_saddr->sa_family)) { in host_to_target_sockaddr()
1726 target_saddr->sa_family = tswap16(addr->sa_family); in host_to_target_sockaddr()
1728 if (addr->sa_family == AF_NETLINK && in host_to_target_sockaddr()
1732 target_nl->nl_pid = tswap32(target_nl->nl_pid); in host_to_target_sockaddr()
1733 target_nl->nl_groups = tswap32(target_nl->nl_groups); in host_to_target_sockaddr()
1734 } else if (addr->sa_family == AF_PACKET) { in host_to_target_sockaddr()
1736 target_ll->sll_ifindex = tswap32(target_ll->sll_ifindex); in host_to_target_sockaddr()
1737 target_ll->sll_hatype = tswap16(target_ll->sll_hatype); in host_to_target_sockaddr()
1738 } else if (addr->sa_family == AF_INET6 && in host_to_target_sockaddr()
1742 target_in6->sin6_scope_id = tswap16(target_in6->sin6_scope_id); in host_to_target_sockaddr()
1758 msg_controllen = tswapal(target_msgh->msg_controllen); in target_to_host_cmsg()
1761 target_cmsg_addr = tswapal(target_msgh->msg_control); in target_to_host_cmsg()
1765 return -TARGET_EFAULT; in target_to_host_cmsg()
1771 int len = tswapal(target_cmsg->cmsg_len) in target_to_host_cmsg()
1772 - sizeof(struct target_cmsghdr); in target_to_host_cmsg()
1775 if (space > msgh->msg_controllen) { in target_to_host_cmsg()
1776 space -= CMSG_SPACE(len); in target_to_host_cmsg()
1778 * area ourselves (unlike overflow in host-to-target in target_to_host_cmsg()
1789 tswap32(target_cmsg->cmsg_level), in target_to_host_cmsg()
1790 tswap32(target_cmsg->cmsg_type)); in target_to_host_cmsg()
1794 if (tswap32(target_cmsg->cmsg_level) == TARGET_SOL_SOCKET) { in target_to_host_cmsg()
1795 cmsg->cmsg_level = SOL_SOCKET; in target_to_host_cmsg()
1797 cmsg->cmsg_level = tswap32(target_cmsg->cmsg_level); in target_to_host_cmsg()
1799 cmsg->cmsg_type = tswap32(target_cmsg->cmsg_type); in target_to_host_cmsg()
1800 cmsg->cmsg_len = CMSG_LEN(len); in target_to_host_cmsg()
1802 if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { in target_to_host_cmsg()
1810 } else if (cmsg->cmsg_level == SOL_SOCKET in target_to_host_cmsg()
1811 && cmsg->cmsg_type == SCM_CREDENTIALS) { in target_to_host_cmsg()
1816 __get_user(cred->pid, &target_cred->pid); in target_to_host_cmsg()
1817 __get_user(cred->uid, &target_cred->uid); in target_to_host_cmsg()
1818 __get_user(cred->gid, &target_cred->gid); in target_to_host_cmsg()
1819 } else if (cmsg->cmsg_level == SOL_ALG) { in target_to_host_cmsg()
1823 /* fix endianness of first 32-bit word */ in target_to_host_cmsg()
1829 cmsg->cmsg_level, cmsg->cmsg_type); in target_to_host_cmsg()
1839 msgh->msg_controllen = space; in target_to_host_cmsg()
1852 msg_controllen = tswapal(target_msgh->msg_controllen); in host_to_target_cmsg()
1855 target_cmsg_addr = tswapal(target_msgh->msg_control); in host_to_target_cmsg()
1859 return -TARGET_EFAULT; in host_to_target_cmsg()
1865 int len = cmsg->cmsg_len - sizeof(struct cmsghdr); in host_to_target_cmsg()
1868 /* We never copy a half-header but may copy half-data; in host_to_target_cmsg()
1875 target_msgh->msg_flags |= tswap32(MSG_CTRUNC); in host_to_target_cmsg()
1879 if (cmsg->cmsg_level == SOL_SOCKET) { in host_to_target_cmsg()
1880 target_cmsg->cmsg_level = tswap32(TARGET_SOL_SOCKET); in host_to_target_cmsg()
1882 target_cmsg->cmsg_level = tswap32(cmsg->cmsg_level); in host_to_target_cmsg()
1884 target_cmsg->cmsg_type = tswap32(cmsg->cmsg_type); in host_to_target_cmsg()
1890 switch (cmsg->cmsg_level) { in host_to_target_cmsg()
1892 switch (cmsg->cmsg_type) { in host_to_target_cmsg()
1905 target_msgh->msg_flags |= tswap32(MSG_CTRUNC); in host_to_target_cmsg()
1906 tgt_len = msg_controllen - sizeof(struct target_cmsghdr); in host_to_target_cmsg()
1909 /* We must now copy-and-convert len bytes of payload in host_to_target_cmsg()
1914 switch (cmsg->cmsg_level) { in host_to_target_cmsg()
1916 switch (cmsg->cmsg_type) { in host_to_target_cmsg()
1940 __put_user(tv->tv_sec, &target_tv->tv_sec); in host_to_target_cmsg()
1941 __put_user(tv->tv_usec, &target_tv->tv_usec); in host_to_target_cmsg()
1950 __put_user(cred->pid, &target_cred->pid); in host_to_target_cmsg()
1951 __put_user(cred->uid, &target_cred->uid); in host_to_target_cmsg()
1952 __put_user(cred->gid, &target_cred->gid); in host_to_target_cmsg()
1961 switch (cmsg->cmsg_type) { in host_to_target_cmsg()
1988 __put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno); in host_to_target_cmsg()
1989 __put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin); in host_to_target_cmsg()
1990 __put_user(errh->ee.ee_type, &target_errh->ee.ee_type); in host_to_target_cmsg()
1991 __put_user(errh->ee.ee_code, &target_errh->ee.ee_code); in host_to_target_cmsg()
1992 __put_user(errh->ee.ee_pad, &target_errh->ee.ee_pad); in host_to_target_cmsg()
1993 __put_user(errh->ee.ee_info, &target_errh->ee.ee_info); in host_to_target_cmsg()
1994 __put_user(errh->ee.ee_data, &target_errh->ee.ee_data); in host_to_target_cmsg()
1995 host_to_target_sockaddr((unsigned long) &target_errh->offender, in host_to_target_cmsg()
1996 (void *) &errh->offender, sizeof(errh->offender)); in host_to_target_cmsg()
2005 switch (cmsg->cmsg_type) { in host_to_target_cmsg()
2032 __put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno); in host_to_target_cmsg()
2033 __put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin); in host_to_target_cmsg()
2034 __put_user(errh->ee.ee_type, &target_errh->ee.ee_type); in host_to_target_cmsg()
2035 __put_user(errh->ee.ee_code, &target_errh->ee.ee_code); in host_to_target_cmsg()
2036 __put_user(errh->ee.ee_pad, &target_errh->ee.ee_pad); in host_to_target_cmsg()
2037 __put_user(errh->ee.ee_info, &target_errh->ee.ee_info); in host_to_target_cmsg()
2038 __put_user(errh->ee.ee_data, &target_errh->ee.ee_data); in host_to_target_cmsg()
2039 host_to_target_sockaddr((unsigned long) &target_errh->offender, in host_to_target_cmsg()
2040 (void *) &errh->offender, sizeof(errh->offender)); in host_to_target_cmsg()
2051 cmsg->cmsg_level, cmsg->cmsg_type); in host_to_target_cmsg()
2054 memset(target_data + len, 0, tgt_len - len); in host_to_target_cmsg()
2058 target_cmsg->cmsg_len = tswapal(TARGET_CMSG_LEN(tgt_len)); in host_to_target_cmsg()
2063 msg_controllen -= tgt_space; in host_to_target_cmsg()
2071 target_msgh->msg_controllen = tswapal(space); in host_to_target_cmsg()
2087 return -TARGET_EINVAL; in do_setsockopt()
2090 return -TARGET_EFAULT; in do_setsockopt()
2114 return -TARGET_EFAULT; in do_setsockopt()
2117 return -TARGET_EFAULT; in do_setsockopt()
2132 return -TARGET_EINVAL; in do_setsockopt()
2137 return -TARGET_EFAULT; in do_setsockopt()
2139 ip_mreq.imr_multiaddr.s_addr = target_smreqn->imr_multiaddr.s_addr; in do_setsockopt()
2140 ip_mreq.imr_address.s_addr = target_smreqn->imr_address.s_addr; in do_setsockopt()
2142 ip_mreq.imr_ifindex = tswapal(target_smreqn->imr_ifindex); in do_setsockopt()
2158 return -TARGET_EINVAL; in do_setsockopt()
2162 return -TARGET_EFAULT; in do_setsockopt()
2210 return -TARGET_EINVAL; in do_setsockopt()
2213 return -TARGET_EFAULT; in do_setsockopt()
2223 return -TARGET_EINVAL; in do_setsockopt()
2227 return -TARGET_EFAULT; in do_setsockopt()
2242 return -TARGET_EINVAL; in do_setsockopt()
2246 return -TARGET_EFAULT; in do_setsockopt()
2270 return -TARGET_EFAULT; in do_setsockopt()
2291 return -TARGET_EINVAL; in do_setsockopt()
2295 return -TARGET_EFAULT; in do_setsockopt()
2312 return -TARGET_EFAULT; in do_setsockopt()
2338 return -TARGET_EINVAL; in do_setsockopt()
2342 return -TARGET_EFAULT; in do_setsockopt()
2360 return -TARGET_EINVAL; in do_setsockopt()
2363 return -TARGET_EFAULT; in do_setsockopt()
2366 tswapal(tfprog->filter), 0)) { in do_setsockopt()
2368 return -TARGET_EFAULT; in do_setsockopt()
2371 fprog.len = tswap16(tfprog->len); in do_setsockopt()
2374 unlock_user_struct(tfilter, tfprog->filter, 1); in do_setsockopt()
2376 return -TARGET_ENOMEM; in do_setsockopt()
2390 unlock_user_struct(tfilter, tfprog->filter, 1); in do_setsockopt()
2398 if (optlen > IFNAMSIZ - 1) { in do_setsockopt()
2399 optlen = IFNAMSIZ - 1; in do_setsockopt()
2403 return -TARGET_EFAULT; in do_setsockopt()
2420 return -TARGET_EINVAL; in do_setsockopt()
2423 return -TARGET_EFAULT; in do_setsockopt()
2425 __get_user(lg.l_onoff, &tlg->l_onoff); in do_setsockopt()
2426 __get_user(lg.l_linger, &tlg->l_linger); in do_setsockopt()
2501 return -TARGET_EINVAL; in do_setsockopt()
2504 return -TARGET_EFAULT; in do_setsockopt()
2531 return -TARGET_EINVAL; in do_setsockopt()
2534 return -TARGET_EFAULT; in do_setsockopt()
2544 ret = -TARGET_ENOPROTOOPT; in do_setsockopt()
2572 return -TARGET_EFAULT; in do_getsockopt()
2575 return -TARGET_EINVAL; in do_getsockopt()
2588 return -TARGET_EFAULT; in do_getsockopt()
2591 return -TARGET_EFAULT; in do_getsockopt()
2604 return -TARGET_EFAULT; in do_getsockopt()
2607 return -TARGET_EINVAL; in do_getsockopt()
2620 return -TARGET_EFAULT; in do_getsockopt()
2622 __put_user(cr.pid, &tcr->pid); in do_getsockopt()
2623 __put_user(cr.uid, &tcr->uid); in do_getsockopt()
2624 __put_user(cr.gid, &tcr->gid); in do_getsockopt()
2627 return -TARGET_EFAULT; in do_getsockopt()
2635 return -TARGET_EFAULT; in do_getsockopt()
2638 return -TARGET_EINVAL; in do_getsockopt()
2642 return -TARGET_EFAULT; in do_getsockopt()
2648 ret = -TARGET_EFAULT; in do_getsockopt()
2660 return -TARGET_EFAULT; in do_getsockopt()
2663 return -TARGET_EINVAL; in do_getsockopt()
2676 return -TARGET_EFAULT; in do_getsockopt()
2678 __put_user(lg.l_onoff, &tlg->l_onoff); in do_getsockopt()
2679 __put_user(lg.l_linger, &tlg->l_linger); in do_getsockopt()
2682 return -TARGET_EFAULT; in do_getsockopt()
2760 return -TARGET_EFAULT; in do_getsockopt()
2762 return -TARGET_EINVAL; in do_getsockopt()
2779 return -TARGET_EFAULT; in do_getsockopt()
2782 return -TARGET_EFAULT; in do_getsockopt()
2785 return -TARGET_EFAULT; in do_getsockopt()
2805 return -TARGET_EFAULT; in do_getsockopt()
2807 return -TARGET_EINVAL; in do_getsockopt()
2816 return -TARGET_EFAULT; in do_getsockopt()
2822 return -TARGET_EFAULT; in do_getsockopt()
2826 ret = -TARGET_ENOPROTOOPT; in do_getsockopt()
2867 return -TARGET_EFAULT; in do_getsockopt()
2869 return -TARGET_EINVAL; in do_getsockopt()
2878 return -TARGET_EFAULT; in do_getsockopt()
2884 return -TARGET_EFAULT; in do_getsockopt()
2888 ret = -TARGET_ENOPROTOOPT; in do_getsockopt()
2909 return -TARGET_EFAULT; in do_getsockopt()
2912 return -TARGET_EINVAL; in do_getsockopt()
2921 return -TARGET_EFAULT; in do_getsockopt()
2930 return -TARGET_EFAULT; in do_getsockopt()
2933 return -TARGET_EINVAL; in do_getsockopt()
2937 return -TARGET_EFAULT; in do_getsockopt()
2950 return -TARGET_EFAULT; in do_getsockopt()
2966 ret = -TARGET_EOPNOTSUPP; in do_getsockopt()
3053 if (len > max_len - total_len) { in lock_iovec()
3054 len = max_len - total_len; in lock_iovec()
3065 while (--i >= 0) { in lock_iovec()
3120 return -TARGET_EINVAL; in target_to_host_sock_type()
3127 return -TARGET_EINVAL; in target_to_host_sock_type()
3140 if (fcntl(fd, F_SETFL, O_NONBLOCK | flags) == -1) { in sock_flags_fixup()
3142 return -TARGET_EINVAL; in sock_flags_fixup()
3166 return -TARGET_EPROTONOSUPPORT; in do_socket()
3211 return -TARGET_EINVAL; in do_bind()
3231 return -TARGET_EINVAL; in do_connect()
3253 if (msgp->msg_name) { in do_sendrecvmsg_locked()
3254 msg.msg_namelen = tswap32(msgp->msg_namelen); in do_sendrecvmsg_locked()
3257 tswapal(msgp->msg_name), in do_sendrecvmsg_locked()
3259 if (ret == -TARGET_EFAULT) { in do_sendrecvmsg_locked()
3265 msg.msg_name = (void *)-1; in do_sendrecvmsg_locked()
3273 msg.msg_controllen = 2 * tswapal(msgp->msg_controllen); in do_sendrecvmsg_locked()
3277 msg.msg_flags = tswap32(msgp->msg_flags); in do_sendrecvmsg_locked()
3279 count = tswapal(msgp->msg_iovlen); in do_sendrecvmsg_locked()
3280 target_vec = tswapal(msgp->msg_iov); in do_sendrecvmsg_locked()
3286 ret = -TARGET_EMSGSIZE; in do_sendrecvmsg_locked()
3293 ret = -host_to_target_errno(errno); in do_sendrecvmsg_locked()
3306 host_msg = g_malloc(msg.msg_iov->iov_len); in do_sendrecvmsg_locked()
3307 memcpy(host_msg, msg.msg_iov->iov_base, msg.msg_iov->iov_len); in do_sendrecvmsg_locked()
3309 msg.msg_iov->iov_len); in do_sendrecvmsg_locked()
3311 msg.msg_iov->iov_base = host_msg; in do_sendrecvmsg_locked()
3326 ret = fd_trans_host_to_target_data(fd)(msg.msg_iov->iov_base, in do_sendrecvmsg_locked()
3327 MIN(msg.msg_iov->iov_len, len)); in do_sendrecvmsg_locked()
3333 msgp->msg_namelen = tswap32(msg.msg_namelen); in do_sendrecvmsg_locked()
3334 msgp->msg_flags = tswap32(msg.msg_flags); in do_sendrecvmsg_locked()
3335 if (msg.msg_name != NULL && msg.msg_name != (void *)-1) { in do_sendrecvmsg_locked()
3336 ret = host_to_target_sockaddr(tswapal(msgp->msg_name), in do_sendrecvmsg_locked()
3366 return -TARGET_EFAULT; in do_sendrecvmsg()
3374 * so it might not have this *mmsg-specific flag either.
3394 return -TARGET_EFAULT; in do_sendrecvmmsg()
3430 return -TARGET_EINVAL; in do_accept4()
3447 return -TARGET_EFAULT; in do_accept4()
3450 return -TARGET_EINVAL; in do_accept4()
3454 return -TARGET_EFAULT; in do_accept4()
3464 ret = -TARGET_EFAULT; in do_accept4()
3479 return -TARGET_EFAULT; in do_getpeername()
3482 return -TARGET_EINVAL; in do_getpeername()
3486 return -TARGET_EFAULT; in do_getpeername()
3496 ret = -TARGET_EFAULT; in do_getpeername()
3511 return -TARGET_EFAULT; in do_getsockname()
3514 return -TARGET_EINVAL; in do_getsockname()
3518 return -TARGET_EFAULT; in do_getsockname()
3528 ret = -TARGET_EFAULT; in do_getsockname()
3547 ret = -TARGET_EFAULT; in do_socketpair()
3562 return -TARGET_EINVAL; in do_sendto()
3567 return -TARGET_EFAULT; in do_sendto()
3611 return -TARGET_EFAULT; in do_recvfrom()
3616 ret = -TARGET_EFAULT; in do_recvfrom()
3620 ret = -TARGET_EINVAL; in do_recvfrom()
3645 ret = -TARGET_EFAULT; in do_recvfrom()
3689 return -TARGET_EINVAL; in do_socketcall()
3693 return -TARGET_EINVAL; in do_socketcall()
3698 return -TARGET_EFAULT; in do_socketcall()
3745 return -TARGET_EINVAL; in do_socketcall()
3751 /* asm-generic version of this struct */
3776 return -TARGET_EFAULT; in target_to_host_ipc_perm()
3777 target_ip = &(target_sd->sem_perm); in target_to_host_ipc_perm()
3778 host_ip->__key = tswap32(target_ip->__key); in target_to_host_ipc_perm()
3779 host_ip->uid = tswap32(target_ip->uid); in target_to_host_ipc_perm()
3780 host_ip->gid = tswap32(target_ip->gid); in target_to_host_ipc_perm()
3781 host_ip->cuid = tswap32(target_ip->cuid); in target_to_host_ipc_perm()
3782 host_ip->cgid = tswap32(target_ip->cgid); in target_to_host_ipc_perm()
3784 host_ip->mode = tswap32(target_ip->mode); in target_to_host_ipc_perm()
3786 host_ip->mode = tswap16(target_ip->mode); in target_to_host_ipc_perm()
3789 host_ip->__seq = tswap32(target_ip->__seq); in target_to_host_ipc_perm()
3791 host_ip->__seq = tswap16(target_ip->__seq); in target_to_host_ipc_perm()
3804 return -TARGET_EFAULT; in host_to_target_ipc_perm()
3805 target_ip = &(target_sd->sem_perm); in host_to_target_ipc_perm()
3806 target_ip->__key = tswap32(host_ip->__key); in host_to_target_ipc_perm()
3807 target_ip->uid = tswap32(host_ip->uid); in host_to_target_ipc_perm()
3808 target_ip->gid = tswap32(host_ip->gid); in host_to_target_ipc_perm()
3809 target_ip->cuid = tswap32(host_ip->cuid); in host_to_target_ipc_perm()
3810 target_ip->cgid = tswap32(host_ip->cgid); in host_to_target_ipc_perm()
3812 target_ip->mode = tswap32(host_ip->mode); in host_to_target_ipc_perm()
3814 target_ip->mode = tswap16(host_ip->mode); in host_to_target_ipc_perm()
3817 target_ip->__seq = tswap32(host_ip->__seq); in host_to_target_ipc_perm()
3819 target_ip->__seq = tswap16(host_ip->__seq); in host_to_target_ipc_perm()
3831 return -TARGET_EFAULT; in target_to_host_semid_ds()
3832 if (target_to_host_ipc_perm(&(host_sd->sem_perm),target_addr)) in target_to_host_semid_ds()
3833 return -TARGET_EFAULT; in target_to_host_semid_ds()
3834 host_sd->sem_nsems = tswapal(target_sd->sem_nsems); in target_to_host_semid_ds()
3835 host_sd->sem_otime = tswapal(target_sd->sem_otime); in target_to_host_semid_ds()
3836 host_sd->sem_ctime = tswapal(target_sd->sem_ctime); in target_to_host_semid_ds()
3847 return -TARGET_EFAULT; in host_to_target_semid_ds()
3848 if (host_to_target_ipc_perm(target_addr,&(host_sd->sem_perm))) in host_to_target_semid_ds()
3849 return -TARGET_EFAULT; in host_to_target_semid_ds()
3850 target_sd->sem_nsems = tswapal(host_sd->sem_nsems); in host_to_target_semid_ds()
3851 target_sd->sem_otime = tswapal(host_sd->sem_otime); in host_to_target_semid_ds()
3852 target_sd->sem_ctime = tswapal(host_sd->sem_ctime); in host_to_target_semid_ds()
3875 return -TARGET_EFAULT; in host_to_target_seminfo()
3876 __put_user(host_seminfo->semmap, &target_seminfo->semmap); in host_to_target_seminfo()
3877 __put_user(host_seminfo->semmni, &target_seminfo->semmni); in host_to_target_seminfo()
3878 __put_user(host_seminfo->semmns, &target_seminfo->semmns); in host_to_target_seminfo()
3879 __put_user(host_seminfo->semmnu, &target_seminfo->semmnu); in host_to_target_seminfo()
3880 __put_user(host_seminfo->semmsl, &target_seminfo->semmsl); in host_to_target_seminfo()
3881 __put_user(host_seminfo->semopm, &target_seminfo->semopm); in host_to_target_seminfo()
3882 __put_user(host_seminfo->semume, &target_seminfo->semume); in host_to_target_seminfo()
3883 __put_user(host_seminfo->semusz, &target_seminfo->semusz); in host_to_target_seminfo()
3884 __put_user(host_seminfo->semvmx, &target_seminfo->semvmx); in host_to_target_seminfo()
3885 __put_user(host_seminfo->semaem, &target_seminfo->semaem); in host_to_target_seminfo()
3916 if (ret == -1) in target_to_host_semarray()
3923 return -TARGET_ENOMEM; in target_to_host_semarray()
3929 return -TARGET_EFAULT; in target_to_host_semarray()
3952 if (ret == -1) in host_to_target_semarray()
3960 return -TARGET_EFAULT; in host_to_target_semarray()
3979 abi_long ret = -TARGET_EINVAL; in do_semctl()
3986 /* In 64 bit cross-endian situations, we will erroneously pick up in do_semctl()
3988 * this, the entire 8-byte structure is byteswapped, followed by in do_semctl()
4057 return -TARGET_EFAULT; in target_to_host_sembuf()
4098 return -TARGET_EFAULT; in do_semtimedop()
4102 return -TARGET_EFAULT; in do_semtimedop()
4108 return -TARGET_E2BIG; in do_semtimedop()
4115 return -TARGET_EFAULT; in do_semtimedop()
4118 ret = -TARGET_ENOSYS; in do_semtimedop()
4123 if (ret == -TARGET_ENOSYS) { in do_semtimedop()
4163 return -TARGET_EFAULT; in target_to_host_msqid_ds()
4164 if (target_to_host_ipc_perm(&(host_md->msg_perm),target_addr)) in target_to_host_msqid_ds()
4165 return -TARGET_EFAULT; in target_to_host_msqid_ds()
4166 host_md->msg_stime = tswapal(target_md->msg_stime); in target_to_host_msqid_ds()
4167 host_md->msg_rtime = tswapal(target_md->msg_rtime); in target_to_host_msqid_ds()
4168 host_md->msg_ctime = tswapal(target_md->msg_ctime); in target_to_host_msqid_ds()
4169 host_md->__msg_cbytes = tswapal(target_md->__msg_cbytes); in target_to_host_msqid_ds()
4170 host_md->msg_qnum = tswapal(target_md->msg_qnum); in target_to_host_msqid_ds()
4171 host_md->msg_qbytes = tswapal(target_md->msg_qbytes); in target_to_host_msqid_ds()
4172 host_md->msg_lspid = tswapal(target_md->msg_lspid); in target_to_host_msqid_ds()
4173 host_md->msg_lrpid = tswapal(target_md->msg_lrpid); in target_to_host_msqid_ds()
4184 return -TARGET_EFAULT; in host_to_target_msqid_ds()
4185 if (host_to_target_ipc_perm(target_addr,&(host_md->msg_perm))) in host_to_target_msqid_ds()
4186 return -TARGET_EFAULT; in host_to_target_msqid_ds()
4187 target_md->msg_stime = tswapal(host_md->msg_stime); in host_to_target_msqid_ds()
4188 target_md->msg_rtime = tswapal(host_md->msg_rtime); in host_to_target_msqid_ds()
4189 target_md->msg_ctime = tswapal(host_md->msg_ctime); in host_to_target_msqid_ds()
4190 target_md->__msg_cbytes = tswapal(host_md->__msg_cbytes); in host_to_target_msqid_ds()
4191 target_md->msg_qnum = tswapal(host_md->msg_qnum); in host_to_target_msqid_ds()
4192 target_md->msg_qbytes = tswapal(host_md->msg_qbytes); in host_to_target_msqid_ds()
4193 target_md->msg_lspid = tswapal(host_md->msg_lspid); in host_to_target_msqid_ds()
4194 target_md->msg_lrpid = tswapal(host_md->msg_lrpid); in host_to_target_msqid_ds()
4215 return -TARGET_EFAULT; in host_to_target_msginfo()
4216 __put_user(host_msginfo->msgpool, &target_msginfo->msgpool); in host_to_target_msginfo()
4217 __put_user(host_msginfo->msgmap, &target_msginfo->msgmap); in host_to_target_msginfo()
4218 __put_user(host_msginfo->msgmax, &target_msginfo->msgmax); in host_to_target_msginfo()
4219 __put_user(host_msginfo->msgmnb, &target_msginfo->msgmnb); in host_to_target_msginfo()
4220 __put_user(host_msginfo->msgmni, &target_msginfo->msgmni); in host_to_target_msginfo()
4221 __put_user(host_msginfo->msgssz, &target_msginfo->msgssz); in host_to_target_msginfo()
4222 __put_user(host_msginfo->msgtql, &target_msginfo->msgtql); in host_to_target_msginfo()
4223 __put_user(host_msginfo->msgseg, &target_msginfo->msgseg); in host_to_target_msginfo()
4232 abi_long ret = -TARGET_EINVAL; in do_msgctl()
4241 return -TARGET_EFAULT; in do_msgctl()
4244 return -TARGET_EFAULT; in do_msgctl()
4253 return -TARGET_EFAULT; in do_msgctl()
4273 return -TARGET_EINVAL; in do_msgsnd()
4277 return -TARGET_EFAULT; in do_msgsnd()
4281 return -TARGET_ENOMEM; in do_msgsnd()
4283 host_mb->mtype = (abi_long) tswapal(target_mb->mtype); in do_msgsnd()
4284 memcpy(host_mb->mtext, target_mb->mtext, msgsz); in do_msgsnd()
4285 ret = -TARGET_ENOSYS; in do_msgsnd()
4290 if (ret == -TARGET_ENOSYS) { in do_msgsnd()
4330 return -TARGET_EINVAL; in do_msgrcv()
4334 return -TARGET_EFAULT; in do_msgrcv()
4338 ret = -TARGET_ENOMEM; in do_msgrcv()
4341 ret = -TARGET_ENOSYS; in do_msgrcv()
4346 if (ret == -TARGET_ENOSYS) { in do_msgrcv()
4356 ret = -TARGET_EFAULT; in do_msgrcv()
4359 memcpy(target_mb->mtext, host_mb->mtext, ret); in do_msgrcv()
4363 target_mb->mtype = tswapal(host_mb->mtype); in do_msgrcv()
4378 return -TARGET_EFAULT; in target_to_host_shmid_ds()
4379 if (target_to_host_ipc_perm(&(host_sd->shm_perm), target_addr)) in target_to_host_shmid_ds()
4380 return -TARGET_EFAULT; in target_to_host_shmid_ds()
4381 __get_user(host_sd->shm_segsz, &target_sd->shm_segsz); in target_to_host_shmid_ds()
4382 __get_user(host_sd->shm_atime, &target_sd->shm_atime); in target_to_host_shmid_ds()
4383 __get_user(host_sd->shm_dtime, &target_sd->shm_dtime); in target_to_host_shmid_ds()
4384 __get_user(host_sd->shm_ctime, &target_sd->shm_ctime); in target_to_host_shmid_ds()
4385 __get_user(host_sd->shm_cpid, &target_sd->shm_cpid); in target_to_host_shmid_ds()
4386 __get_user(host_sd->shm_lpid, &target_sd->shm_lpid); in target_to_host_shmid_ds()
4387 __get_user(host_sd->shm_nattch, &target_sd->shm_nattch); in target_to_host_shmid_ds()
4398 return -TARGET_EFAULT; in host_to_target_shmid_ds()
4399 if (host_to_target_ipc_perm(target_addr, &(host_sd->shm_perm))) in host_to_target_shmid_ds()
4400 return -TARGET_EFAULT; in host_to_target_shmid_ds()
4401 __put_user(host_sd->shm_segsz, &target_sd->shm_segsz); in host_to_target_shmid_ds()
4402 __put_user(host_sd->shm_atime, &target_sd->shm_atime); in host_to_target_shmid_ds()
4403 __put_user(host_sd->shm_dtime, &target_sd->shm_dtime); in host_to_target_shmid_ds()
4404 __put_user(host_sd->shm_ctime, &target_sd->shm_ctime); in host_to_target_shmid_ds()
4405 __put_user(host_sd->shm_cpid, &target_sd->shm_cpid); in host_to_target_shmid_ds()
4406 __put_user(host_sd->shm_lpid, &target_sd->shm_lpid); in host_to_target_shmid_ds()
4407 __put_user(host_sd->shm_nattch, &target_sd->shm_nattch); in host_to_target_shmid_ds()
4425 return -TARGET_EFAULT; in host_to_target_shminfo()
4426 __put_user(host_shminfo->shmmax, &target_shminfo->shmmax); in host_to_target_shminfo()
4427 __put_user(host_shminfo->shmmin, &target_shminfo->shmmin); in host_to_target_shminfo()
4428 __put_user(host_shminfo->shmmni, &target_shminfo->shmmni); in host_to_target_shminfo()
4429 __put_user(host_shminfo->shmseg, &target_shminfo->shmseg); in host_to_target_shminfo()
4430 __put_user(host_shminfo->shmall, &target_shminfo->shmall); in host_to_target_shminfo()
4449 return -TARGET_EFAULT; in host_to_target_shm_info()
4450 __put_user(host_shm_info->used_ids, &target_shm_info->used_ids); in host_to_target_shm_info()
4451 __put_user(host_shm_info->shm_tot, &target_shm_info->shm_tot); in host_to_target_shm_info()
4452 __put_user(host_shm_info->shm_rss, &target_shm_info->shm_rss); in host_to_target_shm_info()
4453 __put_user(host_shm_info->shm_swp, &target_shm_info->shm_swp); in host_to_target_shm_info()
4454 __put_user(host_shm_info->swap_attempts, &target_shm_info->swap_attempts); in host_to_target_shm_info()
4455 __put_user(host_shm_info->swap_successes, &target_shm_info->swap_successes); in host_to_target_shm_info()
4465 abi_long ret = -TARGET_EINVAL; in do_shmctl()
4474 return -TARGET_EFAULT; in do_shmctl()
4477 return -TARGET_EFAULT; in do_shmctl()
4482 return -TARGET_EFAULT; in do_shmctl()
4487 return -TARGET_EFAULT; in do_shmctl()
4566 ret = -TARGET_EFAULT; in do_ipc()
4570 ret = do_msgrcv(first, tswapal(tmp->msgp), second, tswapal(tmp->msgtyp), third); in do_ipc()
4589 return -TARGET_EFAULT; in do_ipc()
4593 ret = -TARGET_EINVAL; in do_ipc()
4613 ret = -TARGET_ENOSYS; in do_ipc()
4644 #define FIEMAP_MAX_EXTENTS ((UINT_MAX - sizeof(struct fiemap)) \
4652 * in fiemap->fm_extent_count. The array is filled in by the in do_ioctl_fs_ioc_fiemap()
4657 const argtype *arg_type = ie->arg_type; in do_ioctl_fs_ioc_fiemap()
4666 assert(ie->access == IOC_RW); in do_ioctl_fs_ioc_fiemap()
4671 return -TARGET_EFAULT; in do_ioctl_fs_ioc_fiemap()
4676 if (fm->fm_extent_count > FIEMAP_MAX_EXTENTS) { in do_ioctl_fs_ioc_fiemap()
4677 return -TARGET_EINVAL; in do_ioctl_fs_ioc_fiemap()
4681 (sizeof(struct fiemap_extent) * fm->fm_extent_count); in do_ioctl_fs_ioc_fiemap()
4689 return -TARGET_ENOMEM; in do_ioctl_fs_ioc_fiemap()
4694 ret = get_errno(safe_ioctl(fd, ie->host_cmd, fm)); in do_ioctl_fs_ioc_fiemap()
4700 if (fm->fm_extent_count != 0) { in do_ioctl_fs_ioc_fiemap()
4701 target_size_out += fm->fm_mapped_extents * extent_size; in do_ioctl_fs_ioc_fiemap()
4705 ret = -TARGET_EFAULT; in do_ioctl_fs_ioc_fiemap()
4709 if (fm->fm_extent_count != 0) { in do_ioctl_fs_ioc_fiemap()
4712 for (i = 0; i < fm->fm_mapped_extents; i++) { in do_ioctl_fs_ioc_fiemap()
4713 thunk_convert(p, &fm->fm_extents[i], extent_arg_type, in do_ioctl_fs_ioc_fiemap()
4731 const argtype *arg_type = ie->arg_type; in do_ioctl_ifconf()
4749 assert(ie->access == IOC_RW); in do_ioctl_ifconf()
4756 return -TARGET_EFAULT; in do_ioctl_ifconf()
4761 target_ifc_buf = (abi_long)(unsigned long)host_ifconf->ifc_buf; in do_ioctl_ifconf()
4765 target_ifc_len = host_ifconf->ifc_len; in do_ioctl_ifconf()
4777 return -TARGET_ENOMEM; in do_ioctl_ifconf()
4784 host_ifconf->ifc_len = host_ifc_len; in do_ioctl_ifconf()
4788 host_ifconf->ifc_buf = host_ifc_buf; in do_ioctl_ifconf()
4790 ret = get_errno(safe_ioctl(fd, ie->host_cmd, host_ifconf)); in do_ioctl_ifconf()
4794 nb_ifreq = host_ifconf->ifc_len / sizeof(struct ifreq); in do_ioctl_ifconf()
4796 host_ifconf->ifc_len = target_ifc_len; in do_ioctl_ifconf()
4800 host_ifconf->ifc_buf = (char *)(unsigned long)target_ifc_buf; in do_ioctl_ifconf()
4806 return -TARGET_EFAULT; in do_ioctl_ifconf()
4884 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl_usbdevfs_reapurb()
4890 lurb = (void *)((uintptr_t)hurb - offsetof(struct live_urb, host_urb)); in do_ioctl_usbdevfs_reapurb()
4891 if (!lurb->target_urb_adr) { in do_ioctl_usbdevfs_reapurb()
4892 return -TARGET_EFAULT; in do_ioctl_usbdevfs_reapurb()
4895 unlock_user(lurb->target_buf_ptr, lurb->target_buf_adr, in do_ioctl_usbdevfs_reapurb()
4896 lurb->host_urb.buffer_length); in do_ioctl_usbdevfs_reapurb()
4897 lurb->target_buf_ptr = NULL; in do_ioctl_usbdevfs_reapurb()
4900 lurb->host_urb.buffer = (void *)(uintptr_t)lurb->target_buf_adr; in do_ioctl_usbdevfs_reapurb()
4903 argptr = lock_user(VERIFY_WRITE, lurb->target_urb_adr, target_size, 0); in do_ioctl_usbdevfs_reapurb()
4906 return -TARGET_EFAULT; in do_ioctl_usbdevfs_reapurb()
4908 thunk_convert(argptr, &lurb->host_urb, usbfsurb_arg_type, THUNK_TARGET); in do_ioctl_usbdevfs_reapurb()
4909 unlock_user(argptr, lurb->target_urb_adr, target_size); in do_ioctl_usbdevfs_reapurb()
4916 return -TARGET_EFAULT; in do_ioctl_usbdevfs_reapurb()
4919 /* GHashTable uses 64-bit keys but thunk_convert expects uintptr_t */ in do_ioctl_usbdevfs_reapurb()
4920 target_urb_adr = lurb->target_urb_adr; in do_ioctl_usbdevfs_reapurb()
4938 return -TARGET_EFAULT; in do_ioctl_usbdevfs_discardurb()
4940 return get_errno(safe_ioctl(fd, ie->host_cmd, &lurb->host_urb)); in do_ioctl_usbdevfs_discardurb()
4947 const argtype *arg_type = ie->arg_type; in do_ioctl_usbdevfs_submiturb()
4966 return -TARGET_ENOMEM; in do_ioctl_usbdevfs_submiturb()
4972 return -TARGET_EFAULT; in do_ioctl_usbdevfs_submiturb()
4974 thunk_convert(&lurb->host_urb, argptr, arg_type, THUNK_HOST); in do_ioctl_usbdevfs_submiturb()
4977 lurb->target_urb_adr = arg; in do_ioctl_usbdevfs_submiturb()
4978 lurb->target_buf_adr = (uintptr_t)lurb->host_urb.buffer; in do_ioctl_usbdevfs_submiturb()
4982 rw_dir = lurb->host_urb.endpoint & USB_DIR_IN ? VERIFY_WRITE : VERIFY_READ; in do_ioctl_usbdevfs_submiturb()
4983 lurb->target_buf_ptr = lock_user(rw_dir, lurb->target_buf_adr, in do_ioctl_usbdevfs_submiturb()
4984 lurb->host_urb.buffer_length, 1); in do_ioctl_usbdevfs_submiturb()
4985 if (lurb->target_buf_ptr == NULL) { in do_ioctl_usbdevfs_submiturb()
4987 return -TARGET_EFAULT; in do_ioctl_usbdevfs_submiturb()
4991 lurb->host_urb.buffer = lurb->target_buf_ptr; in do_ioctl_usbdevfs_submiturb()
4993 ret = get_errno(safe_ioctl(fd, ie->host_cmd, &lurb->host_urb)); in do_ioctl_usbdevfs_submiturb()
4995 unlock_user(lurb->target_buf_ptr, lurb->target_buf_adr, 0); in do_ioctl_usbdevfs_submiturb()
5013 const argtype *arg_type = ie->arg_type; in do_ioctl_dm()
5022 ret = -TARGET_EFAULT; in do_ioctl_dm()
5029 big_buf = g_malloc0(((struct dm_ioctl*)buf_temp)->data_size * 2); in do_ioctl_dm()
5034 guest_data = arg + host_dm->data_start; in do_ioctl_dm()
5035 if ((guest_data - arg) < 0) { in do_ioctl_dm()
5036 ret = -TARGET_EINVAL; in do_ioctl_dm()
5039 guest_data_size = host_dm->data_size - host_dm->data_start; in do_ioctl_dm()
5040 host_data = (char*)host_dm + host_dm->data_start; in do_ioctl_dm()
5044 ret = -TARGET_EFAULT; in do_ioctl_dm()
5048 switch (ie->host_cmd) { in do_ioctl_dm()
5079 for (i = 0; i < host_dm->target_count; i++) { in do_ioctl_dm()
5086 next = spec->next; in do_ioctl_dm()
5087 spec->next = sizeof(*spec) + slen; in do_ioctl_dm()
5090 cur_data += spec->next; in do_ioctl_dm()
5095 ret = -TARGET_EINVAL; in do_ioctl_dm()
5101 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl_dm()
5103 guest_data = arg + host_dm->data_start; in do_ioctl_dm()
5104 guest_data_size = host_dm->data_size - host_dm->data_start; in do_ioctl_dm()
5106 switch (ie->host_cmd) { in do_ioctl_dm()
5121 struct dm_name_list *nl = (void*)host_dm + host_dm->data_start; in do_ioctl_dm()
5128 uint32_t next = nl->next; in do_ioctl_dm()
5130 nl->next = nl_size + (strlen(nl->name) + 1); in do_ioctl_dm()
5132 if (remaining_data < nl->next) { in do_ioctl_dm()
5133 host_dm->flags |= DM_BUFFER_FULL_FLAG; in do_ioctl_dm()
5137 strcpy(cur_data + nl_size, nl->name); in do_ioctl_dm()
5138 cur_data += nl->next; in do_ioctl_dm()
5139 remaining_data -= nl->next; in do_ioctl_dm()
5150 struct dm_target_spec *spec = (void*)host_dm + host_dm->data_start; in do_ioctl_dm()
5156 for (i = 0; i < host_dm->target_count; i++) { in do_ioctl_dm()
5157 uint32_t next = spec->next; in do_ioctl_dm()
5159 spec->next = (cur_data - argptr) + spec_size + slen; in do_ioctl_dm()
5160 if (guest_data_size < spec->next) { in do_ioctl_dm()
5161 host_dm->flags |= DM_BUFFER_FULL_FLAG; in do_ioctl_dm()
5166 cur_data = argptr + spec->next; in do_ioctl_dm()
5167 spec = (void*)host_dm + host_dm->data_start + next; in do_ioctl_dm()
5173 void *hdata = (void*)host_dm + host_dm->data_start; in do_ioctl_dm()
5189 struct dm_target_versions *vers = (void*)host_dm + host_dm->data_start; in do_ioctl_dm()
5196 uint32_t next = vers->next; in do_ioctl_dm()
5198 vers->next = vers_size + (strlen(vers->name) + 1); in do_ioctl_dm()
5200 if (remaining_data < vers->next) { in do_ioctl_dm()
5201 host_dm->flags |= DM_BUFFER_FULL_FLAG; in do_ioctl_dm()
5205 strcpy(cur_data + vers_size, vers->name); in do_ioctl_dm()
5206 cur_data += vers->next; in do_ioctl_dm()
5207 remaining_data -= vers->next; in do_ioctl_dm()
5217 ret = -TARGET_EINVAL; in do_ioctl_dm()
5224 ret = -TARGET_EFAULT; in do_ioctl_dm()
5240 const argtype *arg_type = ie->arg_type; in do_ioctl_blkpg()
5252 ret = -TARGET_EFAULT; in do_ioctl_blkpg()
5258 switch (host_blkpg->op) { in do_ioctl_blkpg()
5265 ret = -TARGET_EINVAL; in do_ioctl_blkpg()
5269 /* Read and convert blkpg->data */ in do_ioctl_blkpg()
5270 arg = (abi_long)(uintptr_t)host_blkpg->data; in do_ioctl_blkpg()
5274 ret = -TARGET_EFAULT; in do_ioctl_blkpg()
5281 host_blkpg->data = &host_part; in do_ioctl_blkpg()
5282 ret = get_errno(safe_ioctl(fd, ie->host_cmd, host_blkpg)); in do_ioctl_blkpg()
5291 const argtype *arg_type = ie->arg_type; in do_ioctl_rt()
5302 assert(ie->access == IOC_W); in do_ioctl_rt()
5309 return -TARGET_EFAULT; in do_ioctl_rt()
5314 assert(se->convert[0] == NULL); in do_ioctl_rt()
5316 field_types = se->field_types; in do_ioctl_rt()
5317 dst_offsets = se->field_offsets[THUNK_HOST]; in do_ioctl_rt()
5318 src_offsets = se->field_offsets[THUNK_TARGET]; in do_ioctl_rt()
5319 for (i = 0; i < se->nb_fields; i++) { in do_ioctl_rt()
5329 return -TARGET_EFAULT; in do_ioctl_rt()
5343 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl_rt()
5358 return get_errno(safe_ioctl(fd, ie->host_cmd, sig)); in do_ioctl_kdsigaccept()
5374 return -TARGET_EFAULT; in do_ioctl_SIOCGSTAMP()
5378 return -TARGET_EFAULT; in do_ioctl_SIOCGSTAMP()
5398 return -TARGET_EFAULT; in do_ioctl_SIOCGSTAMPNS()
5402 return -TARGET_EFAULT; in do_ioctl_SIOCGSTAMPNS()
5414 return get_errno(safe_ioctl(fd, ie->host_cmd, flags)); in do_ioctl_tiocgptpeer()
5424 unlock_user(host_ver->name, target_ver->name, in unlock_drm_version()
5425 copy ? host_ver->name_len : 0); in unlock_drm_version()
5426 unlock_user(host_ver->date, target_ver->date, in unlock_drm_version()
5427 copy ? host_ver->date_len : 0); in unlock_drm_version()
5428 unlock_user(host_ver->desc, target_ver->desc, in unlock_drm_version()
5429 copy ? host_ver->desc_len : 0); in unlock_drm_version()
5437 __get_user(host_ver->name_len, &target_ver->name_len); in target_to_host_drmversion()
5438 if (host_ver->name_len) { in target_to_host_drmversion()
5439 host_ver->name = lock_user(VERIFY_WRITE, target_ver->name, in target_to_host_drmversion()
5440 target_ver->name_len, 0); in target_to_host_drmversion()
5441 if (!host_ver->name) { in target_to_host_drmversion()
5442 return -EFAULT; in target_to_host_drmversion()
5446 __get_user(host_ver->date_len, &target_ver->date_len); in target_to_host_drmversion()
5447 if (host_ver->date_len) { in target_to_host_drmversion()
5448 host_ver->date = lock_user(VERIFY_WRITE, target_ver->date, in target_to_host_drmversion()
5449 target_ver->date_len, 0); in target_to_host_drmversion()
5450 if (!host_ver->date) { in target_to_host_drmversion()
5455 __get_user(host_ver->desc_len, &target_ver->desc_len); in target_to_host_drmversion()
5456 if (host_ver->desc_len) { in target_to_host_drmversion()
5457 host_ver->desc = lock_user(VERIFY_WRITE, target_ver->desc, in target_to_host_drmversion()
5458 target_ver->desc_len, 0); in target_to_host_drmversion()
5459 if (!host_ver->desc) { in target_to_host_drmversion()
5467 return -EFAULT; in target_to_host_drmversion()
5474 __put_user(host_ver->version_major, &target_ver->version_major); in host_to_target_drmversion()
5475 __put_user(host_ver->version_minor, &target_ver->version_minor); in host_to_target_drmversion()
5476 __put_user(host_ver->version_patchlevel, &target_ver->version_patchlevel); in host_to_target_drmversion()
5477 __put_user(host_ver->name_len, &target_ver->name_len); in host_to_target_drmversion()
5478 __put_user(host_ver->date_len, &target_ver->date_len); in host_to_target_drmversion()
5479 __put_user(host_ver->desc_len, &target_ver->desc_len); in host_to_target_drmversion()
5490 switch (ie->host_cmd) { in do_ioctl_drm()
5493 return -TARGET_EFAULT; in do_ioctl_drm()
5498 ret = get_errno(safe_ioctl(fd, ie->host_cmd, ver)); in do_ioctl_drm()
5508 return -TARGET_ENOSYS; in do_ioctl_drm()
5520 return -TARGET_EFAULT; in do_ioctl_drm_i915_getparam()
5523 __get_user(gparam->param, &target_gparam->param); in do_ioctl_drm_i915_getparam()
5524 gparam->value = &value; in do_ioctl_drm_i915_getparam()
5525 ret = get_errno(safe_ioctl(fd, ie->host_cmd, gparam)); in do_ioctl_drm_i915_getparam()
5526 put_user_s32(value, target_gparam->value); in do_ioctl_drm_i915_getparam()
5535 switch (ie->host_cmd) { in do_ioctl_drm_i915()
5541 return -TARGET_ENOSYS; in do_ioctl_drm_i915()
5554 assert(ie->access == IOC_W); in do_ioctl_TUNSETTXFILTER()
5558 return -TARGET_EFAULT; in do_ioctl_TUNSETTXFILTER()
5560 filter->flags = tswap16(target_filter->flags); in do_ioctl_TUNSETTXFILTER()
5561 filter->count = tswap16(target_filter->count); in do_ioctl_TUNSETTXFILTER()
5564 if (filter->count) { in do_ioctl_TUNSETTXFILTER()
5565 if (offsetof(struct tun_filter, addr) + filter->count * ETH_ALEN > in do_ioctl_TUNSETTXFILTER()
5567 return -TARGET_EFAULT; in do_ioctl_TUNSETTXFILTER()
5572 filter->count * ETH_ALEN, 1); in do_ioctl_TUNSETTXFILTER()
5574 return -TARGET_EFAULT; in do_ioctl_TUNSETTXFILTER()
5576 memcpy(filter->addr, target_addr, filter->count * ETH_ALEN); in do_ioctl_TUNSETTXFILTER()
5580 return get_errno(safe_ioctl(fd, ie->host_cmd, filter)); in do_ioctl_TUNSETTXFILTER()
5607 if (ie->target_cmd == 0) { in do_ioctl()
5610 return -TARGET_ENOTTY; in do_ioctl()
5612 if (ie->target_cmd == cmd) in do_ioctl()
5616 arg_type = ie->arg_type; in do_ioctl()
5617 if (ie->do_ioctl) { in do_ioctl()
5618 return ie->do_ioctl(ie, buf_temp, fd, cmd, arg); in do_ioctl()
5619 } else if (!ie->host_cmd) { in do_ioctl()
5620 /* Some architectures define BSD ioctls in their headers in do_ioctl()
5622 return -TARGET_ENOTTY; in do_ioctl()
5628 ret = get_errno(safe_ioctl(fd, ie->host_cmd)); in do_ioctl()
5634 ret = get_errno(safe_ioctl(fd, ie->host_cmd, arg)); in do_ioctl()
5639 switch(ie->access) { in do_ioctl()
5641 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl()
5645 return -TARGET_EFAULT; in do_ioctl()
5653 return -TARGET_EFAULT; in do_ioctl()
5656 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl()
5662 return -TARGET_EFAULT; in do_ioctl()
5665 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl()
5669 return -TARGET_EFAULT; in do_ioctl()
5680 ret = -TARGET_ENOTTY; in do_ioctl()
5789 host->c_iflag = in target_to_host_termios()
5790 target_to_host_bitmask(tswap32(target->c_iflag), iflag_tbl); in target_to_host_termios()
5791 host->c_oflag = in target_to_host_termios()
5792 target_to_host_bitmask(tswap32(target->c_oflag), oflag_tbl); in target_to_host_termios()
5793 host->c_cflag = in target_to_host_termios()
5794 target_to_host_bitmask(tswap32(target->c_cflag), cflag_tbl); in target_to_host_termios()
5795 host->c_lflag = in target_to_host_termios()
5796 target_to_host_bitmask(tswap32(target->c_lflag), lflag_tbl); in target_to_host_termios()
5797 host->c_line = target->c_line; in target_to_host_termios()
5799 memset(host->c_cc, 0, sizeof(host->c_cc)); in target_to_host_termios()
5800 host->c_cc[VINTR] = target->c_cc[TARGET_VINTR]; in target_to_host_termios()
5801 host->c_cc[VQUIT] = target->c_cc[TARGET_VQUIT]; in target_to_host_termios()
5802 host->c_cc[VERASE] = target->c_cc[TARGET_VERASE]; in target_to_host_termios()
5803 host->c_cc[VKILL] = target->c_cc[TARGET_VKILL]; in target_to_host_termios()
5804 host->c_cc[VEOF] = target->c_cc[TARGET_VEOF]; in target_to_host_termios()
5805 host->c_cc[VTIME] = target->c_cc[TARGET_VTIME]; in target_to_host_termios()
5806 host->c_cc[VMIN] = target->c_cc[TARGET_VMIN]; in target_to_host_termios()
5807 host->c_cc[VSWTC] = target->c_cc[TARGET_VSWTC]; in target_to_host_termios()
5808 host->c_cc[VSTART] = target->c_cc[TARGET_VSTART]; in target_to_host_termios()
5809 host->c_cc[VSTOP] = target->c_cc[TARGET_VSTOP]; in target_to_host_termios()
5810 host->c_cc[VSUSP] = target->c_cc[TARGET_VSUSP]; in target_to_host_termios()
5811 host->c_cc[VEOL] = target->c_cc[TARGET_VEOL]; in target_to_host_termios()
5812 host->c_cc[VREPRINT] = target->c_cc[TARGET_VREPRINT]; in target_to_host_termios()
5813 host->c_cc[VDISCARD] = target->c_cc[TARGET_VDISCARD]; in target_to_host_termios()
5814 host->c_cc[VWERASE] = target->c_cc[TARGET_VWERASE]; in target_to_host_termios()
5815 host->c_cc[VLNEXT] = target->c_cc[TARGET_VLNEXT]; in target_to_host_termios()
5816 host->c_cc[VEOL2] = target->c_cc[TARGET_VEOL2]; in target_to_host_termios()
5824 target->c_iflag = in host_to_target_termios()
5825 tswap32(host_to_target_bitmask(host->c_iflag, iflag_tbl)); in host_to_target_termios()
5826 target->c_oflag = in host_to_target_termios()
5827 tswap32(host_to_target_bitmask(host->c_oflag, oflag_tbl)); in host_to_target_termios()
5828 target->c_cflag = in host_to_target_termios()
5829 tswap32(host_to_target_bitmask(host->c_cflag, cflag_tbl)); in host_to_target_termios()
5830 target->c_lflag = in host_to_target_termios()
5831 tswap32(host_to_target_bitmask(host->c_lflag, lflag_tbl)); in host_to_target_termios()
5832 target->c_line = host->c_line; in host_to_target_termios()
5834 memset(target->c_cc, 0, sizeof(target->c_cc)); in host_to_target_termios()
5835 target->c_cc[TARGET_VINTR] = host->c_cc[VINTR]; in host_to_target_termios()
5836 target->c_cc[TARGET_VQUIT] = host->c_cc[VQUIT]; in host_to_target_termios()
5837 target->c_cc[TARGET_VERASE] = host->c_cc[VERASE]; in host_to_target_termios()
5838 target->c_cc[TARGET_VKILL] = host->c_cc[VKILL]; in host_to_target_termios()
5839 target->c_cc[TARGET_VEOF] = host->c_cc[VEOF]; in host_to_target_termios()
5840 target->c_cc[TARGET_VTIME] = host->c_cc[VTIME]; in host_to_target_termios()
5841 target->c_cc[TARGET_VMIN] = host->c_cc[VMIN]; in host_to_target_termios()
5842 target->c_cc[TARGET_VSWTC] = host->c_cc[VSWTC]; in host_to_target_termios()
5843 target->c_cc[TARGET_VSTART] = host->c_cc[VSTART]; in host_to_target_termios()
5844 target->c_cc[TARGET_VSTOP] = host->c_cc[VSTOP]; in host_to_target_termios()
5845 target->c_cc[TARGET_VSUSP] = host->c_cc[VSUSP]; in host_to_target_termios()
5846 target->c_cc[TARGET_VEOL] = host->c_cc[VEOL]; in host_to_target_termios()
5847 target->c_cc[TARGET_VREPRINT] = host->c_cc[VREPRINT]; in host_to_target_termios()
5848 target->c_cc[TARGET_VDISCARD] = host->c_cc[VDISCARD]; in host_to_target_termios()
5849 target->c_cc[TARGET_VWERASE] = host->c_cc[VWERASE]; in host_to_target_termios()
5850 target->c_cc[TARGET_VLNEXT] = host->c_cc[VLNEXT]; in host_to_target_termios()
5851 target->c_cc[TARGET_VEOL2] = host->c_cc[VEOL2]; in host_to_target_termios()
5883 /* MAP_STACK had been ignored by the kernel for quite some time.
5949 return -TARGET_EOPNOTSUPP; in do_mmap()
5957 return -TARGET_EINVAL; in do_mmap()
5985 return -TARGET_EFAULT; in read_ldt()
6003 return -TARGET_EINVAL; in write_ldt()
6005 return -TARGET_EFAULT; in write_ldt()
6006 ldt_info.entry_number = tswap32(target_ldt_info->entry_number); in write_ldt()
6007 ldt_info.base_addr = tswapal(target_ldt_info->base_addr); in write_ldt()
6008 ldt_info.limit = tswap32(target_ldt_info->limit); in write_ldt()
6009 ldt_info.flags = tswap32(target_ldt_info->flags); in write_ldt()
6013 return -TARGET_EINVAL; in write_ldt()
6027 return -TARGET_EINVAL; in write_ldt()
6029 return -TARGET_EINVAL; in write_ldt()
6033 env->ldt.base = target_mmap(0, in write_ldt()
6036 MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); in write_ldt()
6037 if (env->ldt.base == -1) in write_ldt()
6038 return -TARGET_ENOMEM; in write_ldt()
6039 memset(g2h_untagged(env->ldt.base), 0, in write_ldt()
6041 env->ldt.limit = 0xffff; in write_ldt()
6042 ldt_table = g2h_untagged(env->ldt.base); in write_ldt()
6101 ret = -TARGET_ENOSYS; in do_modify_ldt()
6110 uint64_t *gdt_table = g2h_untagged(env->gdt.base); in do_set_thread_area()
6120 return -TARGET_EFAULT; in do_set_thread_area()
6121 ldt_info.entry_number = tswap32(target_ldt_info->entry_number); in do_set_thread_area()
6122 ldt_info.base_addr = tswapal(target_ldt_info->base_addr); in do_set_thread_area()
6123 ldt_info.limit = tswap32(target_ldt_info->limit); in do_set_thread_area()
6124 ldt_info.flags = tswap32(target_ldt_info->flags); in do_set_thread_area()
6125 if (ldt_info.entry_number == -1) { in do_set_thread_area()
6129 target_ldt_info->entry_number = tswap32(i); in do_set_thread_area()
6138 return -TARGET_EINVAL; in do_set_thread_area()
6153 return -TARGET_EINVAL; in do_set_thread_area()
6196 uint64_t *gdt_table = g2h_untagged(env->gdt.base); in do_get_thread_area()
6204 return -TARGET_EFAULT; in do_get_thread_area()
6205 idx = tswap32(target_ldt_info->entry_number); in do_get_thread_area()
6209 return -TARGET_EINVAL; in do_get_thread_area()
6233 target_ldt_info->base_addr = tswapal(base_addr); in do_get_thread_area()
6234 target_ldt_info->limit = tswap32(limit); in do_get_thread_area()
6235 target_ldt_info->flags = tswap32(flags); in do_get_thread_area()
6242 return -TARGET_ENOSYS; in do_arch_prctl()
6259 env->segs[idx].base = addr; in do_arch_prctl()
6267 val = env->segs[idx].base; in do_arch_prctl()
6269 ret = -TARGET_EFAULT; in do_arch_prctl()
6272 ret = -TARGET_EINVAL; in do_arch_prctl()
6330 return -TARGET_EINVAL; in do_prctl_inval0()
6335 return -TARGET_EINVAL; in do_prctl_inval1()
6385 return -TARGET_EFAULT; in do_prctl()
6396 return -TARGET_EFAULT; in do_prctl()
6407 return -TARGET_EFAULT; in do_prctl()
6428 return -TARGET_EINVAL; in do_prctl()
6433 return -TARGET_EINVAL; in do_prctl()
6438 return -TARGET_EINVAL; in do_prctl()
6469 /* Some prctl options have no pointer arguments and we can pass on. */ in do_prctl()
6478 return -TARGET_EFAULT; in do_prctl()
6486 return put_user_ual(ts->child_tidptr, arg2); in do_prctl()
6492 return -TARGET_EINVAL; in do_prctl()
6507 return -TARGET_EINVAL; in do_prctl()
6512 return -TARGET_EINVAL; in do_prctl()
6540 env = info->env; in clone_func()
6544 info->tid = sys_gettid(); in clone_func()
6546 if (info->child_tidptr) in clone_func()
6547 put_user_u32(info->tid, info->child_tidptr); in clone_func()
6548 if (info->parent_tidptr) in clone_func()
6549 put_user_u32(info->tid, info->parent_tidptr); in clone_func()
6550 qemu_guest_random_seed_thread_part2(cpu->random_seed); in clone_func()
6552 sigprocmask(SIG_SETMASK, &info->sigmask, NULL); in clone_func()
6554 pthread_mutex_lock(&info->mutex); in clone_func()
6555 pthread_cond_broadcast(&info->cond); in clone_func()
6556 pthread_mutex_unlock(&info->mutex); in clone_func()
6591 return -TARGET_EINVAL; in do_fork()
6616 new_cpu->opaque = ts; in do_fork()
6617 ts->bprm = parent_ts->bprm; in do_fork()
6618 ts->info = parent_ts->info; in do_fork()
6619 ts->signal_mask = parent_ts->signal_mask; in do_fork()
6622 ts->child_tidptr = child_tidptr; in do_fork()
6648 cpu->random_seed = qemu_guest_random_seed_thread_part1(); in do_fork()
6660 ret = -1; in do_fork()
6669 return -TARGET_EINVAL; in do_fork()
6674 return -TARGET_EINVAL; in do_fork()
6679 return -TARGET_EINVAL; in do_fork()
6685 return -TARGET_EINVAL; in do_fork()
6689 return -QEMU_ERESTARTSYS; in do_fork()
6712 ts->child_tidptr = child_tidptr; in do_fork()
6825 ret = -TARGET_EINVAL; in target_to_host_fcntl_cmd()
6836 ret -= F_GETLK - 5; in target_to_host_fcntl_cmd()
6855 return -TARGET_EINVAL; in target_to_host_flock()
6864 * from the host we copy to the target field as-is in host_to_target_flock()
6876 return -TARGET_EFAULT; in copy_from_user_flock()
6879 __get_user(l_type, &target_fl->l_type); in copy_from_user_flock()
6884 fl->l_type = l_type; in copy_from_user_flock()
6885 __get_user(fl->l_whence, &target_fl->l_whence); in copy_from_user_flock()
6886 __get_user(fl->l_start, &target_fl->l_start); in copy_from_user_flock()
6887 __get_user(fl->l_len, &target_fl->l_len); in copy_from_user_flock()
6888 __get_user(fl->l_pid, &target_fl->l_pid); in copy_from_user_flock()
6900 return -TARGET_EFAULT; in copy_to_user_flock()
6903 l_type = host_to_target_flock(fl->l_type); in copy_to_user_flock()
6904 __put_user(l_type, &target_fl->l_type); in copy_to_user_flock()
6905 __put_user(fl->l_whence, &target_fl->l_whence); in copy_to_user_flock()
6906 __put_user(fl->l_start, &target_fl->l_start); in copy_to_user_flock()
6907 __put_user(fl->l_len, &target_fl->l_len); in copy_to_user_flock()
6908 __put_user(fl->l_pid, &target_fl->l_pid); in copy_to_user_flock()
6932 return -TARGET_EFAULT; in copy_from_user_oabi_flock64()
6935 __get_user(l_type, &target_fl->l_type); in copy_from_user_oabi_flock64()
6940 fl->l_type = l_type; in copy_from_user_oabi_flock64()
6941 __get_user(fl->l_whence, &target_fl->l_whence); in copy_from_user_oabi_flock64()
6942 __get_user(fl->l_start, &target_fl->l_start); in copy_from_user_oabi_flock64()
6943 __get_user(fl->l_len, &target_fl->l_len); in copy_from_user_oabi_flock64()
6944 __get_user(fl->l_pid, &target_fl->l_pid); in copy_from_user_oabi_flock64()
6956 return -TARGET_EFAULT; in copy_to_user_oabi_flock64()
6959 l_type = host_to_target_flock(fl->l_type); in copy_to_user_oabi_flock64()
6960 __put_user(l_type, &target_fl->l_type); in copy_to_user_oabi_flock64()
6961 __put_user(fl->l_whence, &target_fl->l_whence); in copy_to_user_oabi_flock64()
6962 __put_user(fl->l_start, &target_fl->l_start); in copy_to_user_oabi_flock64()
6963 __put_user(fl->l_len, &target_fl->l_len); in copy_to_user_oabi_flock64()
6964 __put_user(fl->l_pid, &target_fl->l_pid); in copy_to_user_oabi_flock64()
6977 return -TARGET_EFAULT; in copy_from_user_flock64()
6980 __get_user(l_type, &target_fl->l_type); in copy_from_user_flock64()
6985 fl->l_type = l_type; in copy_from_user_flock64()
6986 __get_user(fl->l_whence, &target_fl->l_whence); in copy_from_user_flock64()
6987 __get_user(fl->l_start, &target_fl->l_start); in copy_from_user_flock64()
6988 __get_user(fl->l_len, &target_fl->l_len); in copy_from_user_flock64()
6989 __get_user(fl->l_pid, &target_fl->l_pid); in copy_from_user_flock64()
7001 return -TARGET_EFAULT; in copy_to_user_flock64()
7004 l_type = host_to_target_flock(fl->l_type); in copy_to_user_flock64()
7005 __put_user(l_type, &target_fl->l_type); in copy_to_user_flock64()
7006 __put_user(fl->l_whence, &target_fl->l_whence); in copy_to_user_flock64()
7007 __put_user(fl->l_start, &target_fl->l_start); in copy_to_user_flock64()
7008 __put_user(fl->l_len, &target_fl->l_len); in copy_to_user_flock64()
7009 __put_user(fl->l_pid, &target_fl->l_pid); in copy_to_user_flock64()
7024 if (host_cmd == -TARGET_EINVAL) in do_fcntl()
7074 /* tell 32-bit guests it uses largefile on 64-bit hosts: */ in do_fcntl()
7092 return -TARGET_EFAULT; in do_fcntl()
7093 target_fox->type = tswap32(fox.type); in do_fcntl()
7094 target_fox->pid = tswap32(fox.pid); in do_fcntl()
7103 return -TARGET_EFAULT; in do_fcntl()
7104 fox.type = tswap32(target_fox->type); in do_fcntl()
7105 fox.pid = tswap32(target_fox->pid); in do_fcntl()
7157 if ((int16_t)uid == -1) in low2highuid()
7158 return -1; in low2highuid()
7165 if ((int16_t)gid == -1) in low2highgid()
7166 return -1; in low2highgid()
7207 * We use the 32-bit version of the syscalls if present; if it is not
7208 * then either the host architecture supports 32-bit UIDs natively with
7209 * the standard syscall, or the 16-bit UID is the best we can do.
7272 while (ie->target_cmd != 0) { in syscall_init()
7273 if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) == in syscall_init()
7275 arg_type = ie->arg_type; in syscall_init()
7278 ie->target_cmd); in syscall_init()
7283 ie->target_cmd = (ie->target_cmd & in syscall_init()
7291 if (unlikely(ie->target_cmd != ie->host_cmd)) { in syscall_init()
7293 ie->name, ie->target_cmd, ie->host_cmd); in syscall_init()
7333 if (target_to_host_timespec(&host_its->it_interval, target_addr + in target_to_host_itimerspec()
7336 target_to_host_timespec(&host_its->it_value, target_addr + in target_to_host_itimerspec()
7339 return -TARGET_EFAULT; in target_to_host_itimerspec()
7351 if (target_to_host_timespec64(&host_its->it_interval, target_addr + in target_to_host_itimerspec64()
7354 target_to_host_timespec64(&host_its->it_value, target_addr + in target_to_host_itimerspec64()
7357 return -TARGET_EFAULT; in target_to_host_itimerspec64()
7372 &host_its->it_interval) || in host_to_target_itimerspec()
7375 &host_its->it_value)) { in host_to_target_itimerspec()
7376 return -TARGET_EFAULT; in host_to_target_itimerspec()
7391 &host_its->it_interval) || in host_to_target_itimerspec64()
7395 &host_its->it_value)) { in host_to_target_itimerspec64()
7396 return -TARGET_EFAULT; in host_to_target_itimerspec64()
7410 return -TARGET_EFAULT; in target_to_host_timex()
7413 __get_user(host_tx->modes, &target_tx->modes); in target_to_host_timex()
7414 __get_user(host_tx->offset, &target_tx->offset); in target_to_host_timex()
7415 __get_user(host_tx->freq, &target_tx->freq); in target_to_host_timex()
7416 __get_user(host_tx->maxerror, &target_tx->maxerror); in target_to_host_timex()
7417 __get_user(host_tx->esterror, &target_tx->esterror); in target_to_host_timex()
7418 __get_user(host_tx->status, &target_tx->status); in target_to_host_timex()
7419 __get_user(host_tx->constant, &target_tx->constant); in target_to_host_timex()
7420 __get_user(host_tx->precision, &target_tx->precision); in target_to_host_timex()
7421 __get_user(host_tx->tolerance, &target_tx->tolerance); in target_to_host_timex()
7422 __get_user(host_tx->time.tv_sec, &target_tx->time.tv_sec); in target_to_host_timex()
7423 __get_user(host_tx->time.tv_usec, &target_tx->time.tv_usec); in target_to_host_timex()
7424 __get_user(host_tx->tick, &target_tx->tick); in target_to_host_timex()
7425 __get_user(host_tx->ppsfreq, &target_tx->ppsfreq); in target_to_host_timex()
7426 __get_user(host_tx->jitter, &target_tx->jitter); in target_to_host_timex()
7427 __get_user(host_tx->shift, &target_tx->shift); in target_to_host_timex()
7428 __get_user(host_tx->stabil, &target_tx->stabil); in target_to_host_timex()
7429 __get_user(host_tx->jitcnt, &target_tx->jitcnt); in target_to_host_timex()
7430 __get_user(host_tx->calcnt, &target_tx->calcnt); in target_to_host_timex()
7431 __get_user(host_tx->errcnt, &target_tx->errcnt); in target_to_host_timex()
7432 __get_user(host_tx->stbcnt, &target_tx->stbcnt); in target_to_host_timex()
7433 __get_user(host_tx->tai, &target_tx->tai); in target_to_host_timex()
7445 return -TARGET_EFAULT; in host_to_target_timex()
7448 __put_user(host_tx->modes, &target_tx->modes); in host_to_target_timex()
7449 __put_user(host_tx->offset, &target_tx->offset); in host_to_target_timex()
7450 __put_user(host_tx->freq, &target_tx->freq); in host_to_target_timex()
7451 __put_user(host_tx->maxerror, &target_tx->maxerror); in host_to_target_timex()
7452 __put_user(host_tx->esterror, &target_tx->esterror); in host_to_target_timex()
7453 __put_user(host_tx->status, &target_tx->status); in host_to_target_timex()
7454 __put_user(host_tx->constant, &target_tx->constant); in host_to_target_timex()
7455 __put_user(host_tx->precision, &target_tx->precision); in host_to_target_timex()
7456 __put_user(host_tx->tolerance, &target_tx->tolerance); in host_to_target_timex()
7457 __put_user(host_tx->time.tv_sec, &target_tx->time.tv_sec); in host_to_target_timex()
7458 __put_user(host_tx->time.tv_usec, &target_tx->time.tv_usec); in host_to_target_timex()
7459 __put_user(host_tx->tick, &target_tx->tick); in host_to_target_timex()
7460 __put_user(host_tx->ppsfreq, &target_tx->ppsfreq); in host_to_target_timex()
7461 __put_user(host_tx->jitter, &target_tx->jitter); in host_to_target_timex()
7462 __put_user(host_tx->shift, &target_tx->shift); in host_to_target_timex()
7463 __put_user(host_tx->stabil, &target_tx->stabil); in host_to_target_timex()
7464 __put_user(host_tx->jitcnt, &target_tx->jitcnt); in host_to_target_timex()
7465 __put_user(host_tx->calcnt, &target_tx->calcnt); in host_to_target_timex()
7466 __put_user(host_tx->errcnt, &target_tx->errcnt); in host_to_target_timex()
7467 __put_user(host_tx->stbcnt, &target_tx->stbcnt); in host_to_target_timex()
7468 __put_user(host_tx->tai, &target_tx->tai); in host_to_target_timex()
7482 if (copy_from_user_timeval64(&host_tx->time, target_addr + in target_to_host_timex64()
7485 return -TARGET_EFAULT; in target_to_host_timex64()
7489 return -TARGET_EFAULT; in target_to_host_timex64()
7492 __get_user(host_tx->modes, &target_tx->modes); in target_to_host_timex64()
7493 __get_user(host_tx->offset, &target_tx->offset); in target_to_host_timex64()
7494 __get_user(host_tx->freq, &target_tx->freq); in target_to_host_timex64()
7495 __get_user(host_tx->maxerror, &target_tx->maxerror); in target_to_host_timex64()
7496 __get_user(host_tx->esterror, &target_tx->esterror); in target_to_host_timex64()
7497 __get_user(host_tx->status, &target_tx->status); in target_to_host_timex64()
7498 __get_user(host_tx->constant, &target_tx->constant); in target_to_host_timex64()
7499 __get_user(host_tx->precision, &target_tx->precision); in target_to_host_timex64()
7500 __get_user(host_tx->tolerance, &target_tx->tolerance); in target_to_host_timex64()
7501 __get_user(host_tx->tick, &target_tx->tick); in target_to_host_timex64()
7502 __get_user(host_tx->ppsfreq, &target_tx->ppsfreq); in target_to_host_timex64()
7503 __get_user(host_tx->jitter, &target_tx->jitter); in target_to_host_timex64()
7504 __get_user(host_tx->shift, &target_tx->shift); in target_to_host_timex64()
7505 __get_user(host_tx->stabil, &target_tx->stabil); in target_to_host_timex64()
7506 __get_user(host_tx->jitcnt, &target_tx->jitcnt); in target_to_host_timex64()
7507 __get_user(host_tx->calcnt, &target_tx->calcnt); in target_to_host_timex64()
7508 __get_user(host_tx->errcnt, &target_tx->errcnt); in target_to_host_timex64()
7509 __get_user(host_tx->stbcnt, &target_tx->stbcnt); in target_to_host_timex64()
7510 __get_user(host_tx->tai, &target_tx->tai); in target_to_host_timex64()
7523 &host_tx->time)) { in host_to_target_timex64()
7524 return -TARGET_EFAULT; in host_to_target_timex64()
7528 return -TARGET_EFAULT; in host_to_target_timex64()
7531 __put_user(host_tx->modes, &target_tx->modes); in host_to_target_timex64()
7532 __put_user(host_tx->offset, &target_tx->offset); in host_to_target_timex64()
7533 __put_user(host_tx->freq, &target_tx->freq); in host_to_target_timex64()
7534 __put_user(host_tx->maxerror, &target_tx->maxerror); in host_to_target_timex64()
7535 __put_user(host_tx->esterror, &target_tx->esterror); in host_to_target_timex64()
7536 __put_user(host_tx->status, &target_tx->status); in host_to_target_timex64()
7537 __put_user(host_tx->constant, &target_tx->constant); in host_to_target_timex64()
7538 __put_user(host_tx->precision, &target_tx->precision); in host_to_target_timex64()
7539 __put_user(host_tx->tolerance, &target_tx->tolerance); in host_to_target_timex64()
7540 __put_user(host_tx->tick, &target_tx->tick); in host_to_target_timex64()
7541 __put_user(host_tx->ppsfreq, &target_tx->ppsfreq); in host_to_target_timex64()
7542 __put_user(host_tx->jitter, &target_tx->jitter); in host_to_target_timex64()
7543 __put_user(host_tx->shift, &target_tx->shift); in host_to_target_timex64()
7544 __put_user(host_tx->stabil, &target_tx->stabil); in host_to_target_timex64()
7545 __put_user(host_tx->jitcnt, &target_tx->jitcnt); in host_to_target_timex64()
7546 __put_user(host_tx->calcnt, &target_tx->calcnt); in host_to_target_timex64()
7547 __put_user(host_tx->errcnt, &target_tx->errcnt); in host_to_target_timex64()
7548 __put_user(host_tx->stbcnt, &target_tx->stbcnt); in host_to_target_timex64()
7549 __put_user(host_tx->tai, &target_tx->tai); in host_to_target_timex64()
7566 return -TARGET_EFAULT; in target_to_host_sigevent()
7575 host_sevp->sigev_value.sival_ptr = in target_to_host_sigevent()
7576 (void *)(uintptr_t)tswapal(target_sevp->sigev_value.sival_ptr); in target_to_host_sigevent()
7577 host_sevp->sigev_signo = in target_to_host_sigevent()
7578 target_to_host_signal(tswap32(target_sevp->sigev_signo)); in target_to_host_sigevent()
7579 host_sevp->sigev_notify = tswap32(target_sevp->sigev_notify); in target_to_host_sigevent()
7580 host_sevp->sigev_notify_thread_id = tswap32(target_sevp->_sigev_un._tid); in target_to_host_sigevent()
7623 if (cpu_env->eabi) { in host_to_target_stat64()
7627 return -TARGET_EFAULT; in host_to_target_stat64()
7629 __put_user(host_st->st_dev, &target_st->st_dev); in host_to_target_stat64()
7630 __put_user(host_st->st_ino, &target_st->st_ino); in host_to_target_stat64()
7632 __put_user(host_st->st_ino, &target_st->__st_ino); in host_to_target_stat64()
7634 __put_user(host_st->st_mode, &target_st->st_mode); in host_to_target_stat64()
7635 __put_user(host_st->st_nlink, &target_st->st_nlink); in host_to_target_stat64()
7636 __put_user(host_st->st_uid, &target_st->st_uid); in host_to_target_stat64()
7637 __put_user(host_st->st_gid, &target_st->st_gid); in host_to_target_stat64()
7638 __put_user(host_st->st_rdev, &target_st->st_rdev); in host_to_target_stat64()
7639 __put_user(host_st->st_size, &target_st->st_size); in host_to_target_stat64()
7640 __put_user(host_st->st_blksize, &target_st->st_blksize); in host_to_target_stat64()
7641 __put_user(host_st->st_blocks, &target_st->st_blocks); in host_to_target_stat64()
7642 __put_user(host_st->st_atime, &target_st->target_st_atime); in host_to_target_stat64()
7643 __put_user(host_st->st_mtime, &target_st->target_st_mtime); in host_to_target_stat64()
7644 __put_user(host_st->st_ctime, &target_st->target_st_ctime); in host_to_target_stat64()
7646 __put_user(host_st->st_atim.tv_nsec, &target_st->target_st_atime_nsec); in host_to_target_stat64()
7647 __put_user(host_st->st_mtim.tv_nsec, &target_st->target_st_mtime_nsec); in host_to_target_stat64()
7648 __put_user(host_st->st_ctim.tv_nsec, &target_st->target_st_ctime_nsec); in host_to_target_stat64()
7661 return -TARGET_EFAULT; in host_to_target_stat64()
7663 __put_user(host_st->st_dev, &target_st->st_dev); in host_to_target_stat64()
7664 __put_user(host_st->st_ino, &target_st->st_ino); in host_to_target_stat64()
7666 __put_user(host_st->st_ino, &target_st->__st_ino); in host_to_target_stat64()
7668 __put_user(host_st->st_mode, &target_st->st_mode); in host_to_target_stat64()
7669 __put_user(host_st->st_nlink, &target_st->st_nlink); in host_to_target_stat64()
7670 __put_user(host_st->st_uid, &target_st->st_uid); in host_to_target_stat64()
7671 __put_user(host_st->st_gid, &target_st->st_gid); in host_to_target_stat64()
7672 __put_user(host_st->st_rdev, &target_st->st_rdev); in host_to_target_stat64()
7674 __put_user(host_st->st_size, &target_st->st_size); in host_to_target_stat64()
7675 __put_user(host_st->st_blksize, &target_st->st_blksize); in host_to_target_stat64()
7676 __put_user(host_st->st_blocks, &target_st->st_blocks); in host_to_target_stat64()
7677 __put_user(host_st->st_atime, &target_st->target_st_atime); in host_to_target_stat64()
7678 __put_user(host_st->st_mtime, &target_st->target_st_mtime); in host_to_target_stat64()
7679 __put_user(host_st->st_ctime, &target_st->target_st_ctime); in host_to_target_stat64()
7681 __put_user(host_st->st_atim.tv_nsec, &target_st->target_st_atime_nsec); in host_to_target_stat64()
7682 __put_user(host_st->st_mtim.tv_nsec, &target_st->target_st_mtime_nsec); in host_to_target_stat64()
7683 __put_user(host_st->st_ctim.tv_nsec, &target_st->target_st_ctime_nsec); in host_to_target_stat64()
7699 return -TARGET_EFAULT; in host_to_target_statx()
7703 __put_user(host_stx->stx_mask, &target_stx->stx_mask); in host_to_target_statx()
7704 __put_user(host_stx->stx_blksize, &target_stx->stx_blksize); in host_to_target_statx()
7705 __put_user(host_stx->stx_attributes, &target_stx->stx_attributes); in host_to_target_statx()
7706 __put_user(host_stx->stx_nlink, &target_stx->stx_nlink); in host_to_target_statx()
7707 __put_user(host_stx->stx_uid, &target_stx->stx_uid); in host_to_target_statx()
7708 __put_user(host_stx->stx_gid, &target_stx->stx_gid); in host_to_target_statx()
7709 __put_user(host_stx->stx_mode, &target_stx->stx_mode); in host_to_target_statx()
7710 __put_user(host_stx->stx_ino, &target_stx->stx_ino); in host_to_target_statx()
7711 __put_user(host_stx->stx_size, &target_stx->stx_size); in host_to_target_statx()
7712 __put_user(host_stx->stx_blocks, &target_stx->stx_blocks); in host_to_target_statx()
7713 __put_user(host_stx->stx_attributes_mask, &target_stx->stx_attributes_mask); in host_to_target_statx()
7714 __put_user(host_stx->stx_atime.tv_sec, &target_stx->stx_atime.tv_sec); in host_to_target_statx()
7715 __put_user(host_stx->stx_atime.tv_nsec, &target_stx->stx_atime.tv_nsec); in host_to_target_statx()
7716 __put_user(host_stx->stx_btime.tv_sec, &target_stx->stx_btime.tv_sec); in host_to_target_statx()
7717 __put_user(host_stx->stx_btime.tv_nsec, &target_stx->stx_btime.tv_nsec); in host_to_target_statx()
7718 __put_user(host_stx->stx_ctime.tv_sec, &target_stx->stx_ctime.tv_sec); in host_to_target_statx()
7719 __put_user(host_stx->stx_ctime.tv_nsec, &target_stx->stx_ctime.tv_nsec); in host_to_target_statx()
7720 __put_user(host_stx->stx_mtime.tv_sec, &target_stx->stx_mtime.tv_sec); in host_to_target_statx()
7721 __put_user(host_stx->stx_mtime.tv_nsec, &target_stx->stx_mtime.tv_nsec); in host_to_target_statx()
7722 __put_user(host_stx->stx_rdev_major, &target_stx->stx_rdev_major); in host_to_target_statx()
7723 __put_user(host_stx->stx_rdev_minor, &target_stx->stx_rdev_minor); in host_to_target_statx()
7724 __put_user(host_stx->stx_dev_major, &target_stx->stx_dev_major); in host_to_target_statx()
7725 __put_user(host_stx->stx_dev_minor, &target_stx->stx_dev_minor); in host_to_target_statx()
7739 /* always a 64-bit time_t, it doesn't define _time64 version */ in do_sys_futex()
7745 if (sizeof(timeout->tv_sec) == 8) { in do_sys_futex()
7764 /* always a 64-bit time_t, it doesn't define _time64 version */ in do_safe_futex()
7769 if (sizeof(timeout->tv_sec) == 8) { in do_safe_futex()
7780 return -TARGET_ENOSYS; in do_safe_futex()
7842 return -TARGET_ENOSYS; in do_futex()
7849 return -TARGET_EFAULT; in do_futex()
7869 return -TARGET_EFAULT; in do_name_to_handle_at()
7874 return -TARGET_EFAULT; in do_name_to_handle_at()
7881 return -TARGET_EFAULT; in do_name_to_handle_at()
7885 fh->handle_bytes = size; in do_name_to_handle_at()
7896 target_fh->handle_bytes = tswap32(fh->handle_bytes); in do_name_to_handle_at()
7897 target_fh->handle_type = tswap32(fh->handle_type); in do_name_to_handle_at()
7902 return -TARGET_EFAULT; in do_name_to_handle_at()
7920 return -TARGET_EFAULT; in do_open_by_handle_at()
7926 return -TARGET_EFAULT; in do_open_by_handle_at()
7930 fh->handle_bytes = size; in do_open_by_handle_at()
7931 fh->handle_type = tswap32(target_fh->handle_type); in do_open_by_handle_at()
7954 return -TARGET_EINVAL; in do_signalfd4()
7957 return -TARGET_EFAULT; in do_signalfd4()
7992 struct linux_binprm *bprm = get_task_state(cpu)->bprm; in open_self_cmdline()
7995 for (i = 0; i < bprm->argc; i++) { in open_self_cmdline()
7996 size_t len = strlen(bprm->argv[i]) + 1; in open_self_cmdline()
7998 if (write(fd, bprm->argv[i], len) != len) { in open_self_cmdline()
7999 return -1; in open_self_cmdline()
8028 const struct image_info *info = d->ts->info; in open_self_maps_4()
8029 const char *path = mi->path; in open_self_maps_4()
8031 int fd = d->fd; in open_self_maps_4()
8034 if (test_stack(start, end, info->stack_limit)) { in open_self_maps_4()
8036 } else if (start == info->brk) { in open_self_maps_4()
8038 } else if (start == info->vdso) { in open_self_maps_4()
8047 offset = mi->offset; in open_self_maps_4()
8048 if (mi->dev) { in open_self_maps_4()
8050 offset += hstart - mi->itree.start; in open_self_maps_4()
8053 count = dprintf(fd, TARGET_ABI_FMT_ptr "-" TARGET_ABI_FMT_ptr in open_self_maps_4()
8056 (flags & PAGE_READ) ? 'r' : '-', in open_self_maps_4()
8057 (flags & PAGE_WRITE_ORG) ? 'w' : '-', in open_self_maps_4()
8058 (flags & PAGE_EXEC) ? 'x' : '-', in open_self_maps_4()
8059 mi->is_priv ? 'p' : 's', in open_self_maps_4()
8060 offset, major(mi->dev), minor(mi->dev), in open_self_maps_4()
8061 (uint64_t)mi->inode); in open_self_maps_4()
8063 dprintf(fd, "%*s%s\n", 73 - count, "", path); in open_self_maps_4()
8068 if (d->smaps) { in open_self_maps_4()
8069 unsigned long size = end - start; in open_self_maps_4()
8101 mi->is_priv ? "" : " sh", in open_self_maps_4()
8105 mi->is_priv ? "" : " ms"); in open_self_maps_4()
8111 * Proceed without the benefit of host /proc/self/maps cross-check.
8130 uintptr_t host_last = (uintptr_t)g2h_untagged(guest_end - 1); in open_self_maps_2()
8146 interval_tree_iter_first(d->host_maps, host_start, host_start); in open_self_maps_2()
8148 uintptr_t this_hlast = MIN(host_last, n->last); in open_self_maps_2()
8204 gchar *bin = g_strrstr(ts->bprm->argv[0], "/"); in open_self_stat()
8205 bin = bin ? bin + 1 : ts->bprm->argv[0]; in open_self_stat()
8225 g_string_printf(buf, "%" PRIu64 " ", ts->start_boottime); in open_self_stat()
8228 g_string_printf(buf, TARGET_ABI_FMT_ld " ", ts->info->start_stack); in open_self_stat()
8234 if (write(fd, buf->str, buf->len) != buf->len) { in open_self_stat()
8235 return -1; in open_self_stat()
8246 abi_ulong auxv = ts->info->saved_auxv; in open_self_auxv()
8247 abi_ulong len = ts->info->auxv_len; in open_self_auxv()
8262 len -= r; in open_self_auxv()
8344 return -1; in open_net_route()
8354 while ((read = getline(&line, &len, fp)) != -1) { in open_net_route()
8422 return -1; in maybe_do_fake_open()
8431 for (fake_open = fakes; fake_open->filename; fake_open++) { in maybe_do_fake_open()
8432 if (fake_open->cmp(pathname, fake_open->filename)) { in maybe_do_fake_open()
8437 if (fake_open->filename) { in maybe_do_fake_open()
8442 fd = memfd_create("qemu-open", 0); in maybe_do_fake_open()
8451 snprintf(filename, sizeof(filename), "%s/qemu-open.XXXXXX", tmpdir); in maybe_do_fake_open()
8459 if ((r = fake_open->fill(cpu_env, fd))) { in maybe_do_fake_open()
8470 return -2; in maybe_do_fake_open()
8477 if (fd > -2) { in do_guest_openat()
8498 return -TARGET_EINVAL; in do_openat2()
8502 if (ret == -TARGET_E2BIG) { in do_openat2()
8511 return -TARGET_EFAULT; in do_openat2()
8519 if (fd > -2) { in do_openat2()
8537 return -1; in do_guest_readlink()
8543 return -1; in do_guest_readlink()
8577 return -TARGET_EFAULT; in do_execv()
8587 return -TARGET_EFAULT; in do_execv()
8656 ret = -TARGET_EFAULT; in do_execv()
8686 return -TARGET_EINVAL; in get_timer_id()
8692 return -TARGET_EINVAL; in get_timer_id()
8712 return -TARGET_EFAULT; in target_to_host_cpu_mask()
8746 return -TARGET_EFAULT; in host_to_target_cpu_mask()
8776 return -TARGET_ENOMEM; in do_getdents()
8792 return -TARGET_EFAULT; in do_getdents()
8805 namelen = strlen(hde->d_name); in do_getdents()
8806 hreclen = hde->d_reclen; in do_getdents()
8818 toff = -TARGET_EINVAL; /* result buffer is too small */ in do_getdents()
8829 prev_diroff = hde->d_off; in do_getdents()
8830 tde->d_ino = tswapal(hde->d_ino); in do_getdents()
8831 tde->d_off = tswapal(hde->d_off); in do_getdents()
8832 tde->d_reclen = tswap16(treclen); in do_getdents()
8833 memcpy(tde->d_name, hde->d_name, namelen + 1); in do_getdents()
8840 type = *((uint8_t *)hde + hreclen - 1); in do_getdents()
8842 type = hde->d_type; in do_getdents()
8844 *((uint8_t *)tde + treclen - 1) = type; in do_getdents()
8863 return -TARGET_ENOMEM; in do_getdents64()
8873 return -TARGET_EFAULT; in do_getdents64()
8881 namelen = strlen(hde->d_name) + 1; in do_getdents64()
8882 hreclen = hde->d_reclen; in do_getdents64()
8894 toff = -TARGET_EINVAL; /* result buffer is too small */ in do_getdents64()
8905 prev_diroff = hde->d_off; in do_getdents64()
8906 tde->d_ino = tswap64(hde->d_ino); in do_getdents64()
8907 tde->d_off = tswap64(hde->d_off); in do_getdents64()
8908 tde->d_reclen = tswap16(treclen); in do_getdents64()
8909 tde->d_type = hde->d_type; in do_getdents64()
8910 memcpy(tde->d_name, hde->d_name, namelen); in do_getdents64()
8986 for (; pair_count > 0; pair_count--, pair++) { in risc_hwprobe_fill_pairs()
8989 __put_user(0, &pair->value); in risc_hwprobe_fill_pairs()
8990 __get_user(key, &pair->key); in risc_hwprobe_fill_pairs()
8993 __put_user(cfg->mvendorid, &pair->value); in risc_hwprobe_fill_pairs()
8996 __put_user(cfg->marchid, &pair->value); in risc_hwprobe_fill_pairs()
8999 __put_user(cfg->mimpid, &pair->value); in risc_hwprobe_fill_pairs()
9006 __put_user(value, &pair->value); in risc_hwprobe_fill_pairs()
9016 value |= cfg->ext_zba ? in risc_hwprobe_fill_pairs()
9018 value |= cfg->ext_zbb ? in risc_hwprobe_fill_pairs()
9020 value |= cfg->ext_zbs ? in risc_hwprobe_fill_pairs()
9022 value |= cfg->ext_zicboz ? in risc_hwprobe_fill_pairs()
9024 value |= cfg->ext_zbc ? in risc_hwprobe_fill_pairs()
9026 value |= cfg->ext_zbkb ? in risc_hwprobe_fill_pairs()
9028 value |= cfg->ext_zbkc ? in risc_hwprobe_fill_pairs()
9030 value |= cfg->ext_zbkx ? in risc_hwprobe_fill_pairs()
9032 value |= cfg->ext_zknd ? in risc_hwprobe_fill_pairs()
9034 value |= cfg->ext_zkne ? in risc_hwprobe_fill_pairs()
9036 value |= cfg->ext_zknh ? in risc_hwprobe_fill_pairs()
9038 value |= cfg->ext_zksed ? in risc_hwprobe_fill_pairs()
9040 value |= cfg->ext_zksh ? in risc_hwprobe_fill_pairs()
9042 value |= cfg->ext_zkt ? in risc_hwprobe_fill_pairs()
9044 value |= cfg->ext_zvbb ? in risc_hwprobe_fill_pairs()
9046 value |= cfg->ext_zvbc ? in risc_hwprobe_fill_pairs()
9048 value |= cfg->ext_zvkb ? in risc_hwprobe_fill_pairs()
9050 value |= cfg->ext_zvkg ? in risc_hwprobe_fill_pairs()
9052 value |= cfg->ext_zvkned ? in risc_hwprobe_fill_pairs()
9054 value |= cfg->ext_zvknha ? in risc_hwprobe_fill_pairs()
9056 value |= cfg->ext_zvknhb ? in risc_hwprobe_fill_pairs()
9058 value |= cfg->ext_zvksed ? in risc_hwprobe_fill_pairs()
9060 value |= cfg->ext_zvksh ? in risc_hwprobe_fill_pairs()
9062 value |= cfg->ext_zvkt ? in risc_hwprobe_fill_pairs()
9064 value |= cfg->ext_zfh ? in risc_hwprobe_fill_pairs()
9066 value |= cfg->ext_zfhmin ? in risc_hwprobe_fill_pairs()
9068 value |= cfg->ext_zihintntl ? in risc_hwprobe_fill_pairs()
9070 value |= cfg->ext_zvfh ? in risc_hwprobe_fill_pairs()
9072 value |= cfg->ext_zvfhmin ? in risc_hwprobe_fill_pairs()
9074 value |= cfg->ext_zfa ? in risc_hwprobe_fill_pairs()
9076 value |= cfg->ext_ztso ? in risc_hwprobe_fill_pairs()
9078 value |= cfg->ext_zacas ? in risc_hwprobe_fill_pairs()
9080 value |= cfg->ext_zicond ? in risc_hwprobe_fill_pairs()
9082 __put_user(value, &pair->value); in risc_hwprobe_fill_pairs()
9085 __put_user(RISCV_HWPROBE_MISALIGNED_FAST, &pair->value); in risc_hwprobe_fill_pairs()
9088 value = cfg->ext_zicboz ? cfg->cboz_blocksize : 0; in risc_hwprobe_fill_pairs()
9089 __put_user(value, &pair->value); in risc_hwprobe_fill_pairs()
9092 __put_user(-1, &pair->key); in risc_hwprobe_fill_pairs()
9109 target_mask_size = ((arg3 + tmp - 1) / tmp) * sizeof(abi_ulong); in cpu_set_valid()
9110 host_mask_size = (target_mask_size + (sizeof(*host_mask) - 1)) & in cpu_set_valid()
9111 ~(sizeof(*host_mask) - 1); in cpu_set_valid()
9126 return -TARGET_EINVAL; in cpu_set_valid()
9138 return -TARGET_EINVAL; in do_riscv_hwprobe()
9148 return -TARGET_EINVAL; in do_riscv_hwprobe()
9159 return -TARGET_EFAULT; in do_riscv_hwprobe()
9186 * All errnos that do_syscall() returns must be -TARGET_<errcode>. in _syscall2()
9215 return -QEMU_ERESTARTSYS; in _syscall2()
9223 if (ts->child_tidptr) { in _syscall2()
9224 put_user_u32(0, ts->child_tidptr); in _syscall2()
9225 do_sys_futex(g2h(cpu, ts->child_tidptr), in _syscall2()
9233 * from cpu lists. We can clean-up the rest of the thread in _syscall2()
9254 return -TARGET_EFAULT; in _syscall2()
9268 return -TARGET_EFAULT; in _syscall2()
9286 return -TARGET_EFAULT; in _syscall2()
9296 return -TARGET_EFAULT; in _syscall2()
9329 return -TARGET_EFAULT; in _syscall2()
9375 return -TARGET_EFAULT; in _syscall2()
9392 return -TARGET_EFAULT; in _syscall2()
9398 return -TARGET_EFAULT; in _syscall2()
9407 return -TARGET_EFAULT; in _syscall2()
9420 ret = -TARGET_EFAULT; in _syscall2()
9433 return -TARGET_EFAULT; in _syscall2()
9437 ret = -TARGET_EFAULT; in _syscall2()
9448 return -TARGET_EFAULT; in _syscall2()
9456 return -TARGET_EFAULT; in _syscall2()
9467 return -TARGET_EFAULT; in _syscall2()
9479 return -TARGET_EFAULT; in _syscall2()
9486 return -TARGET_EFAULT; in _syscall2()
9494 return -TARGET_EFAULT; in _syscall2()
9502 return -TARGET_EFAULT; in _syscall2()
9514 cpu_env->ir[IR_A4] = getppid(); in _syscall2()
9529 return -TARGET_EFAULT; in _syscall2()
9540 return -TARGET_EFAULT; in _syscall2()
9550 return -TARGET_EFAULT; in _syscall2()
9556 /* FIXME - arg5 should be locked, but it isn't clear how to in _syscall2()
9557 * do that since it's not guaranteed to be a NULL-terminated in _syscall2()
9584 return -TARGET_EFAULT; in _syscall2()
9595 return -TARGET_EFAULT; in _syscall2()
9600 return -TARGET_EFAULT; in _syscall2()
9606 return -TARGET_EFAULT; in _syscall2()
9623 return -TARGET_EFAULT; in _syscall2()
9628 return -TARGET_EFAULT; in _syscall2()
9649 return -TARGET_EFAULT; in _syscall2()
9661 sigsuspend(&get_task_state(cpu)->signal_mask); in _syscall2()
9663 return -TARGET_EINTR; in _syscall2()
9672 return -TARGET_EFAULT; in _syscall2()
9673 tbuf.actime = tswapal(target_tbuf->actime); in _syscall2()
9674 tbuf.modtime = tswapal(target_tbuf->modtime); in _syscall2()
9681 return -TARGET_EFAULT; in _syscall2()
9695 return -TARGET_EFAULT; in _syscall2()
9701 return -TARGET_EFAULT; in _syscall2()
9715 return -TARGET_EFAULT; in _syscall2()
9721 return -TARGET_EFAULT; in _syscall2()
9731 return -TARGET_EFAULT; in _syscall2()
9740 return -TARGET_EFAULT; in _syscall2()
9749 return -TARGET_EFAULT; in _syscall2()
9775 ret = -TARGET_EFAULT; in _syscall2()
9790 ret = -TARGET_EFAULT; in _syscall2()
9805 ret = -TARGET_EFAULT; in _syscall2()
9817 return -TARGET_EFAULT; in _syscall2()
9825 return -TARGET_EFAULT; in _syscall2()
9833 return -TARGET_EFAULT; in _syscall2()
9861 return -TARGET_EFAULT; in _syscall2()
9862 tmsp->tms_utime = tswapal(host_to_target_clock_t(tms.tms_utime)); in _syscall2()
9863 tmsp->tms_stime = tswapal(host_to_target_clock_t(tms.tms_stime)); in _syscall2()
9864 tmsp->tms_cutime = tswapal(host_to_target_clock_t(tms.tms_cutime)); in _syscall2()
9865 tmsp->tms_cstime = tswapal(host_to_target_clock_t(tms.tms_cstime)); in _syscall2()
9876 return -TARGET_EFAULT; in _syscall2()
9885 return -TARGET_EFAULT; in _syscall2()
9902 return -TARGET_EFAULT; in _syscall2()
9920 return -EINVAL; in _syscall2()
9948 return -TARGET_EFAULT; in _syscall2()
9949 act._sa_handler = old_act->_sa_handler; in _syscall2()
9950 target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]); in _syscall2()
9951 act.sa_flags = old_act->sa_flags; in _syscall2()
9962 return -TARGET_EFAULT; in _syscall2()
9963 old_act->_sa_handler = oact._sa_handler; in _syscall2()
9964 old_act->sa_flags = oact.sa_flags; in _syscall2()
9965 old_act->sa_mask.sig[0] = oact.sa_mask.sig[0]; in _syscall2()
9966 old_act->sa_mask.sig[1] = 0; in _syscall2()
9967 old_act->sa_mask.sig[2] = 0; in _syscall2()
9968 old_act->sa_mask.sig[3] = 0; in _syscall2()
9976 return -TARGET_EFAULT; in _syscall2()
9977 act._sa_handler = old_act->_sa_handler; in _syscall2()
9978 target_siginitset(&act.sa_mask, old_act->sa_mask); in _syscall2()
9979 act.sa_flags = old_act->sa_flags; in _syscall2()
9981 act.sa_restorer = old_act->sa_restorer; in _syscall2()
9991 return -TARGET_EFAULT; in _syscall2()
9992 old_act->_sa_handler = oact._sa_handler; in _syscall2()
9993 old_act->sa_mask = oact.sa_mask.sig[0]; in _syscall2()
9994 old_act->sa_flags = oact.sa_flags; in _syscall2()
9996 old_act->sa_restorer = oact.sa_restorer; in _syscall2()
10027 return -TARGET_EINVAL; in _syscall2()
10030 return -TARGET_EFAULT; in _syscall2()
10033 ret = -TARGET_EFAULT; in _syscall2()
10091 return -TARGET_EINVAL; in _syscall2()
10100 cpu_env->ir[IR_V0] = 0; /* force no error */ in _syscall2()
10109 return -TARGET_EFAULT; in _syscall2()
10125 return -TARGET_EINVAL; in _syscall2()
10134 return -TARGET_EFAULT; in _syscall2()
10148 return -TARGET_EINVAL; in _syscall2()
10154 return -TARGET_EFAULT; in _syscall2()
10170 return -TARGET_EINVAL; in _syscall2()
10179 return -TARGET_EFAULT; in _syscall2()
10192 return -TARGET_EFAULT; in _syscall2()
10209 return -TARGET_EINVAL; in _syscall2()
10215 return -TARGET_EFAULT; in _syscall2()
10230 set = &ts->sigsuspend_mask; in _syscall2()
10263 return -TARGET_EINVAL; in _syscall2()
10267 return -TARGET_EFAULT; in _syscall2()
10273 return -TARGET_EFAULT; in _syscall2()
10285 return -TARGET_EFAULT; in _syscall2()
10303 return -TARGET_EINVAL; in _syscall2()
10308 return -TARGET_EFAULT; in _syscall2()
10315 return -TARGET_EFAULT; in _syscall2()
10327 return -TARGET_EFAULT; in _syscall2()
10343 return -TARGET_EFAULT; in _syscall2()
10356 return -TARGET_EFAULT; in _syscall2()
10366 return -QEMU_ERESTARTSYS; in _syscall2()
10372 return -QEMU_ERESTARTSYS; in _syscall2()
10377 return -TARGET_EFAULT; in _syscall2()
10388 return -TARGET_EFAULT; in _syscall2()
10389 rlim.rlim_cur = target_to_host_rlim(target_rlim->rlim_cur); in _syscall2()
10390 rlim.rlim_max = target_to_host_rlim(target_rlim->rlim_max); in _syscall2()
10419 return -TARGET_EFAULT; in _syscall2()
10420 target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); in _syscall2()
10421 target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); in _syscall2()
10445 return -TARGET_EFAULT; in _syscall2()
10448 return -TARGET_EFAULT; in _syscall2()
10462 return -TARGET_EFAULT; in _syscall2()
10469 return -TARGET_EFAULT; in _syscall2()
10480 /* some architectures used to have old_select here in _syscall2()
10483 ret = -TARGET_ENOSYS; in _syscall2()
10506 ret = -TARGET_EFAULT; in _syscall2()
10521 ret = -TARGET_EFAULT; in _syscall2()
10548 ret = -TARGET_EFAULT; in _syscall2()
10551 ret = -TARGET_EINVAL; in _syscall2()
10571 return -TARGET_EFAULT; in _syscall2()
10581 return -TARGET_EFAULT; in _syscall2()
10596 return -TARGET_EFAULT; in _syscall2()
10628 && arg1 >= ts->info->stack_limit in _syscall2()
10629 && arg1 <= ts->info->start_stack) { in _syscall2()
10631 arg2 = arg2 + arg1 - ts->info->stack_limit; in _syscall2()
10632 arg1 = ts->info->stack_limit; in _syscall2()
10642 /* ??? msync/mlock/munlock are broken for softmmu. */ in _syscall2()
10667 return -TARGET_EFAULT; in _syscall2()
10681 return -TARGET_EFAULT; in _syscall2()
10691 if (ret == -1 && errno != 0) { in _syscall2()
10692 return -host_to_target_errno(errno); in _syscall2()
10696 cpu_env->ir[IR_V0] = 0; in _syscall2()
10699 ret = 20 - ret; in _syscall2()
10707 return -TARGET_EFAULT; in _syscall2()
10716 return -TARGET_EFAULT; in _syscall2()
10717 __put_user(stfs.f_type, &target_stfs->f_type); in _syscall2()
10718 __put_user(stfs.f_bsize, &target_stfs->f_bsize); in _syscall2()
10719 __put_user(stfs.f_blocks, &target_stfs->f_blocks); in _syscall2()
10720 __put_user(stfs.f_bfree, &target_stfs->f_bfree); in _syscall2()
10721 __put_user(stfs.f_bavail, &target_stfs->f_bavail); in _syscall2()
10722 __put_user(stfs.f_files, &target_stfs->f_files); in _syscall2()
10723 __put_user(stfs.f_ffree, &target_stfs->f_ffree); in _syscall2()
10724 __put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]); in _syscall2()
10725 __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]); in _syscall2()
10726 __put_user(stfs.f_namelen, &target_stfs->f_namelen); in _syscall2()
10727 __put_user(stfs.f_frsize, &target_stfs->f_frsize); in _syscall2()
10729 __put_user(stfs.f_flags, &target_stfs->f_flags); in _syscall2()
10731 __put_user(0, &target_stfs->f_flags); in _syscall2()
10733 memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); in _syscall2()
10746 return -TARGET_EFAULT; in _syscall2()
10755 return -TARGET_EFAULT; in _syscall2()
10756 __put_user(stfs.f_type, &target_stfs->f_type); in _syscall2()
10757 __put_user(stfs.f_bsize, &target_stfs->f_bsize); in _syscall2()
10758 __put_user(stfs.f_blocks, &target_stfs->f_blocks); in _syscall2()
10759 __put_user(stfs.f_bfree, &target_stfs->f_bfree); in _syscall2()
10760 __put_user(stfs.f_bavail, &target_stfs->f_bavail); in _syscall2()
10761 __put_user(stfs.f_files, &target_stfs->f_files); in _syscall2()
10762 __put_user(stfs.f_ffree, &target_stfs->f_ffree); in _syscall2()
10763 __put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]); in _syscall2()
10764 __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]); in _syscall2()
10765 __put_user(stfs.f_namelen, &target_stfs->f_namelen); in _syscall2()
10766 __put_user(stfs.f_frsize, &target_stfs->f_frsize); in _syscall2()
10768 __put_user(stfs.f_flags, &target_stfs->f_flags); in _syscall2()
10770 __put_user(0, &target_stfs->f_flags); in _syscall2()
10772 memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); in _syscall2()
10856 return -TARGET_EFAULT; in _syscall2()
10894 return -TARGET_EINVAL; in _syscall2()
10901 return -TARGET_EFAULT; in _syscall2()
10908 return -TARGET_EINVAL; in _syscall2()
10919 if (copy_from_user_timeval(&pvalue->it_interval, arg2) in _syscall2()
10920 || copy_from_user_timeval(&pvalue->it_value, in _syscall2()
10922 return -TARGET_EFAULT; in _syscall2()
10932 return -TARGET_EFAULT; in _syscall2()
10946 return -TARGET_EFAULT; in _syscall2()
10953 return -TARGET_EFAULT; in _syscall2()
10962 return -TARGET_EFAULT; in _syscall2()
10979 return -TARGET_EFAULT; in _syscall2()
10981 __put_user(st.st_dev, &target_st->st_dev); in _syscall2()
10982 __put_user(st.st_ino, &target_st->st_ino); in _syscall2()
10983 __put_user(st.st_mode, &target_st->st_mode); in _syscall2()
10984 __put_user(st.st_uid, &target_st->st_uid); in _syscall2()
10985 __put_user(st.st_gid, &target_st->st_gid); in _syscall2()
10986 __put_user(st.st_nlink, &target_st->st_nlink); in _syscall2()
10987 __put_user(st.st_rdev, &target_st->st_rdev); in _syscall2()
10988 __put_user(st.st_size, &target_st->st_size); in _syscall2()
10989 __put_user(st.st_blksize, &target_st->st_blksize); in _syscall2()
10990 __put_user(st.st_blocks, &target_st->st_blocks); in _syscall2()
10991 __put_user(st.st_atime, &target_st->target_st_atime); in _syscall2()
10992 __put_user(st.st_mtime, &target_st->target_st_mtime); in _syscall2()
10993 __put_user(st.st_ctime, &target_st->target_st_ctime); in _syscall2()
10996 &target_st->target_st_atime_nsec); in _syscall2()
10998 &target_st->target_st_mtime_nsec); in _syscall2()
11000 &target_st->target_st_ctime_nsec); in _syscall2()
11031 return -TARGET_EFAULT; in _syscall2()
11046 return -TARGET_EFAULT; in _syscall2()
11059 return -TARGET_EFAULT; in _syscall2()
11060 __put_user(value.uptime, &target_value->uptime); in _syscall2()
11061 __put_user(value.loads[0], &target_value->loads[0]); in _syscall2()
11062 __put_user(value.loads[1], &target_value->loads[1]); in _syscall2()
11063 __put_user(value.loads[2], &target_value->loads[2]); in _syscall2()
11064 __put_user(value.totalram, &target_value->totalram); in _syscall2()
11065 __put_user(value.freeram, &target_value->freeram); in _syscall2()
11066 __put_user(value.sharedram, &target_value->sharedram); in _syscall2()
11067 __put_user(value.bufferram, &target_value->bufferram); in _syscall2()
11068 __put_user(value.totalswap, &target_value->totalswap); in _syscall2()
11069 __put_user(value.freeswap, &target_value->freeswap); in _syscall2()
11070 __put_user(value.procs, &target_value->procs); in _syscall2()
11071 __put_user(value.totalhigh, &target_value->totalhigh); in _syscall2()
11072 __put_user(value.freehigh, &target_value->freehigh); in _syscall2()
11073 __put_user(value.mem_unit, &target_value->mem_unit); in _syscall2()
11161 return -TARGET_EFAULT; in _syscall2()
11171 return -TARGET_EFAULT; in _syscall2()
11176 g_strlcpy(buf->machine, cpu_to_uname_machine(cpu_env), in _syscall2()
11177 sizeof(buf->machine)); in _syscall2()
11180 g_strlcpy(buf->release, qemu_uname_release, in _syscall2()
11181 sizeof(buf->release)); in _syscall2()
11201 return -TARGET_EFAULT; in _syscall2()
11206 return -TARGET_EFAULT; in _syscall2()
11218 return -TARGET_EFAULT; in _syscall2()
11222 return -TARGET_EFAULT; in _syscall2()
11233 return -TARGET_EFAULT; in _syscall2()
11237 return -TARGET_EFAULT; in _syscall2()
11254 if (res == -1) { in _syscall2()
11263 return -TARGET_EFAULT; in _syscall2()
11303 ret = -host_to_target_errno(errno); in _syscall2()
11314 ret = -host_to_target_errno(errno); in _syscall2()
11329 ret = -host_to_target_errno(errno); in _syscall2()
11345 ret = -host_to_target_errno(errno); in _syscall2()
11365 if (arg2 & (sizeof(abi_ulong) - 1)) { in _syscall2()
11366 return -TARGET_EINVAL; in _syscall2()
11368 mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1); in _syscall2()
11385 return -TARGET_EINVAL; in _syscall2()
11391 return -TARGET_EFAULT; in _syscall2()
11405 if (arg2 & (sizeof(abi_ulong) - 1)) { in _syscall2()
11406 return -TARGET_EINVAL; in _syscall2()
11408 mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1); in _syscall2()
11428 return -TARGET_EFAULT; in _syscall2()
11431 return -TARGET_EFAULT; in _syscall2()
11441 return -TARGET_EINVAL; in _syscall2()
11444 return -TARGET_EFAULT; in _syscall2()
11446 schp.sched_priority = tswap32(target_schp->sched_priority); in _syscall2()
11456 return -TARGET_EINVAL; in _syscall2()
11461 return -TARGET_EFAULT; in _syscall2()
11463 target_schp->sched_priority = tswap32(schp.sched_priority); in _syscall2()
11473 return -TARGET_EINVAL; in _syscall2()
11476 return -TARGET_EFAULT; in _syscall2()
11478 schp.sched_priority = tswap32(target_schp->sched_priority); in _syscall2()
11489 return -TARGET_EINVAL; in _syscall2()
11498 return -TARGET_EFAULT; in _syscall2()
11500 target_scha->size = tswap32(scha.size); in _syscall2()
11501 target_scha->sched_policy = tswap32(scha.sched_policy); in _syscall2()
11502 target_scha->sched_flags = tswap64(scha.sched_flags); in _syscall2()
11503 target_scha->sched_nice = tswap32(scha.sched_nice); in _syscall2()
11504 target_scha->sched_priority = tswap32(scha.sched_priority); in _syscall2()
11505 target_scha->sched_runtime = tswap64(scha.sched_runtime); in _syscall2()
11506 target_scha->sched_deadline = tswap64(scha.sched_deadline); in _syscall2()
11507 target_scha->sched_period = tswap64(scha.sched_period); in _syscall2()
11509 target_scha->sched_util_min = tswap32(scha.sched_util_min); in _syscall2()
11510 target_scha->sched_util_max = tswap32(scha.sched_util_max); in _syscall2()
11523 return -TARGET_EINVAL; in _syscall2()
11526 return -TARGET_EFAULT; in _syscall2()
11533 return -TARGET_EFAULT; in _syscall2()
11535 return -TARGET_E2BIG; in _syscall2()
11543 return -TARGET_EFAULT; in _syscall2()
11545 return -TARGET_E2BIG; in _syscall2()
11553 return -TARGET_EFAULT; in _syscall2()
11556 scha.sched_policy = tswap32(target_scha->sched_policy); in _syscall2()
11557 scha.sched_flags = tswap64(target_scha->sched_flags); in _syscall2()
11558 scha.sched_nice = tswap32(target_scha->sched_nice); in _syscall2()
11559 scha.sched_priority = tswap32(target_scha->sched_priority); in _syscall2()
11560 scha.sched_runtime = tswap64(target_scha->sched_runtime); in _syscall2()
11561 scha.sched_deadline = tswap64(target_scha->sched_deadline); in _syscall2()
11562 scha.sched_period = tswap64(target_scha->sched_period); in _syscall2()
11564 scha.sched_util_min = tswap32(target_scha->sched_util_min); in _syscall2()
11565 scha.sched_util_max = tswap32(target_scha->sched_util_max); in _syscall2()
11624 /* Special-case NULL buffer and zero length, which should succeed */ in _syscall2()
11629 return -TARGET_EFAULT; in _syscall2()
11641 /* Special-case NULL buffer and zero length, which should succeed */ in _syscall2()
11646 return -TARGET_EFAULT; in _syscall2()
11655 return -TARGET_EFAULT; in _syscall2()
11671 return -TARGET_EFAULT; in _syscall2()
11673 header.version = tswap32(target_header->version); in _syscall2()
11674 header.pid = tswap32(target_header->pid); in _syscall2()
11691 return -TARGET_EFAULT; in _syscall2()
11712 target_header->version = tswap32(header.version); in _syscall2()
11793 return -TARGET_EFAULT; in _syscall2()
11794 target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); in _syscall2()
11795 target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); in _syscall2()
11804 return -TARGET_EFAULT; in _syscall2()
11816 return -TARGET_EFAULT; in _syscall2()
11827 return -TARGET_EFAULT; in _syscall2()
11850 return -TARGET_EFAULT; in _syscall2()
11867 return -TARGET_EFAULT; in _syscall2()
11881 return -TARGET_EFAULT; in _syscall2()
11885 if (ret != -TARGET_ENOSYS) { in _syscall2()
11896 return -TARGET_EFAULT; in _syscall2()
11899 __put_user(major(st.st_dev), &target_stx->stx_dev_major); in _syscall2()
11900 __put_user(minor(st.st_dev), &target_stx->stx_dev_minor); in _syscall2()
11901 __put_user(st.st_ino, &target_stx->stx_ino); in _syscall2()
11902 __put_user(st.st_mode, &target_stx->stx_mode); in _syscall2()
11903 __put_user(st.st_uid, &target_stx->stx_uid); in _syscall2()
11904 __put_user(st.st_gid, &target_stx->stx_gid); in _syscall2()
11905 __put_user(st.st_nlink, &target_stx->stx_nlink); in _syscall2()
11906 __put_user(major(st.st_rdev), &target_stx->stx_rdev_major); in _syscall2()
11907 __put_user(minor(st.st_rdev), &target_stx->stx_rdev_minor); in _syscall2()
11908 __put_user(st.st_size, &target_stx->stx_size); in _syscall2()
11909 __put_user(st.st_blksize, &target_stx->stx_blksize); in _syscall2()
11910 __put_user(st.st_blocks, &target_stx->stx_blocks); in _syscall2()
11911 __put_user(st.st_atime, &target_stx->stx_atime.tv_sec); in _syscall2()
11912 __put_user(st.st_mtime, &target_stx->stx_mtime.tv_sec); in _syscall2()
11913 __put_user(st.st_ctime, &target_stx->stx_ctime.tv_sec); in _syscall2()
11922 return -TARGET_EFAULT; in _syscall2()
11955 return -TARGET_EINVAL; in _syscall2()
11960 return -TARGET_ENOMEM; in _syscall2()
11968 return -TARGET_EFAULT; in _syscall2()
11986 return -TARGET_EINVAL; in _syscall2()
11991 return -TARGET_ENOMEM; in _syscall2()
11996 return -TARGET_EFAULT; in _syscall2()
12011 return -TARGET_EFAULT; in _syscall2()
12032 return -TARGET_EFAULT; in _syscall2()
12052 return -TARGET_EFAULT; in _syscall2()
12060 return -TARGET_EFAULT; in _syscall2()
12077 return -TARGET_EFAULT; in _syscall2()
12093 cpu_env->ir[IR_A4]=euid; in _syscall2()
12103 cpu_env->ir[IR_A4]=egid; in _syscall2()
12110 ret = -TARGET_EOPNOTSUPP; in _syscall2()
12115 uint64_t swcr = cpu_env->swcr; in _syscall2()
12121 return -TARGET_EFAULT; in _syscall2()
12127 -- Not implemented in linux kernel. in _syscall2()
12129 -- Retrieves current unaligned access state; not much used. in _syscall2()
12131 -- Retrieves implver information; surely not used. in _syscall2()
12133 -- Grabs a copy of the HWRPB; surely not used. in _syscall2()
12141 ret = -TARGET_EOPNOTSUPP; in _syscall2()
12148 return -TARGET_EFAULT; in _syscall2()
12157 cpu_env->swcr = swcr & (SWCR_TRAP_ENABLE_MASK | SWCR_MAP_MASK); in _syscall2()
12172 return -TARGET_EFAULT; in _syscall2()
12181 fex &= (cpu_env)->swcr; in _syscall2()
12213 info._sifields._sigfault._addr = (cpu_env)->pc; in _syscall2()
12222 -- Used with SSIN_UACPROC to enable unaligned accesses. in _syscall2()
12225 -- Not implemented in linux kernel in _syscall2()
12249 return -TARGET_EINVAL; in _syscall2()
12291 return -TARGET_EINVAL; in _syscall2()
12296 return -TARGET_ENOMEM; in _syscall2()
12304 return -TARGET_EFAULT; in _syscall2()
12323 return -TARGET_EINVAL; in _syscall2()
12328 return -TARGET_ENOMEM; in _syscall2()
12333 return -TARGET_EFAULT; in _syscall2()
12360 return -TARGET_EFAULT; in _syscall2()
12378 return -TARGET_EFAULT; in _syscall2()
12386 return -TARGET_EFAULT; in _syscall2()
12412 return -TARGET_ENOMEM; in _syscall2()
12416 ret = -TARGET_EFAULT; in _syscall2()
12430 * Note that offset and len are both 64-bit so appear as in _syscall2()
12431 * pairs of 32-bit registers. in _syscall2()
12435 return -host_to_target_errno(ret); in _syscall2()
12463 return -host_to_target_errno(ret); in _syscall2()
12477 return -host_to_target_errno(ret); in _syscall2()
12480 #else /* not a 32-bit ABI */ in _syscall2()
12497 return -host_to_target_errno(posix_fadvise(arg1, arg2, arg3, arg4)); in _syscall2()
12499 #endif /* end of 64-bit ABI fadvise handling */ in _syscall2()
12514 if (!cpu_env->eabi) { in _syscall2()
12521 if (cmd == -TARGET_EINVAL) { in _syscall2()
12554 /* self-modifying code is handled automatically, so nothing needed */ in _syscall2()
12586 return -TARGET_EFAULT; in _syscall2()
12597 ret = -TARGET_EFAULT; in _syscall2()
12609 return -TARGET_EFAULT; in _syscall2()
12623 return -TARGET_EFAULT; in _syscall2()
12635 ret = -TARGET_EFAULT; in _syscall2()
12648 return -TARGET_EFAULT; in _syscall2()
12655 ret = -TARGET_EFAULT; in _syscall2()
12668 return -TARGET_EFAULT; in _syscall2()
12680 ret = -TARGET_EFAULT; in _syscall2()
12693 return -TARGET_EFAULT; in _syscall2()
12700 ret = -TARGET_EFAULT; in _syscall2()
12719 ret = -TARGET_EFAULT; in _syscall2()
12732 ret = -TARGET_EFAULT; in _syscall2()
12742 cpu_env->active_tc.CP0_UserLocal = arg1; in _syscall2()
12749 ts->tp_value = arg1; in _syscall2()
12753 return -TARGET_ENOSYS; in _syscall2()
12763 return ts->tp_value; in _syscall2()
12766 return -TARGET_ENOSYS; in _syscall2()
12771 return -TARGET_ENOSYS; in _syscall2()
12847 return -TARGET_EFAULT; in _syscall2()
12853 * with error -TARGET_EINTR and if arg4 is not NULL and arg2 is not in _syscall2()
12856 if (ret == -TARGET_EINTR && arg4 && arg2 != TIMER_ABSTIME && in _syscall2()
12858 return -TARGET_EFAULT; in _syscall2()
12870 return -TARGET_EFAULT; in _syscall2()
12876 if (ret == -TARGET_EINTR && arg4 && arg2 != TIMER_ABSTIME && in _syscall2()
12878 return -TARGET_EFAULT; in _syscall2()
12888 ts->child_tidptr = arg1; in _syscall2()
12909 * no way to reliably intercept the thread-death event, we can't in _syscall2()
12911 * falls back to a non-robust futex implementation (which should in _syscall2()
12916 return -TARGET_ENOSYS; in _syscall2()
12927 return -TARGET_EFAULT; in _syscall2()
12931 return -TARGET_EFAULT; in _syscall2()
12939 return -TARGET_EFAULT; in _syscall2()
12955 return -TARGET_EFAULT; in _syscall2()
12959 return -TARGET_EFAULT; in _syscall2()
12968 return -TARGET_EFAULT; in _syscall2()
13026 return -TARGET_EFAULT; in _syscall2()
13030 p = lock_user_string(arg1 - 1); in _syscall2()
13032 return -TARGET_EFAULT; in _syscall2()
13040 p = lock_user_string(arg1 - 1); in _syscall2()
13042 return -TARGET_EFAULT; in _syscall2()
13056 return -TARGET_EFAULT; in _syscall2()
13060 return -TARGET_EFAULT; in _syscall2()
13077 return -TARGET_EFAULT; in _syscall2()
13081 return -TARGET_EFAULT; in _syscall2()
13100 return -TARGET_EFAULT; in _syscall2()
13105 return -TARGET_EFAULT; in _syscall2()
13126 return -TARGET_EFAULT; in _syscall2()
13131 return -TARGET_EFAULT; in _syscall2()
13182 return -TARGET_EFAULT; in _syscall2()
13188 return -TARGET_EFAULT; in _syscall2()
13195 return -TARGET_EFAULT; in _syscall2()
13200 return -TARGET_EFAULT; in _syscall2()
13214 ret = -host_to_target_errno(errno); in _syscall2()
13317 return -TARGET_EFAULT; in _syscall2()
13319 ep.events = tswap32(target_ep->events); in _syscall2()
13325 ep.data.u64 = tswap64(target_ep->data.u64); in _syscall2()
13330 * non-null pointer, even though this argument is ignored. in _syscall2()
13354 return -TARGET_EINVAL; in _syscall2()
13360 return -TARGET_EFAULT; in _syscall2()
13366 return -TARGET_ENOMEM; in _syscall2()
13398 ret = -TARGET_ENOSYS; in _syscall2()
13428 return -TARGET_EFAULT; in _syscall2()
13430 __get_user(rnew.rlim_cur, &target_rnew->rlim_cur); in _syscall2()
13431 __get_user(rnew.rlim_max, &target_rnew->rlim_max); in _syscall2()
13439 return -TARGET_EFAULT; in _syscall2()
13441 __put_user(rold.rlim_cur, &target_rold->rlim_cur); in _syscall2()
13442 __put_user(rold.rlim_max, &target_rold->rlim_max); in _syscall2()
13456 ret = -TARGET_EFAULT; in _syscall2()
13484 qemu arm barrier, no-op this? */ in _syscall2()
13499 ret = -TARGET_EAGAIN; in _syscall2()
13519 return -TARGET_EFAULT; in _syscall2()
13537 ret = -TARGET_EINVAL; in _syscall2()
13543 return -TARGET_EFAULT; in _syscall2()
13548 return -TARGET_EFAULT; in _syscall2()
13563 ret = -TARGET_EINVAL; in _syscall2()
13569 return -TARGET_EFAULT; in _syscall2()
13574 return -TARGET_EFAULT; in _syscall2()
13590 ret = -TARGET_EFAULT; in _syscall2()
13597 ret = -TARGET_EFAULT; in _syscall2()
13613 ret = -TARGET_EFAULT; in _syscall2()
13620 ret = -TARGET_EFAULT; in _syscall2()
13678 return -TARGET_EFAULT; in _syscall2()
13692 return -TARGET_EFAULT; in _syscall2()
13705 return -TARGET_EFAULT; in _syscall2()
13715 return -TARGET_EFAULT; in _syscall2()
13728 return -TARGET_EFAULT; in _syscall2()
13738 return -TARGET_EFAULT; in _syscall2()
13775 return -TARGET_EFAULT; in _syscall2()
13795 return -TARGET_EFAULT; in _syscall2()
13801 return -TARGET_EFAULT; in _syscall2()
13805 /* Do not sign-extend the count parameter. */ in _syscall2()
13811 return -TARGET_EFAULT; in _syscall2()
13816 return -TARGET_EFAULT; in _syscall2()
13831 ret = -TARGET_EFAULT; in _syscall2()
13848 return -TARGET_ENOSYS; in _syscall2()
13862 /* Debug-only code for exercising the syscall-restart code paths in do_syscall()
13863 * in the per-architecture cpu main loops: restart every syscall in do_syscall()
13870 return -QEMU_ERESTARTSYS; in do_syscall()