[PATCH] m32r: task_pt_regs(), task_stack_page(), task_thread_info()

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 6c3559fc b7f6961d

+9 -26
+1 -4
arch/m32r/kernel/process.c
··· 242 242 int copy_thread(int nr, unsigned long clone_flags, unsigned long spu, 243 243 unsigned long unused, struct task_struct *tsk, struct pt_regs *regs) 244 244 { 245 - struct pt_regs *childregs; 246 - unsigned long sp = (unsigned long)tsk->thread_info + THREAD_SIZE; 245 + struct pt_regs *childregs = task_pt_regs(tsk); 247 246 extern void ret_from_fork(void); 248 247 249 248 /* Copy registers */ 250 - sp -= sizeof (struct pt_regs); 251 - childregs = (struct pt_regs *)sp; 252 249 *childregs = *regs; 253 250 254 251 childregs->spu = spu;
+4 -21
arch/m32r/kernel/ptrace.c
··· 35 35 #include <asm/mmu_context.h> 36 36 37 37 /* 38 - * Get the address of the live pt_regs for the specified task. 39 - * These are saved onto the top kernel stack when the process 40 - * is not running. 41 - * 42 - * Note: if a user thread is execve'd from kernel space, the 43 - * kernel stack will not be empty on entry to the kernel, so 44 - * ptracing these tasks will fail. 45 - */ 46 - static inline struct pt_regs * 47 - get_user_regs(struct task_struct *task) 48 - { 49 - return (struct pt_regs *) 50 - ((unsigned long)task->thread_info + THREAD_SIZE 51 - - sizeof(struct pt_regs)); 52 - } 53 - 54 - /* 55 38 * This routine will get a word off of the process kernel stack. 56 39 */ 57 40 static inline unsigned long int ··· 42 59 { 43 60 unsigned long *stack; 44 61 45 - stack = (unsigned long *)get_user_regs(task); 62 + stack = (unsigned long *)task_pt_regs(task); 46 63 47 64 return stack[offset]; 48 65 } ··· 55 72 { 56 73 unsigned long *stack; 57 74 58 - stack = (unsigned long *)get_user_regs(task); 75 + stack = (unsigned long *)task_pt_regs(task); 59 76 stack[offset] = data; 60 77 61 78 return 0; ··· 191 208 */ 192 209 static int ptrace_getregs(struct task_struct *tsk, void __user *uregs) 193 210 { 194 - struct pt_regs *regs = get_user_regs(tsk); 211 + struct pt_regs *regs = task_pt_regs(tsk); 195 212 196 213 return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0; 197 214 } ··· 206 223 207 224 ret = -EFAULT; 208 225 if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) { 209 - struct pt_regs *regs = get_user_regs(tsk); 226 + struct pt_regs *regs = task_pt_regs(tsk); 210 227 *regs = newregs; 211 228 ret = 0; 212 229 }
+1 -1
arch/m32r/kernel/smpboot.c
··· 286 286 /* So we see what's up */ 287 287 printk("Booting processor %d/%d\n", phys_id, cpu_id); 288 288 stack_start.spi = (void *)idle->thread.sp; 289 - idle->thread_info->cpu = cpu_id; 289 + task_thread_info(idle)->cpu = cpu_id; 290 290 291 291 /* 292 292 * Send Startup IPI
+3
include/asm-m32r/ptrace.h
··· 163 163 164 164 extern void withdraw_debug_trap(struct pt_regs *regs); 165 165 166 + #define task_pt_regs(task) \ 167 + ((struct pt_regs *)(task_stack_page(task) + THREAD_SIZE) - 1) 168 + 166 169 #endif /* __KERNEL */ 167 170 168 171 #endif /* _ASM_M32R_PTRACE_H */