compat: provide compat_ptr() on all architectures
In order to avoid needless #ifdef CONFIG_COMPAT checks, move the compat_ptr() definition to linux/compat.h where it can be seen by any file regardless of the architecture. Only s390 needs a special definition, this can use the self-#define trick we have elsewhere. Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
@@ -114,23 +114,6 @@ typedef u32 compat_sigset_word;
|
|||||||
|
|
||||||
#define COMPAT_OFF_T_MAX 0x7fffffff
|
#define COMPAT_OFF_T_MAX 0x7fffffff
|
||||||
|
|
||||||
/*
|
|
||||||
* A pointer passed in from user mode. This should not
|
|
||||||
* be used for syscall parameters, just declare them
|
|
||||||
* as pointers because the syscall entry code will have
|
|
||||||
* appropriately converted them already.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static inline void __user *compat_ptr(compat_uptr_t uptr)
|
|
||||||
{
|
|
||||||
return (void __user *)(unsigned long)uptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline compat_uptr_t ptr_to_compat(void __user *uptr)
|
|
||||||
{
|
|
||||||
return (u32)(unsigned long)uptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current)))
|
#define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current)))
|
||||||
#define COMPAT_MINSIGSTKSZ 2048
|
#define COMPAT_MINSIGSTKSZ 2048
|
||||||
|
|
||||||
|
|||||||
@@ -100,24 +100,6 @@ typedef u32 compat_sigset_word;
|
|||||||
|
|
||||||
#define COMPAT_OFF_T_MAX 0x7fffffff
|
#define COMPAT_OFF_T_MAX 0x7fffffff
|
||||||
|
|
||||||
/*
|
|
||||||
* A pointer passed in from user mode. This should not
|
|
||||||
* be used for syscall parameters, just declare them
|
|
||||||
* as pointers because the syscall entry code will have
|
|
||||||
* appropriately converted them already.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static inline void __user *compat_ptr(compat_uptr_t uptr)
|
|
||||||
{
|
|
||||||
/* cast to a __user pointer via "unsigned long" makes sparse happy */
|
|
||||||
return (void __user *)(unsigned long)(long)uptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline compat_uptr_t ptr_to_compat(void __user *uptr)
|
|
||||||
{
|
|
||||||
return (u32)(unsigned long)uptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void __user *arch_compat_alloc_user_space(long len)
|
static inline void __user *arch_compat_alloc_user_space(long len)
|
||||||
{
|
{
|
||||||
struct pt_regs *regs = (struct pt_regs *)
|
struct pt_regs *regs = (struct pt_regs *)
|
||||||
|
|||||||
@@ -173,23 +173,6 @@ struct compat_shmid64_ds {
|
|||||||
#define COMPAT_ELF_NGREG 80
|
#define COMPAT_ELF_NGREG 80
|
||||||
typedef compat_ulong_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
|
typedef compat_ulong_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
|
||||||
|
|
||||||
/*
|
|
||||||
* A pointer passed in from user mode. This should not
|
|
||||||
* be used for syscall parameters, just declare them
|
|
||||||
* as pointers because the syscall entry code will have
|
|
||||||
* appropriately converted them already.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static inline void __user *compat_ptr(compat_uptr_t uptr)
|
|
||||||
{
|
|
||||||
return (void __user *)(unsigned long)uptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline compat_uptr_t ptr_to_compat(void __user *uptr)
|
|
||||||
{
|
|
||||||
return (u32)(unsigned long)uptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline__ void __user *arch_compat_alloc_user_space(long len)
|
static __inline__ void __user *arch_compat_alloc_user_space(long len)
|
||||||
{
|
{
|
||||||
struct pt_regs *regs = ¤t->thread.regs;
|
struct pt_regs *regs = ¤t->thread.regs;
|
||||||
|
|||||||
@@ -96,23 +96,6 @@ typedef u32 compat_sigset_word;
|
|||||||
|
|
||||||
#define COMPAT_OFF_T_MAX 0x7fffffff
|
#define COMPAT_OFF_T_MAX 0x7fffffff
|
||||||
|
|
||||||
/*
|
|
||||||
* A pointer passed in from user mode. This should not
|
|
||||||
* be used for syscall parameters, just declare them
|
|
||||||
* as pointers because the syscall entry code will have
|
|
||||||
* appropriately converted them already.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static inline void __user *compat_ptr(compat_uptr_t uptr)
|
|
||||||
{
|
|
||||||
return (void __user *)(unsigned long)uptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline compat_uptr_t ptr_to_compat(void __user *uptr)
|
|
||||||
{
|
|
||||||
return (u32)(unsigned long)uptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void __user *arch_compat_alloc_user_space(long len)
|
static inline void __user *arch_compat_alloc_user_space(long len)
|
||||||
{
|
{
|
||||||
struct pt_regs *regs = current->thread.regs;
|
struct pt_regs *regs = current->thread.regs;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <asm/processor.h>
|
#include <asm/processor.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <asm/compat.h>
|
#include <linux/compat.h>
|
||||||
#include <asm/oprofile_impl.h>
|
#include <asm/oprofile_impl.h>
|
||||||
|
|
||||||
#define STACK_SP(STACK) *(STACK)
|
#define STACK_SP(STACK) *(STACK)
|
||||||
|
|||||||
@@ -177,11 +177,7 @@ static inline void __user *compat_ptr(compat_uptr_t uptr)
|
|||||||
{
|
{
|
||||||
return (void __user *)(unsigned long)(uptr & 0x7fffffffUL);
|
return (void __user *)(unsigned long)(uptr & 0x7fffffffUL);
|
||||||
}
|
}
|
||||||
|
#define compat_ptr(uptr) compat_ptr(uptr)
|
||||||
static inline compat_uptr_t ptr_to_compat(void __user *uptr)
|
|
||||||
{
|
|
||||||
return (u32)(unsigned long)uptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_COMPAT
|
#ifdef CONFIG_COMPAT
|
||||||
|
|
||||||
|
|||||||
@@ -125,23 +125,6 @@ typedef u32 compat_sigset_word;
|
|||||||
|
|
||||||
#define COMPAT_OFF_T_MAX 0x7fffffff
|
#define COMPAT_OFF_T_MAX 0x7fffffff
|
||||||
|
|
||||||
/*
|
|
||||||
* A pointer passed in from user mode. This should not
|
|
||||||
* be used for syscall parameters, just declare them
|
|
||||||
* as pointers because the syscall entry code will have
|
|
||||||
* appropriately converted them already.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static inline void __user *compat_ptr(compat_uptr_t uptr)
|
|
||||||
{
|
|
||||||
return (void __user *)(unsigned long)uptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline compat_uptr_t ptr_to_compat(void __user *uptr)
|
|
||||||
{
|
|
||||||
return (u32)(unsigned long)uptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_COMPAT
|
#ifdef CONFIG_COMPAT
|
||||||
static inline void __user *arch_compat_alloc_user_space(long len)
|
static inline void __user *arch_compat_alloc_user_space(long len)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -177,23 +177,6 @@ typedef struct user_regs_struct compat_elf_gregset_t;
|
|||||||
(!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT))
|
(!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* A pointer passed in from user mode. This should not
|
|
||||||
* be used for syscall parameters, just declare them
|
|
||||||
* as pointers because the syscall entry code will have
|
|
||||||
* appropriately converted them already.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static inline void __user *compat_ptr(compat_uptr_t uptr)
|
|
||||||
{
|
|
||||||
return (void __user *)(unsigned long)uptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline compat_uptr_t ptr_to_compat(void __user *uptr)
|
|
||||||
{
|
|
||||||
return (u32)(unsigned long)uptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void __user *arch_compat_alloc_user_space(long len)
|
static inline void __user *arch_compat_alloc_user_space(long len)
|
||||||
{
|
{
|
||||||
compat_uptr_t sp;
|
compat_uptr_t sp;
|
||||||
|
|||||||
@@ -958,4 +958,22 @@ static inline bool in_compat_syscall(void) { return false; }
|
|||||||
|
|
||||||
#endif /* CONFIG_COMPAT */
|
#endif /* CONFIG_COMPAT */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A pointer passed in from user mode. This should not
|
||||||
|
* be used for syscall parameters, just declare them
|
||||||
|
* as pointers because the syscall entry code will have
|
||||||
|
* appropriately converted them already.
|
||||||
|
*/
|
||||||
|
#ifndef compat_ptr
|
||||||
|
static inline void __user *compat_ptr(compat_uptr_t uptr)
|
||||||
|
{
|
||||||
|
return (void __user *)(unsigned long)uptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline compat_uptr_t ptr_to_compat(void __user *uptr)
|
||||||
|
{
|
||||||
|
return (u32)(unsigned long)uptr;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _LINUX_COMPAT_H */
|
#endif /* _LINUX_COMPAT_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user