[PATCH] arm: task_pt_regs()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Al Viro and committed by Linus Torvalds 815d5ec8 e7c1b32f

+12 -28
+2 -3
arch/arm/kernel/process.c
··· 355 copy_thread(int nr, unsigned long clone_flags, unsigned long stack_start, 356 unsigned long stk_sz, struct task_struct *p, struct pt_regs *regs) 357 { 358 - struct thread_info *thread = p->thread_info; 359 - struct pt_regs *childregs; 360 361 - childregs = (void *)thread + THREAD_START_SP - sizeof(*regs); 362 *childregs = *regs; 363 childregs->ARM_r0 = 0; 364 childregs->ARM_sp = stack_start;
··· 355 copy_thread(int nr, unsigned long clone_flags, unsigned long stack_start, 356 unsigned long stk_sz, struct task_struct *p, struct pt_regs *regs) 357 { 358 + struct thread_info *thread = task_thread_info(p); 359 + struct pt_regs *childregs = task_pt_regs(p); 360 361 *childregs = *regs; 362 childregs->ARM_r0 = 0; 363 childregs->ARM_sp = stack_start;
+5 -22
arch/arm/kernel/ptrace.c
··· 55 #endif 56 57 /* 58 - * Get the address of the live pt_regs for the specified task. 59 - * These are saved onto the top kernel stack when the process 60 - * is not running. 61 - * 62 - * Note: if a user thread is execve'd from kernel space, the 63 - * kernel stack will not be empty on entry to the kernel, so 64 - * ptracing these tasks will fail. 65 - */ 66 - static inline struct pt_regs * 67 - get_user_regs(struct task_struct *task) 68 - { 69 - return (struct pt_regs *) 70 - ((unsigned long)task->thread_info + THREAD_SIZE - 71 - 8 - sizeof(struct pt_regs)); 72 - } 73 - 74 - /* 75 * this routine will get a word off of the processes privileged stack. 76 * the offset is how far from the base addr as stored in the THREAD. 77 * this routine assumes that all the privileged stacks are in our ··· 62 */ 63 static inline long get_user_reg(struct task_struct *task, int offset) 64 { 65 - return get_user_regs(task)->uregs[offset]; 66 } 67 68 /* ··· 74 static inline int 75 put_user_reg(struct task_struct *task, int offset, long data) 76 { 77 - struct pt_regs newregs, *regs = get_user_regs(task); 78 int ret = -EINVAL; 79 80 newregs = *regs; ··· 404 u32 insn; 405 int res; 406 407 - regs = get_user_regs(child); 408 pc = instruction_pointer(regs); 409 410 if (thumb_mode(regs)) { ··· 555 */ 556 static int ptrace_getregs(struct task_struct *tsk, void __user *uregs) 557 { 558 - struct pt_regs *regs = get_user_regs(tsk); 559 560 return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0; 561 } ··· 570 571 ret = -EFAULT; 572 if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) { 573 - struct pt_regs *regs = get_user_regs(tsk); 574 575 ret = -EINVAL; 576 if (valid_user_regs(&newregs)) {
··· 55 #endif 56 57 /* 58 * this routine will get a word off of the processes privileged stack. 59 * the offset is how far from the base addr as stored in the THREAD. 60 * this routine assumes that all the privileged stacks are in our ··· 79 */ 80 static inline long get_user_reg(struct task_struct *task, int offset) 81 { 82 + return task_pt_regs(task)->uregs[offset]; 83 } 84 85 /* ··· 91 static inline int 92 put_user_reg(struct task_struct *task, int offset, long data) 93 { 94 + struct pt_regs newregs, *regs = task_pt_regs(task); 95 int ret = -EINVAL; 96 97 newregs = *regs; ··· 421 u32 insn; 422 int res; 423 424 + regs = task_pt_regs(child); 425 pc = instruction_pointer(regs); 426 427 if (thumb_mode(regs)) { ··· 572 */ 573 static int ptrace_getregs(struct task_struct *tsk, void __user *uregs) 574 { 575 + struct pt_regs *regs = task_pt_regs(tsk); 576 577 return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0; 578 } ··· 587 588 ret = -EFAULT; 589 if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) { 590 + struct pt_regs *regs = task_pt_regs(tsk); 591 592 ret = -EINVAL; 593 if (valid_user_regs(&newregs)) {
+5 -3
include/asm-arm/processor.h
··· 85 */ 86 extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); 87 88 - #define KSTK_REGS(tsk) (((struct pt_regs *)(THREAD_START_SP + (unsigned long)(tsk)->thread_info)) - 1) 89 - #define KSTK_EIP(tsk) KSTK_REGS(tsk)->ARM_pc 90 - #define KSTK_ESP(tsk) KSTK_REGS(tsk)->ARM_sp 91 92 /* 93 * Prefetching support - only ARMv5.
··· 85 */ 86 extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); 87 88 + #define task_pt_regs(p) \ 89 + ((struct pt_regs *)(THREAD_START_SP + (void *)(p)->thread_info) - 1) 90 + 91 + #define KSTK_EIP(tsk) task_pt_regs(tsk)->ARM_pc 92 + #define KSTK_ESP(tsk) task_pt_regs(tsk)->ARM_sp 93 94 /* 95 * Prefetching support - only ARMv5.