[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 355 copy_thread(int nr, unsigned long clone_flags, unsigned long stack_start, 356 356 unsigned long stk_sz, struct task_struct *p, struct pt_regs *regs) 357 357 { 358 - struct thread_info *thread = p->thread_info; 359 - struct pt_regs *childregs; 358 + struct thread_info *thread = task_thread_info(p); 359 + struct pt_regs *childregs = task_pt_regs(p); 360 360 361 - childregs = (void *)thread + THREAD_START_SP - sizeof(*regs); 362 361 *childregs = *regs; 363 362 childregs->ARM_r0 = 0; 364 363 childregs->ARM_sp = stack_start;
+5 -22
arch/arm/kernel/ptrace.c
··· 55 55 #endif 56 56 57 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 58 * this routine will get a word off of the processes privileged stack. 76 59 * the offset is how far from the base addr as stored in the THREAD. 77 60 * this routine assumes that all the privileged stacks are in our ··· 62 79 */ 63 80 static inline long get_user_reg(struct task_struct *task, int offset) 64 81 { 65 - return get_user_regs(task)->uregs[offset]; 82 + return task_pt_regs(task)->uregs[offset]; 66 83 } 67 84 68 85 /* ··· 74 91 static inline int 75 92 put_user_reg(struct task_struct *task, int offset, long data) 76 93 { 77 - struct pt_regs newregs, *regs = get_user_regs(task); 94 + struct pt_regs newregs, *regs = task_pt_regs(task); 78 95 int ret = -EINVAL; 79 96 80 97 newregs = *regs; ··· 404 421 u32 insn; 405 422 int res; 406 423 407 - regs = get_user_regs(child); 424 + regs = task_pt_regs(child); 408 425 pc = instruction_pointer(regs); 409 426 410 427 if (thumb_mode(regs)) { ··· 555 572 */ 556 573 static int ptrace_getregs(struct task_struct *tsk, void __user *uregs) 557 574 { 558 - struct pt_regs *regs = get_user_regs(tsk); 575 + struct pt_regs *regs = task_pt_regs(tsk); 559 576 560 577 return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0; 561 578 } ··· 570 587 571 588 ret = -EFAULT; 572 589 if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) { 573 - struct pt_regs *regs = get_user_regs(tsk); 590 + struct pt_regs *regs = task_pt_regs(tsk); 574 591 575 592 ret = -EINVAL; 576 593 if (valid_user_regs(&newregs)) {
+5 -3
include/asm-arm/processor.h
··· 85 85 */ 86 86 extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); 87 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 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 91 93 92 94 /* 93 95 * Prefetching support - only ARMv5.