18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _LINUX_COMPAT_H
38c2ecf20Sopenharmony_ci#define _LINUX_COMPAT_H
48c2ecf20Sopenharmony_ci/*
58c2ecf20Sopenharmony_ci * These are the type definitions for the architecture specific
68c2ecf20Sopenharmony_ci * syscall compatibility layer.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/types.h>
108c2ecf20Sopenharmony_ci#include <linux/time.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/stat.h>
138c2ecf20Sopenharmony_ci#include <linux/param.h>	/* for HZ */
148c2ecf20Sopenharmony_ci#include <linux/sem.h>
158c2ecf20Sopenharmony_ci#include <linux/socket.h>
168c2ecf20Sopenharmony_ci#include <linux/if.h>
178c2ecf20Sopenharmony_ci#include <linux/fs.h>
188c2ecf20Sopenharmony_ci#include <linux/aio_abi.h>	/* for aio_context_t */
198c2ecf20Sopenharmony_ci#include <linux/uaccess.h>
208c2ecf20Sopenharmony_ci#include <linux/unistd.h>
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#include <asm/compat.h>
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#ifdef CONFIG_COMPAT
258c2ecf20Sopenharmony_ci#include <asm/siginfo.h>
268c2ecf20Sopenharmony_ci#include <asm/signal.h>
278c2ecf20Sopenharmony_ci#endif
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
308c2ecf20Sopenharmony_ci/*
318c2ecf20Sopenharmony_ci * It may be useful for an architecture to override the definitions of the
328c2ecf20Sopenharmony_ci * COMPAT_SYSCALL_DEFINE0 and COMPAT_SYSCALL_DEFINEx() macros, in particular
338c2ecf20Sopenharmony_ci * to use a different calling convention for syscalls. To allow for that,
348c2ecf20Sopenharmony_ci + the prototypes for the compat_sys_*() functions below will *not* be included
358c2ecf20Sopenharmony_ci * if CONFIG_ARCH_HAS_SYSCALL_WRAPPER is enabled.
368c2ecf20Sopenharmony_ci */
378c2ecf20Sopenharmony_ci#include <asm/syscall_wrapper.h>
388c2ecf20Sopenharmony_ci#endif /* CONFIG_ARCH_HAS_SYSCALL_WRAPPER */
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#ifndef COMPAT_USE_64BIT_TIME
418c2ecf20Sopenharmony_ci#define COMPAT_USE_64BIT_TIME 0
428c2ecf20Sopenharmony_ci#endif
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#ifndef __SC_DELOUSE
458c2ecf20Sopenharmony_ci#define __SC_DELOUSE(t,v) ((__force t)(unsigned long)(v))
468c2ecf20Sopenharmony_ci#endif
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#ifndef COMPAT_SYSCALL_DEFINE0
498c2ecf20Sopenharmony_ci#define COMPAT_SYSCALL_DEFINE0(name) \
508c2ecf20Sopenharmony_ci	asmlinkage long compat_sys_##name(void); \
518c2ecf20Sopenharmony_ci	ALLOW_ERROR_INJECTION(compat_sys_##name, ERRNO); \
528c2ecf20Sopenharmony_ci	asmlinkage long compat_sys_##name(void)
538c2ecf20Sopenharmony_ci#endif /* COMPAT_SYSCALL_DEFINE0 */
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#define COMPAT_SYSCALL_DEFINE1(name, ...) \
568c2ecf20Sopenharmony_ci        COMPAT_SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
578c2ecf20Sopenharmony_ci#define COMPAT_SYSCALL_DEFINE2(name, ...) \
588c2ecf20Sopenharmony_ci	COMPAT_SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
598c2ecf20Sopenharmony_ci#define COMPAT_SYSCALL_DEFINE3(name, ...) \
608c2ecf20Sopenharmony_ci	COMPAT_SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
618c2ecf20Sopenharmony_ci#define COMPAT_SYSCALL_DEFINE4(name, ...) \
628c2ecf20Sopenharmony_ci	COMPAT_SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
638c2ecf20Sopenharmony_ci#define COMPAT_SYSCALL_DEFINE5(name, ...) \
648c2ecf20Sopenharmony_ci	COMPAT_SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
658c2ecf20Sopenharmony_ci#define COMPAT_SYSCALL_DEFINE6(name, ...) \
668c2ecf20Sopenharmony_ci	COMPAT_SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci/*
698c2ecf20Sopenharmony_ci * The asmlinkage stub is aliased to a function named __se_compat_sys_*() which
708c2ecf20Sopenharmony_ci * sign-extends 32-bit ints to longs whenever needed. The actual work is
718c2ecf20Sopenharmony_ci * done within __do_compat_sys_*().
728c2ecf20Sopenharmony_ci */
738c2ecf20Sopenharmony_ci#ifndef COMPAT_SYSCALL_DEFINEx
748c2ecf20Sopenharmony_ci#define COMPAT_SYSCALL_DEFINEx(x, name, ...)					\
758c2ecf20Sopenharmony_ci	__diag_push();								\
768c2ecf20Sopenharmony_ci	__diag_ignore(GCC, 8, "-Wattribute-alias",				\
778c2ecf20Sopenharmony_ci		      "Type aliasing is used to sanitize syscall arguments");\
788c2ecf20Sopenharmony_ci	asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));	\
798c2ecf20Sopenharmony_ci	asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))	\
808c2ecf20Sopenharmony_ci		__attribute__((alias(__stringify(__se_compat_sys##name))));	\
818c2ecf20Sopenharmony_ci	ALLOW_ERROR_INJECTION(compat_sys##name, ERRNO);				\
828c2ecf20Sopenharmony_ci	static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
838c2ecf20Sopenharmony_ci	asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__));	\
848c2ecf20Sopenharmony_ci	asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__))	\
858c2ecf20Sopenharmony_ci	{									\
868c2ecf20Sopenharmony_ci		long ret = __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));\
878c2ecf20Sopenharmony_ci		__MAP(x,__SC_TEST,__VA_ARGS__);					\
888c2ecf20Sopenharmony_ci		return ret;							\
898c2ecf20Sopenharmony_ci	}									\
908c2ecf20Sopenharmony_ci	__diag_pop();								\
918c2ecf20Sopenharmony_ci	static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
928c2ecf20Sopenharmony_ci#endif /* COMPAT_SYSCALL_DEFINEx */
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_cistruct compat_iovec {
958c2ecf20Sopenharmony_ci	compat_uptr_t	iov_base;
968c2ecf20Sopenharmony_ci	compat_size_t	iov_len;
978c2ecf20Sopenharmony_ci};
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci#ifdef CONFIG_COMPAT
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#ifndef compat_user_stack_pointer
1028c2ecf20Sopenharmony_ci#define compat_user_stack_pointer() current_user_stack_pointer()
1038c2ecf20Sopenharmony_ci#endif
1048c2ecf20Sopenharmony_ci#ifndef compat_sigaltstack	/* we'll need that for MIPS */
1058c2ecf20Sopenharmony_citypedef struct compat_sigaltstack {
1068c2ecf20Sopenharmony_ci	compat_uptr_t			ss_sp;
1078c2ecf20Sopenharmony_ci	int				ss_flags;
1088c2ecf20Sopenharmony_ci	compat_size_t			ss_size;
1098c2ecf20Sopenharmony_ci} compat_stack_t;
1108c2ecf20Sopenharmony_ci#endif
1118c2ecf20Sopenharmony_ci#ifndef COMPAT_MINSIGSTKSZ
1128c2ecf20Sopenharmony_ci#define COMPAT_MINSIGSTKSZ	MINSIGSTKSZ
1138c2ecf20Sopenharmony_ci#endif
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#define compat_jiffies_to_clock_t(x)	\
1168c2ecf20Sopenharmony_ci		(((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_citypedef __compat_uid32_t	compat_uid_t;
1198c2ecf20Sopenharmony_citypedef __compat_gid32_t	compat_gid_t;
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_cistruct compat_sel_arg_struct;
1228c2ecf20Sopenharmony_cistruct rusage;
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_cistruct old_itimerval32;
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_cistruct compat_tms {
1278c2ecf20Sopenharmony_ci	compat_clock_t		tms_utime;
1288c2ecf20Sopenharmony_ci	compat_clock_t		tms_stime;
1298c2ecf20Sopenharmony_ci	compat_clock_t		tms_cutime;
1308c2ecf20Sopenharmony_ci	compat_clock_t		tms_cstime;
1318c2ecf20Sopenharmony_ci};
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci#define _COMPAT_NSIG_WORDS	(_COMPAT_NSIG / _COMPAT_NSIG_BPW)
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_citypedef struct {
1368c2ecf20Sopenharmony_ci	compat_sigset_word	sig[_COMPAT_NSIG_WORDS];
1378c2ecf20Sopenharmony_ci} compat_sigset_t;
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ciint set_compat_user_sigmask(const compat_sigset_t __user *umask,
1408c2ecf20Sopenharmony_ci			    size_t sigsetsize);
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_cistruct compat_sigaction {
1438c2ecf20Sopenharmony_ci#ifndef __ARCH_HAS_IRIX_SIGACTION
1448c2ecf20Sopenharmony_ci	compat_uptr_t			sa_handler;
1458c2ecf20Sopenharmony_ci	compat_ulong_t			sa_flags;
1468c2ecf20Sopenharmony_ci#else
1478c2ecf20Sopenharmony_ci	compat_uint_t			sa_flags;
1488c2ecf20Sopenharmony_ci	compat_uptr_t			sa_handler;
1498c2ecf20Sopenharmony_ci#endif
1508c2ecf20Sopenharmony_ci#ifdef __ARCH_HAS_SA_RESTORER
1518c2ecf20Sopenharmony_ci	compat_uptr_t			sa_restorer;
1528c2ecf20Sopenharmony_ci#endif
1538c2ecf20Sopenharmony_ci	compat_sigset_t			sa_mask __packed;
1548c2ecf20Sopenharmony_ci};
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_citypedef union compat_sigval {
1578c2ecf20Sopenharmony_ci	compat_int_t	sival_int;
1588c2ecf20Sopenharmony_ci	compat_uptr_t	sival_ptr;
1598c2ecf20Sopenharmony_ci} compat_sigval_t;
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_citypedef struct compat_siginfo {
1628c2ecf20Sopenharmony_ci	int si_signo;
1638c2ecf20Sopenharmony_ci#ifndef __ARCH_HAS_SWAPPED_SIGINFO
1648c2ecf20Sopenharmony_ci	int si_errno;
1658c2ecf20Sopenharmony_ci	int si_code;
1668c2ecf20Sopenharmony_ci#else
1678c2ecf20Sopenharmony_ci	int si_code;
1688c2ecf20Sopenharmony_ci	int si_errno;
1698c2ecf20Sopenharmony_ci#endif
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci	union {
1728c2ecf20Sopenharmony_ci		int _pad[128/sizeof(int) - 3];
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci		/* kill() */
1758c2ecf20Sopenharmony_ci		struct {
1768c2ecf20Sopenharmony_ci			compat_pid_t _pid;	/* sender's pid */
1778c2ecf20Sopenharmony_ci			__compat_uid32_t _uid;	/* sender's uid */
1788c2ecf20Sopenharmony_ci		} _kill;
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci		/* POSIX.1b timers */
1818c2ecf20Sopenharmony_ci		struct {
1828c2ecf20Sopenharmony_ci			compat_timer_t _tid;	/* timer id */
1838c2ecf20Sopenharmony_ci			int _overrun;		/* overrun count */
1848c2ecf20Sopenharmony_ci			compat_sigval_t _sigval;	/* same as below */
1858c2ecf20Sopenharmony_ci		} _timer;
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci		/* POSIX.1b signals */
1888c2ecf20Sopenharmony_ci		struct {
1898c2ecf20Sopenharmony_ci			compat_pid_t _pid;	/* sender's pid */
1908c2ecf20Sopenharmony_ci			__compat_uid32_t _uid;	/* sender's uid */
1918c2ecf20Sopenharmony_ci			compat_sigval_t _sigval;
1928c2ecf20Sopenharmony_ci		} _rt;
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci		/* SIGCHLD */
1958c2ecf20Sopenharmony_ci		struct {
1968c2ecf20Sopenharmony_ci			compat_pid_t _pid;	/* which child */
1978c2ecf20Sopenharmony_ci			__compat_uid32_t _uid;	/* sender's uid */
1988c2ecf20Sopenharmony_ci			int _status;		/* exit code */
1998c2ecf20Sopenharmony_ci			compat_clock_t _utime;
2008c2ecf20Sopenharmony_ci			compat_clock_t _stime;
2018c2ecf20Sopenharmony_ci		} _sigchld;
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_X32_ABI
2048c2ecf20Sopenharmony_ci		/* SIGCHLD (x32 version) */
2058c2ecf20Sopenharmony_ci		struct {
2068c2ecf20Sopenharmony_ci			compat_pid_t _pid;	/* which child */
2078c2ecf20Sopenharmony_ci			__compat_uid32_t _uid;	/* sender's uid */
2088c2ecf20Sopenharmony_ci			int _status;		/* exit code */
2098c2ecf20Sopenharmony_ci			compat_s64 _utime;
2108c2ecf20Sopenharmony_ci			compat_s64 _stime;
2118c2ecf20Sopenharmony_ci		} _sigchld_x32;
2128c2ecf20Sopenharmony_ci#endif
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
2158c2ecf20Sopenharmony_ci		struct {
2168c2ecf20Sopenharmony_ci			compat_uptr_t _addr;	/* faulting insn/memory ref. */
2178c2ecf20Sopenharmony_ci#ifdef __ARCH_SI_TRAPNO
2188c2ecf20Sopenharmony_ci			int _trapno;	/* TRAP # which caused the signal */
2198c2ecf20Sopenharmony_ci#endif
2208c2ecf20Sopenharmony_ci#define __COMPAT_ADDR_BND_PKEY_PAD  (__alignof__(compat_uptr_t) < sizeof(short) ? \
2218c2ecf20Sopenharmony_ci				     sizeof(short) : __alignof__(compat_uptr_t))
2228c2ecf20Sopenharmony_ci			union {
2238c2ecf20Sopenharmony_ci				/*
2248c2ecf20Sopenharmony_ci				 * used when si_code=BUS_MCEERR_AR or
2258c2ecf20Sopenharmony_ci				 * used when si_code=BUS_MCEERR_AO
2268c2ecf20Sopenharmony_ci				 */
2278c2ecf20Sopenharmony_ci				short int _addr_lsb;	/* Valid LSB of the reported address. */
2288c2ecf20Sopenharmony_ci				/* used when si_code=SEGV_BNDERR */
2298c2ecf20Sopenharmony_ci				struct {
2308c2ecf20Sopenharmony_ci					char _dummy_bnd[__COMPAT_ADDR_BND_PKEY_PAD];
2318c2ecf20Sopenharmony_ci					compat_uptr_t _lower;
2328c2ecf20Sopenharmony_ci					compat_uptr_t _upper;
2338c2ecf20Sopenharmony_ci				} _addr_bnd;
2348c2ecf20Sopenharmony_ci				/* used when si_code=SEGV_PKUERR */
2358c2ecf20Sopenharmony_ci				struct {
2368c2ecf20Sopenharmony_ci					char _dummy_pkey[__COMPAT_ADDR_BND_PKEY_PAD];
2378c2ecf20Sopenharmony_ci					u32 _pkey;
2388c2ecf20Sopenharmony_ci				} _addr_pkey;
2398c2ecf20Sopenharmony_ci			};
2408c2ecf20Sopenharmony_ci		} _sigfault;
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci		/* SIGPOLL */
2438c2ecf20Sopenharmony_ci		struct {
2448c2ecf20Sopenharmony_ci			compat_long_t _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
2458c2ecf20Sopenharmony_ci			int _fd;
2468c2ecf20Sopenharmony_ci		} _sigpoll;
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci		struct {
2498c2ecf20Sopenharmony_ci			compat_uptr_t _call_addr; /* calling user insn */
2508c2ecf20Sopenharmony_ci			int _syscall;	/* triggering system call number */
2518c2ecf20Sopenharmony_ci			unsigned int _arch;	/* AUDIT_ARCH_* of syscall */
2528c2ecf20Sopenharmony_ci		} _sigsys;
2538c2ecf20Sopenharmony_ci	} _sifields;
2548c2ecf20Sopenharmony_ci} compat_siginfo_t;
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_cistruct compat_rlimit {
2578c2ecf20Sopenharmony_ci	compat_ulong_t	rlim_cur;
2588c2ecf20Sopenharmony_ci	compat_ulong_t	rlim_max;
2598c2ecf20Sopenharmony_ci};
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_cistruct compat_rusage {
2628c2ecf20Sopenharmony_ci	struct old_timeval32 ru_utime;
2638c2ecf20Sopenharmony_ci	struct old_timeval32 ru_stime;
2648c2ecf20Sopenharmony_ci	compat_long_t	ru_maxrss;
2658c2ecf20Sopenharmony_ci	compat_long_t	ru_ixrss;
2668c2ecf20Sopenharmony_ci	compat_long_t	ru_idrss;
2678c2ecf20Sopenharmony_ci	compat_long_t	ru_isrss;
2688c2ecf20Sopenharmony_ci	compat_long_t	ru_minflt;
2698c2ecf20Sopenharmony_ci	compat_long_t	ru_majflt;
2708c2ecf20Sopenharmony_ci	compat_long_t	ru_nswap;
2718c2ecf20Sopenharmony_ci	compat_long_t	ru_inblock;
2728c2ecf20Sopenharmony_ci	compat_long_t	ru_oublock;
2738c2ecf20Sopenharmony_ci	compat_long_t	ru_msgsnd;
2748c2ecf20Sopenharmony_ci	compat_long_t	ru_msgrcv;
2758c2ecf20Sopenharmony_ci	compat_long_t	ru_nsignals;
2768c2ecf20Sopenharmony_ci	compat_long_t	ru_nvcsw;
2778c2ecf20Sopenharmony_ci	compat_long_t	ru_nivcsw;
2788c2ecf20Sopenharmony_ci};
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ciextern int put_compat_rusage(const struct rusage *,
2818c2ecf20Sopenharmony_ci			     struct compat_rusage __user *);
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_cistruct compat_siginfo;
2848c2ecf20Sopenharmony_cistruct __compat_aio_sigset;
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_cistruct compat_dirent {
2878c2ecf20Sopenharmony_ci	u32		d_ino;
2888c2ecf20Sopenharmony_ci	compat_off_t	d_off;
2898c2ecf20Sopenharmony_ci	u16		d_reclen;
2908c2ecf20Sopenharmony_ci	char		d_name[256];
2918c2ecf20Sopenharmony_ci};
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_cistruct compat_ustat {
2948c2ecf20Sopenharmony_ci	compat_daddr_t		f_tfree;
2958c2ecf20Sopenharmony_ci	compat_ino_t		f_tinode;
2968c2ecf20Sopenharmony_ci	char			f_fname[6];
2978c2ecf20Sopenharmony_ci	char			f_fpack[6];
2988c2ecf20Sopenharmony_ci};
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci#define COMPAT_SIGEV_PAD_SIZE	((SIGEV_MAX_SIZE/sizeof(int)) - 3)
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_citypedef struct compat_sigevent {
3038c2ecf20Sopenharmony_ci	compat_sigval_t sigev_value;
3048c2ecf20Sopenharmony_ci	compat_int_t sigev_signo;
3058c2ecf20Sopenharmony_ci	compat_int_t sigev_notify;
3068c2ecf20Sopenharmony_ci	union {
3078c2ecf20Sopenharmony_ci		compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
3088c2ecf20Sopenharmony_ci		compat_int_t _tid;
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci		struct {
3118c2ecf20Sopenharmony_ci			compat_uptr_t _function;
3128c2ecf20Sopenharmony_ci			compat_uptr_t _attribute;
3138c2ecf20Sopenharmony_ci		} _sigev_thread;
3148c2ecf20Sopenharmony_ci	} _sigev_un;
3158c2ecf20Sopenharmony_ci} compat_sigevent_t;
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_cistruct compat_ifmap {
3188c2ecf20Sopenharmony_ci	compat_ulong_t mem_start;
3198c2ecf20Sopenharmony_ci	compat_ulong_t mem_end;
3208c2ecf20Sopenharmony_ci	unsigned short base_addr;
3218c2ecf20Sopenharmony_ci	unsigned char irq;
3228c2ecf20Sopenharmony_ci	unsigned char dma;
3238c2ecf20Sopenharmony_ci	unsigned char port;
3248c2ecf20Sopenharmony_ci};
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_cistruct compat_if_settings {
3278c2ecf20Sopenharmony_ci	unsigned int type;	/* Type of physical device or protocol */
3288c2ecf20Sopenharmony_ci	unsigned int size;	/* Size of the data allocated by the caller */
3298c2ecf20Sopenharmony_ci	compat_uptr_t ifs_ifsu;	/* union of pointers */
3308c2ecf20Sopenharmony_ci};
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_cistruct compat_ifreq {
3338c2ecf20Sopenharmony_ci	union {
3348c2ecf20Sopenharmony_ci		char	ifrn_name[IFNAMSIZ];    /* if name, e.g. "en0" */
3358c2ecf20Sopenharmony_ci	} ifr_ifrn;
3368c2ecf20Sopenharmony_ci	union {
3378c2ecf20Sopenharmony_ci		struct	sockaddr ifru_addr;
3388c2ecf20Sopenharmony_ci		struct	sockaddr ifru_dstaddr;
3398c2ecf20Sopenharmony_ci		struct	sockaddr ifru_broadaddr;
3408c2ecf20Sopenharmony_ci		struct	sockaddr ifru_netmask;
3418c2ecf20Sopenharmony_ci		struct	sockaddr ifru_hwaddr;
3428c2ecf20Sopenharmony_ci		short	ifru_flags;
3438c2ecf20Sopenharmony_ci		compat_int_t	ifru_ivalue;
3448c2ecf20Sopenharmony_ci		compat_int_t	ifru_mtu;
3458c2ecf20Sopenharmony_ci		struct	compat_ifmap ifru_map;
3468c2ecf20Sopenharmony_ci		char	ifru_slave[IFNAMSIZ];   /* Just fits the size */
3478c2ecf20Sopenharmony_ci		char	ifru_newname[IFNAMSIZ];
3488c2ecf20Sopenharmony_ci		compat_caddr_t	ifru_data;
3498c2ecf20Sopenharmony_ci		struct	compat_if_settings ifru_settings;
3508c2ecf20Sopenharmony_ci	} ifr_ifru;
3518c2ecf20Sopenharmony_ci};
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_cistruct compat_ifconf {
3548c2ecf20Sopenharmony_ci	compat_int_t	ifc_len;                /* size of buffer */
3558c2ecf20Sopenharmony_ci	compat_caddr_t  ifcbuf;
3568c2ecf20Sopenharmony_ci};
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_cistruct compat_robust_list {
3598c2ecf20Sopenharmony_ci	compat_uptr_t			next;
3608c2ecf20Sopenharmony_ci};
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_cistruct compat_robust_list_head {
3638c2ecf20Sopenharmony_ci	struct compat_robust_list	list;
3648c2ecf20Sopenharmony_ci	compat_long_t			futex_offset;
3658c2ecf20Sopenharmony_ci	compat_uptr_t			list_op_pending;
3668c2ecf20Sopenharmony_ci};
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ci#ifdef CONFIG_COMPAT_OLD_SIGACTION
3698c2ecf20Sopenharmony_cistruct compat_old_sigaction {
3708c2ecf20Sopenharmony_ci	compat_uptr_t			sa_handler;
3718c2ecf20Sopenharmony_ci	compat_old_sigset_t		sa_mask;
3728c2ecf20Sopenharmony_ci	compat_ulong_t			sa_flags;
3738c2ecf20Sopenharmony_ci	compat_uptr_t			sa_restorer;
3748c2ecf20Sopenharmony_ci};
3758c2ecf20Sopenharmony_ci#endif
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_cistruct compat_keyctl_kdf_params {
3788c2ecf20Sopenharmony_ci	compat_uptr_t hashname;
3798c2ecf20Sopenharmony_ci	compat_uptr_t otherinfo;
3808c2ecf20Sopenharmony_ci	__u32 otherinfolen;
3818c2ecf20Sopenharmony_ci	__u32 __spare[8];
3828c2ecf20Sopenharmony_ci};
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_cistruct compat_statfs;
3858c2ecf20Sopenharmony_cistruct compat_statfs64;
3868c2ecf20Sopenharmony_cistruct compat_old_linux_dirent;
3878c2ecf20Sopenharmony_cistruct compat_linux_dirent;
3888c2ecf20Sopenharmony_cistruct linux_dirent64;
3898c2ecf20Sopenharmony_cistruct compat_msghdr;
3908c2ecf20Sopenharmony_cistruct compat_mmsghdr;
3918c2ecf20Sopenharmony_cistruct compat_sysinfo;
3928c2ecf20Sopenharmony_cistruct compat_sysctl_args;
3938c2ecf20Sopenharmony_cistruct compat_kexec_segment;
3948c2ecf20Sopenharmony_cistruct compat_mq_attr;
3958c2ecf20Sopenharmony_cistruct compat_msgbuf;
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci#define BITS_PER_COMPAT_LONG    (8*sizeof(compat_long_t))
3988c2ecf20Sopenharmony_ci
3998c2ecf20Sopenharmony_ci#define BITS_TO_COMPAT_LONGS(bits) DIV_ROUND_UP(bits, BITS_PER_COMPAT_LONG)
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_cilong compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
4028c2ecf20Sopenharmony_ci		       unsigned long bitmap_size);
4038c2ecf20Sopenharmony_cilong compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
4048c2ecf20Sopenharmony_ci		       unsigned long bitmap_size);
4058c2ecf20Sopenharmony_civoid copy_siginfo_to_external32(struct compat_siginfo *to,
4068c2ecf20Sopenharmony_ci		const struct kernel_siginfo *from);
4078c2ecf20Sopenharmony_ciint copy_siginfo_from_user32(kernel_siginfo_t *to,
4088c2ecf20Sopenharmony_ci		const struct compat_siginfo __user *from);
4098c2ecf20Sopenharmony_ciint __copy_siginfo_to_user32(struct compat_siginfo __user *to,
4108c2ecf20Sopenharmony_ci		const kernel_siginfo_t *from);
4118c2ecf20Sopenharmony_ci#ifndef copy_siginfo_to_user32
4128c2ecf20Sopenharmony_ci#define copy_siginfo_to_user32 __copy_siginfo_to_user32
4138c2ecf20Sopenharmony_ci#endif
4148c2ecf20Sopenharmony_ciint get_compat_sigevent(struct sigevent *event,
4158c2ecf20Sopenharmony_ci		const struct compat_sigevent __user *u_event);
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_ciextern int get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat);
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_ci/*
4208c2ecf20Sopenharmony_ci * Defined inline such that size can be compile time constant, which avoids
4218c2ecf20Sopenharmony_ci * CONFIG_HARDENED_USERCOPY complaining about copies from task_struct
4228c2ecf20Sopenharmony_ci */
4238c2ecf20Sopenharmony_cistatic inline int
4248c2ecf20Sopenharmony_ciput_compat_sigset(compat_sigset_t __user *compat, const sigset_t *set,
4258c2ecf20Sopenharmony_ci		  unsigned int size)
4268c2ecf20Sopenharmony_ci{
4278c2ecf20Sopenharmony_ci	/* size <= sizeof(compat_sigset_t) <= sizeof(sigset_t) */
4288c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN
4298c2ecf20Sopenharmony_ci	compat_sigset_t v;
4308c2ecf20Sopenharmony_ci	switch (_NSIG_WORDS) {
4318c2ecf20Sopenharmony_ci	case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3];
4328c2ecf20Sopenharmony_ci		fallthrough;
4338c2ecf20Sopenharmony_ci	case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2];
4348c2ecf20Sopenharmony_ci		fallthrough;
4358c2ecf20Sopenharmony_ci	case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1];
4368c2ecf20Sopenharmony_ci		fallthrough;
4378c2ecf20Sopenharmony_ci	case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0];
4388c2ecf20Sopenharmony_ci	}
4398c2ecf20Sopenharmony_ci	return copy_to_user(compat, &v, size) ? -EFAULT : 0;
4408c2ecf20Sopenharmony_ci#else
4418c2ecf20Sopenharmony_ci	return copy_to_user(compat, set, size) ? -EFAULT : 0;
4428c2ecf20Sopenharmony_ci#endif
4438c2ecf20Sopenharmony_ci}
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_ciextern int compat_ptrace_request(struct task_struct *child,
4468c2ecf20Sopenharmony_ci				 compat_long_t request,
4478c2ecf20Sopenharmony_ci				 compat_ulong_t addr, compat_ulong_t data);
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ciextern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
4508c2ecf20Sopenharmony_ci			       compat_ulong_t addr, compat_ulong_t data);
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_cistruct epoll_event;	/* fortunately, this one is fixed-layout */
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ciextern void __user *compat_alloc_user_space(unsigned long len);
4558c2ecf20Sopenharmony_ci
4568c2ecf20Sopenharmony_ciint compat_restore_altstack(const compat_stack_t __user *uss);
4578c2ecf20Sopenharmony_ciint __compat_save_altstack(compat_stack_t __user *, unsigned long);
4588c2ecf20Sopenharmony_ci#define unsafe_compat_save_altstack(uss, sp, label) do { \
4598c2ecf20Sopenharmony_ci	compat_stack_t __user *__uss = uss; \
4608c2ecf20Sopenharmony_ci	struct task_struct *t = current; \
4618c2ecf20Sopenharmony_ci	unsafe_put_user(ptr_to_compat((void __user *)t->sas_ss_sp), \
4628c2ecf20Sopenharmony_ci			&__uss->ss_sp, label); \
4638c2ecf20Sopenharmony_ci	unsafe_put_user(t->sas_ss_flags, &__uss->ss_flags, label); \
4648c2ecf20Sopenharmony_ci	unsafe_put_user(t->sas_ss_size, &__uss->ss_size, label); \
4658c2ecf20Sopenharmony_ci	if (t->sas_ss_flags & SS_AUTODISARM) \
4668c2ecf20Sopenharmony_ci		sas_ss_reset(t); \
4678c2ecf20Sopenharmony_ci} while (0);
4688c2ecf20Sopenharmony_ci
4698c2ecf20Sopenharmony_ci/*
4708c2ecf20Sopenharmony_ci * These syscall function prototypes are kept in the same order as
4718c2ecf20Sopenharmony_ci * include/uapi/asm-generic/unistd.h. Deprecated or obsolete system calls
4728c2ecf20Sopenharmony_ci * go below.
4738c2ecf20Sopenharmony_ci *
4748c2ecf20Sopenharmony_ci * Please note that these prototypes here are only provided for information
4758c2ecf20Sopenharmony_ci * purposes, for static analysis, and for linking from the syscall table.
4768c2ecf20Sopenharmony_ci * These functions should not be called elsewhere from kernel code.
4778c2ecf20Sopenharmony_ci *
4788c2ecf20Sopenharmony_ci * As the syscall calling convention may be different from the default
4798c2ecf20Sopenharmony_ci * for architectures overriding the syscall calling convention, do not
4808c2ecf20Sopenharmony_ci * include the prototypes if CONFIG_ARCH_HAS_SYSCALL_WRAPPER is enabled.
4818c2ecf20Sopenharmony_ci */
4828c2ecf20Sopenharmony_ci#ifndef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
4838c2ecf20Sopenharmony_ciasmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p);
4848c2ecf20Sopenharmony_ciasmlinkage long compat_sys_io_submit(compat_aio_context_t ctx_id, int nr,
4858c2ecf20Sopenharmony_ci				     u32 __user *iocb);
4868c2ecf20Sopenharmony_ciasmlinkage long compat_sys_io_pgetevents(compat_aio_context_t ctx_id,
4878c2ecf20Sopenharmony_ci					compat_long_t min_nr,
4888c2ecf20Sopenharmony_ci					compat_long_t nr,
4898c2ecf20Sopenharmony_ci					struct io_event __user *events,
4908c2ecf20Sopenharmony_ci					struct old_timespec32 __user *timeout,
4918c2ecf20Sopenharmony_ci					const struct __compat_aio_sigset __user *usig);
4928c2ecf20Sopenharmony_ciasmlinkage long compat_sys_io_pgetevents_time64(compat_aio_context_t ctx_id,
4938c2ecf20Sopenharmony_ci					compat_long_t min_nr,
4948c2ecf20Sopenharmony_ci					compat_long_t nr,
4958c2ecf20Sopenharmony_ci					struct io_event __user *events,
4968c2ecf20Sopenharmony_ci					struct __kernel_timespec __user *timeout,
4978c2ecf20Sopenharmony_ci					const struct __compat_aio_sigset __user *usig);
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_ci/* fs/cookies.c */
5008c2ecf20Sopenharmony_ciasmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, compat_size_t);
5018c2ecf20Sopenharmony_ci
5028c2ecf20Sopenharmony_ci/* fs/eventpoll.c */
5038c2ecf20Sopenharmony_ciasmlinkage long compat_sys_epoll_pwait(int epfd,
5048c2ecf20Sopenharmony_ci			struct epoll_event __user *events,
5058c2ecf20Sopenharmony_ci			int maxevents, int timeout,
5068c2ecf20Sopenharmony_ci			const compat_sigset_t __user *sigmask,
5078c2ecf20Sopenharmony_ci			compat_size_t sigsetsize);
5088c2ecf20Sopenharmony_ci
5098c2ecf20Sopenharmony_ci/* fs/fcntl.c */
5108c2ecf20Sopenharmony_ciasmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
5118c2ecf20Sopenharmony_ci				 compat_ulong_t arg);
5128c2ecf20Sopenharmony_ciasmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
5138c2ecf20Sopenharmony_ci				   compat_ulong_t arg);
5148c2ecf20Sopenharmony_ci
5158c2ecf20Sopenharmony_ci/* fs/ioctl.c */
5168c2ecf20Sopenharmony_ciasmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
5178c2ecf20Sopenharmony_ci				 compat_ulong_t arg);
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci/* fs/open.c */
5208c2ecf20Sopenharmony_ciasmlinkage long compat_sys_statfs(const char __user *pathname,
5218c2ecf20Sopenharmony_ci				  struct compat_statfs __user *buf);
5228c2ecf20Sopenharmony_ciasmlinkage long compat_sys_statfs64(const char __user *pathname,
5238c2ecf20Sopenharmony_ci				    compat_size_t sz,
5248c2ecf20Sopenharmony_ci				    struct compat_statfs64 __user *buf);
5258c2ecf20Sopenharmony_ciasmlinkage long compat_sys_fstatfs(unsigned int fd,
5268c2ecf20Sopenharmony_ci				   struct compat_statfs __user *buf);
5278c2ecf20Sopenharmony_ciasmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz,
5288c2ecf20Sopenharmony_ci				     struct compat_statfs64 __user *buf);
5298c2ecf20Sopenharmony_ciasmlinkage long compat_sys_truncate(const char __user *, compat_off_t);
5308c2ecf20Sopenharmony_ciasmlinkage long compat_sys_ftruncate(unsigned int, compat_off_t);
5318c2ecf20Sopenharmony_ci/* No generic prototype for truncate64, ftruncate64, fallocate */
5328c2ecf20Sopenharmony_ciasmlinkage long compat_sys_openat(int dfd, const char __user *filename,
5338c2ecf20Sopenharmony_ci				  int flags, umode_t mode);
5348c2ecf20Sopenharmony_ci
5358c2ecf20Sopenharmony_ci/* fs/readdir.c */
5368c2ecf20Sopenharmony_ciasmlinkage long compat_sys_getdents(unsigned int fd,
5378c2ecf20Sopenharmony_ci				    struct compat_linux_dirent __user *dirent,
5388c2ecf20Sopenharmony_ci				    unsigned int count);
5398c2ecf20Sopenharmony_ci
5408c2ecf20Sopenharmony_ci/* fs/read_write.c */
5418c2ecf20Sopenharmony_ciasmlinkage long compat_sys_lseek(unsigned int, compat_off_t, unsigned int);
5428c2ecf20Sopenharmony_ci/* No generic prototype for pread64 and pwrite64 */
5438c2ecf20Sopenharmony_ciasmlinkage ssize_t compat_sys_preadv(compat_ulong_t fd,
5448c2ecf20Sopenharmony_ci		const struct iovec __user *vec,
5458c2ecf20Sopenharmony_ci		compat_ulong_t vlen, u32 pos_low, u32 pos_high);
5468c2ecf20Sopenharmony_ciasmlinkage ssize_t compat_sys_pwritev(compat_ulong_t fd,
5478c2ecf20Sopenharmony_ci		const struct iovec __user *vec,
5488c2ecf20Sopenharmony_ci		compat_ulong_t vlen, u32 pos_low, u32 pos_high);
5498c2ecf20Sopenharmony_ci#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64
5508c2ecf20Sopenharmony_ciasmlinkage long compat_sys_preadv64(unsigned long fd,
5518c2ecf20Sopenharmony_ci		const struct iovec __user *vec,
5528c2ecf20Sopenharmony_ci		unsigned long vlen, loff_t pos);
5538c2ecf20Sopenharmony_ci#endif
5548c2ecf20Sopenharmony_ci
5558c2ecf20Sopenharmony_ci#ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64
5568c2ecf20Sopenharmony_ciasmlinkage long compat_sys_pwritev64(unsigned long fd,
5578c2ecf20Sopenharmony_ci		const struct iovec __user *vec,
5588c2ecf20Sopenharmony_ci		unsigned long vlen, loff_t pos);
5598c2ecf20Sopenharmony_ci#endif
5608c2ecf20Sopenharmony_ci
5618c2ecf20Sopenharmony_ci/* fs/sendfile.c */
5628c2ecf20Sopenharmony_ciasmlinkage long compat_sys_sendfile(int out_fd, int in_fd,
5638c2ecf20Sopenharmony_ci				    compat_off_t __user *offset, compat_size_t count);
5648c2ecf20Sopenharmony_ciasmlinkage long compat_sys_sendfile64(int out_fd, int in_fd,
5658c2ecf20Sopenharmony_ci				    compat_loff_t __user *offset, compat_size_t count);
5668c2ecf20Sopenharmony_ci
5678c2ecf20Sopenharmony_ci/* fs/select.c */
5688c2ecf20Sopenharmony_ciasmlinkage long compat_sys_pselect6_time32(int n, compat_ulong_t __user *inp,
5698c2ecf20Sopenharmony_ci				    compat_ulong_t __user *outp,
5708c2ecf20Sopenharmony_ci				    compat_ulong_t __user *exp,
5718c2ecf20Sopenharmony_ci				    struct old_timespec32 __user *tsp,
5728c2ecf20Sopenharmony_ci				    void __user *sig);
5738c2ecf20Sopenharmony_ciasmlinkage long compat_sys_pselect6_time64(int n, compat_ulong_t __user *inp,
5748c2ecf20Sopenharmony_ci				    compat_ulong_t __user *outp,
5758c2ecf20Sopenharmony_ci				    compat_ulong_t __user *exp,
5768c2ecf20Sopenharmony_ci				    struct __kernel_timespec __user *tsp,
5778c2ecf20Sopenharmony_ci				    void __user *sig);
5788c2ecf20Sopenharmony_ciasmlinkage long compat_sys_ppoll_time32(struct pollfd __user *ufds,
5798c2ecf20Sopenharmony_ci				 unsigned int nfds,
5808c2ecf20Sopenharmony_ci				 struct old_timespec32 __user *tsp,
5818c2ecf20Sopenharmony_ci				 const compat_sigset_t __user *sigmask,
5828c2ecf20Sopenharmony_ci				 compat_size_t sigsetsize);
5838c2ecf20Sopenharmony_ciasmlinkage long compat_sys_ppoll_time64(struct pollfd __user *ufds,
5848c2ecf20Sopenharmony_ci				 unsigned int nfds,
5858c2ecf20Sopenharmony_ci				 struct __kernel_timespec __user *tsp,
5868c2ecf20Sopenharmony_ci				 const compat_sigset_t __user *sigmask,
5878c2ecf20Sopenharmony_ci				 compat_size_t sigsetsize);
5888c2ecf20Sopenharmony_ci
5898c2ecf20Sopenharmony_ci/* fs/signalfd.c */
5908c2ecf20Sopenharmony_ciasmlinkage long compat_sys_signalfd4(int ufd,
5918c2ecf20Sopenharmony_ci				     const compat_sigset_t __user *sigmask,
5928c2ecf20Sopenharmony_ci				     compat_size_t sigsetsize, int flags);
5938c2ecf20Sopenharmony_ci
5948c2ecf20Sopenharmony_ci/* fs/stat.c */
5958c2ecf20Sopenharmony_ciasmlinkage long compat_sys_newfstatat(unsigned int dfd,
5968c2ecf20Sopenharmony_ci				      const char __user *filename,
5978c2ecf20Sopenharmony_ci				      struct compat_stat __user *statbuf,
5988c2ecf20Sopenharmony_ci				      int flag);
5998c2ecf20Sopenharmony_ciasmlinkage long compat_sys_newfstat(unsigned int fd,
6008c2ecf20Sopenharmony_ci				    struct compat_stat __user *statbuf);
6018c2ecf20Sopenharmony_ci
6028c2ecf20Sopenharmony_ci/* fs/sync.c: No generic prototype for sync_file_range and sync_file_range2 */
6038c2ecf20Sopenharmony_ci
6048c2ecf20Sopenharmony_ci/* kernel/exit.c */
6058c2ecf20Sopenharmony_ciasmlinkage long compat_sys_waitid(int, compat_pid_t,
6068c2ecf20Sopenharmony_ci		struct compat_siginfo __user *, int,
6078c2ecf20Sopenharmony_ci		struct compat_rusage __user *);
6088c2ecf20Sopenharmony_ci
6098c2ecf20Sopenharmony_ci
6108c2ecf20Sopenharmony_ci
6118c2ecf20Sopenharmony_ci/* kernel/futex.c */
6128c2ecf20Sopenharmony_ciasmlinkage long
6138c2ecf20Sopenharmony_cicompat_sys_set_robust_list(struct compat_robust_list_head __user *head,
6148c2ecf20Sopenharmony_ci			   compat_size_t len);
6158c2ecf20Sopenharmony_ciasmlinkage long
6168c2ecf20Sopenharmony_cicompat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
6178c2ecf20Sopenharmony_ci			   compat_size_t __user *len_ptr);
6188c2ecf20Sopenharmony_ci
6198c2ecf20Sopenharmony_ci/* kernel/itimer.c */
6208c2ecf20Sopenharmony_ciasmlinkage long compat_sys_getitimer(int which,
6218c2ecf20Sopenharmony_ci				     struct old_itimerval32 __user *it);
6228c2ecf20Sopenharmony_ciasmlinkage long compat_sys_setitimer(int which,
6238c2ecf20Sopenharmony_ci				     struct old_itimerval32 __user *in,
6248c2ecf20Sopenharmony_ci				     struct old_itimerval32 __user *out);
6258c2ecf20Sopenharmony_ci
6268c2ecf20Sopenharmony_ci/* kernel/kexec.c */
6278c2ecf20Sopenharmony_ciasmlinkage long compat_sys_kexec_load(compat_ulong_t entry,
6288c2ecf20Sopenharmony_ci				      compat_ulong_t nr_segments,
6298c2ecf20Sopenharmony_ci				      struct compat_kexec_segment __user *,
6308c2ecf20Sopenharmony_ci				      compat_ulong_t flags);
6318c2ecf20Sopenharmony_ci
6328c2ecf20Sopenharmony_ci/* kernel/posix-timers.c */
6338c2ecf20Sopenharmony_ciasmlinkage long compat_sys_timer_create(clockid_t which_clock,
6348c2ecf20Sopenharmony_ci			struct compat_sigevent __user *timer_event_spec,
6358c2ecf20Sopenharmony_ci			timer_t __user *created_timer_id);
6368c2ecf20Sopenharmony_ci
6378c2ecf20Sopenharmony_ci/* kernel/ptrace.c */
6388c2ecf20Sopenharmony_ciasmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
6398c2ecf20Sopenharmony_ci				  compat_long_t addr, compat_long_t data);
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_ci/* kernel/sched/core.c */
6428c2ecf20Sopenharmony_ciasmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
6438c2ecf20Sopenharmony_ci				     unsigned int len,
6448c2ecf20Sopenharmony_ci				     compat_ulong_t __user *user_mask_ptr);
6458c2ecf20Sopenharmony_ciasmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid,
6468c2ecf20Sopenharmony_ci				     unsigned int len,
6478c2ecf20Sopenharmony_ci				     compat_ulong_t __user *user_mask_ptr);
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_ci/* kernel/signal.c */
6508c2ecf20Sopenharmony_ciasmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr,
6518c2ecf20Sopenharmony_ci				       compat_stack_t __user *uoss_ptr);
6528c2ecf20Sopenharmony_ciasmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset,
6538c2ecf20Sopenharmony_ci					 compat_size_t sigsetsize);
6548c2ecf20Sopenharmony_ci#ifndef CONFIG_ODD_RT_SIGACTION
6558c2ecf20Sopenharmony_ciasmlinkage long compat_sys_rt_sigaction(int,
6568c2ecf20Sopenharmony_ci				 const struct compat_sigaction __user *,
6578c2ecf20Sopenharmony_ci				 struct compat_sigaction __user *,
6588c2ecf20Sopenharmony_ci				 compat_size_t);
6598c2ecf20Sopenharmony_ci#endif
6608c2ecf20Sopenharmony_ciasmlinkage long compat_sys_rt_sigprocmask(int how, compat_sigset_t __user *set,
6618c2ecf20Sopenharmony_ci					  compat_sigset_t __user *oset,
6628c2ecf20Sopenharmony_ci					  compat_size_t sigsetsize);
6638c2ecf20Sopenharmony_ciasmlinkage long compat_sys_rt_sigpending(compat_sigset_t __user *uset,
6648c2ecf20Sopenharmony_ci					 compat_size_t sigsetsize);
6658c2ecf20Sopenharmony_ciasmlinkage long compat_sys_rt_sigtimedwait_time32(compat_sigset_t __user *uthese,
6668c2ecf20Sopenharmony_ci		struct compat_siginfo __user *uinfo,
6678c2ecf20Sopenharmony_ci		struct old_timespec32 __user *uts, compat_size_t sigsetsize);
6688c2ecf20Sopenharmony_ciasmlinkage long compat_sys_rt_sigtimedwait_time64(compat_sigset_t __user *uthese,
6698c2ecf20Sopenharmony_ci		struct compat_siginfo __user *uinfo,
6708c2ecf20Sopenharmony_ci		struct __kernel_timespec __user *uts, compat_size_t sigsetsize);
6718c2ecf20Sopenharmony_ciasmlinkage long compat_sys_rt_sigqueueinfo(compat_pid_t pid, int sig,
6728c2ecf20Sopenharmony_ci				struct compat_siginfo __user *uinfo);
6738c2ecf20Sopenharmony_ci/* No generic prototype for rt_sigreturn */
6748c2ecf20Sopenharmony_ci
6758c2ecf20Sopenharmony_ci/* kernel/sys.c */
6768c2ecf20Sopenharmony_ciasmlinkage long compat_sys_times(struct compat_tms __user *tbuf);
6778c2ecf20Sopenharmony_ciasmlinkage long compat_sys_getrlimit(unsigned int resource,
6788c2ecf20Sopenharmony_ci				     struct compat_rlimit __user *rlim);
6798c2ecf20Sopenharmony_ciasmlinkage long compat_sys_setrlimit(unsigned int resource,
6808c2ecf20Sopenharmony_ci				     struct compat_rlimit __user *rlim);
6818c2ecf20Sopenharmony_ciasmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru);
6828c2ecf20Sopenharmony_ci
6838c2ecf20Sopenharmony_ci/* kernel/time.c */
6848c2ecf20Sopenharmony_ciasmlinkage long compat_sys_gettimeofday(struct old_timeval32 __user *tv,
6858c2ecf20Sopenharmony_ci		struct timezone __user *tz);
6868c2ecf20Sopenharmony_ciasmlinkage long compat_sys_settimeofday(struct old_timeval32 __user *tv,
6878c2ecf20Sopenharmony_ci		struct timezone __user *tz);
6888c2ecf20Sopenharmony_ci
6898c2ecf20Sopenharmony_ci/* kernel/timer.c */
6908c2ecf20Sopenharmony_ciasmlinkage long compat_sys_sysinfo(struct compat_sysinfo __user *info);
6918c2ecf20Sopenharmony_ci
6928c2ecf20Sopenharmony_ci/* ipc/mqueue.c */
6938c2ecf20Sopenharmony_ciasmlinkage long compat_sys_mq_open(const char __user *u_name,
6948c2ecf20Sopenharmony_ci			int oflag, compat_mode_t mode,
6958c2ecf20Sopenharmony_ci			struct compat_mq_attr __user *u_attr);
6968c2ecf20Sopenharmony_ciasmlinkage long compat_sys_mq_notify(mqd_t mqdes,
6978c2ecf20Sopenharmony_ci			const struct compat_sigevent __user *u_notification);
6988c2ecf20Sopenharmony_ciasmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes,
6998c2ecf20Sopenharmony_ci			const struct compat_mq_attr __user *u_mqstat,
7008c2ecf20Sopenharmony_ci			struct compat_mq_attr __user *u_omqstat);
7018c2ecf20Sopenharmony_ci
7028c2ecf20Sopenharmony_ci/* ipc/msg.c */
7038c2ecf20Sopenharmony_ciasmlinkage long compat_sys_msgctl(int first, int second, void __user *uptr);
7048c2ecf20Sopenharmony_ciasmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp,
7058c2ecf20Sopenharmony_ci		compat_ssize_t msgsz, compat_long_t msgtyp, int msgflg);
7068c2ecf20Sopenharmony_ciasmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
7078c2ecf20Sopenharmony_ci		compat_ssize_t msgsz, int msgflg);
7088c2ecf20Sopenharmony_ci
7098c2ecf20Sopenharmony_ci/* ipc/sem.c */
7108c2ecf20Sopenharmony_ciasmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
7118c2ecf20Sopenharmony_ci
7128c2ecf20Sopenharmony_ci/* ipc/shm.c */
7138c2ecf20Sopenharmony_ciasmlinkage long compat_sys_shmctl(int first, int second, void __user *uptr);
7148c2ecf20Sopenharmony_ciasmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
7158c2ecf20Sopenharmony_ci
7168c2ecf20Sopenharmony_ci/* net/socket.c */
7178c2ecf20Sopenharmony_ciasmlinkage long compat_sys_recvfrom(int fd, void __user *buf, compat_size_t len,
7188c2ecf20Sopenharmony_ci			    unsigned flags, struct sockaddr __user *addr,
7198c2ecf20Sopenharmony_ci			    int __user *addrlen);
7208c2ecf20Sopenharmony_ciasmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg,
7218c2ecf20Sopenharmony_ci				   unsigned flags);
7228c2ecf20Sopenharmony_ciasmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg,
7238c2ecf20Sopenharmony_ci				   unsigned int flags);
7248c2ecf20Sopenharmony_ci
7258c2ecf20Sopenharmony_ci/* mm/filemap.c: No generic prototype for readahead */
7268c2ecf20Sopenharmony_ci
7278c2ecf20Sopenharmony_ci/* security/keys/keyctl.c */
7288c2ecf20Sopenharmony_ciasmlinkage long compat_sys_keyctl(u32 option,
7298c2ecf20Sopenharmony_ci			      u32 arg2, u32 arg3, u32 arg4, u32 arg5);
7308c2ecf20Sopenharmony_ci
7318c2ecf20Sopenharmony_ci/* arch/example/kernel/sys_example.c */
7328c2ecf20Sopenharmony_ciasmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv,
7338c2ecf20Sopenharmony_ci		     const compat_uptr_t __user *envp);
7348c2ecf20Sopenharmony_ci
7358c2ecf20Sopenharmony_ci/* mm/fadvise.c: No generic prototype for fadvise64_64 */
7368c2ecf20Sopenharmony_ci
7378c2ecf20Sopenharmony_ci/* mm/, CONFIG_MMU only */
7388c2ecf20Sopenharmony_ciasmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len,
7398c2ecf20Sopenharmony_ci				 compat_ulong_t mode,
7408c2ecf20Sopenharmony_ci				 compat_ulong_t __user *nmask,
7418c2ecf20Sopenharmony_ci				 compat_ulong_t maxnode, compat_ulong_t flags);
7428c2ecf20Sopenharmony_ciasmlinkage long compat_sys_get_mempolicy(int __user *policy,
7438c2ecf20Sopenharmony_ci					 compat_ulong_t __user *nmask,
7448c2ecf20Sopenharmony_ci					 compat_ulong_t maxnode,
7458c2ecf20Sopenharmony_ci					 compat_ulong_t addr,
7468c2ecf20Sopenharmony_ci					 compat_ulong_t flags);
7478c2ecf20Sopenharmony_ciasmlinkage long compat_sys_set_mempolicy(int mode, compat_ulong_t __user *nmask,
7488c2ecf20Sopenharmony_ci					 compat_ulong_t maxnode);
7498c2ecf20Sopenharmony_ciasmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
7508c2ecf20Sopenharmony_ci		compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,
7518c2ecf20Sopenharmony_ci		const compat_ulong_t __user *new_nodes);
7528c2ecf20Sopenharmony_ciasmlinkage long compat_sys_move_pages(pid_t pid, compat_ulong_t nr_pages,
7538c2ecf20Sopenharmony_ci				      __u32 __user *pages,
7548c2ecf20Sopenharmony_ci				      const int __user *nodes,
7558c2ecf20Sopenharmony_ci				      int __user *status,
7568c2ecf20Sopenharmony_ci				      int flags);
7578c2ecf20Sopenharmony_ci
7588c2ecf20Sopenharmony_ciasmlinkage long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid,
7598c2ecf20Sopenharmony_ci					compat_pid_t pid, int sig,
7608c2ecf20Sopenharmony_ci					struct compat_siginfo __user *uinfo);
7618c2ecf20Sopenharmony_ciasmlinkage long compat_sys_recvmmsg_time64(int fd, struct compat_mmsghdr __user *mmsg,
7628c2ecf20Sopenharmony_ci				    unsigned vlen, unsigned int flags,
7638c2ecf20Sopenharmony_ci				    struct __kernel_timespec __user *timeout);
7648c2ecf20Sopenharmony_ciasmlinkage long compat_sys_recvmmsg_time32(int fd, struct compat_mmsghdr __user *mmsg,
7658c2ecf20Sopenharmony_ci				    unsigned vlen, unsigned int flags,
7668c2ecf20Sopenharmony_ci				    struct old_timespec32 __user *timeout);
7678c2ecf20Sopenharmony_ciasmlinkage long compat_sys_wait4(compat_pid_t pid,
7688c2ecf20Sopenharmony_ci				 compat_uint_t __user *stat_addr, int options,
7698c2ecf20Sopenharmony_ci				 struct compat_rusage __user *ru);
7708c2ecf20Sopenharmony_ciasmlinkage long compat_sys_fanotify_mark(int, unsigned int, __u32, __u32,
7718c2ecf20Sopenharmony_ci					    int, const char __user *);
7728c2ecf20Sopenharmony_ciasmlinkage long compat_sys_open_by_handle_at(int mountdirfd,
7738c2ecf20Sopenharmony_ci					     struct file_handle __user *handle,
7748c2ecf20Sopenharmony_ci					     int flags);
7758c2ecf20Sopenharmony_ciasmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
7768c2ecf20Sopenharmony_ci				    unsigned vlen, unsigned int flags);
7778c2ecf20Sopenharmony_ciasmlinkage long compat_sys_execveat(int dfd, const char __user *filename,
7788c2ecf20Sopenharmony_ci		     const compat_uptr_t __user *argv,
7798c2ecf20Sopenharmony_ci		     const compat_uptr_t __user *envp, int flags);
7808c2ecf20Sopenharmony_ciasmlinkage ssize_t compat_sys_preadv2(compat_ulong_t fd,
7818c2ecf20Sopenharmony_ci		const struct iovec __user *vec,
7828c2ecf20Sopenharmony_ci		compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags);
7838c2ecf20Sopenharmony_ciasmlinkage ssize_t compat_sys_pwritev2(compat_ulong_t fd,
7848c2ecf20Sopenharmony_ci		const struct iovec __user *vec,
7858c2ecf20Sopenharmony_ci		compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags);
7868c2ecf20Sopenharmony_ci#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64V2
7878c2ecf20Sopenharmony_ciasmlinkage long  compat_sys_preadv64v2(unsigned long fd,
7888c2ecf20Sopenharmony_ci		const struct iovec __user *vec,
7898c2ecf20Sopenharmony_ci		unsigned long vlen, loff_t pos, rwf_t flags);
7908c2ecf20Sopenharmony_ci#endif
7918c2ecf20Sopenharmony_ci
7928c2ecf20Sopenharmony_ci#ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64V2
7938c2ecf20Sopenharmony_ciasmlinkage long compat_sys_pwritev64v2(unsigned long fd,
7948c2ecf20Sopenharmony_ci		const struct iovec __user *vec,
7958c2ecf20Sopenharmony_ci		unsigned long vlen, loff_t pos, rwf_t flags);
7968c2ecf20Sopenharmony_ci#endif
7978c2ecf20Sopenharmony_ci
7988c2ecf20Sopenharmony_ci
7998c2ecf20Sopenharmony_ci/*
8008c2ecf20Sopenharmony_ci * Deprecated system calls which are still defined in
8018c2ecf20Sopenharmony_ci * include/uapi/asm-generic/unistd.h and wanted by >= 1 arch
8028c2ecf20Sopenharmony_ci */
8038c2ecf20Sopenharmony_ci
8048c2ecf20Sopenharmony_ci/* __ARCH_WANT_SYSCALL_NO_AT */
8058c2ecf20Sopenharmony_ciasmlinkage long compat_sys_open(const char __user *filename, int flags,
8068c2ecf20Sopenharmony_ci				umode_t mode);
8078c2ecf20Sopenharmony_ci
8088c2ecf20Sopenharmony_ci/* __ARCH_WANT_SYSCALL_NO_FLAGS */
8098c2ecf20Sopenharmony_ciasmlinkage long compat_sys_signalfd(int ufd,
8108c2ecf20Sopenharmony_ci				    const compat_sigset_t __user *sigmask,
8118c2ecf20Sopenharmony_ci				    compat_size_t sigsetsize);
8128c2ecf20Sopenharmony_ci
8138c2ecf20Sopenharmony_ci/* __ARCH_WANT_SYSCALL_OFF_T */
8148c2ecf20Sopenharmony_ciasmlinkage long compat_sys_newstat(const char __user *filename,
8158c2ecf20Sopenharmony_ci				   struct compat_stat __user *statbuf);
8168c2ecf20Sopenharmony_ciasmlinkage long compat_sys_newlstat(const char __user *filename,
8178c2ecf20Sopenharmony_ci				    struct compat_stat __user *statbuf);
8188c2ecf20Sopenharmony_ci
8198c2ecf20Sopenharmony_ci/* __ARCH_WANT_SYSCALL_DEPRECATED */
8208c2ecf20Sopenharmony_ciasmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
8218c2ecf20Sopenharmony_ci		compat_ulong_t __user *outp, compat_ulong_t __user *exp,
8228c2ecf20Sopenharmony_ci		struct old_timeval32 __user *tvp);
8238c2ecf20Sopenharmony_ciasmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
8248c2ecf20Sopenharmony_ciasmlinkage long compat_sys_recv(int fd, void __user *buf, compat_size_t len,
8258c2ecf20Sopenharmony_ci				unsigned flags);
8268c2ecf20Sopenharmony_ci
8278c2ecf20Sopenharmony_ci/* obsolete: fs/readdir.c */
8288c2ecf20Sopenharmony_ciasmlinkage long compat_sys_old_readdir(unsigned int fd,
8298c2ecf20Sopenharmony_ci				       struct compat_old_linux_dirent __user *,
8308c2ecf20Sopenharmony_ci				       unsigned int count);
8318c2ecf20Sopenharmony_ci
8328c2ecf20Sopenharmony_ci/* obsolete: fs/select.c */
8338c2ecf20Sopenharmony_ciasmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg);
8348c2ecf20Sopenharmony_ci
8358c2ecf20Sopenharmony_ci/* obsolete: ipc */
8368c2ecf20Sopenharmony_ciasmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
8378c2ecf20Sopenharmony_ci
8388c2ecf20Sopenharmony_ci/* obsolete: kernel/signal.c */
8398c2ecf20Sopenharmony_ci#ifdef __ARCH_WANT_SYS_SIGPENDING
8408c2ecf20Sopenharmony_ciasmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set);
8418c2ecf20Sopenharmony_ci#endif
8428c2ecf20Sopenharmony_ci
8438c2ecf20Sopenharmony_ci#ifdef __ARCH_WANT_SYS_SIGPROCMASK
8448c2ecf20Sopenharmony_ciasmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *nset,
8458c2ecf20Sopenharmony_ci				       compat_old_sigset_t __user *oset);
8468c2ecf20Sopenharmony_ci#endif
8478c2ecf20Sopenharmony_ci#ifdef CONFIG_COMPAT_OLD_SIGACTION
8488c2ecf20Sopenharmony_ciasmlinkage long compat_sys_sigaction(int sig,
8498c2ecf20Sopenharmony_ci                                   const struct compat_old_sigaction __user *act,
8508c2ecf20Sopenharmony_ci                                   struct compat_old_sigaction __user *oact);
8518c2ecf20Sopenharmony_ci#endif
8528c2ecf20Sopenharmony_ci
8538c2ecf20Sopenharmony_ci/* obsolete: net/socket.c */
8548c2ecf20Sopenharmony_ciasmlinkage long compat_sys_socketcall(int call, u32 __user *args);
8558c2ecf20Sopenharmony_ci
8568c2ecf20Sopenharmony_ci#endif /* CONFIG_ARCH_HAS_SYSCALL_WRAPPER */
8578c2ecf20Sopenharmony_ci
8588c2ecf20Sopenharmony_ci
8598c2ecf20Sopenharmony_ci/*
8608c2ecf20Sopenharmony_ci * For most but not all architectures, "am I in a compat syscall?" and
8618c2ecf20Sopenharmony_ci * "am I a compat task?" are the same question.  For architectures on which
8628c2ecf20Sopenharmony_ci * they aren't the same question, arch code can override in_compat_syscall.
8638c2ecf20Sopenharmony_ci */
8648c2ecf20Sopenharmony_ci
8658c2ecf20Sopenharmony_ci#ifndef in_compat_syscall
8668c2ecf20Sopenharmony_cistatic inline bool in_compat_syscall(void) { return is_compat_task(); }
8678c2ecf20Sopenharmony_ci#endif
8688c2ecf20Sopenharmony_ci
8698c2ecf20Sopenharmony_ci/**
8708c2ecf20Sopenharmony_ci * ns_to_old_timeval32 - Compat version of ns_to_timeval
8718c2ecf20Sopenharmony_ci * @nsec:	the nanoseconds value to be converted
8728c2ecf20Sopenharmony_ci *
8738c2ecf20Sopenharmony_ci * Returns the old_timeval32 representation of the nsec parameter.
8748c2ecf20Sopenharmony_ci */
8758c2ecf20Sopenharmony_cistatic inline struct old_timeval32 ns_to_old_timeval32(s64 nsec)
8768c2ecf20Sopenharmony_ci{
8778c2ecf20Sopenharmony_ci	struct __kernel_old_timeval tv;
8788c2ecf20Sopenharmony_ci	struct old_timeval32 ctv;
8798c2ecf20Sopenharmony_ci
8808c2ecf20Sopenharmony_ci	tv = ns_to_kernel_old_timeval(nsec);
8818c2ecf20Sopenharmony_ci	ctv.tv_sec = tv.tv_sec;
8828c2ecf20Sopenharmony_ci	ctv.tv_usec = tv.tv_usec;
8838c2ecf20Sopenharmony_ci
8848c2ecf20Sopenharmony_ci	return ctv;
8858c2ecf20Sopenharmony_ci}
8868c2ecf20Sopenharmony_ci
8878c2ecf20Sopenharmony_ci/*
8888c2ecf20Sopenharmony_ci * Kernel code should not call compat syscalls (i.e., compat_sys_xyzyyz())
8898c2ecf20Sopenharmony_ci * directly.  Instead, use one of the functions which work equivalently, such
8908c2ecf20Sopenharmony_ci * as the kcompat_sys_xyzyyz() functions prototyped below.
8918c2ecf20Sopenharmony_ci */
8928c2ecf20Sopenharmony_ci
8938c2ecf20Sopenharmony_ciint kcompat_sys_statfs64(const char __user * pathname, compat_size_t sz,
8948c2ecf20Sopenharmony_ci		     struct compat_statfs64 __user * buf);
8958c2ecf20Sopenharmony_ciint kcompat_sys_fstatfs64(unsigned int fd, compat_size_t sz,
8968c2ecf20Sopenharmony_ci			  struct compat_statfs64 __user * buf);
8978c2ecf20Sopenharmony_ci
8988c2ecf20Sopenharmony_ci#else /* !CONFIG_COMPAT */
8998c2ecf20Sopenharmony_ci
9008c2ecf20Sopenharmony_ci#define is_compat_task() (0)
9018c2ecf20Sopenharmony_ci/* Ensure no one redefines in_compat_syscall() under !CONFIG_COMPAT */
9028c2ecf20Sopenharmony_ci#define in_compat_syscall in_compat_syscall
9038c2ecf20Sopenharmony_cistatic inline bool in_compat_syscall(void) { return false; }
9048c2ecf20Sopenharmony_ci
9058c2ecf20Sopenharmony_ci#endif /* CONFIG_COMPAT */
9068c2ecf20Sopenharmony_ci
9078c2ecf20Sopenharmony_ci/*
9088c2ecf20Sopenharmony_ci * Some legacy ABIs like the i386 one use less than natural alignment for 64-bit
9098c2ecf20Sopenharmony_ci * types, and will need special compat treatment for that.  Most architectures
9108c2ecf20Sopenharmony_ci * don't need that special handling even for compat syscalls.
9118c2ecf20Sopenharmony_ci */
9128c2ecf20Sopenharmony_ci#ifndef compat_need_64bit_alignment_fixup
9138c2ecf20Sopenharmony_ci#define compat_need_64bit_alignment_fixup()		false
9148c2ecf20Sopenharmony_ci#endif
9158c2ecf20Sopenharmony_ci
9168c2ecf20Sopenharmony_ci/*
9178c2ecf20Sopenharmony_ci * A pointer passed in from user mode. This should not
9188c2ecf20Sopenharmony_ci * be used for syscall parameters, just declare them
9198c2ecf20Sopenharmony_ci * as pointers because the syscall entry code will have
9208c2ecf20Sopenharmony_ci * appropriately converted them already.
9218c2ecf20Sopenharmony_ci */
9228c2ecf20Sopenharmony_ci#ifndef compat_ptr
9238c2ecf20Sopenharmony_cistatic inline void __user *compat_ptr(compat_uptr_t uptr)
9248c2ecf20Sopenharmony_ci{
9258c2ecf20Sopenharmony_ci	return (void __user *)(unsigned long)uptr;
9268c2ecf20Sopenharmony_ci}
9278c2ecf20Sopenharmony_ci#endif
9288c2ecf20Sopenharmony_ci
9298c2ecf20Sopenharmony_cistatic inline compat_uptr_t ptr_to_compat(void __user *uptr)
9308c2ecf20Sopenharmony_ci{
9318c2ecf20Sopenharmony_ci	return (u32)(unsigned long)uptr;
9328c2ecf20Sopenharmony_ci}
9338c2ecf20Sopenharmony_ci
9348c2ecf20Sopenharmony_ci#endif /* _LINUX_COMPAT_H */
935