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.
Unified · Split
| @@ -114,23 +114,6 @@ typedef u32 compat_sigset_word; · 113 unmodified lines | ||
| 114 | 114 | |
| 115 | 115 | #define COMPAT_OFF_T_MAX 0x7fffffff |
| 116 | 116 | |
| 117 | −/* | |
| 118 | − * A pointer passed in from user mode. This should not | |
| 119 | − * be used for syscall parameters, just declare them | |
| 120 | − * as pointers because the syscall entry code will have | |
| 121 | − * appropriately converted them already. | |
| 122 | − */ | |
| 123 | − | |
| 124 | −static inline void __user *compat_ptr(compat_uptr_t uptr) | |
| 125 | −{ | |
| 126 | − return (void __user *)(unsigned long)uptr; | |
| 127 | −} | |
| 128 | − | |
| 129 | −static inline compat_uptr_t ptr_to_compat(void __user *uptr) | |
| 130 | −{ | |
| 131 | − return (u32)(unsigned long)uptr; | |
| 132 | −} | |
| 133 | − | |
| 134 | 117 | #define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current))) |
| 135 | 118 | #define COMPAT_MINSIGSTKSZ 2048 |
| 136 | 119 | |
| @@ -100,24 +100,6 @@ typedef u32 compat_sigset_word; · 99 unmodified lines | ||
| 100 | 100 | |
| 101 | 101 | #define COMPAT_OFF_T_MAX 0x7fffffff |
| 102 | 102 | |
| 103 | −/* | |
| 104 | − * A pointer passed in from user mode. This should not | |
| 105 | − * be used for syscall parameters, just declare them | |
| 106 | − * as pointers because the syscall entry code will have | |
| 107 | − * appropriately converted them already. | |
| 108 | − */ | |
| 109 | − | |
| 110 | −static inline void __user *compat_ptr(compat_uptr_t uptr) | |
| 111 | −{ | |
| 112 | − /* cast to a __user pointer via "unsigned long" makes sparse happy */ | |
| 113 | − return (void __user *)(unsigned long)(long)uptr; | |
| 114 | −} | |
| 115 | − | |
| 116 | −static inline compat_uptr_t ptr_to_compat(void __user *uptr) | |
| 117 | −{ | |
| 118 | − return (u32)(unsigned long)uptr; | |
| 119 | −} | |
| 120 | − | |
| 121 | 103 | static inline void __user *arch_compat_alloc_user_space(long len) |
| 122 | 104 | { |
| 123 | 105 | struct pt_regs *regs = (struct pt_regs *) |
| @@ -173,23 +173,6 @@ struct compat_shmid64_ds { · 172 unmodified lines | ||
| 173 | 173 | #define COMPAT_ELF_NGREG 80 |
| 174 | 174 | typedef compat_ulong_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; |
| 175 | 175 | |
| 176 | −/* | |
| 177 | − * A pointer passed in from user mode. This should not | |
| 178 | − * be used for syscall parameters, just declare them | |
| 179 | − * as pointers because the syscall entry code will have | |
| 180 | − * appropriately converted them already. | |
| 181 | − */ | |
| 182 | − | |
| 183 | −static inline void __user *compat_ptr(compat_uptr_t uptr) | |
| 184 | −{ | |
| 185 | − return (void __user *)(unsigned long)uptr; | |
| 186 | −} | |
| 187 | − | |
| 188 | −static inline compat_uptr_t ptr_to_compat(void __user *uptr) | |
| 189 | −{ | |
| 190 | − return (u32)(unsigned long)uptr; | |
| 191 | −} | |
| 192 | − | |
| 193 | 176 | static __inline__ void __user *arch_compat_alloc_user_space(long len) |
| 194 | 177 | { |
| 195 | 178 | struct pt_regs *regs = ¤t->thread.regs; |
| @@ -96,23 +96,6 @@ typedef u32 compat_sigset_word; · 95 unmodified lines | ||
| 96 | 96 | |
| 97 | 97 | #define COMPAT_OFF_T_MAX 0x7fffffff |
| 98 | 98 | |
| 99 | −/* | |
| 100 | − * A pointer passed in from user mode. This should not | |
| 101 | − * be used for syscall parameters, just declare them | |
| 102 | − * as pointers because the syscall entry code will have | |
| 103 | − * appropriately converted them already. | |
| 104 | − */ | |
| 105 | − | |
| 106 | −static inline void __user *compat_ptr(compat_uptr_t uptr) | |
| 107 | −{ | |
| 108 | − return (void __user *)(unsigned long)uptr; | |
| 109 | −} | |
| 110 | − | |
| 111 | −static inline compat_uptr_t ptr_to_compat(void __user *uptr) | |
| 112 | −{ | |
| 113 | − return (u32)(unsigned long)uptr; | |
| 114 | −} | |
| 115 | − | |
| 116 | 99 | static inline void __user *arch_compat_alloc_user_space(long len) |
| 117 | 100 | { |
| 118 | 101 | struct pt_regs *regs = current->thread.regs; |
| @@ -9,7 +9,7 @@ · 8 unmodified lines | ||
| 9 | 9 | #include <linux/sched.h> |
| 10 | 10 | #include <asm/processor.h> |
| 11 | 11 | #include <linux/uaccess.h> |
| 12 | −#include <asm/compat.h> | |
| 12 | +#include <linux/compat.h> | |
| 13 | 13 | #include <asm/oprofile_impl.h> |
| 14 | 14 | |
| 15 | 15 | #define STACK_SP(STACK) *(STACK) |
| @@ -177,11 +177,7 @@ static inline void __user *compat_ptr(compat_uptr_t uptr) · 176 unmodified lines | ||
| 177 | 177 | { |
| 178 | 178 | return (void __user *)(unsigned long)(uptr & 0x7fffffffUL); |
| 179 | 179 | } |
| 180 | − | |
| 181 | −static inline compat_uptr_t ptr_to_compat(void __user *uptr) | |
| 182 | −{ | |
| 183 | − return (u32)(unsigned long)uptr; | |
| 184 | −} | |
| 180 | +#define compat_ptr(uptr) compat_ptr(uptr) | |
| 185 | 181 | |
| 186 | 182 | #ifdef CONFIG_COMPAT |
| 187 | 183 | |
| @@ -125,23 +125,6 @@ typedef u32 compat_sigset_word; · 124 unmodified lines | ||
| 125 | 125 | |
| 126 | 126 | #define COMPAT_OFF_T_MAX 0x7fffffff |
| 127 | 127 | |
| 128 | −/* | |
| 129 | − * A pointer passed in from user mode. This should not | |
| 130 | − * be used for syscall parameters, just declare them | |
| 131 | − * as pointers because the syscall entry code will have | |
| 132 | − * appropriately converted them already. | |
| 133 | − */ | |
| 134 | − | |
| 135 | −static inline void __user *compat_ptr(compat_uptr_t uptr) | |
| 136 | −{ | |
| 137 | − return (void __user *)(unsigned long)uptr; | |
| 138 | −} | |
| 139 | − | |
| 140 | −static inline compat_uptr_t ptr_to_compat(void __user *uptr) | |
| 141 | −{ | |
| 142 | − return (u32)(unsigned long)uptr; | |
| 143 | −} | |
| 144 | − | |
| 145 | 128 | #ifdef CONFIG_COMPAT |
| 146 | 129 | static inline void __user *arch_compat_alloc_user_space(long len) |
| 147 | 130 | { |
| @@ -177,23 +177,6 @@ typedef struct user_regs_struct compat_elf_gregset_t; · 176 unmodified lines | ||
| 177 | 177 | (!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT)) |
| 178 | 178 | #endif |
| 179 | 179 | |
| 180 | −/* | |
| 181 | − * A pointer passed in from user mode. This should not | |
| 182 | − * be used for syscall parameters, just declare them | |
| 183 | − * as pointers because the syscall entry code will have | |
| 184 | − * appropriately converted them already. | |
| 185 | − */ | |
| 186 | − | |
| 187 | −static inline void __user *compat_ptr(compat_uptr_t uptr) | |
| 188 | −{ | |
| 189 | − return (void __user *)(unsigned long)uptr; | |
| 190 | −} | |
| 191 | − | |
| 192 | −static inline compat_uptr_t ptr_to_compat(void __user *uptr) | |
| 193 | −{ | |
| 194 | − return (u32)(unsigned long)uptr; | |
| 195 | −} | |
| 196 | − | |
| 197 | 180 | static inline void __user *arch_compat_alloc_user_space(long len) |
| 198 | 181 | { |
| 199 | 182 | compat_uptr_t sp; |
| @@ -958,4 +958,22 @@ static inline bool in_compat_syscall(void) { return false; } · 957 unmodified lines | ||
| 958 | 958 | |
| 959 | 959 | #endif /* CONFIG_COMPAT */ |
| 960 | 960 | |
| 961 | +/* | |
| 962 | + * A pointer passed in from user mode. This should not | |
| 963 | + * be used for syscall parameters, just declare them | |
| 964 | + * as pointers because the syscall entry code will have | |
| 965 | + * appropriately converted them already. | |
| 966 | + */ | |
| 967 | +#ifndef compat_ptr | |
| 968 | +static inline void __user *compat_ptr(compat_uptr_t uptr) | |
| 969 | +{ | |
| 970 | + return (void __user *)(unsigned long)uptr; | |
| 971 | +} | |
| 972 | +#endif | |
| 973 | + | |
| 974 | +static inline compat_uptr_t ptr_to_compat(void __user *uptr) | |
| 975 | +{ | |
| 976 | + return (u32)(unsigned long)uptr; | |
| 977 | +} | |
| 978 | + | |
| 961 | 979 | #endif /* _LINUX_COMPAT_H */ |