syscall.c (9699e9f06dc58043a97934db9b9e17f687d6a517) syscall.c (d95fd9838b540e69da9b07538ec8ad6ab9eab260)
1/*
2 * Linux syscalls
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 40 unchanged lines hidden (view full) ---

49#include <poll.h>
50#include <sys/times.h>
51#include <sys/shm.h>
52#include <sys/sem.h>
53#include <sys/statfs.h>
54#include <utime.h>
55#include <sys/sysinfo.h>
56#include <sys/signalfd.h>
1/*
2 * Linux syscalls
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 40 unchanged lines hidden (view full) ---

49#include <poll.h>
50#include <sys/times.h>
51#include <sys/shm.h>
52#include <sys/sem.h>
53#include <sys/statfs.h>
54#include <utime.h>
55#include <sys/sysinfo.h>
56#include <sys/signalfd.h>
57//#include <sys/user.h>
58#include <netinet/in.h>
59#include <netinet/ip.h>
60#include <netinet/tcp.h>
61#include <netinet/udp.h>
62#include <linux/wireless.h>
63#include <linux/icmp.h>
64#include <linux/icmpv6.h>
65#include <linux/if_tun.h>

--- 531 unchanged lines hidden (view full) ---

597 }
598 if (b != 0) {
599 return 0;
600 }
601 }
602 return 1;
603}
604
57#include <netinet/in.h>
58#include <netinet/ip.h>
59#include <netinet/tcp.h>
60#include <netinet/udp.h>
61#include <linux/wireless.h>
62#include <linux/icmp.h>
63#include <linux/icmpv6.h>
64#include <linux/if_tun.h>

--- 531 unchanged lines hidden (view full) ---

596 }
597 if (b != 0) {
598 return 0;
599 }
600 }
601 return 1;
602}
603
604/*
605 * Copies a target struct to a host struct, in a way that guarantees
606 * backwards-compatibility for struct syscall arguments.
607 *
608 * Similar to kernels uaccess.h:copy_struct_from_user()
609 */
610int copy_struct_from_user(void *dst, size_t ksize, abi_ptr src, size_t usize)
611{
612 size_t size = MIN(ksize, usize);
613 size_t rest = MAX(ksize, usize) - size;
614
615 /* Deal with trailing bytes. */
616 if (usize < ksize) {
617 memset(dst + size, 0, rest);
618 } else if (usize > ksize) {
619 int ret = check_zeroed_user(src, ksize, usize);
620 if (ret <= 0) {
621 return ret ?: -TARGET_E2BIG;
622 }
623 }
624 /* Copy the interoperable parts of the struct. */
625 if (copy_from_user(dst, src, size)) {
626 return -TARGET_EFAULT;
627 }
628 return 0;
629}
630
605#define safe_syscall0(type, name) \
606static type safe_##name(void) \
607{ \
608 return safe_syscall(__NR_##name); \
609}
610
611#define safe_syscall1(type, name, type1, arg1) \
612static type safe_##name(type1 arg1) \

--- 35 unchanged lines hidden (view full) ---

648{ \
649 return safe_syscall(__NR_##name, arg1, arg2, arg3, arg4, arg5, arg6); \
650}
651
652safe_syscall3(ssize_t, read, int, fd, void *, buff, size_t, count)
653safe_syscall3(ssize_t, write, int, fd, const void *, buff, size_t, count)
654safe_syscall4(int, openat, int, dirfd, const char *, pathname, \
655 int, flags, mode_t, mode)
631#define safe_syscall0(type, name) \
632static type safe_##name(void) \
633{ \
634 return safe_syscall(__NR_##name); \
635}
636
637#define safe_syscall1(type, name, type1, arg1) \
638static type safe_##name(type1 arg1) \

--- 35 unchanged lines hidden (view full) ---

674{ \
675 return safe_syscall(__NR_##name, arg1, arg2, arg3, arg4, arg5, arg6); \
676}
677
678safe_syscall3(ssize_t, read, int, fd, void *, buff, size_t, count)
679safe_syscall3(ssize_t, write, int, fd, const void *, buff, size_t, count)
680safe_syscall4(int, openat, int, dirfd, const char *, pathname, \
681 int, flags, mode_t, mode)
682
683safe_syscall4(int, openat2, int, dirfd, const char *, pathname, \
684 const struct open_how_ver0 *, how, size_t, size)
685
656#if defined(TARGET_NR_wait4) || defined(TARGET_NR_waitpid)
657safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, \
658 struct rusage *, rusage)
659#endif
660safe_syscall5(int, waitid, idtype_t, idtype, id_t, id, siginfo_t *, infop, \
661 int, options, struct rusage *, rusage)
662safe_syscall3(int, execve, const char *, filename, char **, argv, char **, envp)
663safe_syscall5(int, execveat, int, dirfd, const char *, filename,

--- 90 unchanged lines hidden (view full) ---

754 unsigned int, flags)
755#endif
756
757/* We do ioctl like this rather than via safe_syscall3 to preserve the
758 * "third argument might be integer or pointer or not present" behaviour of
759 * the libc function.
760 */
761#define safe_ioctl(...) safe_syscall(__NR_ioctl, __VA_ARGS__)
686#if defined(TARGET_NR_wait4) || defined(TARGET_NR_waitpid)
687safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, \
688 struct rusage *, rusage)
689#endif
690safe_syscall5(int, waitid, idtype_t, idtype, id_t, id, siginfo_t *, infop, \
691 int, options, struct rusage *, rusage)
692safe_syscall3(int, execve, const char *, filename, char **, argv, char **, envp)
693safe_syscall5(int, execveat, int, dirfd, const char *, filename,

--- 90 unchanged lines hidden (view full) ---

784 unsigned int, flags)
785#endif
786
787/* We do ioctl like this rather than via safe_syscall3 to preserve the
788 * "third argument might be integer or pointer or not present" behaviour of
789 * the libc function.
790 */
791#define safe_ioctl(...) safe_syscall(__NR_ioctl, __VA_ARGS__)
762/* Similarly for fcntl. Note that callers must always:
763 * pass the F_GETLK64 etc constants rather than the unsuffixed F_GETLK
764 * use the flock64 struct rather than unsuffixed flock
765 * This will then work and use a 64-bit offset for both 32-bit and 64-bit hosts.
792/* Similarly for fcntl. Since we always build with LFS enabled,
793 * we should be using the 64-bit structures automatically.
766 */
767#ifdef __NR_fcntl64
768#define safe_fcntl(...) safe_syscall(__NR_fcntl64, __VA_ARGS__)
769#else
770#define safe_fcntl(...) safe_syscall(__NR_fcntl, __VA_ARGS__)
771#endif
772
773static inline int host_to_target_sock_type(int host_type)

--- 5943 unchanged lines hidden (view full) ---

6717 case TARGET_F_GETFL:
6718 case TARGET_F_SETFL:
6719 case TARGET_F_OFD_GETLK:
6720 case TARGET_F_OFD_SETLK:
6721 case TARGET_F_OFD_SETLKW:
6722 ret = cmd;
6723 break;
6724 case TARGET_F_GETLK:
794 */
795#ifdef __NR_fcntl64
796#define safe_fcntl(...) safe_syscall(__NR_fcntl64, __VA_ARGS__)
797#else
798#define safe_fcntl(...) safe_syscall(__NR_fcntl, __VA_ARGS__)
799#endif
800
801static inline int host_to_target_sock_type(int host_type)

--- 5943 unchanged lines hidden (view full) ---

6745 case TARGET_F_GETFL:
6746 case TARGET_F_SETFL:
6747 case TARGET_F_OFD_GETLK:
6748 case TARGET_F_OFD_SETLK:
6749 case TARGET_F_OFD_SETLKW:
6750 ret = cmd;
6751 break;
6752 case TARGET_F_GETLK:
6725 ret = F_GETLK64;
6753 ret = F_GETLK;
6726 break;
6727 case TARGET_F_SETLK:
6754 break;
6755 case TARGET_F_SETLK:
6728 ret = F_SETLK64;
6756 ret = F_SETLK;
6729 break;
6730 case TARGET_F_SETLKW:
6757 break;
6758 case TARGET_F_SETLKW:
6731 ret = F_SETLKW64;
6759 ret = F_SETLKW;
6732 break;
6733 case TARGET_F_GETOWN:
6734 ret = F_GETOWN;
6735 break;
6736 case TARGET_F_SETOWN:
6737 ret = F_SETOWN;
6738 break;
6739 case TARGET_F_GETSIG:
6740 ret = F_GETSIG;
6741 break;
6742 case TARGET_F_SETSIG:
6743 ret = F_SETSIG;
6744 break;
6745#if TARGET_ABI_BITS == 32
6746 case TARGET_F_GETLK64:
6760 break;
6761 case TARGET_F_GETOWN:
6762 ret = F_GETOWN;
6763 break;
6764 case TARGET_F_SETOWN:
6765 ret = F_SETOWN;
6766 break;
6767 case TARGET_F_GETSIG:
6768 ret = F_GETSIG;
6769 break;
6770 case TARGET_F_SETSIG:
6771 ret = F_SETSIG;
6772 break;
6773#if TARGET_ABI_BITS == 32
6774 case TARGET_F_GETLK64:
6747 ret = F_GETLK64;
6775 ret = F_GETLK;
6748 break;
6749 case TARGET_F_SETLK64:
6776 break;
6777 case TARGET_F_SETLK64:
6750 ret = F_SETLK64;
6778 ret = F_SETLK;
6751 break;
6752 case TARGET_F_SETLKW64:
6779 break;
6780 case TARGET_F_SETLKW64:
6753 ret = F_SETLKW64;
6781 ret = F_SETLKW;
6754 break;
6755#endif
6756 case TARGET_F_SETLEASE:
6757 ret = F_SETLEASE;
6758 break;
6759 case TARGET_F_GETLEASE:
6760 ret = F_GETLEASE;
6761 break;

--- 37 unchanged lines hidden (view full) ---

6799 }
6800
6801#if defined(__powerpc64__)
6802 /* On PPC64, glibc headers has the F_*LK* defined to 12, 13 and 14 and
6803 * is not supported by kernel. The glibc fcntl call actually adjusts
6804 * them to 5, 6 and 7 before making the syscall(). Since we make the
6805 * syscall directly, adjust to what is supported by the kernel.
6806 */
6782 break;
6783#endif
6784 case TARGET_F_SETLEASE:
6785 ret = F_SETLEASE;
6786 break;
6787 case TARGET_F_GETLEASE:
6788 ret = F_GETLEASE;
6789 break;

--- 37 unchanged lines hidden (view full) ---

6827 }
6828
6829#if defined(__powerpc64__)
6830 /* On PPC64, glibc headers has the F_*LK* defined to 12, 13 and 14 and
6831 * is not supported by kernel. The glibc fcntl call actually adjusts
6832 * them to 5, 6 and 7 before making the syscall(). Since we make the
6833 * syscall directly, adjust to what is supported by the kernel.
6834 */
6807 if (ret >= F_GETLK64 && ret <= F_SETLKW64) {
6808 ret -= F_GETLK64 - 5;
6835 if (ret >= F_GETLK && ret <= F_SETLKW) {
6836 ret -= F_GETLK - 5;
6809 }
6810#endif
6811
6812 return ret;
6813}
6814
6815#define FLOCK_TRANSTBL \
6816 switch (type) { \

--- 16 unchanged lines hidden (view full) ---

6833 FLOCK_TRANSTBL
6834#undef TRANSTBL_CONVERT
6835 /* if we don't know how to convert the value coming
6836 * from the host we copy to the target field as-is
6837 */
6838 return type;
6839}
6840
6837 }
6838#endif
6839
6840 return ret;
6841}
6842
6843#define FLOCK_TRANSTBL \
6844 switch (type) { \

--- 16 unchanged lines hidden (view full) ---

6861 FLOCK_TRANSTBL
6862#undef TRANSTBL_CONVERT
6863 /* if we don't know how to convert the value coming
6864 * from the host we copy to the target field as-is
6865 */
6866 return type;
6867}
6868
6841static inline abi_long copy_from_user_flock(struct flock64 *fl,
6869static inline abi_long copy_from_user_flock(struct flock *fl,
6842 abi_ulong target_flock_addr)
6843{
6844 struct target_flock *target_fl;
6845 int l_type;
6846
6847 if (!lock_user_struct(VERIFY_READ, target_fl, target_flock_addr, 1)) {
6848 return -TARGET_EFAULT;
6849 }

--- 8 unchanged lines hidden (view full) ---

6858 __get_user(fl->l_start, &target_fl->l_start);
6859 __get_user(fl->l_len, &target_fl->l_len);
6860 __get_user(fl->l_pid, &target_fl->l_pid);
6861 unlock_user_struct(target_fl, target_flock_addr, 0);
6862 return 0;
6863}
6864
6865static inline abi_long copy_to_user_flock(abi_ulong target_flock_addr,
6870 abi_ulong target_flock_addr)
6871{
6872 struct target_flock *target_fl;
6873 int l_type;
6874
6875 if (!lock_user_struct(VERIFY_READ, target_fl, target_flock_addr, 1)) {
6876 return -TARGET_EFAULT;
6877 }

--- 8 unchanged lines hidden (view full) ---

6886 __get_user(fl->l_start, &target_fl->l_start);
6887 __get_user(fl->l_len, &target_fl->l_len);
6888 __get_user(fl->l_pid, &target_fl->l_pid);
6889 unlock_user_struct(target_fl, target_flock_addr, 0);
6890 return 0;
6891}
6892
6893static inline abi_long copy_to_user_flock(abi_ulong target_flock_addr,
6866 const struct flock64 *fl)
6894 const struct flock *fl)
6867{
6868 struct target_flock *target_fl;
6869 short l_type;
6870
6871 if (!lock_user_struct(VERIFY_WRITE, target_fl, target_flock_addr, 0)) {
6872 return -TARGET_EFAULT;
6873 }
6874
6875 l_type = host_to_target_flock(fl->l_type);
6876 __put_user(l_type, &target_fl->l_type);
6877 __put_user(fl->l_whence, &target_fl->l_whence);
6878 __put_user(fl->l_start, &target_fl->l_start);
6879 __put_user(fl->l_len, &target_fl->l_len);
6880 __put_user(fl->l_pid, &target_fl->l_pid);
6881 unlock_user_struct(target_fl, target_flock_addr, 1);
6882 return 0;
6883}
6884
6895{
6896 struct target_flock *target_fl;
6897 short l_type;
6898
6899 if (!lock_user_struct(VERIFY_WRITE, target_fl, target_flock_addr, 0)) {
6900 return -TARGET_EFAULT;
6901 }
6902
6903 l_type = host_to_target_flock(fl->l_type);
6904 __put_user(l_type, &target_fl->l_type);
6905 __put_user(fl->l_whence, &target_fl->l_whence);
6906 __put_user(fl->l_start, &target_fl->l_start);
6907 __put_user(fl->l_len, &target_fl->l_len);
6908 __put_user(fl->l_pid, &target_fl->l_pid);
6909 unlock_user_struct(target_fl, target_flock_addr, 1);
6910 return 0;
6911}
6912
6885typedef abi_long from_flock64_fn(struct flock64 *fl, abi_ulong target_addr);
6886typedef abi_long to_flock64_fn(abi_ulong target_addr, const struct flock64 *fl);
6913typedef abi_long from_flock64_fn(struct flock *fl, abi_ulong target_addr);
6914typedef abi_long to_flock64_fn(abi_ulong target_addr, const struct flock *fl);
6887
6888#if defined(TARGET_ARM) && TARGET_ABI_BITS == 32
6889struct target_oabi_flock64 {
6890 abi_short l_type;
6891 abi_short l_whence;
6892 abi_llong l_start;
6893 abi_llong l_len;
6894 abi_int l_pid;
6895} QEMU_PACKED;
6896
6915
6916#if defined(TARGET_ARM) && TARGET_ABI_BITS == 32
6917struct target_oabi_flock64 {
6918 abi_short l_type;
6919 abi_short l_whence;
6920 abi_llong l_start;
6921 abi_llong l_len;
6922 abi_int l_pid;
6923} QEMU_PACKED;
6924
6897static inline abi_long copy_from_user_oabi_flock64(struct flock64 *fl,
6925static inline abi_long copy_from_user_oabi_flock64(struct flock *fl,
6898 abi_ulong target_flock_addr)
6899{
6900 struct target_oabi_flock64 *target_fl;
6901 int l_type;
6902
6903 if (!lock_user_struct(VERIFY_READ, target_fl, target_flock_addr, 1)) {
6904 return -TARGET_EFAULT;
6905 }

--- 8 unchanged lines hidden (view full) ---

6914 __get_user(fl->l_start, &target_fl->l_start);
6915 __get_user(fl->l_len, &target_fl->l_len);
6916 __get_user(fl->l_pid, &target_fl->l_pid);
6917 unlock_user_struct(target_fl, target_flock_addr, 0);
6918 return 0;
6919}
6920
6921static inline abi_long copy_to_user_oabi_flock64(abi_ulong target_flock_addr,
6926 abi_ulong target_flock_addr)
6927{
6928 struct target_oabi_flock64 *target_fl;
6929 int l_type;
6930
6931 if (!lock_user_struct(VERIFY_READ, target_fl, target_flock_addr, 1)) {
6932 return -TARGET_EFAULT;
6933 }

--- 8 unchanged lines hidden (view full) ---

6942 __get_user(fl->l_start, &target_fl->l_start);
6943 __get_user(fl->l_len, &target_fl->l_len);
6944 __get_user(fl->l_pid, &target_fl->l_pid);
6945 unlock_user_struct(target_fl, target_flock_addr, 0);
6946 return 0;
6947}
6948
6949static inline abi_long copy_to_user_oabi_flock64(abi_ulong target_flock_addr,
6922 const struct flock64 *fl)
6950 const struct flock *fl)
6923{
6924 struct target_oabi_flock64 *target_fl;
6925 short l_type;
6926
6927 if (!lock_user_struct(VERIFY_WRITE, target_fl, target_flock_addr, 0)) {
6928 return -TARGET_EFAULT;
6929 }
6930
6931 l_type = host_to_target_flock(fl->l_type);
6932 __put_user(l_type, &target_fl->l_type);
6933 __put_user(fl->l_whence, &target_fl->l_whence);
6934 __put_user(fl->l_start, &target_fl->l_start);
6935 __put_user(fl->l_len, &target_fl->l_len);
6936 __put_user(fl->l_pid, &target_fl->l_pid);
6937 unlock_user_struct(target_fl, target_flock_addr, 1);
6938 return 0;
6939}
6940#endif
6941
6951{
6952 struct target_oabi_flock64 *target_fl;
6953 short l_type;
6954
6955 if (!lock_user_struct(VERIFY_WRITE, target_fl, target_flock_addr, 0)) {
6956 return -TARGET_EFAULT;
6957 }
6958
6959 l_type = host_to_target_flock(fl->l_type);
6960 __put_user(l_type, &target_fl->l_type);
6961 __put_user(fl->l_whence, &target_fl->l_whence);
6962 __put_user(fl->l_start, &target_fl->l_start);
6963 __put_user(fl->l_len, &target_fl->l_len);
6964 __put_user(fl->l_pid, &target_fl->l_pid);
6965 unlock_user_struct(target_fl, target_flock_addr, 1);
6966 return 0;
6967}
6968#endif
6969
6942static inline abi_long copy_from_user_flock64(struct flock64 *fl,
6970static inline abi_long copy_from_user_flock64(struct flock *fl,
6943 abi_ulong target_flock_addr)
6944{
6945 struct target_flock64 *target_fl;
6946 int l_type;
6947
6948 if (!lock_user_struct(VERIFY_READ, target_fl, target_flock_addr, 1)) {
6949 return -TARGET_EFAULT;
6950 }

--- 8 unchanged lines hidden (view full) ---

6959 __get_user(fl->l_start, &target_fl->l_start);
6960 __get_user(fl->l_len, &target_fl->l_len);
6961 __get_user(fl->l_pid, &target_fl->l_pid);
6962 unlock_user_struct(target_fl, target_flock_addr, 0);
6963 return 0;
6964}
6965
6966static inline abi_long copy_to_user_flock64(abi_ulong target_flock_addr,
6971 abi_ulong target_flock_addr)
6972{
6973 struct target_flock64 *target_fl;
6974 int l_type;
6975
6976 if (!lock_user_struct(VERIFY_READ, target_fl, target_flock_addr, 1)) {
6977 return -TARGET_EFAULT;
6978 }

--- 8 unchanged lines hidden (view full) ---

6987 __get_user(fl->l_start, &target_fl->l_start);
6988 __get_user(fl->l_len, &target_fl->l_len);
6989 __get_user(fl->l_pid, &target_fl->l_pid);
6990 unlock_user_struct(target_fl, target_flock_addr, 0);
6991 return 0;
6992}
6993
6994static inline abi_long copy_to_user_flock64(abi_ulong target_flock_addr,
6967 const struct flock64 *fl)
6995 const struct flock *fl)
6968{
6969 struct target_flock64 *target_fl;
6970 short l_type;
6971
6972 if (!lock_user_struct(VERIFY_WRITE, target_fl, target_flock_addr, 0)) {
6973 return -TARGET_EFAULT;
6974 }
6975

--- 4 unchanged lines hidden (view full) ---

6980 __put_user(fl->l_len, &target_fl->l_len);
6981 __put_user(fl->l_pid, &target_fl->l_pid);
6982 unlock_user_struct(target_fl, target_flock_addr, 1);
6983 return 0;
6984}
6985
6986static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)
6987{
6996{
6997 struct target_flock64 *target_fl;
6998 short l_type;
6999
7000 if (!lock_user_struct(VERIFY_WRITE, target_fl, target_flock_addr, 0)) {
7001 return -TARGET_EFAULT;
7002 }
7003

--- 4 unchanged lines hidden (view full) ---

7008 __put_user(fl->l_len, &target_fl->l_len);
7009 __put_user(fl->l_pid, &target_fl->l_pid);
7010 unlock_user_struct(target_fl, target_flock_addr, 1);
7011 return 0;
7012}
7013
7014static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)
7015{
6988 struct flock64 fl64;
7016 struct flock fl;
6989#ifdef F_GETOWN_EX
6990 struct f_owner_ex fox;
6991 struct target_f_owner_ex *target_fox;
6992#endif
6993 abi_long ret;
6994 int host_cmd = target_to_host_fcntl_cmd(cmd);
6995
6996 if (host_cmd == -TARGET_EINVAL)
6997 return host_cmd;
6998
6999 switch(cmd) {
7000 case TARGET_F_GETLK:
7017#ifdef F_GETOWN_EX
7018 struct f_owner_ex fox;
7019 struct target_f_owner_ex *target_fox;
7020#endif
7021 abi_long ret;
7022 int host_cmd = target_to_host_fcntl_cmd(cmd);
7023
7024 if (host_cmd == -TARGET_EINVAL)
7025 return host_cmd;
7026
7027 switch(cmd) {
7028 case TARGET_F_GETLK:
7001 ret = copy_from_user_flock(&fl64, arg);
7029 ret = copy_from_user_flock(&fl, arg);
7002 if (ret) {
7003 return ret;
7004 }
7030 if (ret) {
7031 return ret;
7032 }
7005 ret = get_errno(safe_fcntl(fd, host_cmd, &fl64));
7033 ret = get_errno(safe_fcntl(fd, host_cmd, &fl));
7006 if (ret == 0) {
7034 if (ret == 0) {
7007 ret = copy_to_user_flock(arg, &fl64);
7035 ret = copy_to_user_flock(arg, &fl);
7008 }
7009 break;
7010
7011 case TARGET_F_SETLK:
7012 case TARGET_F_SETLKW:
7036 }
7037 break;
7038
7039 case TARGET_F_SETLK:
7040 case TARGET_F_SETLKW:
7013 ret = copy_from_user_flock(&fl64, arg);
7041 ret = copy_from_user_flock(&fl, arg);
7014 if (ret) {
7015 return ret;
7016 }
7042 if (ret) {
7043 return ret;
7044 }
7017 ret = get_errno(safe_fcntl(fd, host_cmd, &fl64));
7045 ret = get_errno(safe_fcntl(fd, host_cmd, &fl));
7018 break;
7019
7020 case TARGET_F_GETLK64:
7021 case TARGET_F_OFD_GETLK:
7046 break;
7047
7048 case TARGET_F_GETLK64:
7049 case TARGET_F_OFD_GETLK:
7022 ret = copy_from_user_flock64(&fl64, arg);
7050 ret = copy_from_user_flock64(&fl, arg);
7023 if (ret) {
7024 return ret;
7025 }
7051 if (ret) {
7052 return ret;
7053 }
7026 ret = get_errno(safe_fcntl(fd, host_cmd, &fl64));
7054 ret = get_errno(safe_fcntl(fd, host_cmd, &fl));
7027 if (ret == 0) {
7055 if (ret == 0) {
7028 ret = copy_to_user_flock64(arg, &fl64);
7056 ret = copy_to_user_flock64(arg, &fl);
7029 }
7030 break;
7031 case TARGET_F_SETLK64:
7032 case TARGET_F_SETLKW64:
7033 case TARGET_F_OFD_SETLK:
7034 case TARGET_F_OFD_SETLKW:
7057 }
7058 break;
7059 case TARGET_F_SETLK64:
7060 case TARGET_F_SETLKW64:
7061 case TARGET_F_OFD_SETLK:
7062 case TARGET_F_OFD_SETLKW:
7035 ret = copy_from_user_flock64(&fl64, arg);
7063 ret = copy_from_user_flock64(&fl, arg);
7036 if (ret) {
7037 return ret;
7038 }
7064 if (ret) {
7065 return ret;
7066 }
7039 ret = get_errno(safe_fcntl(fd, host_cmd, &fl64));
7067 ret = get_errno(safe_fcntl(fd, host_cmd, &fl));
7040 break;
7041
7042 case TARGET_F_GETFL:
7043 ret = get_errno(safe_fcntl(fd, host_cmd, arg));
7044 if (ret >= 0) {
7045 ret = host_to_target_bitmask(ret, fcntl_flags_tbl);
7046 /* tell 32-bit guests it uses largefile on 64-bit hosts: */
7047 if (O_LARGEFILE == 0 && HOST_LONG_BITS == 64) {

--- 226 unchanged lines hidden (view full) ---

7274 abi_long arg2,
7275 abi_long arg3,
7276 abi_long arg4)
7277{
7278 if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) {
7279 arg2 = arg3;
7280 arg3 = arg4;
7281 }
7068 break;
7069
7070 case TARGET_F_GETFL:
7071 ret = get_errno(safe_fcntl(fd, host_cmd, arg));
7072 if (ret >= 0) {
7073 ret = host_to_target_bitmask(ret, fcntl_flags_tbl);
7074 /* tell 32-bit guests it uses largefile on 64-bit hosts: */
7075 if (O_LARGEFILE == 0 && HOST_LONG_BITS == 64) {

--- 226 unchanged lines hidden (view full) ---

7302 abi_long arg2,
7303 abi_long arg3,
7304 abi_long arg4)
7305{
7306 if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) {
7307 arg2 = arg3;
7308 arg3 = arg4;
7309 }
7282 return get_errno(truncate64(arg1, target_offset64(arg2, arg3)));
7310 return get_errno(truncate(arg1, target_offset64(arg2, arg3)));
7283}
7284#endif
7285
7286#ifdef TARGET_NR_ftruncate64
7287static inline abi_long target_ftruncate64(CPUArchState *cpu_env, abi_long arg1,
7288 abi_long arg2,
7289 abi_long arg3,
7290 abi_long arg4)
7291{
7292 if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) {
7293 arg2 = arg3;
7294 arg3 = arg4;
7295 }
7311}
7312#endif
7313
7314#ifdef TARGET_NR_ftruncate64
7315static inline abi_long target_ftruncate64(CPUArchState *cpu_env, abi_long arg1,
7316 abi_long arg2,
7317 abi_long arg3,
7318 abi_long arg4)
7319{
7320 if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) {
7321 arg2 = arg3;
7322 arg3 = arg4;
7323 }
7296 return get_errno(ftruncate64(arg1, target_offset64(arg2, arg3)));
7324 return get_errno(ftruncate(arg1, target_offset64(arg2, arg3)));
7297}
7298#endif
7299
7300#if defined(TARGET_NR_timer_settime) || \
7301 (defined(TARGET_NR_timerfd_settime) && defined(CONFIG_TIMERFD))
7302static inline abi_long target_to_host_itimerspec(struct itimerspec *host_its,
7303 abi_ulong target_addr)
7304{

--- 1038 unchanged lines hidden (view full) ---

8343
8344 free(line);
8345 fclose(fp);
8346
8347 return 0;
8348}
8349#endif
8350
7325}
7326#endif
7327
7328#if defined(TARGET_NR_timer_settime) || \
7329 (defined(TARGET_NR_timerfd_settime) && defined(CONFIG_TIMERFD))
7330static inline abi_long target_to_host_itimerspec(struct itimerspec *host_its,
7331 abi_ulong target_addr)
7332{

--- 1038 unchanged lines hidden (view full) ---

8371
8372 free(line);
8373 fclose(fp);
8374
8375 return 0;
8376}
8377#endif
8378
8351int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *fname,
8352 int flags, mode_t mode, bool safe)
8379static int maybe_do_fake_open(CPUArchState *cpu_env, int dirfd,
8380 const char *fname, int flags, mode_t mode,
8381 int openat2_resolve, bool safe)
8353{
8354 g_autofree char *proc_name = NULL;
8355 const char *pathname;
8356 struct fake_open {
8357 const char *filename;
8358 int (*fill)(CPUArchState *cpu_env, int fd);
8359 int (*cmp)(const char *s1, const char *s2);
8360 };

--- 20 unchanged lines hidden (view full) ---

8381 proc_name = realpath(fname, NULL);
8382 if (proc_name && strncmp(proc_name, "/proc/", 6) == 0) {
8383 pathname = proc_name;
8384 } else {
8385 pathname = fname;
8386 }
8387
8388 if (is_proc_myself(pathname, "exe")) {
8382{
8383 g_autofree char *proc_name = NULL;
8384 const char *pathname;
8385 struct fake_open {
8386 const char *filename;
8387 int (*fill)(CPUArchState *cpu_env, int fd);
8388 int (*cmp)(const char *s1, const char *s2);
8389 };

--- 20 unchanged lines hidden (view full) ---

8410 proc_name = realpath(fname, NULL);
8411 if (proc_name && strncmp(proc_name, "/proc/", 6) == 0) {
8412 pathname = proc_name;
8413 } else {
8414 pathname = fname;
8415 }
8416
8417 if (is_proc_myself(pathname, "exe")) {
8418 /* Honor openat2 resolve flags */
8419 if ((openat2_resolve & RESOLVE_NO_MAGICLINKS) ||
8420 (openat2_resolve & RESOLVE_NO_SYMLINKS)) {
8421 errno = ELOOP;
8422 return -1;
8423 }
8389 if (safe) {
8390 return safe_openat(dirfd, exec_path, flags, mode);
8391 } else {
8392 return openat(dirfd, exec_path, flags, mode);
8393 }
8394 }
8395
8396 for (fake_open = fakes; fake_open->filename; fake_open++) {

--- 30 unchanged lines hidden (view full) ---

8427 errno = e;
8428 return r;
8429 }
8430 lseek(fd, 0, SEEK_SET);
8431
8432 return fd;
8433 }
8434
8424 if (safe) {
8425 return safe_openat(dirfd, exec_path, flags, mode);
8426 } else {
8427 return openat(dirfd, exec_path, flags, mode);
8428 }
8429 }
8430
8431 for (fake_open = fakes; fake_open->filename; fake_open++) {

--- 30 unchanged lines hidden (view full) ---

8462 errno = e;
8463 return r;
8464 }
8465 lseek(fd, 0, SEEK_SET);
8466
8467 return fd;
8468 }
8469
8470 return -2;
8471}
8472
8473int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname,
8474 int flags, mode_t mode, bool safe)
8475{
8476 int fd = maybe_do_fake_open(cpu_env, dirfd, pathname, flags, mode, 0, safe);
8477 if (fd > -2) {
8478 return fd;
8479 }
8480
8435 if (safe) {
8436 return safe_openat(dirfd, path(pathname), flags, mode);
8437 } else {
8438 return openat(dirfd, path(pathname), flags, mode);
8439 }
8440}
8441
8481 if (safe) {
8482 return safe_openat(dirfd, path(pathname), flags, mode);
8483 } else {
8484 return openat(dirfd, path(pathname), flags, mode);
8485 }
8486}
8487
8488
8489static int do_openat2(CPUArchState *cpu_env, abi_long dirfd,
8490 abi_ptr guest_pathname, abi_ptr guest_open_how,
8491 abi_ulong guest_size)
8492{
8493 struct open_how_ver0 how = {0};
8494 char *pathname;
8495 int ret;
8496
8497 if (guest_size < sizeof(struct target_open_how_ver0)) {
8498 return -TARGET_EINVAL;
8499 }
8500 ret = copy_struct_from_user(&how, sizeof(how), guest_open_how, guest_size);
8501 if (ret) {
8502 if (ret == -TARGET_E2BIG) {
8503 qemu_log_mask(LOG_UNIMP,
8504 "Unimplemented openat2 open_how size: "
8505 TARGET_ABI_FMT_lu "\n", guest_size);
8506 }
8507 return ret;
8508 }
8509 pathname = lock_user_string(guest_pathname);
8510 if (!pathname) {
8511 return -TARGET_EFAULT;
8512 }
8513
8514 how.flags = target_to_host_bitmask(tswap64(how.flags), fcntl_flags_tbl);
8515 how.mode = tswap64(how.mode);
8516 how.resolve = tswap64(how.resolve);
8517 int fd = maybe_do_fake_open(cpu_env, dirfd, pathname, how.flags, how.mode,
8518 how.resolve, true);
8519 if (fd > -2) {
8520 ret = get_errno(fd);
8521 } else {
8522 ret = get_errno(safe_openat2(dirfd, pathname, &how,
8523 sizeof(struct open_how_ver0)));
8524 }
8525
8526 fd_trans_unregister(ret);
8527 unlock_user(pathname, guest_pathname, 0);
8528 return ret;
8529}
8530
8442ssize_t do_guest_readlink(const char *pathname, char *buf, size_t bufsiz)
8443{
8444 ssize_t ret;
8445
8446 if (!pathname || !buf) {
8447 errno = EFAULT;
8448 return -1;
8449 }

--- 225 unchanged lines hidden (view full) ---

8675
8676#ifdef TARGET_NR_getdents
8677static int do_getdents(abi_long dirfd, abi_long arg2, abi_long count)
8678{
8679 g_autofree void *hdirp = NULL;
8680 void *tdirp;
8681 int hlen, hoff, toff;
8682 int hreclen, treclen;
8531ssize_t do_guest_readlink(const char *pathname, char *buf, size_t bufsiz)
8532{
8533 ssize_t ret;
8534
8535 if (!pathname || !buf) {
8536 errno = EFAULT;
8537 return -1;
8538 }

--- 225 unchanged lines hidden (view full) ---

8764
8765#ifdef TARGET_NR_getdents
8766static int do_getdents(abi_long dirfd, abi_long arg2, abi_long count)
8767{
8768 g_autofree void *hdirp = NULL;
8769 void *tdirp;
8770 int hlen, hoff, toff;
8771 int hreclen, treclen;
8683 off64_t prev_diroff = 0;
8772 off_t prev_diroff = 0;
8684
8685 hdirp = g_try_malloc(count);
8686 if (!hdirp) {
8687 return -TARGET_ENOMEM;
8688 }
8689
8690#ifdef EMULATE_GETDENTS_WITH_GETDENTS
8691 hlen = sys_getdents(dirfd, hdirp, count);

--- 36 unchanged lines hidden (view full) ---

8728 if (toff == 0) {
8729 toff = -TARGET_EINVAL; /* result buffer is too small */
8730 break;
8731 }
8732 /*
8733 * Return what we have, resetting the file pointer to the
8734 * location of the first record not returned.
8735 */
8773
8774 hdirp = g_try_malloc(count);
8775 if (!hdirp) {
8776 return -TARGET_ENOMEM;
8777 }
8778
8779#ifdef EMULATE_GETDENTS_WITH_GETDENTS
8780 hlen = sys_getdents(dirfd, hdirp, count);

--- 36 unchanged lines hidden (view full) ---

8817 if (toff == 0) {
8818 toff = -TARGET_EINVAL; /* result buffer is too small */
8819 break;
8820 }
8821 /*
8822 * Return what we have, resetting the file pointer to the
8823 * location of the first record not returned.
8824 */
8736 lseek64(dirfd, prev_diroff, SEEK_SET);
8825 lseek(dirfd, prev_diroff, SEEK_SET);
8737 break;
8738 }
8739
8740 prev_diroff = hde->d_off;
8741 tde->d_ino = tswapal(hde->d_ino);
8742 tde->d_off = tswapal(hde->d_off);
8743 tde->d_reclen = tswap16(treclen);
8744 memcpy(tde->d_name, hde->d_name, namelen + 1);

--- 17 unchanged lines hidden (view full) ---

8762
8763#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)
8764static int do_getdents64(abi_long dirfd, abi_long arg2, abi_long count)
8765{
8766 g_autofree void *hdirp = NULL;
8767 void *tdirp;
8768 int hlen, hoff, toff;
8769 int hreclen, treclen;
8826 break;
8827 }
8828
8829 prev_diroff = hde->d_off;
8830 tde->d_ino = tswapal(hde->d_ino);
8831 tde->d_off = tswapal(hde->d_off);
8832 tde->d_reclen = tswap16(treclen);
8833 memcpy(tde->d_name, hde->d_name, namelen + 1);

--- 17 unchanged lines hidden (view full) ---

8851
8852#if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)
8853static int do_getdents64(abi_long dirfd, abi_long arg2, abi_long count)
8854{
8855 g_autofree void *hdirp = NULL;
8856 void *tdirp;
8857 int hlen, hoff, toff;
8858 int hreclen, treclen;
8770 off64_t prev_diroff = 0;
8859 off_t prev_diroff = 0;
8771
8772 hdirp = g_try_malloc(count);
8773 if (!hdirp) {
8774 return -TARGET_ENOMEM;
8775 }
8776
8777 hlen = get_errno(sys_getdents64(dirfd, hdirp, count));
8778 if (is_error(hlen)) {

--- 25 unchanged lines hidden (view full) ---

8804 if (toff == 0) {
8805 toff = -TARGET_EINVAL; /* result buffer is too small */
8806 break;
8807 }
8808 /*
8809 * Return what we have, resetting the file pointer to the
8810 * location of the first record not returned.
8811 */
8860
8861 hdirp = g_try_malloc(count);
8862 if (!hdirp) {
8863 return -TARGET_ENOMEM;
8864 }
8865
8866 hlen = get_errno(sys_getdents64(dirfd, hdirp, count));
8867 if (is_error(hlen)) {

--- 25 unchanged lines hidden (view full) ---

8893 if (toff == 0) {
8894 toff = -TARGET_EINVAL; /* result buffer is too small */
8895 break;
8896 }
8897 /*
8898 * Return what we have, resetting the file pointer to the
8899 * location of the first record not returned.
8900 */
8812 lseek64(dirfd, prev_diroff, SEEK_SET);
8901 lseek(dirfd, prev_diroff, SEEK_SET);
8813 break;
8814 }
8815
8816 prev_diroff = hde->d_off;
8817 tde->d_ino = tswap64(hde->d_ino);
8818 tde->d_off = tswap64(hde->d_off);
8819 tde->d_reclen = tswap16(treclen);
8820 tde->d_type = hde->d_type;

--- 385 unchanged lines hidden (view full) ---

9206 if (!(p = lock_user_string(arg2)))
9207 return -TARGET_EFAULT;
9208 ret = get_errno(do_guest_openat(cpu_env, arg1, p,
9209 target_to_host_bitmask(arg3, fcntl_flags_tbl),
9210 arg4, true));
9211 fd_trans_unregister(ret);
9212 unlock_user(p, arg2, 0);
9213 return ret;
8902 break;
8903 }
8904
8905 prev_diroff = hde->d_off;
8906 tde->d_ino = tswap64(hde->d_ino);
8907 tde->d_off = tswap64(hde->d_off);
8908 tde->d_reclen = tswap16(treclen);
8909 tde->d_type = hde->d_type;

--- 385 unchanged lines hidden (view full) ---

9295 if (!(p = lock_user_string(arg2)))
9296 return -TARGET_EFAULT;
9297 ret = get_errno(do_guest_openat(cpu_env, arg1, p,
9298 target_to_host_bitmask(arg3, fcntl_flags_tbl),
9299 arg4, true));
9300 fd_trans_unregister(ret);
9301 unlock_user(p, arg2, 0);
9302 return ret;
9303 case TARGET_NR_openat2:
9304 ret = do_openat2(cpu_env, arg1, arg2, arg3, arg4);
9305 return ret;
9214#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
9215 case TARGET_NR_name_to_handle_at:
9216 ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5);
9217 return ret;
9218#endif
9219#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
9220 case TARGET_NR_open_by_handle_at:
9221 ret = do_open_by_handle_at(arg1, arg2, arg3);

--- 1269 unchanged lines hidden (view full) ---

10491 ret = get_errno(reboot(arg1, arg2, arg3, p));
10492 unlock_user(p, arg4, 0);
10493 } else {
10494 ret = get_errno(reboot(arg1, arg2, arg3, NULL));
10495 }
10496 return ret;
10497#ifdef TARGET_NR_mmap
10498 case TARGET_NR_mmap:
9306#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
9307 case TARGET_NR_name_to_handle_at:
9308 ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5);
9309 return ret;
9310#endif
9311#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
9312 case TARGET_NR_open_by_handle_at:
9313 ret = do_open_by_handle_at(arg1, arg2, arg3);

--- 1269 unchanged lines hidden (view full) ---

10583 ret = get_errno(reboot(arg1, arg2, arg3, p));
10584 unlock_user(p, arg4, 0);
10585 } else {
10586 ret = get_errno(reboot(arg1, arg2, arg3, NULL));
10587 }
10588 return ret;
10589#ifdef TARGET_NR_mmap
10590 case TARGET_NR_mmap:
10499#if (defined(TARGET_I386) && defined(TARGET_ABI32)) || \
10500 (defined(TARGET_ARM) && defined(TARGET_ABI32)) || \
10501 defined(TARGET_M68K) || defined(TARGET_CRIS) || defined(TARGET_MICROBLAZE) \
10502 || defined(TARGET_S390X)
10591#ifdef TARGET_ARCH_WANT_SYS_OLD_MMAP
10503 {
10504 abi_ulong *v;
10505 abi_ulong v1, v2, v3, v4, v5, v6;
10506 if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1)))
10507 return -TARGET_EFAULT;
10508 v1 = tswapal(v[0]);
10509 v2 = tswapal(v[1]);
10510 v3 = tswapal(v[2]);

--- 1024 unchanged lines hidden (view full) ---

11535 /* Special-case NULL buffer and zero length, which should succeed */
11536 p = 0;
11537 } else {
11538 p = lock_user(VERIFY_WRITE, arg2, arg3, 0);
11539 if (!p) {
11540 return -TARGET_EFAULT;
11541 }
11542 }
10592 {
10593 abi_ulong *v;
10594 abi_ulong v1, v2, v3, v4, v5, v6;
10595 if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1)))
10596 return -TARGET_EFAULT;
10597 v1 = tswapal(v[0]);
10598 v2 = tswapal(v[1]);
10599 v3 = tswapal(v[2]);

--- 1024 unchanged lines hidden (view full) ---

11624 /* Special-case NULL buffer and zero length, which should succeed */
11625 p = 0;
11626 } else {
11627 p = lock_user(VERIFY_WRITE, arg2, arg3, 0);
11628 if (!p) {
11629 return -TARGET_EFAULT;
11630 }
11631 }
11543 ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5)));
11632 ret = get_errno(pread(arg1, p, arg3, target_offset64(arg4, arg5)));
11544 unlock_user(p, arg2, ret);
11545 return ret;
11546 case TARGET_NR_pwrite64:
11547 if (regpairs_aligned(cpu_env, num)) {
11548 arg4 = arg5;
11549 arg5 = arg6;
11550 }
11551 if (arg2 == 0 && arg3 == 0) {
11552 /* Special-case NULL buffer and zero length, which should succeed */
11553 p = 0;
11554 } else {
11555 p = lock_user(VERIFY_READ, arg2, arg3, 1);
11556 if (!p) {
11557 return -TARGET_EFAULT;
11558 }
11559 }
11633 unlock_user(p, arg2, ret);
11634 return ret;
11635 case TARGET_NR_pwrite64:
11636 if (regpairs_aligned(cpu_env, num)) {
11637 arg4 = arg5;
11638 arg5 = arg6;
11639 }
11640 if (arg2 == 0 && arg3 == 0) {
11641 /* Special-case NULL buffer and zero length, which should succeed */
11642 p = 0;
11643 } else {
11644 p = lock_user(VERIFY_READ, arg2, arg3, 1);
11645 if (!p) {
11646 return -TARGET_EFAULT;
11647 }
11648 }
11560 ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5)));
11649 ret = get_errno(pwrite(arg1, p, arg3, target_offset64(arg4, arg5)));
11561 unlock_user(p, arg2, 0);
11562 return ret;
11563#endif
11564 case TARGET_NR_getcwd:
11565 if (!(p = lock_user(VERIFY_WRITE, arg1, arg2, 0)))
11566 return -TARGET_EFAULT;
11567 ret = get_errno(sys_getcwd1(p, arg2));
11568 unlock_user(p, arg1, ret);

--- 843 unchanged lines hidden (view full) ---

12412#ifdef TARGET_NR_madvise
12413 case TARGET_NR_madvise:
12414 return target_madvise(arg1, arg2, arg3);
12415#endif
12416#ifdef TARGET_NR_fcntl64
12417 case TARGET_NR_fcntl64:
12418 {
12419 int cmd;
11650 unlock_user(p, arg2, 0);
11651 return ret;
11652#endif
11653 case TARGET_NR_getcwd:
11654 if (!(p = lock_user(VERIFY_WRITE, arg1, arg2, 0)))
11655 return -TARGET_EFAULT;
11656 ret = get_errno(sys_getcwd1(p, arg2));
11657 unlock_user(p, arg1, ret);

--- 843 unchanged lines hidden (view full) ---

12501#ifdef TARGET_NR_madvise
12502 case TARGET_NR_madvise:
12503 return target_madvise(arg1, arg2, arg3);
12504#endif
12505#ifdef TARGET_NR_fcntl64
12506 case TARGET_NR_fcntl64:
12507 {
12508 int cmd;
12420 struct flock64 fl;
12509 struct flock fl;
12421 from_flock64_fn *copyfrom = copy_from_user_flock64;
12422 to_flock64_fn *copyto = copy_to_user_flock64;
12423
12424#ifdef TARGET_ARM
12425 if (!cpu_env->eabi) {
12426 copyfrom = copy_from_user_oabi_flock64;
12427 copyto = copy_to_user_oabi_flock64;
12428 }

--- 218 unchanged lines hidden (view full) ---

12647 return ret;
12648#endif
12649#endif /* CONFIG_ATTR */
12650#ifdef TARGET_NR_set_thread_area
12651 case TARGET_NR_set_thread_area:
12652#if defined(TARGET_MIPS)
12653 cpu_env->active_tc.CP0_UserLocal = arg1;
12654 return 0;
12510 from_flock64_fn *copyfrom = copy_from_user_flock64;
12511 to_flock64_fn *copyto = copy_to_user_flock64;
12512
12513#ifdef TARGET_ARM
12514 if (!cpu_env->eabi) {
12515 copyfrom = copy_from_user_oabi_flock64;
12516 copyto = copy_to_user_oabi_flock64;
12517 }

--- 218 unchanged lines hidden (view full) ---

12736 return ret;
12737#endif
12738#endif /* CONFIG_ATTR */
12739#ifdef TARGET_NR_set_thread_area
12740 case TARGET_NR_set_thread_area:
12741#if defined(TARGET_MIPS)
12742 cpu_env->active_tc.CP0_UserLocal = arg1;
12743 return 0;
12655#elif defined(TARGET_CRIS)
12656 if (arg1 & 0xff)
12657 ret = -TARGET_EINVAL;
12658 else {
12659 cpu_env->pregs[PR_PID] = arg1;
12660 ret = 0;
12661 }
12662 return ret;
12663#elif defined(TARGET_I386) && defined(TARGET_ABI32)
12664 return do_set_thread_area(cpu_env, arg1);
12665#elif defined(TARGET_M68K)
12666 {
12667 TaskState *ts = get_task_state(cpu);
12668 ts->tp_value = arg1;
12669 return 0;
12670 }

--- 1141 unchanged lines hidden ---
12744#elif defined(TARGET_I386) && defined(TARGET_ABI32)
12745 return do_set_thread_area(cpu_env, arg1);
12746#elif defined(TARGET_M68K)
12747 {
12748 TaskState *ts = get_task_state(cpu);
12749 ts->tp_value = arg1;
12750 return 0;
12751 }

--- 1141 unchanged lines hidden ---