Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ptrace: move user_enable_single_step & co prototypes to linux/ptrace.h

While in theory user_enable_single_step/user_disable_single_step/
user_enable_blockstep could also be provided as an inline or macro there's
no good reason to do so, and having the prototype in one places keeps code
size and confusion down.

Roland said:

The original thought there was that user_enable_single_step() et al
might well be only an instruction or three on a sane machine (as if we
have any of those!), and since there is only one call site inlining
would be beneficial. But I agree that there is no strong reason to care
about inlining it.

As to the arch changes, there is only one thought I'd add to the
record. It was always my thinking that for an arch where
PTRACE_SINGLESTEP does text-modifying breakpoint insertion,
user_enable_single_step() should not be provided. That is,
arch_has_single_step()=>true means that there is an arch facility with
"pure" semantics that does not have any unexpected side effects.
Inserting a breakpoint might do very unexpected strange things in
multi-threaded situations. Aside from that, it is a peculiar side
effect that user_{enable,disable}_single_step() should cause COW
de-sharing of text pages and so forth. For PTRACE_SINGLESTEP, all these
peculiarities are the status quo ante for that arch, so having
arch_ptrace() itself do those is one thing. But for building other
things in the future, it is nicer to have a uniform "pure" semantics
that arch-independent code can expect.

OTOH, all such arch issues are really up to the arch maintainer. As
of today, there is nothing but ptrace using user_enable_single_step() et
al so it's a distinction without a practical difference. If/when there
are other facilities that use user_enable_single_step() and might care,
the affected arch's can revisit the question when someone cares about
the quality of the arch support for said new facility.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Christoph Hellwig and committed by
Linus Torvalds
dacbe41f b3c1e01a

+6 -42
-2
arch/frv/include/asm/ptrace.h
··· 84 84 #define task_pt_regs(task) ((task)->thread.frame0) 85 85 86 86 #define arch_has_single_step() (1) 87 - extern void user_enable_single_step(struct task_struct *); 88 - extern void user_disable_single_step(struct task_struct *); 89 87 90 88 #endif /* !__ASSEMBLY__ */ 91 89 #endif /* __KERNEL__ */
-4
arch/ia64/include/asm/ptrace.h
··· 319 319 ptrace_attach_sync_user_rbs(child) 320 320 321 321 #define arch_has_single_step() (1) 322 - extern void user_enable_single_step(struct task_struct *); 323 - extern void user_disable_single_step(struct task_struct *); 324 - 325 322 #define arch_has_block_step() (1) 326 - extern void user_enable_block_step(struct task_struct *); 327 323 328 324 #endif /* !__KERNEL__ */ 329 325
-8
arch/m68k/include/asm/ptrace.h
··· 87 87 #define profile_pc(regs) instruction_pointer(regs) 88 88 extern void show_regs(struct pt_regs *); 89 89 90 - /* 91 - * These are defined as per linux/ptrace.h. 92 - */ 93 - struct task_struct; 94 - 95 90 #define arch_has_single_step() (1) 96 - extern void user_enable_single_step(struct task_struct *); 97 - extern void user_disable_single_step(struct task_struct *); 98 91 99 92 #ifdef CONFIG_MMU 100 93 #define arch_has_block_step() (1) 101 - extern void user_enable_block_step(struct task_struct *); 102 94 #endif 103 95 104 96 #endif /* __KERNEL__ */
-2
arch/mn10300/include/asm/ptrace.h
··· 99 99 extern void show_regs(struct pt_regs *); 100 100 101 101 #define arch_has_single_step() (1) 102 - extern void user_enable_single_step(struct task_struct *); 103 - extern void user_disable_single_step(struct task_struct *); 104 102 105 103 #endif /* !__ASSEMBLY */ 106 104
-5
arch/parisc/include/asm/ptrace.h
··· 47 47 48 48 #define task_regs(task) ((struct pt_regs *) ((char *)(task) + TASK_REGS)) 49 49 50 - struct task_struct; 51 50 #define arch_has_single_step() 1 52 - void user_disable_single_step(struct task_struct *task); 53 - void user_enable_single_step(struct task_struct *task); 54 - 55 51 #define arch_has_block_step() 1 56 - void user_enable_block_step(struct task_struct *task); 57 52 58 53 /* XXX should we use iaoq[1] or iaoq[0] ? */ 59 54 #define user_mode(regs) (((regs)->iaoq[0] & 3) ? 1 : 0)
-7
arch/powerpc/include/asm/ptrace.h
··· 137 137 } while (0) 138 138 #endif /* __powerpc64__ */ 139 139 140 - /* 141 - * These are defined as per linux/ptrace.h, which see. 142 - */ 143 140 #define arch_has_single_step() (1) 144 141 #define arch_has_block_step() (!cpu_has_feature(CPU_FTR_601)) 145 - extern void user_enable_single_step(struct task_struct *); 146 - extern void user_enable_block_step(struct task_struct *); 147 - extern void user_disable_single_step(struct task_struct *); 148 - 149 142 #define ARCH_HAS_USER_SINGLE_STEP_INFO 150 143 151 144 #endif /* __ASSEMBLY__ */
-3
arch/s390/include/asm/ptrace.h
··· 489 489 * These are defined as per linux/ptrace.h, which see. 490 490 */ 491 491 #define arch_has_single_step() (1) 492 - struct task_struct; 493 - extern void user_enable_single_step(struct task_struct *); 494 - extern void user_disable_single_step(struct task_struct *); 495 492 extern void show_regs(struct pt_regs * regs); 496 493 497 494 #define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0)
+1 -2
arch/score/include/asm/ptrace.h
··· 90 90 unsigned short *); 91 91 92 92 #define arch_has_single_step() (1) 93 - extern void user_enable_single_step(struct task_struct *); 94 - extern void user_disable_single_step(struct task_struct *); 93 + 95 94 #endif /* __KERNEL__ */ 96 95 97 96 #endif /* _ASM_SCORE_PTRACE_H */
-2
arch/sh/include/asm/ptrace.h
··· 123 123 struct task_struct; 124 124 125 125 #define arch_has_single_step() (1) 126 - extern void user_enable_single_step(struct task_struct *); 127 - extern void user_disable_single_step(struct task_struct *); 128 126 129 127 struct perf_event; 130 128 struct perf_sample_data;
-7
arch/x86/include/asm/ptrace.h
··· 274 274 return 0; 275 275 } 276 276 277 - /* 278 - * These are defined as per linux/ptrace.h, which see. 279 - */ 280 277 #define arch_has_single_step() (1) 281 - extern void user_enable_single_step(struct task_struct *); 282 - extern void user_disable_single_step(struct task_struct *); 283 - 284 - extern void user_enable_block_step(struct task_struct *); 285 278 #ifdef CONFIG_X86_DEBUGCTLMSR 286 279 #define arch_has_block_step() (1) 287 280 #else
+5
include/linux/ptrace.h
··· 264 264 static inline void user_disable_single_step(struct task_struct *task) 265 265 { 266 266 } 267 + #else 268 + extern void user_enable_single_step(struct task_struct *); 269 + extern void user_disable_single_step(struct task_struct *); 267 270 #endif /* arch_has_single_step */ 268 271 269 272 #ifndef arch_has_block_step ··· 294 291 { 295 292 BUG(); /* This can never be called. */ 296 293 } 294 + #else 295 + extern void user_enable_block_step(struct task_struct *); 297 296 #endif /* arch_has_block_step */ 298 297 299 298 #ifdef ARCH_HAS_USER_SINGLE_STEP_INFO