Lines Matching +full:sparc +full:- +full:softmmu
28 #include "exec/page-protection.h"
29 #include "exec/mmap-lock.h"
30 #include "exec/tb-flush.h"
31 #include "exec/translation-block.h"
115 #include <linux/dm-ioctl.h>
136 #include "user-internals.h"
138 #include "signal-common.h"
140 #include "user-mmap.h"
141 #include "user/page-protection.h"
142 #include "user/safe-syscall.h"
144 #include "qemu/guest-random.h"
146 #include "user/syscall-trace.h"
147 #include "special-errno.h"
149 #include "fd-trans.h"
306 /* For the 64-bit guest on 32-bit host case we must emulate
461 /* Don't terminate the list prematurely on 64-bit host+guest. */
479 return -1;
497 return -1;
514 # define __NR_prlimit64 -1
542 return -1; in next_free_host_timer()
575 if (ret == -1) in get_errno()
576 return -host_to_target_errno(errno); in get_errno()
602 return -TARGET_EFAULT; in check_zeroed_user()
613 * backwards-compatibility for struct syscall arguments.
620 size_t rest = MAX(ksize, usize) - size; in copy_struct_from_user()
628 return ret ?: -TARGET_E2BIG; in copy_struct_from_user()
633 return -TARGET_EFAULT; in copy_struct_from_user()
804 * we should be using the 64-bit structures automatically. in safe_syscall3()
876 target_munmap(new_brk, old_brk - new_brk); in do_brk()
882 mapped_addr = target_mmap(old_brk, new_brk - old_brk, in do_brk()
885 -1, 0); in do_brk()
895 return -TARGET_ENOMEM; in do_brk()
915 return -TARGET_EFAULT; in copy_from_user_fdset()
941 return -TARGET_EFAULT; in copy_from_user_fdset_ptr()
962 return -TARGET_EFAULT; in copy_to_user_fdset()
1001 return -TARGET_EFAULT; in host_to_target_rusage()
1002 target_rusage->ru_utime.tv_sec = tswapal(rusage->ru_utime.tv_sec); in host_to_target_rusage()
1003 target_rusage->ru_utime.tv_usec = tswapal(rusage->ru_utime.tv_usec); in host_to_target_rusage()
1004 target_rusage->ru_stime.tv_sec = tswapal(rusage->ru_stime.tv_sec); in host_to_target_rusage()
1005 target_rusage->ru_stime.tv_usec = tswapal(rusage->ru_stime.tv_usec); in host_to_target_rusage()
1006 target_rusage->ru_maxrss = tswapal(rusage->ru_maxrss); in host_to_target_rusage()
1007 target_rusage->ru_ixrss = tswapal(rusage->ru_ixrss); in host_to_target_rusage()
1008 target_rusage->ru_idrss = tswapal(rusage->ru_idrss); in host_to_target_rusage()
1009 target_rusage->ru_isrss = tswapal(rusage->ru_isrss); in host_to_target_rusage()
1010 target_rusage->ru_minflt = tswapal(rusage->ru_minflt); in host_to_target_rusage()
1011 target_rusage->ru_majflt = tswapal(rusage->ru_majflt); in host_to_target_rusage()
1012 target_rusage->ru_nswap = tswapal(rusage->ru_nswap); in host_to_target_rusage()
1013 target_rusage->ru_inblock = tswapal(rusage->ru_inblock); in host_to_target_rusage()
1014 target_rusage->ru_oublock = tswapal(rusage->ru_oublock); in host_to_target_rusage()
1015 target_rusage->ru_msgsnd = tswapal(rusage->ru_msgsnd); in host_to_target_rusage()
1016 target_rusage->ru_msgrcv = tswapal(rusage->ru_msgrcv); in host_to_target_rusage()
1017 target_rusage->ru_nsignals = tswapal(rusage->ru_nsignals); in host_to_target_rusage()
1018 target_rusage->ru_nvcsw = tswapal(rusage->ru_nvcsw); in host_to_target_rusage()
1019 target_rusage->ru_nivcsw = tswapal(rusage->ru_nivcsw); in host_to_target_rusage()
1107 return -TARGET_EFAULT; in copy_from_user_timeval()
1110 __get_user(tv->tv_sec, &target_tv->tv_sec); in copy_from_user_timeval()
1111 __get_user(tv->tv_usec, &target_tv->tv_usec); in copy_from_user_timeval()
1124 return -TARGET_EFAULT; in copy_to_user_timeval()
1127 __put_user(tv->tv_sec, &target_tv->tv_sec); in copy_to_user_timeval()
1128 __put_user(tv->tv_usec, &target_tv->tv_usec); in copy_to_user_timeval()
1142 return -TARGET_EFAULT; in copy_from_user_timeval64()
1145 __get_user(tv->tv_sec, &target_tv->tv_sec); in copy_from_user_timeval64()
1146 __get_user(tv->tv_usec, &target_tv->tv_usec); in copy_from_user_timeval64()
1160 return -TARGET_EFAULT; in copy_to_user_timeval64()
1163 __put_user(tv->tv_sec, &target_tv->tv_sec); in copy_to_user_timeval64()
1164 __put_user(tv->tv_usec, &target_tv->tv_usec); in copy_to_user_timeval64()
1186 return -TARGET_EFAULT; in target_to_host_timespec()
1188 __get_user(host_ts->tv_sec, &target_ts->tv_sec); in target_to_host_timespec()
1189 __get_user(host_ts->tv_nsec, &target_ts->tv_nsec); in target_to_host_timespec()
1212 return -TARGET_EFAULT; in target_to_host_timespec64()
1214 __get_user(host_ts->tv_sec, &target_ts->tv_sec); in target_to_host_timespec64()
1215 __get_user(host_ts->tv_nsec, &target_ts->tv_nsec); in target_to_host_timespec64()
1217 host_ts->tv_nsec = (long)(abi_long)host_ts->tv_nsec; in target_to_host_timespec64()
1229 return -TARGET_EFAULT; in host_to_target_timespec()
1231 __put_user(host_ts->tv_sec, &target_ts->tv_sec); in host_to_target_timespec()
1232 __put_user(host_ts->tv_nsec, &target_ts->tv_nsec); in host_to_target_timespec()
1243 return -TARGET_EFAULT; in host_to_target_timespec64()
1245 __put_user(host_ts->tv_sec, &target_ts->tv_sec); in host_to_target_timespec64()
1246 __put_user(host_ts->tv_nsec, &target_ts->tv_nsec); in host_to_target_timespec64()
1258 return -TARGET_EFAULT; in copy_to_user_timezone()
1261 __put_user(tz->tz_minuteswest, &target_tz->tz_minuteswest); in copy_to_user_timezone()
1262 __put_user(tz->tz_dsttime, &target_tz->tz_dsttime); in copy_to_user_timezone()
1277 return -TARGET_EFAULT; in copy_from_user_timezone()
1280 __get_user(tz->tz_minuteswest, &target_tz->tz_minuteswest); in copy_from_user_timezone()
1281 __get_user(tz->tz_dsttime, &target_tz->tz_dsttime); in copy_from_user_timezone()
1299 return -TARGET_EFAULT; in copy_from_user_mq_attr()
1301 __get_user(attr->mq_flags, &target_mq_attr->mq_flags); in copy_from_user_mq_attr()
1302 __get_user(attr->mq_maxmsg, &target_mq_attr->mq_maxmsg); in copy_from_user_mq_attr()
1303 __get_user(attr->mq_msgsize, &target_mq_attr->mq_msgsize); in copy_from_user_mq_attr()
1304 __get_user(attr->mq_curmsgs, &target_mq_attr->mq_curmsgs); in copy_from_user_mq_attr()
1318 return -TARGET_EFAULT; in copy_to_user_mq_attr()
1320 __put_user(attr->mq_flags, &target_mq_attr->mq_flags); in copy_to_user_mq_attr()
1321 __put_user(attr->mq_maxmsg, &target_mq_attr->mq_maxmsg); in copy_to_user_mq_attr()
1322 __put_user(attr->mq_msgsize, &target_mq_attr->mq_msgsize); in copy_to_user_mq_attr()
1323 __put_user(attr->mq_curmsgs, &target_mq_attr->mq_curmsgs); in copy_to_user_mq_attr()
1358 return -TARGET_EFAULT; in do_select()
1371 return -TARGET_EFAULT; in do_select()
1373 return -TARGET_EFAULT; in do_select()
1375 return -TARGET_EFAULT; in do_select()
1381 return -TARGET_EFAULT; in do_select()
1397 return -TARGET_EFAULT; in do_old_select()
1400 nsel = tswapal(sel->n); in do_old_select()
1401 inp = tswapal(sel->inp); in do_old_select()
1402 outp = tswapal(sel->outp); in do_old_select()
1403 exp = tswapal(sel->exp); in do_old_select()
1404 tvp = tswapal(sel->tvp); in do_old_select()
1461 return -TARGET_EFAULT; in do_pselect6()
1465 return -TARGET_EFAULT; in do_pselect6()
1478 return -TARGET_EFAULT; in do_pselect6()
1503 return -TARGET_EFAULT; in do_pselect6()
1506 return -TARGET_EFAULT; in do_pselect6()
1509 return -TARGET_EFAULT; in do_pselect6()
1513 return -TARGET_EFAULT; in do_pselect6()
1517 return -TARGET_EFAULT; in do_pselect6()
1540 return -TARGET_EINVAL; in do_ppoll()
1545 return -TARGET_EFAULT; in do_ppoll()
1562 return -TARGET_EFAULT; in do_ppoll()
1567 return -TARGET_EFAULT; in do_ppoll()
1591 return -TARGET_EFAULT; in do_ppoll()
1595 return -TARGET_EFAULT; in do_ppoll()
1608 /* -ve poll() timeout means "infinite" */ in do_ppoll()
1638 cpu_env->ir[IR_A4] = host_pipe[1]; in do_pipe()
1641 cpu_env->active_tc.gpr[3] = host_pipe[1]; in do_pipe()
1644 cpu_env->gregs[1] = host_pipe[1]; in do_pipe()
1647 cpu_env->regwptr[1] = host_pipe[1]; in do_pipe()
1654 return -TARGET_EFAULT; in do_pipe()
1672 return -TARGET_EFAULT; in target_to_host_sockaddr()
1674 sa_family = tswap16(target_saddr->sa_family); in target_to_host_sockaddr()
1679 * length as "strlen(x->sun_path)" while it should be in target_to_host_sockaddr()
1688 if ( cp[len-1] && !cp[len] ) in target_to_host_sockaddr()
1696 addr->sa_family = sa_family; in target_to_host_sockaddr()
1701 nladdr->nl_pid = tswap32(nladdr->nl_pid); in target_to_host_sockaddr()
1702 nladdr->nl_groups = tswap32(nladdr->nl_groups); in target_to_host_sockaddr()
1707 lladdr->sll_ifindex = tswap32(lladdr->sll_ifindex); in target_to_host_sockaddr()
1708 lladdr->sll_hatype = tswap16(lladdr->sll_hatype); in target_to_host_sockaddr()
1713 in6addr->sin6_scope_id = tswap32(in6addr->sin6_scope_id); in target_to_host_sockaddr()
1733 return -TARGET_EFAULT; in host_to_target_sockaddr()
1736 sizeof(target_saddr->sa_family)) { in host_to_target_sockaddr()
1737 target_saddr->sa_family = tswap16(addr->sa_family); in host_to_target_sockaddr()
1739 if (addr->sa_family == AF_NETLINK && in host_to_target_sockaddr()
1743 target_nl->nl_pid = tswap32(target_nl->nl_pid); in host_to_target_sockaddr()
1744 target_nl->nl_groups = tswap32(target_nl->nl_groups); in host_to_target_sockaddr()
1745 } else if (addr->sa_family == AF_PACKET) { in host_to_target_sockaddr()
1747 target_ll->sll_ifindex = tswap32(target_ll->sll_ifindex); in host_to_target_sockaddr()
1748 target_ll->sll_hatype = tswap16(target_ll->sll_hatype); in host_to_target_sockaddr()
1749 } else if (addr->sa_family == AF_INET6 && in host_to_target_sockaddr()
1753 target_in6->sin6_scope_id = tswap16(target_in6->sin6_scope_id); in host_to_target_sockaddr()
1769 msg_controllen = tswapal(target_msgh->msg_controllen); in target_to_host_cmsg()
1772 target_cmsg_addr = tswapal(target_msgh->msg_control); in target_to_host_cmsg()
1776 return -TARGET_EFAULT; in target_to_host_cmsg()
1782 int len = tswapal(target_cmsg->cmsg_len) in target_to_host_cmsg()
1783 - sizeof(struct target_cmsghdr); in target_to_host_cmsg()
1786 if (space > msgh->msg_controllen) { in target_to_host_cmsg()
1787 space -= CMSG_SPACE(len); in target_to_host_cmsg()
1789 * area ourselves (unlike overflow in host-to-target in target_to_host_cmsg()
1800 tswap32(target_cmsg->cmsg_level), in target_to_host_cmsg()
1801 tswap32(target_cmsg->cmsg_type)); in target_to_host_cmsg()
1805 if (tswap32(target_cmsg->cmsg_level) == TARGET_SOL_SOCKET) { in target_to_host_cmsg()
1806 cmsg->cmsg_level = SOL_SOCKET; in target_to_host_cmsg()
1808 cmsg->cmsg_level = tswap32(target_cmsg->cmsg_level); in target_to_host_cmsg()
1810 cmsg->cmsg_type = tswap32(target_cmsg->cmsg_type); in target_to_host_cmsg()
1811 cmsg->cmsg_len = CMSG_LEN(len); in target_to_host_cmsg()
1813 if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { in target_to_host_cmsg()
1821 } else if (cmsg->cmsg_level == SOL_SOCKET in target_to_host_cmsg()
1822 && cmsg->cmsg_type == SCM_CREDENTIALS) { in target_to_host_cmsg()
1827 __get_user(cred->pid, &target_cred->pid); in target_to_host_cmsg()
1828 __get_user(cred->uid, &target_cred->uid); in target_to_host_cmsg()
1829 __get_user(cred->gid, &target_cred->gid); in target_to_host_cmsg()
1830 } else if (cmsg->cmsg_level == SOL_ALG) { in target_to_host_cmsg()
1834 /* fix endianness of first 32-bit word */ in target_to_host_cmsg()
1840 cmsg->cmsg_level, cmsg->cmsg_type); in target_to_host_cmsg()
1850 msgh->msg_controllen = space; in target_to_host_cmsg()
1863 msg_controllen = tswapal(target_msgh->msg_controllen); in host_to_target_cmsg()
1866 target_cmsg_addr = tswapal(target_msgh->msg_control); in host_to_target_cmsg()
1870 return -TARGET_EFAULT; in host_to_target_cmsg()
1876 int len = cmsg->cmsg_len - sizeof(struct cmsghdr); in host_to_target_cmsg()
1879 /* We never copy a half-header but may copy half-data; in host_to_target_cmsg()
1886 target_msgh->msg_flags |= tswap32(MSG_CTRUNC); in host_to_target_cmsg()
1890 if (cmsg->cmsg_level == SOL_SOCKET) { in host_to_target_cmsg()
1891 target_cmsg->cmsg_level = tswap32(TARGET_SOL_SOCKET); in host_to_target_cmsg()
1893 target_cmsg->cmsg_level = tswap32(cmsg->cmsg_level); in host_to_target_cmsg()
1895 target_cmsg->cmsg_type = tswap32(cmsg->cmsg_type); in host_to_target_cmsg()
1901 switch (cmsg->cmsg_level) { in host_to_target_cmsg()
1903 switch (cmsg->cmsg_type) { in host_to_target_cmsg()
1916 target_msgh->msg_flags |= tswap32(MSG_CTRUNC); in host_to_target_cmsg()
1917 tgt_len = msg_controllen - sizeof(struct target_cmsghdr); in host_to_target_cmsg()
1920 /* We must now copy-and-convert len bytes of payload in host_to_target_cmsg()
1925 switch (cmsg->cmsg_level) { in host_to_target_cmsg()
1927 switch (cmsg->cmsg_type) { in host_to_target_cmsg()
1951 __put_user(tv->tv_sec, &target_tv->tv_sec); in host_to_target_cmsg()
1952 __put_user(tv->tv_usec, &target_tv->tv_usec); in host_to_target_cmsg()
1961 __put_user(cred->pid, &target_cred->pid); in host_to_target_cmsg()
1962 __put_user(cred->uid, &target_cred->uid); in host_to_target_cmsg()
1963 __put_user(cred->gid, &target_cred->gid); in host_to_target_cmsg()
1972 switch (cmsg->cmsg_type) { in host_to_target_cmsg()
1999 __put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno); in host_to_target_cmsg()
2000 __put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin); in host_to_target_cmsg()
2001 __put_user(errh->ee.ee_type, &target_errh->ee.ee_type); in host_to_target_cmsg()
2002 __put_user(errh->ee.ee_code, &target_errh->ee.ee_code); in host_to_target_cmsg()
2003 __put_user(errh->ee.ee_pad, &target_errh->ee.ee_pad); in host_to_target_cmsg()
2004 __put_user(errh->ee.ee_info, &target_errh->ee.ee_info); in host_to_target_cmsg()
2005 __put_user(errh->ee.ee_data, &target_errh->ee.ee_data); in host_to_target_cmsg()
2006 host_to_target_sockaddr((unsigned long) &target_errh->offender, in host_to_target_cmsg()
2007 (void *) &errh->offender, sizeof(errh->offender)); in host_to_target_cmsg()
2015 __put_user(pkti->ipi_ifindex, &target_pi->ipi_ifindex); in host_to_target_cmsg()
2016 target_pi->ipi_spec_dst.s_addr = pkti->ipi_spec_dst.s_addr; in host_to_target_cmsg()
2017 target_pi->ipi_addr.s_addr = pkti->ipi_addr.s_addr; in host_to_target_cmsg()
2026 switch (cmsg->cmsg_type) { in host_to_target_cmsg()
2053 __put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno); in host_to_target_cmsg()
2054 __put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin); in host_to_target_cmsg()
2055 __put_user(errh->ee.ee_type, &target_errh->ee.ee_type); in host_to_target_cmsg()
2056 __put_user(errh->ee.ee_code, &target_errh->ee.ee_code); in host_to_target_cmsg()
2057 __put_user(errh->ee.ee_pad, &target_errh->ee.ee_pad); in host_to_target_cmsg()
2058 __put_user(errh->ee.ee_info, &target_errh->ee.ee_info); in host_to_target_cmsg()
2059 __put_user(errh->ee.ee_data, &target_errh->ee.ee_data); in host_to_target_cmsg()
2060 host_to_target_sockaddr((unsigned long) &target_errh->offender, in host_to_target_cmsg()
2061 (void *) &errh->offender, sizeof(errh->offender)); in host_to_target_cmsg()
2072 cmsg->cmsg_level, cmsg->cmsg_type); in host_to_target_cmsg()
2075 memset(target_data + len, 0, tgt_len - len); in host_to_target_cmsg()
2079 target_cmsg->cmsg_len = tswapal(TARGET_CMSG_LEN(tgt_len)); in host_to_target_cmsg()
2084 msg_controllen -= tgt_space; in host_to_target_cmsg()
2092 target_msgh->msg_controllen = tswapal(space); in host_to_target_cmsg()
2108 return -TARGET_EINVAL; in do_setsockopt()
2111 return -TARGET_EFAULT; in do_setsockopt()
2135 return -TARGET_EFAULT; in do_setsockopt()
2138 return -TARGET_EFAULT; in do_setsockopt()
2160 return -TARGET_EINVAL; in do_setsockopt()
2165 return -TARGET_EFAULT; in do_setsockopt()
2167 ip_mreq.imr_multiaddr.s_addr = target_smreqn->imr_multiaddr.s_addr; in do_setsockopt()
2169 ip_mreq.imr_address.s_addr = target_smreqn->imr_address.s_addr; in do_setsockopt()
2171 __put_user(target_smreqn->imr_ifindex, &ip_mreq.imr_ifindex); in do_setsockopt()
2187 return -TARGET_EINVAL; in do_setsockopt()
2191 return -TARGET_EFAULT; in do_setsockopt()
2239 return -TARGET_EINVAL; in do_setsockopt()
2242 return -TARGET_EFAULT; in do_setsockopt()
2252 return -TARGET_EINVAL; in do_setsockopt()
2256 return -TARGET_EFAULT; in do_setsockopt()
2271 return -TARGET_EINVAL; in do_setsockopt()
2275 return -TARGET_EFAULT; in do_setsockopt()
2299 return -TARGET_EFAULT; in do_setsockopt()
2320 return -TARGET_EINVAL; in do_setsockopt()
2324 return -TARGET_EFAULT; in do_setsockopt()
2341 return -TARGET_EFAULT; in do_setsockopt()
2367 return -TARGET_EINVAL; in do_setsockopt()
2371 return -TARGET_EFAULT; in do_setsockopt()
2389 return -TARGET_EINVAL; in do_setsockopt()
2392 return -TARGET_EFAULT; in do_setsockopt()
2395 tswapal(tfprog->filter), 0)) { in do_setsockopt()
2397 return -TARGET_EFAULT; in do_setsockopt()
2400 fprog.len = tswap16(tfprog->len); in do_setsockopt()
2403 unlock_user_struct(tfilter, tfprog->filter, 1); in do_setsockopt()
2405 return -TARGET_ENOMEM; in do_setsockopt()
2419 unlock_user_struct(tfilter, tfprog->filter, 1); in do_setsockopt()
2427 if (optlen > IFNAMSIZ - 1) { in do_setsockopt()
2428 optlen = IFNAMSIZ - 1; in do_setsockopt()
2432 return -TARGET_EFAULT; in do_setsockopt()
2449 return -TARGET_EINVAL; in do_setsockopt()
2452 return -TARGET_EFAULT; in do_setsockopt()
2454 __get_user(lg.l_onoff, &tlg->l_onoff); in do_setsockopt()
2455 __get_user(lg.l_linger, &tlg->l_linger); in do_setsockopt()
2530 return -TARGET_EINVAL; in do_setsockopt()
2533 return -TARGET_EFAULT; in do_setsockopt()
2560 return -TARGET_EINVAL; in do_setsockopt()
2563 return -TARGET_EFAULT; in do_setsockopt()
2573 ret = -TARGET_ENOPROTOOPT; in do_setsockopt()
2601 return -TARGET_EFAULT; in do_getsockopt()
2604 return -TARGET_EINVAL; in do_getsockopt()
2617 return -TARGET_EFAULT; in do_getsockopt()
2620 return -TARGET_EFAULT; in do_getsockopt()
2633 return -TARGET_EFAULT; in do_getsockopt()
2636 return -TARGET_EINVAL; in do_getsockopt()
2649 return -TARGET_EFAULT; in do_getsockopt()
2651 __put_user(cr.pid, &tcr->pid); in do_getsockopt()
2652 __put_user(cr.uid, &tcr->uid); in do_getsockopt()
2653 __put_user(cr.gid, &tcr->gid); in do_getsockopt()
2656 return -TARGET_EFAULT; in do_getsockopt()
2664 return -TARGET_EFAULT; in do_getsockopt()
2667 return -TARGET_EINVAL; in do_getsockopt()
2671 return -TARGET_EFAULT; in do_getsockopt()
2677 ret = -TARGET_EFAULT; in do_getsockopt()
2689 return -TARGET_EFAULT; in do_getsockopt()
2692 return -TARGET_EINVAL; in do_getsockopt()
2705 return -TARGET_EFAULT; in do_getsockopt()
2707 __put_user(lg.l_onoff, &tlg->l_onoff); in do_getsockopt()
2708 __put_user(lg.l_linger, &tlg->l_linger); in do_getsockopt()
2711 return -TARGET_EFAULT; in do_getsockopt()
2789 return -TARGET_EFAULT; in do_getsockopt()
2791 return -TARGET_EINVAL; in do_getsockopt()
2808 return -TARGET_EFAULT; in do_getsockopt()
2811 return -TARGET_EFAULT; in do_getsockopt()
2814 return -TARGET_EFAULT; in do_getsockopt()
2834 return -TARGET_EFAULT; in do_getsockopt()
2836 return -TARGET_EINVAL; in do_getsockopt()
2845 return -TARGET_EFAULT; in do_getsockopt()
2851 return -TARGET_EFAULT; in do_getsockopt()
2855 ret = -TARGET_ENOPROTOOPT; in do_getsockopt()
2896 return -TARGET_EFAULT; in do_getsockopt()
2898 return -TARGET_EINVAL; in do_getsockopt()
2907 return -TARGET_EFAULT; in do_getsockopt()
2913 return -TARGET_EFAULT; in do_getsockopt()
2917 ret = -TARGET_ENOPROTOOPT; in do_getsockopt()
2938 return -TARGET_EFAULT; in do_getsockopt()
2941 return -TARGET_EINVAL; in do_getsockopt()
2950 return -TARGET_EFAULT; in do_getsockopt()
2959 return -TARGET_EFAULT; in do_getsockopt()
2962 return -TARGET_EINVAL; in do_getsockopt()
2966 return -TARGET_EFAULT; in do_getsockopt()
2979 return -TARGET_EFAULT; in do_getsockopt()
2995 ret = -TARGET_EOPNOTSUPP; in do_getsockopt()
3082 if (len > max_len - total_len) { in lock_iovec()
3083 len = max_len - total_len; in lock_iovec()
3094 while (--i >= 0) { in lock_iovec()
3149 return -TARGET_EINVAL; in target_to_host_sock_type()
3156 return -TARGET_EINVAL; in target_to_host_sock_type()
3169 if (fcntl(fd, F_SETFL, O_NONBLOCK | flags) == -1) { in sock_flags_fixup()
3171 return -TARGET_EINVAL; in sock_flags_fixup()
3195 return -TARGET_EPROTONOSUPPORT; in do_socket()
3240 return -TARGET_EINVAL; in do_bind()
3260 return -TARGET_EINVAL; in do_connect()
3282 if (msgp->msg_name) { in do_sendrecvmsg_locked()
3283 msg.msg_namelen = tswap32(msgp->msg_namelen); in do_sendrecvmsg_locked()
3286 tswapal(msgp->msg_name), in do_sendrecvmsg_locked()
3288 if (ret == -TARGET_EFAULT) { in do_sendrecvmsg_locked()
3294 msg.msg_name = (void *)-1; in do_sendrecvmsg_locked()
3302 msg.msg_controllen = 2 * tswapal(msgp->msg_controllen); in do_sendrecvmsg_locked()
3306 msg.msg_flags = tswap32(msgp->msg_flags); in do_sendrecvmsg_locked()
3308 count = tswapal(msgp->msg_iovlen); in do_sendrecvmsg_locked()
3309 target_vec = tswapal(msgp->msg_iov); in do_sendrecvmsg_locked()
3315 ret = -TARGET_EMSGSIZE; in do_sendrecvmsg_locked()
3322 ret = -host_to_target_errno(errno); in do_sendrecvmsg_locked()
3335 host_msg = g_malloc(msg.msg_iov->iov_len); in do_sendrecvmsg_locked()
3336 memcpy(host_msg, msg.msg_iov->iov_base, msg.msg_iov->iov_len); in do_sendrecvmsg_locked()
3338 msg.msg_iov->iov_len); in do_sendrecvmsg_locked()
3340 msg.msg_iov->iov_base = host_msg; in do_sendrecvmsg_locked()
3355 ret = fd_trans_host_to_target_data(fd)(msg.msg_iov->iov_base, in do_sendrecvmsg_locked()
3356 MIN(msg.msg_iov->iov_len, len)); in do_sendrecvmsg_locked()
3362 msgp->msg_namelen = tswap32(msg.msg_namelen); in do_sendrecvmsg_locked()
3363 msgp->msg_flags = tswap32(msg.msg_flags); in do_sendrecvmsg_locked()
3364 if (msg.msg_name != NULL && msg.msg_name != (void *)-1) { in do_sendrecvmsg_locked()
3365 ret = host_to_target_sockaddr(tswapal(msgp->msg_name), in do_sendrecvmsg_locked()
3395 return -TARGET_EFAULT; in do_sendrecvmsg()
3403 * so it might not have this *mmsg-specific flag either.
3423 return -TARGET_EFAULT; in do_sendrecvmmsg()
3459 return -TARGET_EINVAL; in do_accept4()
3476 return -TARGET_EFAULT; in do_accept4()
3479 return -TARGET_EINVAL; in do_accept4()
3483 return -TARGET_EFAULT; in do_accept4()
3493 ret = -TARGET_EFAULT; in do_accept4()
3508 return -TARGET_EFAULT; in do_getpeername()
3511 return -TARGET_EINVAL; in do_getpeername()
3515 return -TARGET_EFAULT; in do_getpeername()
3525 ret = -TARGET_EFAULT; in do_getpeername()
3540 return -TARGET_EFAULT; in do_getsockname()
3543 return -TARGET_EINVAL; in do_getsockname()
3547 return -TARGET_EFAULT; in do_getsockname()
3557 ret = -TARGET_EFAULT; in do_getsockname()
3576 ret = -TARGET_EFAULT; in do_socketpair()
3591 return -TARGET_EINVAL; in do_sendto()
3596 return -TARGET_EFAULT; in do_sendto()
3640 return -TARGET_EFAULT; in do_recvfrom()
3645 ret = -TARGET_EFAULT; in do_recvfrom()
3649 ret = -TARGET_EINVAL; in do_recvfrom()
3674 ret = -TARGET_EFAULT; in do_recvfrom()
3718 return -TARGET_EINVAL; in do_socketcall()
3722 return -TARGET_EINVAL; in do_socketcall()
3727 return -TARGET_EFAULT; in do_socketcall()
3774 return -TARGET_EINVAL; in do_socketcall()
3780 /* asm-generic version of this struct */
3805 return -TARGET_EFAULT; in target_to_host_ipc_perm()
3806 target_ip = &(target_sd->sem_perm); in target_to_host_ipc_perm()
3807 host_ip->__key = tswap32(target_ip->__key); in target_to_host_ipc_perm()
3808 host_ip->uid = tswap32(target_ip->uid); in target_to_host_ipc_perm()
3809 host_ip->gid = tswap32(target_ip->gid); in target_to_host_ipc_perm()
3810 host_ip->cuid = tswap32(target_ip->cuid); in target_to_host_ipc_perm()
3811 host_ip->cgid = tswap32(target_ip->cgid); in target_to_host_ipc_perm()
3813 host_ip->mode = tswap32(target_ip->mode); in target_to_host_ipc_perm()
3815 host_ip->mode = tswap16(target_ip->mode); in target_to_host_ipc_perm()
3818 host_ip->__seq = tswap32(target_ip->__seq); in target_to_host_ipc_perm()
3820 host_ip->__seq = tswap16(target_ip->__seq); in target_to_host_ipc_perm()
3833 return -TARGET_EFAULT; in host_to_target_ipc_perm()
3834 target_ip = &(target_sd->sem_perm); in host_to_target_ipc_perm()
3835 target_ip->__key = tswap32(host_ip->__key); in host_to_target_ipc_perm()
3836 target_ip->uid = tswap32(host_ip->uid); in host_to_target_ipc_perm()
3837 target_ip->gid = tswap32(host_ip->gid); in host_to_target_ipc_perm()
3838 target_ip->cuid = tswap32(host_ip->cuid); in host_to_target_ipc_perm()
3839 target_ip->cgid = tswap32(host_ip->cgid); in host_to_target_ipc_perm()
3841 target_ip->mode = tswap32(host_ip->mode); in host_to_target_ipc_perm()
3843 target_ip->mode = tswap16(host_ip->mode); in host_to_target_ipc_perm()
3846 target_ip->__seq = tswap32(host_ip->__seq); in host_to_target_ipc_perm()
3848 target_ip->__seq = tswap16(host_ip->__seq); in host_to_target_ipc_perm()
3860 return -TARGET_EFAULT; in target_to_host_semid_ds()
3861 if (target_to_host_ipc_perm(&(host_sd->sem_perm),target_addr)) in target_to_host_semid_ds()
3862 return -TARGET_EFAULT; in target_to_host_semid_ds()
3863 host_sd->sem_nsems = tswapal(target_sd->sem_nsems); in target_to_host_semid_ds()
3864 host_sd->sem_otime = tswapal(target_sd->sem_otime); in target_to_host_semid_ds()
3865 host_sd->sem_ctime = tswapal(target_sd->sem_ctime); in target_to_host_semid_ds()
3876 return -TARGET_EFAULT; in host_to_target_semid_ds()
3877 if (host_to_target_ipc_perm(target_addr,&(host_sd->sem_perm))) in host_to_target_semid_ds()
3878 return -TARGET_EFAULT; in host_to_target_semid_ds()
3879 target_sd->sem_nsems = tswapal(host_sd->sem_nsems); in host_to_target_semid_ds()
3880 target_sd->sem_otime = tswapal(host_sd->sem_otime); in host_to_target_semid_ds()
3881 target_sd->sem_ctime = tswapal(host_sd->sem_ctime); in host_to_target_semid_ds()
3904 return -TARGET_EFAULT; in host_to_target_seminfo()
3905 __put_user(host_seminfo->semmap, &target_seminfo->semmap); in host_to_target_seminfo()
3906 __put_user(host_seminfo->semmni, &target_seminfo->semmni); in host_to_target_seminfo()
3907 __put_user(host_seminfo->semmns, &target_seminfo->semmns); in host_to_target_seminfo()
3908 __put_user(host_seminfo->semmnu, &target_seminfo->semmnu); in host_to_target_seminfo()
3909 __put_user(host_seminfo->semmsl, &target_seminfo->semmsl); in host_to_target_seminfo()
3910 __put_user(host_seminfo->semopm, &target_seminfo->semopm); in host_to_target_seminfo()
3911 __put_user(host_seminfo->semume, &target_seminfo->semume); in host_to_target_seminfo()
3912 __put_user(host_seminfo->semusz, &target_seminfo->semusz); in host_to_target_seminfo()
3913 __put_user(host_seminfo->semvmx, &target_seminfo->semvmx); in host_to_target_seminfo()
3914 __put_user(host_seminfo->semaem, &target_seminfo->semaem); in host_to_target_seminfo()
3945 if (ret == -1) in target_to_host_semarray()
3952 return -TARGET_ENOMEM; in target_to_host_semarray()
3958 return -TARGET_EFAULT; in target_to_host_semarray()
3981 if (ret == -1) in host_to_target_semarray()
3989 return -TARGET_EFAULT; in host_to_target_semarray()
4008 abi_long ret = -TARGET_EINVAL; in do_semctl()
4015 /* In 64 bit cross-endian situations, we will erroneously pick up in do_semctl()
4017 * this, the entire 8-byte structure is byteswapped, followed by in do_semctl()
4086 return -TARGET_EFAULT; in target_to_host_sembuf()
4127 return -TARGET_EFAULT; in do_semtimedop()
4131 return -TARGET_EFAULT; in do_semtimedop()
4137 return -TARGET_E2BIG; in do_semtimedop()
4144 return -TARGET_EFAULT; in do_semtimedop()
4147 ret = -TARGET_ENOSYS; in do_semtimedop()
4152 if (ret == -TARGET_ENOSYS) { in do_semtimedop()
4192 return -TARGET_EFAULT; in target_to_host_msqid_ds()
4193 if (target_to_host_ipc_perm(&(host_md->msg_perm),target_addr)) in target_to_host_msqid_ds()
4194 return -TARGET_EFAULT; in target_to_host_msqid_ds()
4195 host_md->msg_stime = tswapal(target_md->msg_stime); in target_to_host_msqid_ds()
4196 host_md->msg_rtime = tswapal(target_md->msg_rtime); in target_to_host_msqid_ds()
4197 host_md->msg_ctime = tswapal(target_md->msg_ctime); in target_to_host_msqid_ds()
4198 host_md->__msg_cbytes = tswapal(target_md->__msg_cbytes); in target_to_host_msqid_ds()
4199 host_md->msg_qnum = tswapal(target_md->msg_qnum); in target_to_host_msqid_ds()
4200 host_md->msg_qbytes = tswapal(target_md->msg_qbytes); in target_to_host_msqid_ds()
4201 host_md->msg_lspid = tswapal(target_md->msg_lspid); in target_to_host_msqid_ds()
4202 host_md->msg_lrpid = tswapal(target_md->msg_lrpid); in target_to_host_msqid_ds()
4213 return -TARGET_EFAULT; in host_to_target_msqid_ds()
4214 if (host_to_target_ipc_perm(target_addr,&(host_md->msg_perm))) in host_to_target_msqid_ds()
4215 return -TARGET_EFAULT; in host_to_target_msqid_ds()
4216 target_md->msg_stime = tswapal(host_md->msg_stime); in host_to_target_msqid_ds()
4217 target_md->msg_rtime = tswapal(host_md->msg_rtime); in host_to_target_msqid_ds()
4218 target_md->msg_ctime = tswapal(host_md->msg_ctime); in host_to_target_msqid_ds()
4219 target_md->__msg_cbytes = tswapal(host_md->__msg_cbytes); in host_to_target_msqid_ds()
4220 target_md->msg_qnum = tswapal(host_md->msg_qnum); in host_to_target_msqid_ds()
4221 target_md->msg_qbytes = tswapal(host_md->msg_qbytes); in host_to_target_msqid_ds()
4222 target_md->msg_lspid = tswapal(host_md->msg_lspid); in host_to_target_msqid_ds()
4223 target_md->msg_lrpid = tswapal(host_md->msg_lrpid); in host_to_target_msqid_ds()
4244 return -TARGET_EFAULT; in host_to_target_msginfo()
4245 __put_user(host_msginfo->msgpool, &target_msginfo->msgpool); in host_to_target_msginfo()
4246 __put_user(host_msginfo->msgmap, &target_msginfo->msgmap); in host_to_target_msginfo()
4247 __put_user(host_msginfo->msgmax, &target_msginfo->msgmax); in host_to_target_msginfo()
4248 __put_user(host_msginfo->msgmnb, &target_msginfo->msgmnb); in host_to_target_msginfo()
4249 __put_user(host_msginfo->msgmni, &target_msginfo->msgmni); in host_to_target_msginfo()
4250 __put_user(host_msginfo->msgssz, &target_msginfo->msgssz); in host_to_target_msginfo()
4251 __put_user(host_msginfo->msgtql, &target_msginfo->msgtql); in host_to_target_msginfo()
4252 __put_user(host_msginfo->msgseg, &target_msginfo->msgseg); in host_to_target_msginfo()
4261 abi_long ret = -TARGET_EINVAL; in do_msgctl()
4270 return -TARGET_EFAULT; in do_msgctl()
4273 return -TARGET_EFAULT; in do_msgctl()
4282 return -TARGET_EFAULT; in do_msgctl()
4302 return -TARGET_EINVAL; in do_msgsnd()
4306 return -TARGET_EFAULT; in do_msgsnd()
4310 return -TARGET_ENOMEM; in do_msgsnd()
4312 host_mb->mtype = (abi_long) tswapal(target_mb->mtype); in do_msgsnd()
4313 memcpy(host_mb->mtext, target_mb->mtext, msgsz); in do_msgsnd()
4314 ret = -TARGET_ENOSYS; in do_msgsnd()
4319 if (ret == -TARGET_ENOSYS) { in do_msgsnd()
4337 /* SPARC for msgrcv it does not use the kludge on final 2 arguments. */
4359 return -TARGET_EINVAL; in do_msgrcv()
4363 return -TARGET_EFAULT; in do_msgrcv()
4367 ret = -TARGET_ENOMEM; in do_msgrcv()
4370 ret = -TARGET_ENOSYS; in do_msgrcv()
4375 if (ret == -TARGET_ENOSYS) { in do_msgrcv()
4385 ret = -TARGET_EFAULT; in do_msgrcv()
4388 memcpy(target_mb->mtext, host_mb->mtext, ret); in do_msgrcv()
4392 target_mb->mtype = tswapal(host_mb->mtype); in do_msgrcv()
4407 return -TARGET_EFAULT; in target_to_host_shmid_ds()
4408 if (target_to_host_ipc_perm(&(host_sd->shm_perm), target_addr)) in target_to_host_shmid_ds()
4409 return -TARGET_EFAULT; in target_to_host_shmid_ds()
4410 __get_user(host_sd->shm_segsz, &target_sd->shm_segsz); in target_to_host_shmid_ds()
4411 __get_user(host_sd->shm_atime, &target_sd->shm_atime); in target_to_host_shmid_ds()
4412 __get_user(host_sd->shm_dtime, &target_sd->shm_dtime); in target_to_host_shmid_ds()
4413 __get_user(host_sd->shm_ctime, &target_sd->shm_ctime); in target_to_host_shmid_ds()
4414 __get_user(host_sd->shm_cpid, &target_sd->shm_cpid); in target_to_host_shmid_ds()
4415 __get_user(host_sd->shm_lpid, &target_sd->shm_lpid); in target_to_host_shmid_ds()
4416 __get_user(host_sd->shm_nattch, &target_sd->shm_nattch); in target_to_host_shmid_ds()
4427 return -TARGET_EFAULT; in host_to_target_shmid_ds()
4428 if (host_to_target_ipc_perm(target_addr, &(host_sd->shm_perm))) in host_to_target_shmid_ds()
4429 return -TARGET_EFAULT; in host_to_target_shmid_ds()
4430 __put_user(host_sd->shm_segsz, &target_sd->shm_segsz); in host_to_target_shmid_ds()
4431 __put_user(host_sd->shm_atime, &target_sd->shm_atime); in host_to_target_shmid_ds()
4432 __put_user(host_sd->shm_dtime, &target_sd->shm_dtime); in host_to_target_shmid_ds()
4433 __put_user(host_sd->shm_ctime, &target_sd->shm_ctime); in host_to_target_shmid_ds()
4434 __put_user(host_sd->shm_cpid, &target_sd->shm_cpid); in host_to_target_shmid_ds()
4435 __put_user(host_sd->shm_lpid, &target_sd->shm_lpid); in host_to_target_shmid_ds()
4436 __put_user(host_sd->shm_nattch, &target_sd->shm_nattch); in host_to_target_shmid_ds()
4454 return -TARGET_EFAULT; in host_to_target_shminfo()
4455 __put_user(host_shminfo->shmmax, &target_shminfo->shmmax); in host_to_target_shminfo()
4456 __put_user(host_shminfo->shmmin, &target_shminfo->shmmin); in host_to_target_shminfo()
4457 __put_user(host_shminfo->shmmni, &target_shminfo->shmmni); in host_to_target_shminfo()
4458 __put_user(host_shminfo->shmseg, &target_shminfo->shmseg); in host_to_target_shminfo()
4459 __put_user(host_shminfo->shmall, &target_shminfo->shmall); in host_to_target_shminfo()
4478 return -TARGET_EFAULT; in host_to_target_shm_info()
4479 __put_user(host_shm_info->used_ids, &target_shm_info->used_ids); in host_to_target_shm_info()
4480 __put_user(host_shm_info->shm_tot, &target_shm_info->shm_tot); in host_to_target_shm_info()
4481 __put_user(host_shm_info->shm_rss, &target_shm_info->shm_rss); in host_to_target_shm_info()
4482 __put_user(host_shm_info->shm_swp, &target_shm_info->shm_swp); in host_to_target_shm_info()
4483 __put_user(host_shm_info->swap_attempts, &target_shm_info->swap_attempts); in host_to_target_shm_info()
4484 __put_user(host_shm_info->swap_successes, &target_shm_info->swap_successes); in host_to_target_shm_info()
4494 abi_long ret = -TARGET_EINVAL; in do_shmctl()
4503 return -TARGET_EFAULT; in do_shmctl()
4506 return -TARGET_EFAULT; in do_shmctl()
4511 return -TARGET_EFAULT; in do_shmctl()
4516 return -TARGET_EFAULT; in do_shmctl()
4595 ret = -TARGET_EFAULT; in do_ipc()
4599 ret = do_msgrcv(first, tswapal(tmp->msgp), second, tswapal(tmp->msgtyp), third); in do_ipc()
4618 return -TARGET_EFAULT; in do_ipc()
4622 ret = -TARGET_EINVAL; in do_ipc()
4642 ret = -TARGET_ENOSYS; in do_ipc()
4673 #define FIEMAP_MAX_EXTENTS ((UINT_MAX - sizeof(struct fiemap)) \
4681 * in fiemap->fm_extent_count. The array is filled in by the in do_ioctl_fs_ioc_fiemap()
4686 const argtype *arg_type = ie->arg_type; in do_ioctl_fs_ioc_fiemap()
4695 assert(ie->access == IOC_RW); in do_ioctl_fs_ioc_fiemap()
4700 return -TARGET_EFAULT; in do_ioctl_fs_ioc_fiemap()
4705 if (fm->fm_extent_count > FIEMAP_MAX_EXTENTS) { in do_ioctl_fs_ioc_fiemap()
4706 return -TARGET_EINVAL; in do_ioctl_fs_ioc_fiemap()
4710 (sizeof(struct fiemap_extent) * fm->fm_extent_count); in do_ioctl_fs_ioc_fiemap()
4718 return -TARGET_ENOMEM; in do_ioctl_fs_ioc_fiemap()
4723 ret = get_errno(safe_ioctl(fd, ie->host_cmd, fm)); in do_ioctl_fs_ioc_fiemap()
4729 if (fm->fm_extent_count != 0) { in do_ioctl_fs_ioc_fiemap()
4730 target_size_out += fm->fm_mapped_extents * extent_size; in do_ioctl_fs_ioc_fiemap()
4734 ret = -TARGET_EFAULT; in do_ioctl_fs_ioc_fiemap()
4738 if (fm->fm_extent_count != 0) { in do_ioctl_fs_ioc_fiemap()
4741 for (i = 0; i < fm->fm_mapped_extents; i++) { in do_ioctl_fs_ioc_fiemap()
4742 thunk_convert(p, &fm->fm_extents[i], extent_arg_type, in do_ioctl_fs_ioc_fiemap()
4760 const argtype *arg_type = ie->arg_type; in do_ioctl_ifconf()
4778 assert(ie->access == IOC_RW); in do_ioctl_ifconf()
4785 return -TARGET_EFAULT; in do_ioctl_ifconf()
4790 target_ifc_buf = (abi_long)(unsigned long)host_ifconf->ifc_buf; in do_ioctl_ifconf()
4794 target_ifc_len = host_ifconf->ifc_len; in do_ioctl_ifconf()
4806 return -TARGET_ENOMEM; in do_ioctl_ifconf()
4813 host_ifconf->ifc_len = host_ifc_len; in do_ioctl_ifconf()
4817 host_ifconf->ifc_buf = host_ifc_buf; in do_ioctl_ifconf()
4819 ret = get_errno(safe_ioctl(fd, ie->host_cmd, host_ifconf)); in do_ioctl_ifconf()
4823 nb_ifreq = host_ifconf->ifc_len / sizeof(struct ifreq); in do_ioctl_ifconf()
4825 host_ifconf->ifc_len = target_ifc_len; in do_ioctl_ifconf()
4829 host_ifconf->ifc_buf = (char *)(unsigned long)target_ifc_buf; in do_ioctl_ifconf()
4835 return -TARGET_EFAULT; in do_ioctl_ifconf()
4913 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl_usbdevfs_reapurb()
4919 lurb = (void *)((uintptr_t)hurb - offsetof(struct live_urb, host_urb)); in do_ioctl_usbdevfs_reapurb()
4920 if (!lurb->target_urb_adr) { in do_ioctl_usbdevfs_reapurb()
4921 return -TARGET_EFAULT; in do_ioctl_usbdevfs_reapurb()
4924 unlock_user(lurb->target_buf_ptr, lurb->target_buf_adr, in do_ioctl_usbdevfs_reapurb()
4925 lurb->host_urb.buffer_length); in do_ioctl_usbdevfs_reapurb()
4926 lurb->target_buf_ptr = NULL; in do_ioctl_usbdevfs_reapurb()
4929 lurb->host_urb.buffer = (void *)(uintptr_t)lurb->target_buf_adr; in do_ioctl_usbdevfs_reapurb()
4932 argptr = lock_user(VERIFY_WRITE, lurb->target_urb_adr, target_size, 0); in do_ioctl_usbdevfs_reapurb()
4935 return -TARGET_EFAULT; in do_ioctl_usbdevfs_reapurb()
4937 thunk_convert(argptr, &lurb->host_urb, usbfsurb_arg_type, THUNK_TARGET); in do_ioctl_usbdevfs_reapurb()
4938 unlock_user(argptr, lurb->target_urb_adr, target_size); in do_ioctl_usbdevfs_reapurb()
4945 return -TARGET_EFAULT; in do_ioctl_usbdevfs_reapurb()
4948 /* GHashTable uses 64-bit keys but thunk_convert expects uintptr_t */ in do_ioctl_usbdevfs_reapurb()
4949 target_urb_adr = lurb->target_urb_adr; in do_ioctl_usbdevfs_reapurb()
4967 return -TARGET_EFAULT; in do_ioctl_usbdevfs_discardurb()
4969 return get_errno(safe_ioctl(fd, ie->host_cmd, &lurb->host_urb)); in do_ioctl_usbdevfs_discardurb()
4976 const argtype *arg_type = ie->arg_type; in do_ioctl_usbdevfs_submiturb()
4995 return -TARGET_ENOMEM; in do_ioctl_usbdevfs_submiturb()
5001 return -TARGET_EFAULT; in do_ioctl_usbdevfs_submiturb()
5003 thunk_convert(&lurb->host_urb, argptr, arg_type, THUNK_HOST); in do_ioctl_usbdevfs_submiturb()
5006 lurb->target_urb_adr = arg; in do_ioctl_usbdevfs_submiturb()
5007 lurb->target_buf_adr = (uintptr_t)lurb->host_urb.buffer; in do_ioctl_usbdevfs_submiturb()
5011 rw_dir = lurb->host_urb.endpoint & USB_DIR_IN ? VERIFY_WRITE : VERIFY_READ; in do_ioctl_usbdevfs_submiturb()
5012 lurb->target_buf_ptr = lock_user(rw_dir, lurb->target_buf_adr, in do_ioctl_usbdevfs_submiturb()
5013 lurb->host_urb.buffer_length, 1); in do_ioctl_usbdevfs_submiturb()
5014 if (lurb->target_buf_ptr == NULL) { in do_ioctl_usbdevfs_submiturb()
5016 return -TARGET_EFAULT; in do_ioctl_usbdevfs_submiturb()
5020 lurb->host_urb.buffer = lurb->target_buf_ptr; in do_ioctl_usbdevfs_submiturb()
5022 ret = get_errno(safe_ioctl(fd, ie->host_cmd, &lurb->host_urb)); in do_ioctl_usbdevfs_submiturb()
5024 unlock_user(lurb->target_buf_ptr, lurb->target_buf_adr, 0); in do_ioctl_usbdevfs_submiturb()
5042 const argtype *arg_type = ie->arg_type; in do_ioctl_dm()
5051 ret = -TARGET_EFAULT; in do_ioctl_dm()
5058 big_buf = g_malloc0(((struct dm_ioctl*)buf_temp)->data_size * 2); in do_ioctl_dm()
5063 guest_data = arg + host_dm->data_start; in do_ioctl_dm()
5064 if ((guest_data - arg) < 0) { in do_ioctl_dm()
5065 ret = -TARGET_EINVAL; in do_ioctl_dm()
5068 guest_data_size = host_dm->data_size - host_dm->data_start; in do_ioctl_dm()
5069 host_data = (char*)host_dm + host_dm->data_start; in do_ioctl_dm()
5073 ret = -TARGET_EFAULT; in do_ioctl_dm()
5077 switch (ie->host_cmd) { in do_ioctl_dm()
5108 for (i = 0; i < host_dm->target_count; i++) { in do_ioctl_dm()
5115 next = spec->next; in do_ioctl_dm()
5116 spec->next = sizeof(*spec) + slen; in do_ioctl_dm()
5119 cur_data += spec->next; in do_ioctl_dm()
5124 ret = -TARGET_EINVAL; in do_ioctl_dm()
5130 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl_dm()
5132 guest_data = arg + host_dm->data_start; in do_ioctl_dm()
5133 guest_data_size = host_dm->data_size - host_dm->data_start; in do_ioctl_dm()
5135 switch (ie->host_cmd) { in do_ioctl_dm()
5150 struct dm_name_list *nl = (void*)host_dm + host_dm->data_start; in do_ioctl_dm()
5157 uint32_t next = nl->next; in do_ioctl_dm()
5159 nl->next = nl_size + (strlen(nl->name) + 1); in do_ioctl_dm()
5161 if (remaining_data < nl->next) { in do_ioctl_dm()
5162 host_dm->flags |= DM_BUFFER_FULL_FLAG; in do_ioctl_dm()
5166 strcpy(cur_data + nl_size, nl->name); in do_ioctl_dm()
5167 cur_data += nl->next; in do_ioctl_dm()
5168 remaining_data -= nl->next; in do_ioctl_dm()
5179 struct dm_target_spec *spec = (void*)host_dm + host_dm->data_start; in do_ioctl_dm()
5185 for (i = 0; i < host_dm->target_count; i++) { in do_ioctl_dm()
5186 uint32_t next = spec->next; in do_ioctl_dm()
5188 spec->next = (cur_data - argptr) + spec_size + slen; in do_ioctl_dm()
5189 if (guest_data_size < spec->next) { in do_ioctl_dm()
5190 host_dm->flags |= DM_BUFFER_FULL_FLAG; in do_ioctl_dm()
5195 cur_data = argptr + spec->next; in do_ioctl_dm()
5196 spec = (void*)host_dm + host_dm->data_start + next; in do_ioctl_dm()
5202 void *hdata = (void*)host_dm + host_dm->data_start; in do_ioctl_dm()
5218 struct dm_target_versions *vers = (void*)host_dm + host_dm->data_start; in do_ioctl_dm()
5225 uint32_t next = vers->next; in do_ioctl_dm()
5227 vers->next = vers_size + (strlen(vers->name) + 1); in do_ioctl_dm()
5229 if (remaining_data < vers->next) { in do_ioctl_dm()
5230 host_dm->flags |= DM_BUFFER_FULL_FLAG; in do_ioctl_dm()
5234 strcpy(cur_data + vers_size, vers->name); in do_ioctl_dm()
5235 cur_data += vers->next; in do_ioctl_dm()
5236 remaining_data -= vers->next; in do_ioctl_dm()
5246 ret = -TARGET_EINVAL; in do_ioctl_dm()
5253 ret = -TARGET_EFAULT; in do_ioctl_dm()
5269 const argtype *arg_type = ie->arg_type; in do_ioctl_blkpg()
5281 ret = -TARGET_EFAULT; in do_ioctl_blkpg()
5287 switch (host_blkpg->op) { in do_ioctl_blkpg()
5294 ret = -TARGET_EINVAL; in do_ioctl_blkpg()
5298 /* Read and convert blkpg->data */ in do_ioctl_blkpg()
5299 arg = (abi_long)(uintptr_t)host_blkpg->data; in do_ioctl_blkpg()
5303 ret = -TARGET_EFAULT; in do_ioctl_blkpg()
5310 host_blkpg->data = &host_part; in do_ioctl_blkpg()
5311 ret = get_errno(safe_ioctl(fd, ie->host_cmd, host_blkpg)); in do_ioctl_blkpg()
5320 const argtype *arg_type = ie->arg_type; in do_ioctl_rt()
5331 assert(ie->access == IOC_W); in do_ioctl_rt()
5338 return -TARGET_EFAULT; in do_ioctl_rt()
5343 assert(se->convert[0] == NULL); in do_ioctl_rt()
5345 field_types = se->field_types; in do_ioctl_rt()
5346 dst_offsets = se->field_offsets[THUNK_HOST]; in do_ioctl_rt()
5347 src_offsets = se->field_offsets[THUNK_TARGET]; in do_ioctl_rt()
5348 for (i = 0; i < se->nb_fields; i++) { in do_ioctl_rt()
5358 return -TARGET_EFAULT; in do_ioctl_rt()
5372 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl_rt()
5387 return get_errno(safe_ioctl(fd, ie->host_cmd, sig)); in do_ioctl_kdsigaccept()
5403 return -TARGET_EFAULT; in do_ioctl_SIOCGSTAMP()
5407 return -TARGET_EFAULT; in do_ioctl_SIOCGSTAMP()
5427 return -TARGET_EFAULT; in do_ioctl_SIOCGSTAMPNS()
5431 return -TARGET_EFAULT; in do_ioctl_SIOCGSTAMPNS()
5443 return get_errno(safe_ioctl(fd, ie->host_cmd, flags)); in do_ioctl_tiocgptpeer()
5453 unlock_user(host_ver->name, target_ver->name, in unlock_drm_version()
5454 copy ? host_ver->name_len : 0); in unlock_drm_version()
5455 unlock_user(host_ver->date, target_ver->date, in unlock_drm_version()
5456 copy ? host_ver->date_len : 0); in unlock_drm_version()
5457 unlock_user(host_ver->desc, target_ver->desc, in unlock_drm_version()
5458 copy ? host_ver->desc_len : 0); in unlock_drm_version()
5466 __get_user(host_ver->name_len, &target_ver->name_len); in target_to_host_drmversion()
5467 if (host_ver->name_len) { in target_to_host_drmversion()
5468 host_ver->name = lock_user(VERIFY_WRITE, target_ver->name, in target_to_host_drmversion()
5469 target_ver->name_len, 0); in target_to_host_drmversion()
5470 if (!host_ver->name) { in target_to_host_drmversion()
5471 return -EFAULT; in target_to_host_drmversion()
5475 __get_user(host_ver->date_len, &target_ver->date_len); in target_to_host_drmversion()
5476 if (host_ver->date_len) { in target_to_host_drmversion()
5477 host_ver->date = lock_user(VERIFY_WRITE, target_ver->date, in target_to_host_drmversion()
5478 target_ver->date_len, 0); in target_to_host_drmversion()
5479 if (!host_ver->date) { in target_to_host_drmversion()
5484 __get_user(host_ver->desc_len, &target_ver->desc_len); in target_to_host_drmversion()
5485 if (host_ver->desc_len) { in target_to_host_drmversion()
5486 host_ver->desc = lock_user(VERIFY_WRITE, target_ver->desc, in target_to_host_drmversion()
5487 target_ver->desc_len, 0); in target_to_host_drmversion()
5488 if (!host_ver->desc) { in target_to_host_drmversion()
5496 return -EFAULT; in target_to_host_drmversion()
5503 __put_user(host_ver->version_major, &target_ver->version_major); in host_to_target_drmversion()
5504 __put_user(host_ver->version_minor, &target_ver->version_minor); in host_to_target_drmversion()
5505 __put_user(host_ver->version_patchlevel, &target_ver->version_patchlevel); in host_to_target_drmversion()
5506 __put_user(host_ver->name_len, &target_ver->name_len); in host_to_target_drmversion()
5507 __put_user(host_ver->date_len, &target_ver->date_len); in host_to_target_drmversion()
5508 __put_user(host_ver->desc_len, &target_ver->desc_len); in host_to_target_drmversion()
5519 switch (ie->host_cmd) { in do_ioctl_drm()
5522 return -TARGET_EFAULT; in do_ioctl_drm()
5527 ret = get_errno(safe_ioctl(fd, ie->host_cmd, ver)); in do_ioctl_drm()
5537 return -TARGET_ENOSYS; in do_ioctl_drm()
5549 return -TARGET_EFAULT; in do_ioctl_drm_i915_getparam()
5552 __get_user(gparam->param, &target_gparam->param); in do_ioctl_drm_i915_getparam()
5553 gparam->value = &value; in do_ioctl_drm_i915_getparam()
5554 ret = get_errno(safe_ioctl(fd, ie->host_cmd, gparam)); in do_ioctl_drm_i915_getparam()
5555 put_user_s32(value, target_gparam->value); in do_ioctl_drm_i915_getparam()
5564 switch (ie->host_cmd) { in do_ioctl_drm_i915()
5570 return -TARGET_ENOSYS; in do_ioctl_drm_i915()
5583 assert(ie->access == IOC_W); in do_ioctl_TUNSETTXFILTER()
5587 return -TARGET_EFAULT; in do_ioctl_TUNSETTXFILTER()
5589 filter->flags = tswap16(target_filter->flags); in do_ioctl_TUNSETTXFILTER()
5590 filter->count = tswap16(target_filter->count); in do_ioctl_TUNSETTXFILTER()
5593 if (filter->count) { in do_ioctl_TUNSETTXFILTER()
5594 if (offsetof(struct tun_filter, addr) + filter->count * ETH_ALEN > in do_ioctl_TUNSETTXFILTER()
5596 return -TARGET_EFAULT; in do_ioctl_TUNSETTXFILTER()
5601 filter->count * ETH_ALEN, 1); in do_ioctl_TUNSETTXFILTER()
5603 return -TARGET_EFAULT; in do_ioctl_TUNSETTXFILTER()
5605 memcpy(filter->addr, target_addr, filter->count * ETH_ALEN); in do_ioctl_TUNSETTXFILTER()
5609 return get_errno(safe_ioctl(fd, ie->host_cmd, filter)); in do_ioctl_TUNSETTXFILTER()
5636 if (ie->target_cmd == 0) { in do_ioctl()
5639 return -TARGET_ENOTTY; in do_ioctl()
5641 if (ie->target_cmd == cmd) in do_ioctl()
5645 arg_type = ie->arg_type; in do_ioctl()
5646 if (ie->do_ioctl) { in do_ioctl()
5647 return ie->do_ioctl(ie, buf_temp, fd, cmd, arg); in do_ioctl()
5648 } else if (!ie->host_cmd) { in do_ioctl()
5651 return -TARGET_ENOTTY; in do_ioctl()
5657 ret = get_errno(safe_ioctl(fd, ie->host_cmd)); in do_ioctl()
5663 ret = get_errno(safe_ioctl(fd, ie->host_cmd, arg)); in do_ioctl()
5668 switch(ie->access) { in do_ioctl()
5670 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl()
5674 return -TARGET_EFAULT; in do_ioctl()
5682 return -TARGET_EFAULT; in do_ioctl()
5685 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl()
5691 return -TARGET_EFAULT; in do_ioctl()
5694 ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp)); in do_ioctl()
5698 return -TARGET_EFAULT; in do_ioctl()
5709 ret = -TARGET_ENOTTY; in do_ioctl()
5818 host->c_iflag = in target_to_host_termios()
5819 target_to_host_bitmask(tswap32(target->c_iflag), iflag_tbl); in target_to_host_termios()
5820 host->c_oflag = in target_to_host_termios()
5821 target_to_host_bitmask(tswap32(target->c_oflag), oflag_tbl); in target_to_host_termios()
5822 host->c_cflag = in target_to_host_termios()
5823 target_to_host_bitmask(tswap32(target->c_cflag), cflag_tbl); in target_to_host_termios()
5824 host->c_lflag = in target_to_host_termios()
5825 target_to_host_bitmask(tswap32(target->c_lflag), lflag_tbl); in target_to_host_termios()
5826 host->c_line = target->c_line; in target_to_host_termios()
5828 memset(host->c_cc, 0, sizeof(host->c_cc)); in target_to_host_termios()
5829 host->c_cc[VINTR] = target->c_cc[TARGET_VINTR]; in target_to_host_termios()
5830 host->c_cc[VQUIT] = target->c_cc[TARGET_VQUIT]; in target_to_host_termios()
5831 host->c_cc[VERASE] = target->c_cc[TARGET_VERASE]; in target_to_host_termios()
5832 host->c_cc[VKILL] = target->c_cc[TARGET_VKILL]; in target_to_host_termios()
5833 host->c_cc[VEOF] = target->c_cc[TARGET_VEOF]; in target_to_host_termios()
5834 host->c_cc[VTIME] = target->c_cc[TARGET_VTIME]; in target_to_host_termios()
5835 host->c_cc[VMIN] = target->c_cc[TARGET_VMIN]; in target_to_host_termios()
5836 host->c_cc[VSWTC] = target->c_cc[TARGET_VSWTC]; in target_to_host_termios()
5837 host->c_cc[VSTART] = target->c_cc[TARGET_VSTART]; in target_to_host_termios()
5838 host->c_cc[VSTOP] = target->c_cc[TARGET_VSTOP]; in target_to_host_termios()
5839 host->c_cc[VSUSP] = target->c_cc[TARGET_VSUSP]; in target_to_host_termios()
5840 host->c_cc[VEOL] = target->c_cc[TARGET_VEOL]; in target_to_host_termios()
5841 host->c_cc[VREPRINT] = target->c_cc[TARGET_VREPRINT]; in target_to_host_termios()
5842 host->c_cc[VDISCARD] = target->c_cc[TARGET_VDISCARD]; in target_to_host_termios()
5843 host->c_cc[VWERASE] = target->c_cc[TARGET_VWERASE]; in target_to_host_termios()
5844 host->c_cc[VLNEXT] = target->c_cc[TARGET_VLNEXT]; in target_to_host_termios()
5845 host->c_cc[VEOL2] = target->c_cc[TARGET_VEOL2]; in target_to_host_termios()
5853 target->c_iflag = in host_to_target_termios()
5854 tswap32(host_to_target_bitmask(host->c_iflag, iflag_tbl)); in host_to_target_termios()
5855 target->c_oflag = in host_to_target_termios()
5856 tswap32(host_to_target_bitmask(host->c_oflag, oflag_tbl)); in host_to_target_termios()
5857 target->c_cflag = in host_to_target_termios()
5858 tswap32(host_to_target_bitmask(host->c_cflag, cflag_tbl)); in host_to_target_termios()
5859 target->c_lflag = in host_to_target_termios()
5860 tswap32(host_to_target_bitmask(host->c_lflag, lflag_tbl)); in host_to_target_termios()
5861 target->c_line = host->c_line; in host_to_target_termios()
5863 memset(target->c_cc, 0, sizeof(target->c_cc)); in host_to_target_termios()
5864 target->c_cc[TARGET_VINTR] = host->c_cc[VINTR]; in host_to_target_termios()
5865 target->c_cc[TARGET_VQUIT] = host->c_cc[VQUIT]; in host_to_target_termios()
5866 target->c_cc[TARGET_VERASE] = host->c_cc[VERASE]; in host_to_target_termios()
5867 target->c_cc[TARGET_VKILL] = host->c_cc[VKILL]; in host_to_target_termios()
5868 target->c_cc[TARGET_VEOF] = host->c_cc[VEOF]; in host_to_target_termios()
5869 target->c_cc[TARGET_VTIME] = host->c_cc[VTIME]; in host_to_target_termios()
5870 target->c_cc[TARGET_VMIN] = host->c_cc[VMIN]; in host_to_target_termios()
5871 target->c_cc[TARGET_VSWTC] = host->c_cc[VSWTC]; in host_to_target_termios()
5872 target->c_cc[TARGET_VSTART] = host->c_cc[VSTART]; in host_to_target_termios()
5873 target->c_cc[TARGET_VSTOP] = host->c_cc[VSTOP]; in host_to_target_termios()
5874 target->c_cc[TARGET_VSUSP] = host->c_cc[VSUSP]; in host_to_target_termios()
5875 target->c_cc[TARGET_VEOL] = host->c_cc[VEOL]; in host_to_target_termios()
5876 target->c_cc[TARGET_VREPRINT] = host->c_cc[VREPRINT]; in host_to_target_termios()
5877 target->c_cc[TARGET_VDISCARD] = host->c_cc[VDISCARD]; in host_to_target_termios()
5878 target->c_cc[TARGET_VWERASE] = host->c_cc[VWERASE]; in host_to_target_termios()
5879 target->c_cc[TARGET_VLNEXT] = host->c_cc[VLNEXT]; in host_to_target_termios()
5880 target->c_cc[TARGET_VEOL2] = host->c_cc[VEOL2]; in host_to_target_termios()
5978 return -TARGET_EOPNOTSUPP; in do_mmap()
5986 return -TARGET_EINVAL; in do_mmap()
6014 return -TARGET_EFAULT; in read_ldt()
6032 return -TARGET_EINVAL; in write_ldt()
6034 return -TARGET_EFAULT; in write_ldt()
6035 ldt_info.entry_number = tswap32(target_ldt_info->entry_number); in write_ldt()
6036 ldt_info.base_addr = tswapal(target_ldt_info->base_addr); in write_ldt()
6037 ldt_info.limit = tswap32(target_ldt_info->limit); in write_ldt()
6038 ldt_info.flags = tswap32(target_ldt_info->flags); in write_ldt()
6042 return -TARGET_EINVAL; in write_ldt()
6056 return -TARGET_EINVAL; in write_ldt()
6058 return -TARGET_EINVAL; in write_ldt()
6062 env->ldt.base = target_mmap(0, in write_ldt()
6065 MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); in write_ldt()
6066 if (env->ldt.base == -1) in write_ldt()
6067 return -TARGET_ENOMEM; in write_ldt()
6068 memset(g2h_untagged(env->ldt.base), 0, in write_ldt()
6070 env->ldt.limit = 0xffff; in write_ldt()
6071 ldt_table = g2h_untagged(env->ldt.base); in write_ldt()
6130 ret = -TARGET_ENOSYS; in do_modify_ldt()
6139 uint64_t *gdt_table = g2h_untagged(env->gdt.base); in do_set_thread_area()
6149 return -TARGET_EFAULT; in do_set_thread_area()
6150 ldt_info.entry_number = tswap32(target_ldt_info->entry_number); in do_set_thread_area()
6151 ldt_info.base_addr = tswapal(target_ldt_info->base_addr); in do_set_thread_area()
6152 ldt_info.limit = tswap32(target_ldt_info->limit); in do_set_thread_area()
6153 ldt_info.flags = tswap32(target_ldt_info->flags); in do_set_thread_area()
6154 if (ldt_info.entry_number == -1) { in do_set_thread_area()
6158 target_ldt_info->entry_number = tswap32(i); in do_set_thread_area()
6167 return -TARGET_EINVAL; in do_set_thread_area()
6182 return -TARGET_EINVAL; in do_set_thread_area()
6225 uint64_t *gdt_table = g2h_untagged(env->gdt.base); in do_get_thread_area()
6233 return -TARGET_EFAULT; in do_get_thread_area()
6234 idx = tswap32(target_ldt_info->entry_number); in do_get_thread_area()
6238 return -TARGET_EINVAL; in do_get_thread_area()
6262 target_ldt_info->base_addr = tswapal(base_addr); in do_get_thread_area()
6263 target_ldt_info->limit = tswap32(limit); in do_get_thread_area()
6264 target_ldt_info->flags = tswap32(flags); in do_get_thread_area()
6271 return -TARGET_ENOSYS; in do_arch_prctl()
6288 env->segs[idx].base = addr; in do_arch_prctl()
6296 val = env->segs[idx].base; in do_arch_prctl()
6298 ret = -TARGET_EFAULT; in do_arch_prctl()
6301 ret = -TARGET_EINVAL; in do_arch_prctl()
6359 return -TARGET_EINVAL; in do_prctl_inval0()
6364 return -TARGET_EINVAL; in do_prctl_inval1()
6414 return -TARGET_EFAULT; in do_prctl()
6425 return -TARGET_EFAULT; in do_prctl()
6436 return -TARGET_EFAULT; in do_prctl()
6457 return -TARGET_EINVAL; in do_prctl()
6462 return -TARGET_EINVAL; in do_prctl()
6467 return -TARGET_EINVAL; in do_prctl()
6507 return -TARGET_EFAULT; in do_prctl()
6515 return put_user_ual(ts->child_tidptr, arg2); in do_prctl()
6521 return -TARGET_EINVAL; in do_prctl()
6536 return -TARGET_EINVAL; in do_prctl()
6541 return -TARGET_EINVAL; in do_prctl()
6569 env = info->env; in clone_func()
6573 info->tid = sys_gettid(); in clone_func()
6575 if (info->child_tidptr) in clone_func()
6576 put_user_u32(info->tid, info->child_tidptr); in clone_func()
6577 if (info->parent_tidptr) in clone_func()
6578 put_user_u32(info->tid, info->parent_tidptr); in clone_func()
6579 qemu_guest_random_seed_thread_part2(cpu->random_seed); in clone_func()
6581 sigprocmask(SIG_SETMASK, &info->sigmask, NULL); in clone_func()
6583 pthread_mutex_lock(&info->mutex); in clone_func()
6584 pthread_cond_broadcast(&info->cond); in clone_func()
6585 pthread_mutex_unlock(&info->mutex); in clone_func()
6620 return -TARGET_EINVAL; in do_fork()
6645 new_cpu->opaque = ts; in do_fork()
6646 ts->bprm = parent_ts->bprm; in do_fork()
6647 ts->info = parent_ts->info; in do_fork()
6648 ts->signal_mask = parent_ts->signal_mask; in do_fork()
6651 ts->child_tidptr = child_tidptr; in do_fork()
6677 cpu->random_seed = qemu_guest_random_seed_thread_part1(); in do_fork()
6689 ret = -1; in do_fork()
6698 return -TARGET_EINVAL; in do_fork()
6703 return -TARGET_EINVAL; in do_fork()
6708 return -TARGET_EINVAL; in do_fork()
6714 return -TARGET_EINVAL; in do_fork()
6718 return -QEMU_ERESTARTSYS; in do_fork()
6741 ts->child_tidptr = child_tidptr; in do_fork()
6853 ret = -TARGET_EINVAL; in target_to_host_fcntl_cmd()
6864 ret -= F_GETLK - 5; in target_to_host_fcntl_cmd()
6883 return -TARGET_EINVAL; in target_to_host_flock()
6892 * from the host we copy to the target field as-is in host_to_target_flock()
6904 return -TARGET_EFAULT; in copy_from_user_flock()
6907 __get_user(l_type, &target_fl->l_type); in copy_from_user_flock()
6912 fl->l_type = l_type; in copy_from_user_flock()
6913 __get_user(fl->l_whence, &target_fl->l_whence); in copy_from_user_flock()
6914 __get_user(fl->l_start, &target_fl->l_start); in copy_from_user_flock()
6915 __get_user(fl->l_len, &target_fl->l_len); in copy_from_user_flock()
6916 __get_user(fl->l_pid, &target_fl->l_pid); in copy_from_user_flock()
6928 return -TARGET_EFAULT; in copy_to_user_flock()
6931 l_type = host_to_target_flock(fl->l_type); in copy_to_user_flock()
6932 __put_user(l_type, &target_fl->l_type); in copy_to_user_flock()
6933 __put_user(fl->l_whence, &target_fl->l_whence); in copy_to_user_flock()
6934 __put_user(fl->l_start, &target_fl->l_start); in copy_to_user_flock()
6935 __put_user(fl->l_len, &target_fl->l_len); in copy_to_user_flock()
6936 __put_user(fl->l_pid, &target_fl->l_pid); in copy_to_user_flock()
6960 return -TARGET_EFAULT; in copy_from_user_oabi_flock64()
6963 __get_user(l_type, &target_fl->l_type); in copy_from_user_oabi_flock64()
6968 fl->l_type = l_type; in copy_from_user_oabi_flock64()
6969 __get_user(fl->l_whence, &target_fl->l_whence); in copy_from_user_oabi_flock64()
6970 __get_user(fl->l_start, &target_fl->l_start); in copy_from_user_oabi_flock64()
6971 __get_user(fl->l_len, &target_fl->l_len); in copy_from_user_oabi_flock64()
6972 __get_user(fl->l_pid, &target_fl->l_pid); in copy_from_user_oabi_flock64()
6984 return -TARGET_EFAULT; in copy_to_user_oabi_flock64()
6987 l_type = host_to_target_flock(fl->l_type); in copy_to_user_oabi_flock64()
6988 __put_user(l_type, &target_fl->l_type); in copy_to_user_oabi_flock64()
6989 __put_user(fl->l_whence, &target_fl->l_whence); in copy_to_user_oabi_flock64()
6990 __put_user(fl->l_start, &target_fl->l_start); in copy_to_user_oabi_flock64()
6991 __put_user(fl->l_len, &target_fl->l_len); in copy_to_user_oabi_flock64()
6992 __put_user(fl->l_pid, &target_fl->l_pid); in copy_to_user_oabi_flock64()
7005 return -TARGET_EFAULT; in copy_from_user_flock64()
7008 __get_user(l_type, &target_fl->l_type); in copy_from_user_flock64()
7013 fl->l_type = l_type; in copy_from_user_flock64()
7014 __get_user(fl->l_whence, &target_fl->l_whence); in copy_from_user_flock64()
7015 __get_user(fl->l_start, &target_fl->l_start); in copy_from_user_flock64()
7016 __get_user(fl->l_len, &target_fl->l_len); in copy_from_user_flock64()
7017 __get_user(fl->l_pid, &target_fl->l_pid); in copy_from_user_flock64()
7029 return -TARGET_EFAULT; in copy_to_user_flock64()
7032 l_type = host_to_target_flock(fl->l_type); in copy_to_user_flock64()
7033 __put_user(l_type, &target_fl->l_type); in copy_to_user_flock64()
7034 __put_user(fl->l_whence, &target_fl->l_whence); in copy_to_user_flock64()
7035 __put_user(fl->l_start, &target_fl->l_start); in copy_to_user_flock64()
7036 __put_user(fl->l_len, &target_fl->l_len); in copy_to_user_flock64()
7037 __put_user(fl->l_pid, &target_fl->l_pid); in copy_to_user_flock64()
7052 if (host_cmd == -TARGET_EINVAL) in do_fcntl()
7102 /* tell 32-bit guests it uses largefile on 64-bit hosts: */ in do_fcntl()
7120 return -TARGET_EFAULT; in do_fcntl()
7121 target_fox->type = tswap32(fox.type); in do_fcntl()
7122 target_fox->pid = tswap32(fox.pid); in do_fcntl()
7131 return -TARGET_EFAULT; in do_fcntl()
7132 fox.type = tswap32(target_fox->type); in do_fcntl()
7133 fox.pid = tswap32(target_fox->pid); in do_fcntl()
7185 if ((int16_t)uid == -1) in low2highuid()
7186 return -1; in low2highuid()
7193 if ((int16_t)gid == -1) in low2highgid()
7194 return -1; in low2highgid()
7235 * We use the 32-bit version of the syscalls if present; if it is not
7236 * then either the host architecture supports 32-bit UIDs natively with
7237 * the standard syscall, or the 16-bit UID is the best we can do.
7300 while (ie->target_cmd != 0) { in syscall_init()
7301 if (((ie->target_cmd >> TARGET_IOC_SIZESHIFT) & TARGET_IOC_SIZEMASK) == in syscall_init()
7303 arg_type = ie->arg_type; in syscall_init()
7306 ie->target_cmd); in syscall_init()
7311 ie->target_cmd = (ie->target_cmd & in syscall_init()
7319 if (unlikely(ie->target_cmd != ie->host_cmd)) { in syscall_init()
7321 ie->name, ie->target_cmd, ie->host_cmd); in syscall_init()
7361 if (target_to_host_timespec(&host_its->it_interval, target_addr + in target_to_host_itimerspec()
7364 target_to_host_timespec(&host_its->it_value, target_addr + in target_to_host_itimerspec()
7367 return -TARGET_EFAULT; in target_to_host_itimerspec()
7379 if (target_to_host_timespec64(&host_its->it_interval, target_addr + in target_to_host_itimerspec64()
7382 target_to_host_timespec64(&host_its->it_value, target_addr + in target_to_host_itimerspec64()
7385 return -TARGET_EFAULT; in target_to_host_itimerspec64()
7400 &host_its->it_interval) || in host_to_target_itimerspec()
7403 &host_its->it_value)) { in host_to_target_itimerspec()
7404 return -TARGET_EFAULT; in host_to_target_itimerspec()
7419 &host_its->it_interval) || in host_to_target_itimerspec64()
7423 &host_its->it_value)) { in host_to_target_itimerspec64()
7424 return -TARGET_EFAULT; in host_to_target_itimerspec64()
7438 return -TARGET_EFAULT; in target_to_host_timex()
7441 __get_user(host_tx->modes, &target_tx->modes); in target_to_host_timex()
7442 __get_user(host_tx->offset, &target_tx->offset); in target_to_host_timex()
7443 __get_user(host_tx->freq, &target_tx->freq); in target_to_host_timex()
7444 __get_user(host_tx->maxerror, &target_tx->maxerror); in target_to_host_timex()
7445 __get_user(host_tx->esterror, &target_tx->esterror); in target_to_host_timex()
7446 __get_user(host_tx->status, &target_tx->status); in target_to_host_timex()
7447 __get_user(host_tx->constant, &target_tx->constant); in target_to_host_timex()
7448 __get_user(host_tx->precision, &target_tx->precision); in target_to_host_timex()
7449 __get_user(host_tx->tolerance, &target_tx->tolerance); in target_to_host_timex()
7450 __get_user(host_tx->time.tv_sec, &target_tx->time.tv_sec); in target_to_host_timex()
7451 __get_user(host_tx->time.tv_usec, &target_tx->time.tv_usec); in target_to_host_timex()
7452 __get_user(host_tx->tick, &target_tx->tick); in target_to_host_timex()
7453 __get_user(host_tx->ppsfreq, &target_tx->ppsfreq); in target_to_host_timex()
7454 __get_user(host_tx->jitter, &target_tx->jitter); in target_to_host_timex()
7455 __get_user(host_tx->shift, &target_tx->shift); in target_to_host_timex()
7456 __get_user(host_tx->stabil, &target_tx->stabil); in target_to_host_timex()
7457 __get_user(host_tx->jitcnt, &target_tx->jitcnt); in target_to_host_timex()
7458 __get_user(host_tx->calcnt, &target_tx->calcnt); in target_to_host_timex()
7459 __get_user(host_tx->errcnt, &target_tx->errcnt); in target_to_host_timex()
7460 __get_user(host_tx->stbcnt, &target_tx->stbcnt); in target_to_host_timex()
7461 __get_user(host_tx->tai, &target_tx->tai); in target_to_host_timex()
7473 return -TARGET_EFAULT; in host_to_target_timex()
7476 __put_user(host_tx->modes, &target_tx->modes); in host_to_target_timex()
7477 __put_user(host_tx->offset, &target_tx->offset); in host_to_target_timex()
7478 __put_user(host_tx->freq, &target_tx->freq); in host_to_target_timex()
7479 __put_user(host_tx->maxerror, &target_tx->maxerror); in host_to_target_timex()
7480 __put_user(host_tx->esterror, &target_tx->esterror); in host_to_target_timex()
7481 __put_user(host_tx->status, &target_tx->status); in host_to_target_timex()
7482 __put_user(host_tx->constant, &target_tx->constant); in host_to_target_timex()
7483 __put_user(host_tx->precision, &target_tx->precision); in host_to_target_timex()
7484 __put_user(host_tx->tolerance, &target_tx->tolerance); in host_to_target_timex()
7485 __put_user(host_tx->time.tv_sec, &target_tx->time.tv_sec); in host_to_target_timex()
7486 __put_user(host_tx->time.tv_usec, &target_tx->time.tv_usec); in host_to_target_timex()
7487 __put_user(host_tx->tick, &target_tx->tick); in host_to_target_timex()
7488 __put_user(host_tx->ppsfreq, &target_tx->ppsfreq); in host_to_target_timex()
7489 __put_user(host_tx->jitter, &target_tx->jitter); in host_to_target_timex()
7490 __put_user(host_tx->shift, &target_tx->shift); in host_to_target_timex()
7491 __put_user(host_tx->stabil, &target_tx->stabil); in host_to_target_timex()
7492 __put_user(host_tx->jitcnt, &target_tx->jitcnt); in host_to_target_timex()
7493 __put_user(host_tx->calcnt, &target_tx->calcnt); in host_to_target_timex()
7494 __put_user(host_tx->errcnt, &target_tx->errcnt); in host_to_target_timex()
7495 __put_user(host_tx->stbcnt, &target_tx->stbcnt); in host_to_target_timex()
7496 __put_user(host_tx->tai, &target_tx->tai); in host_to_target_timex()
7510 if (copy_from_user_timeval64(&host_tx->time, target_addr + in target_to_host_timex64()
7513 return -TARGET_EFAULT; in target_to_host_timex64()
7517 return -TARGET_EFAULT; in target_to_host_timex64()
7520 __get_user(host_tx->modes, &target_tx->modes); in target_to_host_timex64()
7521 __get_user(host_tx->offset, &target_tx->offset); in target_to_host_timex64()
7522 __get_user(host_tx->freq, &target_tx->freq); in target_to_host_timex64()
7523 __get_user(host_tx->maxerror, &target_tx->maxerror); in target_to_host_timex64()
7524 __get_user(host_tx->esterror, &target_tx->esterror); in target_to_host_timex64()
7525 __get_user(host_tx->status, &target_tx->status); in target_to_host_timex64()
7526 __get_user(host_tx->constant, &target_tx->constant); in target_to_host_timex64()
7527 __get_user(host_tx->precision, &target_tx->precision); in target_to_host_timex64()
7528 __get_user(host_tx->tolerance, &target_tx->tolerance); in target_to_host_timex64()
7529 __get_user(host_tx->tick, &target_tx->tick); in target_to_host_timex64()
7530 __get_user(host_tx->ppsfreq, &target_tx->ppsfreq); in target_to_host_timex64()
7531 __get_user(host_tx->jitter, &target_tx->jitter); in target_to_host_timex64()
7532 __get_user(host_tx->shift, &target_tx->shift); in target_to_host_timex64()
7533 __get_user(host_tx->stabil, &target_tx->stabil); in target_to_host_timex64()
7534 __get_user(host_tx->jitcnt, &target_tx->jitcnt); in target_to_host_timex64()
7535 __get_user(host_tx->calcnt, &target_tx->calcnt); in target_to_host_timex64()
7536 __get_user(host_tx->errcnt, &target_tx->errcnt); in target_to_host_timex64()
7537 __get_user(host_tx->stbcnt, &target_tx->stbcnt); in target_to_host_timex64()
7538 __get_user(host_tx->tai, &target_tx->tai); in target_to_host_timex64()
7551 &host_tx->time)) { in host_to_target_timex64()
7552 return -TARGET_EFAULT; in host_to_target_timex64()
7556 return -TARGET_EFAULT; in host_to_target_timex64()
7559 __put_user(host_tx->modes, &target_tx->modes); in host_to_target_timex64()
7560 __put_user(host_tx->offset, &target_tx->offset); in host_to_target_timex64()
7561 __put_user(host_tx->freq, &target_tx->freq); in host_to_target_timex64()
7562 __put_user(host_tx->maxerror, &target_tx->maxerror); in host_to_target_timex64()
7563 __put_user(host_tx->esterror, &target_tx->esterror); in host_to_target_timex64()
7564 __put_user(host_tx->status, &target_tx->status); in host_to_target_timex64()
7565 __put_user(host_tx->constant, &target_tx->constant); in host_to_target_timex64()
7566 __put_user(host_tx->precision, &target_tx->precision); in host_to_target_timex64()
7567 __put_user(host_tx->tolerance, &target_tx->tolerance); in host_to_target_timex64()
7568 __put_user(host_tx->tick, &target_tx->tick); in host_to_target_timex64()
7569 __put_user(host_tx->ppsfreq, &target_tx->ppsfreq); in host_to_target_timex64()
7570 __put_user(host_tx->jitter, &target_tx->jitter); in host_to_target_timex64()
7571 __put_user(host_tx->shift, &target_tx->shift); in host_to_target_timex64()
7572 __put_user(host_tx->stabil, &target_tx->stabil); in host_to_target_timex64()
7573 __put_user(host_tx->jitcnt, &target_tx->jitcnt); in host_to_target_timex64()
7574 __put_user(host_tx->calcnt, &target_tx->calcnt); in host_to_target_timex64()
7575 __put_user(host_tx->errcnt, &target_tx->errcnt); in host_to_target_timex64()
7576 __put_user(host_tx->stbcnt, &target_tx->stbcnt); in host_to_target_timex64()
7577 __put_user(host_tx->tai, &target_tx->tai); in host_to_target_timex64()
7594 return -TARGET_EFAULT; in target_to_host_sigevent()
7603 host_sevp->sigev_value.sival_ptr = in target_to_host_sigevent()
7604 (void *)(uintptr_t)tswapal(target_sevp->sigev_value.sival_ptr); in target_to_host_sigevent()
7605 host_sevp->sigev_signo = in target_to_host_sigevent()
7606 target_to_host_signal(tswap32(target_sevp->sigev_signo)); in target_to_host_sigevent()
7607 host_sevp->sigev_notify = tswap32(target_sevp->sigev_notify); in target_to_host_sigevent()
7608 host_sevp->sigev_notify_thread_id = tswap32(target_sevp->_sigev_un._tid); in target_to_host_sigevent()
7651 if (cpu_env->eabi) { in host_to_target_stat64()
7655 return -TARGET_EFAULT; in host_to_target_stat64()
7657 __put_user(host_st->st_dev, &target_st->st_dev); in host_to_target_stat64()
7658 __put_user(host_st->st_ino, &target_st->st_ino); in host_to_target_stat64()
7660 __put_user(host_st->st_ino, &target_st->__st_ino); in host_to_target_stat64()
7662 __put_user(host_st->st_mode, &target_st->st_mode); in host_to_target_stat64()
7663 __put_user(host_st->st_nlink, &target_st->st_nlink); in host_to_target_stat64()
7664 __put_user(host_st->st_uid, &target_st->st_uid); in host_to_target_stat64()
7665 __put_user(host_st->st_gid, &target_st->st_gid); in host_to_target_stat64()
7666 __put_user(host_st->st_rdev, &target_st->st_rdev); in host_to_target_stat64()
7667 __put_user(host_st->st_size, &target_st->st_size); in host_to_target_stat64()
7668 __put_user(host_st->st_blksize, &target_st->st_blksize); in host_to_target_stat64()
7669 __put_user(host_st->st_blocks, &target_st->st_blocks); in host_to_target_stat64()
7670 __put_user(host_st->st_atime, &target_st->target_st_atime); in host_to_target_stat64()
7671 __put_user(host_st->st_mtime, &target_st->target_st_mtime); in host_to_target_stat64()
7672 __put_user(host_st->st_ctime, &target_st->target_st_ctime); in host_to_target_stat64()
7674 __put_user(host_st->st_atim.tv_nsec, &target_st->target_st_atime_nsec); in host_to_target_stat64()
7675 __put_user(host_st->st_mtim.tv_nsec, &target_st->target_st_mtime_nsec); in host_to_target_stat64()
7676 __put_user(host_st->st_ctim.tv_nsec, &target_st->target_st_ctime_nsec); in host_to_target_stat64()
7689 return -TARGET_EFAULT; in host_to_target_stat64()
7691 __put_user(host_st->st_dev, &target_st->st_dev); in host_to_target_stat64()
7692 __put_user(host_st->st_ino, &target_st->st_ino); in host_to_target_stat64()
7694 __put_user(host_st->st_ino, &target_st->__st_ino); in host_to_target_stat64()
7696 __put_user(host_st->st_mode, &target_st->st_mode); in host_to_target_stat64()
7697 __put_user(host_st->st_nlink, &target_st->st_nlink); in host_to_target_stat64()
7698 __put_user(host_st->st_uid, &target_st->st_uid); in host_to_target_stat64()
7699 __put_user(host_st->st_gid, &target_st->st_gid); in host_to_target_stat64()
7700 __put_user(host_st->st_rdev, &target_st->st_rdev); in host_to_target_stat64()
7702 __put_user(host_st->st_size, &target_st->st_size); in host_to_target_stat64()
7703 __put_user(host_st->st_blksize, &target_st->st_blksize); in host_to_target_stat64()
7704 __put_user(host_st->st_blocks, &target_st->st_blocks); in host_to_target_stat64()
7705 __put_user(host_st->st_atime, &target_st->target_st_atime); in host_to_target_stat64()
7706 __put_user(host_st->st_mtime, &target_st->target_st_mtime); in host_to_target_stat64()
7707 __put_user(host_st->st_ctime, &target_st->target_st_ctime); in host_to_target_stat64()
7709 __put_user(host_st->st_atim.tv_nsec, &target_st->target_st_atime_nsec); in host_to_target_stat64()
7710 __put_user(host_st->st_mtim.tv_nsec, &target_st->target_st_mtime_nsec); in host_to_target_stat64()
7711 __put_user(host_st->st_ctim.tv_nsec, &target_st->target_st_ctime_nsec); in host_to_target_stat64()
7727 return -TARGET_EFAULT; in host_to_target_statx()
7731 __put_user(host_stx->stx_mask, &target_stx->stx_mask); in host_to_target_statx()
7732 __put_user(host_stx->stx_blksize, &target_stx->stx_blksize); in host_to_target_statx()
7733 __put_user(host_stx->stx_attributes, &target_stx->stx_attributes); in host_to_target_statx()
7734 __put_user(host_stx->stx_nlink, &target_stx->stx_nlink); in host_to_target_statx()
7735 __put_user(host_stx->stx_uid, &target_stx->stx_uid); in host_to_target_statx()
7736 __put_user(host_stx->stx_gid, &target_stx->stx_gid); in host_to_target_statx()
7737 __put_user(host_stx->stx_mode, &target_stx->stx_mode); in host_to_target_statx()
7738 __put_user(host_stx->stx_ino, &target_stx->stx_ino); in host_to_target_statx()
7739 __put_user(host_stx->stx_size, &target_stx->stx_size); in host_to_target_statx()
7740 __put_user(host_stx->stx_blocks, &target_stx->stx_blocks); in host_to_target_statx()
7741 __put_user(host_stx->stx_attributes_mask, &target_stx->stx_attributes_mask); in host_to_target_statx()
7742 __put_user(host_stx->stx_atime.tv_sec, &target_stx->stx_atime.tv_sec); in host_to_target_statx()
7743 __put_user(host_stx->stx_atime.tv_nsec, &target_stx->stx_atime.tv_nsec); in host_to_target_statx()
7744 __put_user(host_stx->stx_btime.tv_sec, &target_stx->stx_btime.tv_sec); in host_to_target_statx()
7745 __put_user(host_stx->stx_btime.tv_nsec, &target_stx->stx_btime.tv_nsec); in host_to_target_statx()
7746 __put_user(host_stx->stx_ctime.tv_sec, &target_stx->stx_ctime.tv_sec); in host_to_target_statx()
7747 __put_user(host_stx->stx_ctime.tv_nsec, &target_stx->stx_ctime.tv_nsec); in host_to_target_statx()
7748 __put_user(host_stx->stx_mtime.tv_sec, &target_stx->stx_mtime.tv_sec); in host_to_target_statx()
7749 __put_user(host_stx->stx_mtime.tv_nsec, &target_stx->stx_mtime.tv_nsec); in host_to_target_statx()
7750 __put_user(host_stx->stx_rdev_major, &target_stx->stx_rdev_major); in host_to_target_statx()
7751 __put_user(host_stx->stx_rdev_minor, &target_stx->stx_rdev_minor); in host_to_target_statx()
7752 __put_user(host_stx->stx_dev_major, &target_stx->stx_dev_major); in host_to_target_statx()
7753 __put_user(host_stx->stx_dev_minor, &target_stx->stx_dev_minor); in host_to_target_statx()
7767 /* always a 64-bit time_t, it doesn't define _time64 version */ in do_sys_futex()
7773 if (sizeof(timeout->tv_sec) == 8) { in do_sys_futex()
7792 /* always a 64-bit time_t, it doesn't define _time64 version */ in do_safe_futex()
7797 if (sizeof(timeout->tv_sec) == 8) { in do_safe_futex()
7808 return -TARGET_ENOSYS; in do_safe_futex()
7870 return -TARGET_ENOSYS; in do_futex()
7877 return -TARGET_EFAULT; in do_futex()
7897 return -TARGET_EFAULT; in do_name_to_handle_at()
7902 return -TARGET_EFAULT; in do_name_to_handle_at()
7909 return -TARGET_EFAULT; in do_name_to_handle_at()
7913 fh->handle_bytes = size; in do_name_to_handle_at()
7924 target_fh->handle_bytes = tswap32(fh->handle_bytes); in do_name_to_handle_at()
7925 target_fh->handle_type = tswap32(fh->handle_type); in do_name_to_handle_at()
7930 return -TARGET_EFAULT; in do_name_to_handle_at()
7948 return -TARGET_EFAULT; in do_open_by_handle_at()
7954 return -TARGET_EFAULT; in do_open_by_handle_at()
7958 fh->handle_bytes = size; in do_open_by_handle_at()
7959 fh->handle_type = tswap32(target_fh->handle_type); in do_open_by_handle_at()
7982 return -TARGET_EINVAL; in do_signalfd4()
7985 return -TARGET_EFAULT; in do_signalfd4()
8020 struct linux_binprm *bprm = get_task_state(cpu)->bprm; in open_self_cmdline()
8023 for (i = 0; i < bprm->argc; i++) { in open_self_cmdline()
8024 size_t len = strlen(bprm->argv[i]) + 1; in open_self_cmdline()
8026 if (write(fd, bprm->argv[i], len) != len) { in open_self_cmdline()
8027 return -1; in open_self_cmdline()
8056 const struct image_info *info = d->ts->info; in open_self_maps_4()
8057 const char *path = mi->path; in open_self_maps_4()
8059 int fd = d->fd; in open_self_maps_4()
8062 if (test_stack(start, end, info->stack_limit)) { in open_self_maps_4()
8064 } else if (start == info->brk) { in open_self_maps_4()
8066 } else if (start == info->vdso) { in open_self_maps_4()
8075 offset = mi->offset; in open_self_maps_4()
8076 if (mi->dev) { in open_self_maps_4()
8078 offset += hstart - mi->itree.start; in open_self_maps_4()
8081 count = dprintf(fd, TARGET_ABI_FMT_ptr "-" TARGET_ABI_FMT_ptr in open_self_maps_4()
8084 (flags & PAGE_READ) ? 'r' : '-', in open_self_maps_4()
8085 (flags & PAGE_WRITE_ORG) ? 'w' : '-', in open_self_maps_4()
8086 (flags & PAGE_EXEC) ? 'x' : '-', in open_self_maps_4()
8087 mi->is_priv ? 'p' : 's', in open_self_maps_4()
8088 offset, major(mi->dev), minor(mi->dev), in open_self_maps_4()
8089 (uint64_t)mi->inode); in open_self_maps_4()
8091 dprintf(fd, "%*s%s\n", 73 - count, "", path); in open_self_maps_4()
8096 if (d->smaps) { in open_self_maps_4()
8097 unsigned long size = end - start; in open_self_maps_4()
8129 mi->is_priv ? "" : " sh", in open_self_maps_4()
8133 mi->is_priv ? "" : " ms"); in open_self_maps_4()
8139 * Proceed without the benefit of host /proc/self/maps cross-check.
8158 uintptr_t host_last = (uintptr_t)g2h_untagged(guest_end - 1); in open_self_maps_2()
8174 interval_tree_iter_first(d->host_maps, host_start, host_start); in open_self_maps_2()
8176 uintptr_t this_hlast = MIN(host_last, n->last); in open_self_maps_2()
8232 gchar *bin = g_strrstr(ts->bprm->argv[0], "/"); in open_self_stat()
8233 bin = bin ? bin + 1 : ts->bprm->argv[0]; in open_self_stat()
8256 g_string_printf(buf, "%" PRIu64 " ", ts->start_boottime); in open_self_stat()
8259 g_string_printf(buf, TARGET_ABI_FMT_ld " ", ts->info->start_stack); in open_self_stat()
8265 if (write(fd, buf->str, buf->len) != buf->len) { in open_self_stat()
8266 return -1; in open_self_stat()
8277 abi_ulong auxv = ts->info->saved_auxv; in open_self_auxv()
8278 abi_ulong len = ts->info->auxv_len; in open_self_auxv()
8293 len -= r; in open_self_auxv()
8375 return -1; in open_net_route()
8385 while ((read = getline(&line, &len, fp)) != -1) { in open_net_route()
8453 return -1; in maybe_do_fake_open()
8462 for (fake_open = fakes; fake_open->filename; fake_open++) { in maybe_do_fake_open()
8463 if (fake_open->cmp(pathname, fake_open->filename)) { in maybe_do_fake_open()
8468 if (fake_open->filename) { in maybe_do_fake_open()
8473 fd = memfd_create("qemu-open", 0); in maybe_do_fake_open()
8482 snprintf(filename, sizeof(filename), "%s/qemu-open.XXXXXX", tmpdir); in maybe_do_fake_open()
8490 if ((r = fake_open->fill(cpu_env, fd))) { in maybe_do_fake_open()
8501 return -2; in maybe_do_fake_open()
8508 if (fd > -2) { in do_guest_openat()
8529 return -TARGET_EINVAL; in do_openat2()
8533 if (ret == -TARGET_E2BIG) { in do_openat2()
8542 return -TARGET_EFAULT; in do_openat2()
8550 if (fd > -2) { in do_openat2()
8568 return -1; in do_guest_readlink()
8574 return -1; in do_guest_readlink()
8608 return -TARGET_EFAULT; in do_execv()
8618 return -TARGET_EFAULT; in do_execv()
8687 ret = -TARGET_EFAULT; in do_execv()
8717 return -TARGET_EINVAL; in get_timer_id()
8723 return -TARGET_EINVAL; in get_timer_id()
8743 return -TARGET_EFAULT; in target_to_host_cpu_mask()
8777 return -TARGET_EFAULT; in host_to_target_cpu_mask()
8807 return -TARGET_ENOMEM; in do_getdents()
8823 return -TARGET_EFAULT; in do_getdents()
8836 namelen = strlen(hde->d_name); in do_getdents()
8837 hreclen = hde->d_reclen; in do_getdents()
8849 toff = -TARGET_EINVAL; /* result buffer is too small */ in do_getdents()
8860 prev_diroff = hde->d_off; in do_getdents()
8861 tde->d_ino = tswapal(hde->d_ino); in do_getdents()
8862 tde->d_off = tswapal(hde->d_off); in do_getdents()
8863 tde->d_reclen = tswap16(treclen); in do_getdents()
8864 memcpy(tde->d_name, hde->d_name, namelen + 1); in do_getdents()
8871 type = *((uint8_t *)hde + hreclen - 1); in do_getdents()
8873 type = hde->d_type; in do_getdents()
8875 *((uint8_t *)tde + treclen - 1) = type; in do_getdents()
8894 return -TARGET_ENOMEM; in do_getdents64()
8904 return -TARGET_EFAULT; in do_getdents64()
8912 namelen = strlen(hde->d_name) + 1; in do_getdents64()
8913 hreclen = hde->d_reclen; in do_getdents64()
8925 toff = -TARGET_EINVAL; /* result buffer is too small */ in do_getdents64()
8936 prev_diroff = hde->d_off; in do_getdents64()
8937 tde->d_ino = tswap64(hde->d_ino); in do_getdents64()
8938 tde->d_off = tswap64(hde->d_off); in do_getdents64()
8939 tde->d_reclen = tswap16(treclen); in do_getdents64()
8940 tde->d_type = hde->d_type; in do_getdents64()
8941 memcpy(tde->d_name, hde->d_name, namelen); in do_getdents64()
9017 for (; pair_count > 0; pair_count--, pair++) { in risc_hwprobe_fill_pairs()
9020 __put_user(0, &pair->value); in risc_hwprobe_fill_pairs()
9021 __get_user(key, &pair->key); in risc_hwprobe_fill_pairs()
9024 __put_user(cfg->mvendorid, &pair->value); in risc_hwprobe_fill_pairs()
9027 __put_user(cfg->marchid, &pair->value); in risc_hwprobe_fill_pairs()
9030 __put_user(cfg->mimpid, &pair->value); in risc_hwprobe_fill_pairs()
9037 __put_user(value, &pair->value); in risc_hwprobe_fill_pairs()
9047 value |= cfg->ext_zba ? in risc_hwprobe_fill_pairs()
9049 value |= cfg->ext_zbb ? in risc_hwprobe_fill_pairs()
9051 value |= cfg->ext_zbs ? in risc_hwprobe_fill_pairs()
9053 value |= cfg->ext_zicboz ? in risc_hwprobe_fill_pairs()
9055 value |= cfg->ext_zbc ? in risc_hwprobe_fill_pairs()
9057 value |= cfg->ext_zbkb ? in risc_hwprobe_fill_pairs()
9059 value |= cfg->ext_zbkc ? in risc_hwprobe_fill_pairs()
9061 value |= cfg->ext_zbkx ? in risc_hwprobe_fill_pairs()
9063 value |= cfg->ext_zknd ? in risc_hwprobe_fill_pairs()
9065 value |= cfg->ext_zkne ? in risc_hwprobe_fill_pairs()
9067 value |= cfg->ext_zknh ? in risc_hwprobe_fill_pairs()
9069 value |= cfg->ext_zksed ? in risc_hwprobe_fill_pairs()
9071 value |= cfg->ext_zksh ? in risc_hwprobe_fill_pairs()
9073 value |= cfg->ext_zkt ? in risc_hwprobe_fill_pairs()
9075 value |= cfg->ext_zvbb ? in risc_hwprobe_fill_pairs()
9077 value |= cfg->ext_zvbc ? in risc_hwprobe_fill_pairs()
9079 value |= cfg->ext_zvkb ? in risc_hwprobe_fill_pairs()
9081 value |= cfg->ext_zvkg ? in risc_hwprobe_fill_pairs()
9083 value |= cfg->ext_zvkned ? in risc_hwprobe_fill_pairs()
9085 value |= cfg->ext_zvknha ? in risc_hwprobe_fill_pairs()
9087 value |= cfg->ext_zvknhb ? in risc_hwprobe_fill_pairs()
9089 value |= cfg->ext_zvksed ? in risc_hwprobe_fill_pairs()
9091 value |= cfg->ext_zvksh ? in risc_hwprobe_fill_pairs()
9093 value |= cfg->ext_zvkt ? in risc_hwprobe_fill_pairs()
9095 value |= cfg->ext_zfh ? in risc_hwprobe_fill_pairs()
9097 value |= cfg->ext_zfhmin ? in risc_hwprobe_fill_pairs()
9099 value |= cfg->ext_zihintntl ? in risc_hwprobe_fill_pairs()
9101 value |= cfg->ext_zvfh ? in risc_hwprobe_fill_pairs()
9103 value |= cfg->ext_zvfhmin ? in risc_hwprobe_fill_pairs()
9105 value |= cfg->ext_zfa ? in risc_hwprobe_fill_pairs()
9107 value |= cfg->ext_ztso ? in risc_hwprobe_fill_pairs()
9109 value |= cfg->ext_zacas ? in risc_hwprobe_fill_pairs()
9111 value |= cfg->ext_zicond ? in risc_hwprobe_fill_pairs()
9113 __put_user(value, &pair->value); in risc_hwprobe_fill_pairs()
9116 __put_user(RISCV_HWPROBE_MISALIGNED_FAST, &pair->value); in risc_hwprobe_fill_pairs()
9119 value = cfg->ext_zicboz ? cfg->cboz_blocksize : 0; in risc_hwprobe_fill_pairs()
9120 __put_user(value, &pair->value); in risc_hwprobe_fill_pairs()
9123 __put_user(-1, &pair->key); in risc_hwprobe_fill_pairs()
9130 * If the cpumask_t of (target_cpus, cpusetsize) cannot be read: -EFAULT.
9131 * If the cpumast_t has no bits set: -EINVAL.
9139 int ret = -TARGET_EFAULT; in nonempty_cpu_set()
9142 ret = -TARGET_EINVAL; in nonempty_cpu_set()
9144 * Since we only care about the empty/non-empty state of the cpumask_t in nonempty_cpu_set()
9172 return -TARGET_EINVAL; in do_riscv_hwprobe()
9182 return -TARGET_EINVAL; in do_riscv_hwprobe()
9193 return -TARGET_EFAULT; in do_riscv_hwprobe()
9220 * All errnos that do_syscall() returns must be -TARGET_<errcode>. in _syscall2()
9249 return -QEMU_ERESTARTSYS; in _syscall2()
9257 if (ts->child_tidptr) { in _syscall2()
9258 put_user_u32(0, ts->child_tidptr); in _syscall2()
9259 do_sys_futex(g2h(cpu, ts->child_tidptr), in _syscall2()
9267 * from cpu lists. We can clean-up the rest of the thread in _syscall2()
9288 return -TARGET_EFAULT; in _syscall2()
9302 return -TARGET_EFAULT; in _syscall2()
9320 return -TARGET_EFAULT; in _syscall2()
9330 return -TARGET_EFAULT; in _syscall2()
9363 return -TARGET_EFAULT; in _syscall2()
9409 return -TARGET_EFAULT; in _syscall2()
9426 return -TARGET_EFAULT; in _syscall2()
9432 return -TARGET_EFAULT; in _syscall2()
9441 return -TARGET_EFAULT; in _syscall2()
9454 ret = -TARGET_EFAULT; in _syscall2()
9467 return -TARGET_EFAULT; in _syscall2()
9471 ret = -TARGET_EFAULT; in _syscall2()
9482 return -TARGET_EFAULT; in _syscall2()
9490 return -TARGET_EFAULT; in _syscall2()
9501 return -TARGET_EFAULT; in _syscall2()
9513 return -TARGET_EFAULT; in _syscall2()
9520 return -TARGET_EFAULT; in _syscall2()
9528 return -TARGET_EFAULT; in _syscall2()
9536 return -TARGET_EFAULT; in _syscall2()
9548 cpu_env->ir[IR_A4] = getppid(); in _syscall2()
9563 return -TARGET_EFAULT; in _syscall2()
9574 return -TARGET_EFAULT; in _syscall2()
9584 return -TARGET_EFAULT; in _syscall2()
9590 /* FIXME - arg5 should be locked, but it isn't clear how to in _syscall2()
9591 * do that since it's not guaranteed to be a NULL-terminated in _syscall2()
9618 return -TARGET_EFAULT; in _syscall2()
9629 return -TARGET_EFAULT; in _syscall2()
9634 return -TARGET_EFAULT; in _syscall2()
9640 return -TARGET_EFAULT; in _syscall2()
9657 return -TARGET_EFAULT; in _syscall2()
9662 return -TARGET_EFAULT; in _syscall2()
9683 return -TARGET_EFAULT; in _syscall2()
9695 sigsuspend(&get_task_state(cpu)->signal_mask); in _syscall2()
9697 return -TARGET_EINTR; in _syscall2()
9706 return -TARGET_EFAULT; in _syscall2()
9707 tbuf.actime = tswapal(target_tbuf->actime); in _syscall2()
9708 tbuf.modtime = tswapal(target_tbuf->modtime); in _syscall2()
9715 return -TARGET_EFAULT; in _syscall2()
9729 return -TARGET_EFAULT; in _syscall2()
9735 return -TARGET_EFAULT; in _syscall2()
9749 return -TARGET_EFAULT; in _syscall2()
9755 return -TARGET_EFAULT; in _syscall2()
9765 return -TARGET_EFAULT; in _syscall2()
9774 return -TARGET_EFAULT; in _syscall2()
9783 return -TARGET_EFAULT; in _syscall2()
9809 ret = -TARGET_EFAULT; in _syscall2()
9824 ret = -TARGET_EFAULT; in _syscall2()
9839 ret = -TARGET_EFAULT; in _syscall2()
9851 return -TARGET_EFAULT; in _syscall2()
9859 return -TARGET_EFAULT; in _syscall2()
9867 return -TARGET_EFAULT; in _syscall2()
9895 return -TARGET_EFAULT; in _syscall2()
9896 tmsp->tms_utime = tswapal(host_to_target_clock_t(tms.tms_utime)); in _syscall2()
9897 tmsp->tms_stime = tswapal(host_to_target_clock_t(tms.tms_stime)); in _syscall2()
9898 tmsp->tms_cutime = tswapal(host_to_target_clock_t(tms.tms_cutime)); in _syscall2()
9899 tmsp->tms_cstime = tswapal(host_to_target_clock_t(tms.tms_cstime)); in _syscall2()
9910 return -TARGET_EFAULT; in _syscall2()
9919 return -TARGET_EFAULT; in _syscall2()
9936 return -TARGET_EFAULT; in _syscall2()
9954 return -EINVAL; in _syscall2()
9982 return -TARGET_EFAULT; in _syscall2()
9983 act._sa_handler = old_act->_sa_handler; in _syscall2()
9984 target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]); in _syscall2()
9985 act.sa_flags = old_act->sa_flags; in _syscall2()
9996 return -TARGET_EFAULT; in _syscall2()
9997 old_act->_sa_handler = oact._sa_handler; in _syscall2()
9998 old_act->sa_flags = oact.sa_flags; in _syscall2()
9999 old_act->sa_mask.sig[0] = oact.sa_mask.sig[0]; in _syscall2()
10000 old_act->sa_mask.sig[1] = 0; in _syscall2()
10001 old_act->sa_mask.sig[2] = 0; in _syscall2()
10002 old_act->sa_mask.sig[3] = 0; in _syscall2()
10010 return -TARGET_EFAULT; in _syscall2()
10011 act._sa_handler = old_act->_sa_handler; in _syscall2()
10012 target_siginitset(&act.sa_mask, old_act->sa_mask); in _syscall2()
10013 act.sa_flags = old_act->sa_flags; in _syscall2()
10015 act.sa_restorer = old_act->sa_restorer; in _syscall2()
10025 return -TARGET_EFAULT; in _syscall2()
10026 old_act->_sa_handler = oact._sa_handler; in _syscall2()
10027 old_act->sa_mask = oact.sa_mask.sig[0]; in _syscall2()
10028 old_act->sa_flags = oact.sa_flags; in _syscall2()
10030 old_act->sa_restorer = oact.sa_restorer; in _syscall2()
10041 * For Alpha and SPARC this is a 5 argument syscall, with in _syscall2()
10044 * For Alpha that 'restorer' is arg5; for SPARC it is arg4, in _syscall2()
10061 return -TARGET_EINVAL; in _syscall2()
10064 return -TARGET_EFAULT; in _syscall2()
10067 ret = -TARGET_EFAULT; in _syscall2()
10125 return -TARGET_EINVAL; in _syscall2()
10134 cpu_env->ir[IR_V0] = 0; /* force no error */ in _syscall2()
10143 return -TARGET_EFAULT; in _syscall2()
10159 return -TARGET_EINVAL; in _syscall2()
10168 return -TARGET_EFAULT; in _syscall2()
10182 return -TARGET_EINVAL; in _syscall2()
10188 return -TARGET_EFAULT; in _syscall2()
10204 return -TARGET_EINVAL; in _syscall2()
10213 return -TARGET_EFAULT; in _syscall2()
10226 return -TARGET_EFAULT; in _syscall2()
10243 return -TARGET_EINVAL; in _syscall2()
10249 return -TARGET_EFAULT; in _syscall2()
10264 set = &ts->sigsuspend_mask; in _syscall2()
10297 return -TARGET_EINVAL; in _syscall2()
10301 return -TARGET_EFAULT; in _syscall2()
10307 return -TARGET_EFAULT; in _syscall2()
10319 return -TARGET_EFAULT; in _syscall2()
10337 return -TARGET_EINVAL; in _syscall2()
10342 return -TARGET_EFAULT; in _syscall2()
10349 return -TARGET_EFAULT; in _syscall2()
10361 return -TARGET_EFAULT; in _syscall2()
10377 return -TARGET_EFAULT; in _syscall2()
10390 return -TARGET_EFAULT; in _syscall2()
10400 return -QEMU_ERESTARTSYS; in _syscall2()
10406 return -QEMU_ERESTARTSYS; in _syscall2()
10411 return -TARGET_EFAULT; in _syscall2()
10422 return -TARGET_EFAULT; in _syscall2()
10423 rlim.rlim_cur = target_to_host_rlim(target_rlim->rlim_cur); in _syscall2()
10424 rlim.rlim_max = target_to_host_rlim(target_rlim->rlim_max); in _syscall2()
10453 return -TARGET_EFAULT; in _syscall2()
10454 target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); in _syscall2()
10455 target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); in _syscall2()
10479 return -TARGET_EFAULT; in _syscall2()
10482 return -TARGET_EFAULT; in _syscall2()
10496 return -TARGET_EFAULT; in _syscall2()
10503 return -TARGET_EFAULT; in _syscall2()
10517 ret = -TARGET_ENOSYS; in _syscall2()
10540 ret = -TARGET_EFAULT; in _syscall2()
10555 ret = -TARGET_EFAULT; in _syscall2()
10582 ret = -TARGET_EFAULT; in _syscall2()
10585 ret = -TARGET_EINVAL; in _syscall2()
10605 return -TARGET_EFAULT; in _syscall2()
10615 return -TARGET_EFAULT; in _syscall2()
10630 return -TARGET_EFAULT; in _syscall2()
10662 && arg1 >= ts->info->stack_limit in _syscall2()
10663 && arg1 <= ts->info->start_stack) { in _syscall2()
10665 arg2 = arg2 + arg1 - ts->info->stack_limit; in _syscall2()
10666 arg1 = ts->info->stack_limit; in _syscall2()
10676 /* ??? msync/mlock/munlock are broken for softmmu. */ in _syscall2()
10701 return -TARGET_EFAULT; in _syscall2()
10715 return -TARGET_EFAULT; in _syscall2()
10723 return -TARGET_EFAULT; in _syscall2()
10734 if (ret == -1 && errno != 0) { in _syscall2()
10735 return -host_to_target_errno(errno); in _syscall2()
10739 cpu_env->ir[IR_V0] = 0; in _syscall2()
10742 ret = 20 - ret; in _syscall2()
10750 return -TARGET_EFAULT; in _syscall2()
10759 return -TARGET_EFAULT; in _syscall2()
10760 __put_user(stfs.f_type, &target_stfs->f_type); in _syscall2()
10761 __put_user(stfs.f_bsize, &target_stfs->f_bsize); in _syscall2()
10762 __put_user(stfs.f_blocks, &target_stfs->f_blocks); in _syscall2()
10763 __put_user(stfs.f_bfree, &target_stfs->f_bfree); in _syscall2()
10764 __put_user(stfs.f_bavail, &target_stfs->f_bavail); in _syscall2()
10765 __put_user(stfs.f_files, &target_stfs->f_files); in _syscall2()
10766 __put_user(stfs.f_ffree, &target_stfs->f_ffree); in _syscall2()
10767 __put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]); in _syscall2()
10768 __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]); in _syscall2()
10769 __put_user(stfs.f_namelen, &target_stfs->f_namelen); in _syscall2()
10770 __put_user(stfs.f_frsize, &target_stfs->f_frsize); in _syscall2()
10772 __put_user(stfs.f_flags, &target_stfs->f_flags); in _syscall2()
10774 __put_user(0, &target_stfs->f_flags); in _syscall2()
10776 memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); in _syscall2()
10789 return -TARGET_EFAULT; in _syscall2()
10798 return -TARGET_EFAULT; in _syscall2()
10799 __put_user(stfs.f_type, &target_stfs->f_type); in _syscall2()
10800 __put_user(stfs.f_bsize, &target_stfs->f_bsize); in _syscall2()
10801 __put_user(stfs.f_blocks, &target_stfs->f_blocks); in _syscall2()
10802 __put_user(stfs.f_bfree, &target_stfs->f_bfree); in _syscall2()
10803 __put_user(stfs.f_bavail, &target_stfs->f_bavail); in _syscall2()
10804 __put_user(stfs.f_files, &target_stfs->f_files); in _syscall2()
10805 __put_user(stfs.f_ffree, &target_stfs->f_ffree); in _syscall2()
10806 __put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]); in _syscall2()
10807 __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]); in _syscall2()
10808 __put_user(stfs.f_namelen, &target_stfs->f_namelen); in _syscall2()
10809 __put_user(stfs.f_frsize, &target_stfs->f_frsize); in _syscall2()
10811 __put_user(stfs.f_flags, &target_stfs->f_flags); in _syscall2()
10813 __put_user(0, &target_stfs->f_flags); in _syscall2()
10815 memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); in _syscall2()
10899 return -TARGET_EFAULT; in _syscall2()
10937 return -TARGET_EINVAL; in _syscall2()
10944 return -TARGET_EFAULT; in _syscall2()
10951 return -TARGET_EINVAL; in _syscall2()
10962 if (copy_from_user_timeval(&pvalue->it_interval, arg2) in _syscall2()
10963 || copy_from_user_timeval(&pvalue->it_value, in _syscall2()
10965 return -TARGET_EFAULT; in _syscall2()
10975 return -TARGET_EFAULT; in _syscall2()
10989 return -TARGET_EFAULT; in _syscall2()
10996 return -TARGET_EFAULT; in _syscall2()
11005 return -TARGET_EFAULT; in _syscall2()
11022 return -TARGET_EFAULT; in _syscall2()
11024 __put_user(st.st_dev, &target_st->st_dev); in _syscall2()
11025 __put_user(st.st_ino, &target_st->st_ino); in _syscall2()
11026 __put_user(st.st_mode, &target_st->st_mode); in _syscall2()
11027 __put_user(st.st_uid, &target_st->st_uid); in _syscall2()
11028 __put_user(st.st_gid, &target_st->st_gid); in _syscall2()
11029 __put_user(st.st_nlink, &target_st->st_nlink); in _syscall2()
11030 __put_user(st.st_rdev, &target_st->st_rdev); in _syscall2()
11031 __put_user(st.st_size, &target_st->st_size); in _syscall2()
11032 __put_user(st.st_blksize, &target_st->st_blksize); in _syscall2()
11033 __put_user(st.st_blocks, &target_st->st_blocks); in _syscall2()
11034 __put_user(st.st_atime, &target_st->target_st_atime); in _syscall2()
11035 __put_user(st.st_mtime, &target_st->target_st_mtime); in _syscall2()
11036 __put_user(st.st_ctime, &target_st->target_st_ctime); in _syscall2()
11039 &target_st->target_st_atime_nsec); in _syscall2()
11041 &target_st->target_st_mtime_nsec); in _syscall2()
11043 &target_st->target_st_ctime_nsec); in _syscall2()
11074 return -TARGET_EFAULT; in _syscall2()
11089 return -TARGET_EFAULT; in _syscall2()
11102 return -TARGET_EFAULT; in _syscall2()
11103 __put_user(value.uptime, &target_value->uptime); in _syscall2()
11104 __put_user(value.loads[0], &target_value->loads[0]); in _syscall2()
11105 __put_user(value.loads[1], &target_value->loads[1]); in _syscall2()
11106 __put_user(value.loads[2], &target_value->loads[2]); in _syscall2()
11107 __put_user(value.totalram, &target_value->totalram); in _syscall2()
11108 __put_user(value.freeram, &target_value->freeram); in _syscall2()
11109 __put_user(value.sharedram, &target_value->sharedram); in _syscall2()
11110 __put_user(value.bufferram, &target_value->bufferram); in _syscall2()
11111 __put_user(value.totalswap, &target_value->totalswap); in _syscall2()
11112 __put_user(value.freeswap, &target_value->freeswap); in _syscall2()
11113 __put_user(value.procs, &target_value->procs); in _syscall2()
11114 __put_user(value.totalhigh, &target_value->totalhigh); in _syscall2()
11115 __put_user(value.freehigh, &target_value->freehigh); in _syscall2()
11116 __put_user(value.mem_unit, &target_value->mem_unit); in _syscall2()
11204 return -TARGET_EFAULT; in _syscall2()
11214 return -TARGET_EFAULT; in _syscall2()
11219 g_strlcpy(buf->machine, cpu_to_uname_machine(cpu_env), in _syscall2()
11220 sizeof(buf->machine)); in _syscall2()
11223 g_strlcpy(buf->release, qemu_uname_release, in _syscall2()
11224 sizeof(buf->release)); in _syscall2()
11244 return -TARGET_EFAULT; in _syscall2()
11249 return -TARGET_EFAULT; in _syscall2()
11261 return -TARGET_EFAULT; in _syscall2()
11265 return -TARGET_EFAULT; in _syscall2()
11276 return -TARGET_EFAULT; in _syscall2()
11280 return -TARGET_EFAULT; in _syscall2()
11297 if (res == -1) { in _syscall2()
11306 return -TARGET_EFAULT; in _syscall2()
11346 ret = -host_to_target_errno(errno); in _syscall2()
11357 ret = -host_to_target_errno(errno); in _syscall2()
11372 ret = -host_to_target_errno(errno); in _syscall2()
11388 ret = -host_to_target_errno(errno); in _syscall2()
11408 if (arg2 & (sizeof(abi_ulong) - 1)) { in _syscall2()
11409 return -TARGET_EINVAL; in _syscall2()
11411 mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1); in _syscall2()
11428 return -TARGET_EINVAL; in _syscall2()
11434 return -TARGET_EFAULT; in _syscall2()
11448 if (arg2 & (sizeof(abi_ulong) - 1)) { in _syscall2()
11449 return -TARGET_EINVAL; in _syscall2()
11451 mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1); in _syscall2()
11471 return -TARGET_EFAULT; in _syscall2()
11474 return -TARGET_EFAULT; in _syscall2()
11484 return -TARGET_EINVAL; in _syscall2()
11487 return -TARGET_EFAULT; in _syscall2()
11489 schp.sched_priority = tswap32(target_schp->sched_priority); in _syscall2()
11499 return -TARGET_EINVAL; in _syscall2()
11504 return -TARGET_EFAULT; in _syscall2()
11506 target_schp->sched_priority = tswap32(schp.sched_priority); in _syscall2()
11516 return -TARGET_EINVAL; in _syscall2()
11519 return -TARGET_EFAULT; in _syscall2()
11521 schp.sched_priority = tswap32(target_schp->sched_priority); in _syscall2()
11532 return -TARGET_EINVAL; in _syscall2()
11541 return -TARGET_EFAULT; in _syscall2()
11543 target_scha->size = tswap32(scha.size); in _syscall2()
11544 target_scha->sched_policy = tswap32(scha.sched_policy); in _syscall2()
11545 target_scha->sched_flags = tswap64(scha.sched_flags); in _syscall2()
11546 target_scha->sched_nice = tswap32(scha.sched_nice); in _syscall2()
11547 target_scha->sched_priority = tswap32(scha.sched_priority); in _syscall2()
11548 target_scha->sched_runtime = tswap64(scha.sched_runtime); in _syscall2()
11549 target_scha->sched_deadline = tswap64(scha.sched_deadline); in _syscall2()
11550 target_scha->sched_period = tswap64(scha.sched_period); in _syscall2()
11552 target_scha->sched_util_min = tswap32(scha.sched_util_min); in _syscall2()
11553 target_scha->sched_util_max = tswap32(scha.sched_util_max); in _syscall2()
11566 return -TARGET_EINVAL; in _syscall2()
11569 return -TARGET_EFAULT; in _syscall2()
11576 return -TARGET_EFAULT; in _syscall2()
11578 return -TARGET_E2BIG; in _syscall2()
11586 return -TARGET_EFAULT; in _syscall2()
11588 return -TARGET_E2BIG; in _syscall2()
11596 return -TARGET_EFAULT; in _syscall2()
11599 scha.sched_policy = tswap32(target_scha->sched_policy); in _syscall2()
11600 scha.sched_flags = tswap64(target_scha->sched_flags); in _syscall2()
11601 scha.sched_nice = tswap32(target_scha->sched_nice); in _syscall2()
11602 scha.sched_priority = tswap32(target_scha->sched_priority); in _syscall2()
11603 scha.sched_runtime = tswap64(target_scha->sched_runtime); in _syscall2()
11604 scha.sched_deadline = tswap64(target_scha->sched_deadline); in _syscall2()
11605 scha.sched_period = tswap64(target_scha->sched_period); in _syscall2()
11607 scha.sched_util_min = tswap32(target_scha->sched_util_min); in _syscall2()
11608 scha.sched_util_max = tswap32(target_scha->sched_util_max); in _syscall2()
11646 return -TARGET_EFAULT; in _syscall2()
11651 return -TARGET_EFAULT; in _syscall2()
11671 /* Special-case NULL buffer and zero length, which should succeed */ in _syscall2()
11676 return -TARGET_EFAULT; in _syscall2()
11688 /* Special-case NULL buffer and zero length, which should succeed */ in _syscall2()
11693 return -TARGET_EFAULT; in _syscall2()
11702 return -TARGET_EFAULT; in _syscall2()
11718 return -TARGET_EFAULT; in _syscall2()
11720 header.version = tswap32(target_header->version); in _syscall2()
11721 header.pid = tswap32(target_header->pid); in _syscall2()
11738 return -TARGET_EFAULT; in _syscall2()
11759 target_header->version = tswap32(header.version); in _syscall2()
11840 return -TARGET_EFAULT; in _syscall2()
11841 target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur); in _syscall2()
11842 target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max); in _syscall2()
11851 return -TARGET_EFAULT; in _syscall2()
11863 return -TARGET_EFAULT; in _syscall2()
11874 return -TARGET_EFAULT; in _syscall2()
11897 return -TARGET_EFAULT; in _syscall2()
11914 return -TARGET_EFAULT; in _syscall2()
11928 return -TARGET_EFAULT; in _syscall2()
11932 if (ret != -TARGET_ENOSYS) { in _syscall2()
11943 return -TARGET_EFAULT; in _syscall2()
11946 __put_user(major(st.st_dev), &target_stx->stx_dev_major); in _syscall2()
11947 __put_user(minor(st.st_dev), &target_stx->stx_dev_minor); in _syscall2()
11948 __put_user(st.st_ino, &target_stx->stx_ino); in _syscall2()
11949 __put_user(st.st_mode, &target_stx->stx_mode); in _syscall2()
11950 __put_user(st.st_uid, &target_stx->stx_uid); in _syscall2()
11951 __put_user(st.st_gid, &target_stx->stx_gid); in _syscall2()
11952 __put_user(st.st_nlink, &target_stx->stx_nlink); in _syscall2()
11953 __put_user(major(st.st_rdev), &target_stx->stx_rdev_major); in _syscall2()
11954 __put_user(minor(st.st_rdev), &target_stx->stx_rdev_minor); in _syscall2()
11955 __put_user(st.st_size, &target_stx->stx_size); in _syscall2()
11956 __put_user(st.st_blksize, &target_stx->stx_blksize); in _syscall2()
11957 __put_user(st.st_blocks, &target_stx->stx_blocks); in _syscall2()
11958 __put_user(st.st_atime, &target_stx->stx_atime.tv_sec); in _syscall2()
11959 __put_user(st.st_mtime, &target_stx->stx_mtime.tv_sec); in _syscall2()
11960 __put_user(st.st_ctime, &target_stx->stx_ctime.tv_sec); in _syscall2()
11969 return -TARGET_EFAULT; in _syscall2()
12002 return -TARGET_EINVAL; in _syscall2()
12007 return -TARGET_ENOMEM; in _syscall2()
12015 return -TARGET_EFAULT; in _syscall2()
12033 return -TARGET_EINVAL; in _syscall2()
12038 return -TARGET_ENOMEM; in _syscall2()
12043 return -TARGET_EFAULT; in _syscall2()
12058 return -TARGET_EFAULT; in _syscall2()
12079 return -TARGET_EFAULT; in _syscall2()
12099 return -TARGET_EFAULT; in _syscall2()
12107 return -TARGET_EFAULT; in _syscall2()
12124 return -TARGET_EFAULT; in _syscall2()
12140 cpu_env->ir[IR_A4]=euid; in _syscall2()
12150 cpu_env->ir[IR_A4]=egid; in _syscall2()
12157 ret = -TARGET_EOPNOTSUPP; in _syscall2()
12162 uint64_t swcr = cpu_env->swcr; in _syscall2()
12168 return -TARGET_EFAULT; in _syscall2()
12174 -- Not implemented in linux kernel. in _syscall2()
12176 -- Retrieves current unaligned access state; not much used. in _syscall2()
12178 -- Retrieves implver information; surely not used. in _syscall2()
12180 -- Grabs a copy of the HWRPB; surely not used. in _syscall2()
12188 ret = -TARGET_EOPNOTSUPP; in _syscall2()
12195 return -TARGET_EFAULT; in _syscall2()
12204 cpu_env->swcr = swcr & (SWCR_TRAP_ENABLE_MASK | SWCR_MAP_MASK); in _syscall2()
12219 return -TARGET_EFAULT; in _syscall2()
12228 fex &= (cpu_env)->swcr; in _syscall2()
12260 info._sifields._sigfault._addr = (cpu_env)->pc; in _syscall2()
12269 -- Used with SSIN_UACPROC to enable unaligned accesses. in _syscall2()
12272 -- Not implemented in linux kernel in _syscall2()
12296 return -TARGET_EINVAL; in _syscall2()
12338 return -TARGET_EINVAL; in _syscall2()
12343 return -TARGET_ENOMEM; in _syscall2()
12351 return -TARGET_EFAULT; in _syscall2()
12370 return -TARGET_EINVAL; in _syscall2()
12375 return -TARGET_ENOMEM; in _syscall2()
12380 return -TARGET_EFAULT; in _syscall2()
12407 return -TARGET_EFAULT; in _syscall2()
12425 return -TARGET_EFAULT; in _syscall2()
12433 return -TARGET_EFAULT; in _syscall2()
12459 return -TARGET_ENOMEM; in _syscall2()
12463 ret = -TARGET_EFAULT; in _syscall2()
12477 * Note that offset and len are both 64-bit so appear as in _syscall2()
12478 * pairs of 32-bit registers. in _syscall2()
12482 return -host_to_target_errno(ret); in _syscall2()
12510 return -host_to_target_errno(ret); in _syscall2()
12524 return -host_to_target_errno(ret); in _syscall2()
12527 #else /* not a 32-bit ABI */ in _syscall2()
12544 return -host_to_target_errno(posix_fadvise(arg1, arg2, arg3, arg4)); in _syscall2()
12546 #endif /* end of 64-bit ABI fadvise handling */ in _syscall2()
12561 if (!cpu_env->eabi) { in _syscall2()
12568 if (cmd == -TARGET_EINVAL) { in _syscall2()
12601 /* self-modifying code is handled automatically, so nothing needed */ in _syscall2()
12633 return -TARGET_EFAULT; in _syscall2()
12644 ret = -TARGET_EFAULT; in _syscall2()
12656 return -TARGET_EFAULT; in _syscall2()
12670 return -TARGET_EFAULT; in _syscall2()
12682 ret = -TARGET_EFAULT; in _syscall2()
12695 return -TARGET_EFAULT; in _syscall2()
12702 ret = -TARGET_EFAULT; in _syscall2()
12715 return -TARGET_EFAULT; in _syscall2()
12727 ret = -TARGET_EFAULT; in _syscall2()
12740 return -TARGET_EFAULT; in _syscall2()
12747 ret = -TARGET_EFAULT; in _syscall2()
12766 ret = -TARGET_EFAULT; in _syscall2()
12779 ret = -TARGET_EFAULT; in _syscall2()
12789 cpu_env->active_tc.CP0_UserLocal = arg1; in _syscall2()
12796 ts->tp_value = arg1; in _syscall2()
12800 return -TARGET_ENOSYS; in _syscall2()
12810 return ts->tp_value; in _syscall2()
12813 return -TARGET_ENOSYS; in _syscall2()
12818 return -TARGET_ENOSYS; in _syscall2()
12894 return -TARGET_EFAULT; in _syscall2()
12900 * with error -TARGET_EINTR and if arg4 is not NULL and arg2 is not in _syscall2()
12903 if (ret == -TARGET_EINTR && arg4 && arg2 != TIMER_ABSTIME && in _syscall2()
12905 return -TARGET_EFAULT; in _syscall2()
12917 return -TARGET_EFAULT; in _syscall2()
12923 if (ret == -TARGET_EINTR && arg4 && arg2 != TIMER_ABSTIME && in _syscall2()
12925 return -TARGET_EFAULT; in _syscall2()
12935 ts->child_tidptr = arg1; in _syscall2()
12956 * no way to reliably intercept the thread-death event, we can't in _syscall2()
12958 * falls back to a non-robust futex implementation (which should in _syscall2()
12963 return -TARGET_ENOSYS; in _syscall2()
12974 return -TARGET_EFAULT; in _syscall2()
12978 return -TARGET_EFAULT; in _syscall2()
12986 return -TARGET_EFAULT; in _syscall2()
13002 return -TARGET_EFAULT; in _syscall2()
13006 return -TARGET_EFAULT; in _syscall2()
13015 return -TARGET_EFAULT; in _syscall2()
13073 return -TARGET_EFAULT; in _syscall2()
13077 p = lock_user_string(arg1 - 1); in _syscall2()
13079 return -TARGET_EFAULT; in _syscall2()
13087 p = lock_user_string(arg1 - 1); in _syscall2()
13089 return -TARGET_EFAULT; in _syscall2()
13103 return -TARGET_EFAULT; in _syscall2()
13107 return -TARGET_EFAULT; in _syscall2()
13124 return -TARGET_EFAULT; in _syscall2()
13128 return -TARGET_EFAULT; in _syscall2()
13147 return -TARGET_EFAULT; in _syscall2()
13152 return -TARGET_EFAULT; in _syscall2()
13173 return -TARGET_EFAULT; in _syscall2()
13178 return -TARGET_EFAULT; in _syscall2()
13229 return -TARGET_EFAULT; in _syscall2()
13235 return -TARGET_EFAULT; in _syscall2()
13242 return -TARGET_EFAULT; in _syscall2()
13247 return -TARGET_EFAULT; in _syscall2()
13261 ret = -host_to_target_errno(errno); in _syscall2()
13364 return -TARGET_EFAULT; in _syscall2()
13366 ep.events = tswap32(target_ep->events); in _syscall2()
13372 ep.data.u64 = tswap64(target_ep->data.u64); in _syscall2()
13377 * non-null pointer, even though this argument is ignored. in _syscall2()
13401 return -TARGET_EINVAL; in _syscall2()
13407 return -TARGET_EFAULT; in _syscall2()
13413 return -TARGET_ENOMEM; in _syscall2()
13445 ret = -TARGET_ENOSYS; in _syscall2()
13475 return -TARGET_EFAULT; in _syscall2()
13477 __get_user(rnew.rlim_cur, &target_rnew->rlim_cur); in _syscall2()
13478 __get_user(rnew.rlim_max, &target_rnew->rlim_max); in _syscall2()
13486 return -TARGET_EFAULT; in _syscall2()
13488 __put_user(rold.rlim_cur, &target_rold->rlim_cur); in _syscall2()
13489 __put_user(rold.rlim_max, &target_rold->rlim_max); in _syscall2()
13503 ret = -TARGET_EFAULT; in _syscall2()
13531 qemu arm barrier, no-op this? */ in _syscall2()
13546 ret = -TARGET_EAGAIN; in _syscall2()
13566 return -TARGET_EFAULT; in _syscall2()
13584 ret = -TARGET_EINVAL; in _syscall2()
13590 return -TARGET_EFAULT; in _syscall2()
13595 return -TARGET_EFAULT; in _syscall2()
13610 ret = -TARGET_EINVAL; in _syscall2()
13616 return -TARGET_EFAULT; in _syscall2()
13621 return -TARGET_EFAULT; in _syscall2()
13637 ret = -TARGET_EFAULT; in _syscall2()
13644 ret = -TARGET_EFAULT; in _syscall2()
13660 ret = -TARGET_EFAULT; in _syscall2()
13667 ret = -TARGET_EFAULT; in _syscall2()
13725 return -TARGET_EFAULT; in _syscall2()
13739 return -TARGET_EFAULT; in _syscall2()
13752 return -TARGET_EFAULT; in _syscall2()
13762 return -TARGET_EFAULT; in _syscall2()
13775 return -TARGET_EFAULT; in _syscall2()
13785 return -TARGET_EFAULT; in _syscall2()
13822 return -TARGET_EFAULT; in _syscall2()
13842 return -TARGET_EFAULT; in _syscall2()
13848 return -TARGET_EFAULT; in _syscall2()
13852 /* Do not sign-extend the count parameter. */ in _syscall2()
13858 return -TARGET_EFAULT; in _syscall2()
13863 return -TARGET_EFAULT; in _syscall2()
13878 ret = -TARGET_EFAULT; in _syscall2()
13895 return -TARGET_ENOSYS; in _syscall2()
13909 /* Debug-only code for exercising the syscall-restart code paths in do_syscall()
13910 * in the per-architecture cpu main loops: restart every syscall in do_syscall()
13917 return -QEMU_ERESTARTSYS; in do_syscall()