generic is_compat_task helper
RFC v2 1/1 generic is_compat_task helper
Take two of is_compat_task... Add a default function that will get optimized away in the !CONFIG_COMPAT case. Modify x86-64's is_compat_task to take a struct task_struct * argument. parisc at least can use the arg in several places in arch-dependant code to clean up ugliness (fixing the fact that it uses PER_LINUX32 is also on the agenda for later). There's only one arch indep user in the kernel (drivers/input/evdev.c) right now, so it can be moved as architectures which need it add the is_compat_task helper.
include/asm-parisc/compat.h +6 -0
@@ -5,6 +5,7 @@*/ #include <linux/types.h> #include <linux/sched.h> +#include <linux/personality.h> #define COMPAT_USER_HZ 100
@@ -144,4 +145,9 @@ static __inline__ void __user *compat_al return (void __user *)regs->gr[30]; } +static inline int is_compat_task (struct task_struct *t) +{ +return (personality (t->personality) ==PER_LINUX32 ); +} +#endif /* _ASM_PARISC_COMPAT_H */
include/asm-x86_64/compat.h +2 -2
@@ -202,9 +202,9 @@ static __inline__ void __user *compat_al return (void __user *)regs->rsp - len; } -static inline int is_compat_task (void ) +static inline int is_compat_task (struct task_struct *t) { -return current_thread_info ()->status &TS_COMPAT ; +return t->thread_info->status &TS_COMPAT ; }#endif /* _ASM_X86_64_COMPAT_H */
include/linux/compat.h +7 -0
@@ -161,5 +161,12 @@ int copy_siginfo_to_user32(struct compatint get_compat_sigevent (struct sigevent *event,const struct compat_sigevent __user *u_event); +#else /* !CONFIG_COMPAT */ + +static inline int is_compat_task (struct task_struct *t) { +return 0 ; +} +#endif /* CONFIG_COMPAT */ +#endif /* _LINUX_COMPAT_H */
RFC v3 1/1 generic is_compat_task helper
Take 3... External facing interface implicitly uses current. Use backend on parisc to clean up users in arch/parisc/kernel/ptrace.c which act on *child. No generic CONFIG_COMPAT case, arch maintainers must add their own (since they know best) to asm/compat.h.
include/asm-parisc/compat.h +10 -0
@@ -144,4 +144,14 @@ static __inline__ void __user *compat_al return (void __user *)regs->gr[30]; } +static inline int __is_compat_task (struct task_struct *t) +{ +return (personality (t->personality) ==PER_LINUX32 ); +} + +static inline int is_compat_task (void ) +{ +return __is_compat_task (current); +} +#endif /* _ASM_PARISC_COMPAT_H */
include/linux/compat.h +7 -0
@@ -161,5 +161,12 @@ int copy_siginfo_to_user32(struct compatint get_compat_sigevent (struct sigevent *event,const struct compat_sigevent __user *u_event); +#else /* !CONFIG_COMPAT */ + +static inline int is_compat_task (void ) +{ +return 0 ; +} +#endif /* CONFIG_COMPAT */ #endif /* _LINUX_COMPAT_H */