[PATCH] arm26: 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 02ef691f 697102cd

+7 -23
+1 -2
arch/arm26/kernel/process.c
··· 278 278 unsigned long unused, struct task_struct *p, struct pt_regs *regs) 279 279 { 280 280 struct thread_info *thread = task_thread_info(p); 281 - struct pt_regs *childregs; 281 + struct pt_regs *childregs = task_pt_regs(p); 282 282 283 - childregs = __get_user_regs(thread); 284 283 *childregs = *regs; 285 284 childregs->ARM_r0 = 0; 286 285 childregs->ARM_sp = stack_start;
+5 -20
arch/arm26/kernel/ptrace.c
··· 40 40 #define BREAKINST_ARM 0xef9f0001 41 41 42 42 /* 43 - * Get the address of the live pt_regs for the specified task. 44 - * These are saved onto the top kernel stack when the process 45 - * is not running. 46 - * 47 - * Note: if a user thread is execve'd from kernel space, the 48 - * kernel stack will not be empty on entry to the kernel, so 49 - * ptracing these tasks will fail. 50 - */ 51 - static inline struct pt_regs * 52 - get_user_regs(struct task_struct *task) 53 - { 54 - return __get_user_regs(task->thread_info); 55 - } 56 - 57 - /* 58 43 * this routine will get a word off of the processes privileged stack. 59 44 * the offset is how far from the base addr as stored in the THREAD. 60 45 * this routine assumes that all the privileged stacks are in our ··· 47 62 */ 48 63 static inline long get_user_reg(struct task_struct *task, int offset) 49 64 { 50 - return get_user_regs(task)->uregs[offset]; 65 + return task_pt_regs(task)->uregs[offset]; 51 66 } 52 67 53 68 /* ··· 59 74 static inline int 60 75 put_user_reg(struct task_struct *task, int offset, long data) 61 76 { 62 - struct pt_regs newregs, *regs = get_user_regs(task); 77 + struct pt_regs newregs, *regs = task_pt_regs(task); 63 78 int ret = -EINVAL; 64 79 65 80 newregs = *regs; ··· 362 377 u32 insn; 363 378 int res; 364 379 365 - regs = get_user_regs(child); 380 + regs = task_pt_regs(child); 366 381 pc = instruction_pointer(regs); 367 382 368 383 res = read_instr(child, pc, &insn); ··· 485 500 */ 486 501 static int ptrace_getregs(struct task_struct *tsk, void *uregs) 487 502 { 488 - struct pt_regs *regs = get_user_regs(tsk); 503 + struct pt_regs *regs = task_pt_regs(tsk); 489 504 490 505 return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0; 491 506 } ··· 500 515 501 516 ret = -EFAULT; 502 517 if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) { 503 - struct pt_regs *regs = get_user_regs(tsk); 518 + struct pt_regs *regs = task_pt_regs(tsk); 504 519 505 520 ret = -EINVAL; 506 521 if (valid_user_regs(&newregs)) {
+1 -1
include/asm-arm26/thread_info.h
··· 82 82 83 83 /* FIXME - PAGE_SIZE < 32K */ 84 84 #define THREAD_SIZE (8*32768) // FIXME - this needs attention (see kernel/fork.c which gets a nice div by zero if this is lower than 8*32768 85 - #define __get_user_regs(x) (((struct pt_regs *)((unsigned long)(x) + THREAD_SIZE - 8)) - 1) 85 + #define task_pt_regs(task) ((struct pt_regs *)((unsigned long)(task)->thread_info + THREAD_SIZE - 8) - 1) 86 86 87 87 extern struct thread_info *alloc_thread_info(struct task_struct *task); 88 88 extern void free_thread_info(struct thread_info *);