diff options
Diffstat (limited to 'arch/x86/include/asm/compat.h')
| -rw-r--r-- | arch/x86/include/asm/compat.h | 117 | 
1 files changed, 111 insertions, 6 deletions
diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h index 1d9cd27c292..59c6c401f79 100644 --- a/arch/x86/include/asm/compat.h +++ b/arch/x86/include/asm/compat.h @@ -6,7 +6,9 @@   */  #include <linux/types.h>  #include <linux/sched.h> +#include <asm/processor.h>  #include <asm/user32.h> +#include <asm/unistd.h>  #define COMPAT_USER_HZ		100  #define COMPAT_UTS_MACHINE	"i686\0\0" @@ -39,6 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;  typedef u32		compat_uint_t;  typedef u32		compat_ulong_t;  typedef u64 __attribute__((aligned(4))) compat_u64; +typedef u32		compat_uptr_t;  struct compat_timespec {  	compat_time_t	tv_sec; @@ -108,7 +111,8 @@ struct compat_statfs {  	compat_fsid_t	f_fsid;  	int		f_namelen;	/* SunOS ignores this field. */  	int		f_frsize; -	int		f_spare[5]; +	int		f_flags; +	int		f_spare[4];  };  #define COMPAT_RLIM_OLD_INFINITY	0x7fffffff @@ -121,6 +125,78 @@ typedef u32		compat_old_sigset_t;	/* at least 32 bits */  typedef u32               compat_sigset_word; +typedef union compat_sigval { +	compat_int_t	sival_int; +	compat_uptr_t	sival_ptr; +} compat_sigval_t; + +typedef struct compat_siginfo { +	int si_signo; +	int si_errno; +	int si_code; + +	union { +		int _pad[128/sizeof(int) - 3]; + +		/* kill() */ +		struct { +			unsigned int _pid;	/* sender's pid */ +			unsigned int _uid;	/* sender's uid */ +		} _kill; + +		/* POSIX.1b timers */ +		struct { +			compat_timer_t _tid;	/* timer id */ +			int _overrun;		/* overrun count */ +			compat_sigval_t _sigval;	/* same as below */ +			int _sys_private;	/* not to be passed to user */ +			int _overrun_incr;	/* amount to add to overrun */ +		} _timer; + +		/* POSIX.1b signals */ +		struct { +			unsigned int _pid;	/* sender's pid */ +			unsigned int _uid;	/* sender's uid */ +			compat_sigval_t _sigval; +		} _rt; + +		/* SIGCHLD */ +		struct { +			unsigned int _pid;	/* which child */ +			unsigned int _uid;	/* sender's uid */ +			int _status;		/* exit code */ +			compat_clock_t _utime; +			compat_clock_t _stime; +		} _sigchld; + +		/* SIGCHLD (x32 version) */ +		struct { +			unsigned int _pid;	/* which child */ +			unsigned int _uid;	/* sender's uid */ +			int _status;		/* exit code */ +			compat_s64 _utime; +			compat_s64 _stime; +		} _sigchld_x32; + +		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ +		struct { +			unsigned int _addr;	/* faulting insn/memory ref. */ +		} _sigfault; + +		/* SIGPOLL */ +		struct { +			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */ +			int _fd; +		} _sigpoll; + +		struct { +			unsigned int _call_addr; /* calling insn */ +			int _syscall;	/* triggering system call number */ +			unsigned int _arch;	/* AUDIT_ARCH_* of syscall */ +		} _sigsys; +	} _sifields; +} compat_siginfo_t; +  #define COMPAT_OFF_T_MAX	0x7fffffff  #define COMPAT_LOFF_T_MAX	0x7fffffffffffffffL @@ -185,7 +261,20 @@ struct compat_shmid64_ds {  /*   * The type of struct elf_prstatus.pr_reg in compatible core dumps.   */ +#ifdef CONFIG_X86_X32_ABI +typedef struct user_regs_struct compat_elf_gregset_t; + +#define PR_REG_SIZE(S) (test_thread_flag(TIF_IA32) ? 68 : 216) +#define PRSTATUS_SIZE(S) (test_thread_flag(TIF_IA32) ? 144 : 296) +#define SET_PR_FPVALID(S,V) \ +  do { *(int *) (((void *) &((S)->pr_reg)) + PR_REG_SIZE(0)) = (V); } \ +  while (0) + +#define COMPAT_USE_64BIT_TIME \ +	(!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT)) +#else  typedef struct user_regs_struct32 compat_elf_gregset_t; +#endif  /*   * A pointer passed in from user mode. This should not @@ -193,7 +282,6 @@ typedef struct user_regs_struct32 compat_elf_gregset_t;   * as pointers because the syscall entry code will have   * appropriately converted them already.   */ -typedef	u32		compat_uptr_t;  static inline void __user *compat_ptr(compat_uptr_t uptr)  { @@ -207,13 +295,30 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)  static inline void __user *arch_compat_alloc_user_space(long len)  { -	struct pt_regs *regs = task_pt_regs(current); -	return (void __user *)regs->sp - len; +	compat_uptr_t sp; + +	if (test_thread_flag(TIF_IA32)) { +		sp = task_pt_regs(current)->sp; +	} else { +		/* -128 for the x32 ABI redzone */ +		sp = this_cpu_read(old_rsp) - 128; +	} + +	return (void __user *)round_down(sp - len, 16); +} + +static inline bool is_x32_task(void) +{ +#ifdef CONFIG_X86_X32_ABI +	if (task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT) +		return true; +#endif +	return false;  } -static inline int is_compat_task(void) +static inline bool is_compat_task(void)  { -	return current_thread_info()->status & TS_COMPAT; +	return is_ia32_task() || is_x32_task();  }  #endif /* _ASM_X86_COMPAT_H */  | 
