sparc: We need to implement arch_ptrace_stop().

In order to always provide fully synchronized state to the debugger,
we might need to do a synchronize_user_stack().

A pair of hooks, arch_ptrace_stop_needed() and arch_ptrace_stop(),
exist to handle this kind of situation. It was created for
the sake of IA64.

Use them, to flush the kernel side cached register windows
to the user stack, when necessary.

Signed-off-by: David S. Miller <davem@davemloft.net>

+19
+10
arch/sparc/include/asm/ptrace_32.h
··· 62 63 #ifdef __KERNEL__ 64 65 static inline bool pt_regs_is_syscall(struct pt_regs *regs) 66 { 67 return (regs->psr & PSR_SYSCALL); ··· 73 { 74 return (regs->psr &= ~PSR_SYSCALL); 75 } 76 77 #define user_mode(regs) (!((regs)->psr & PSR_PS)) 78 #define instruction_pointer(regs) ((regs)->pc)
··· 62 63 #ifdef __KERNEL__ 64 65 + #include <asm/system.h> 66 + 67 static inline bool pt_regs_is_syscall(struct pt_regs *regs) 68 { 69 return (regs->psr & PSR_SYSCALL); ··· 71 { 72 return (regs->psr &= ~PSR_SYSCALL); 73 } 74 + 75 + #define arch_ptrace_stop_needed(exit_code, info) \ 76 + ({ flush_user_windows(); \ 77 + current_thread_info()->w_saved != 0; \ 78 + }) 79 + 80 + #define arch_ptrace_stop(exit_code, info) \ 81 + synchronize_user_stack() 82 83 #define user_mode(regs) (!((regs)->psr & PSR_PS)) 84 #define instruction_pointer(regs) ((regs)->pc)
+9
arch/sparc/include/asm/ptrace_64.h
··· 114 #ifdef __KERNEL__ 115 116 #include <linux/threads.h> 117 118 static inline int pt_regs_trap_type(struct pt_regs *regs) 119 { ··· 130 { 131 return (regs->tstate &= ~TSTATE_SYSCALL); 132 } 133 134 struct global_reg_snapshot { 135 unsigned long tstate;
··· 114 #ifdef __KERNEL__ 115 116 #include <linux/threads.h> 117 + #include <asm/system.h> 118 119 static inline int pt_regs_trap_type(struct pt_regs *regs) 120 { ··· 129 { 130 return (regs->tstate &= ~TSTATE_SYSCALL); 131 } 132 + 133 + #define arch_ptrace_stop_needed(exit_code, info) \ 134 + ({ flush_user_windows(); \ 135 + get_thread_wsaved() != 0; \ 136 + }) 137 + 138 + #define arch_ptrace_stop(exit_code, info) \ 139 + synchronize_user_stack() 140 141 struct global_reg_snapshot { 142 unsigned long tstate;