diff mbox series

[v2,6/6] arm64: ptrace: add support for syscall emulation

Message ID 20190318104925.16600-7-sudeep.holla@arm.com (mailing list archive)
State Not Applicable
Headers show
Series ptrace: consolidate PTRACE_SYSEMU handling and add support for arm64 | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (de3c83c2fd2b87cf68214eda76dfa66989d78cb6)
snowpatch_ozlabs/build-ppc64le success Build succeeded
snowpatch_ozlabs/build-ppc64be success Build succeeded
snowpatch_ozlabs/build-ppc64e success Build succeeded
snowpatch_ozlabs/build-pmac32 success Build succeeded
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 38 lines checked

Commit Message

Sudeep Holla March 18, 2019, 10:49 a.m. UTC
Add PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP support on arm64.
We can just make sure of the generic ptrace_syscall_enter hook to
support PTRACE_SYSEMU. We don't need any special handling for
PTRACE_SYSEMU_SINGLESTEP.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 arch/arm64/include/asm/thread_info.h | 5 ++++-
 arch/arm64/kernel/ptrace.c           | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Haibo Xu (Arm Technology China) March 19, 2019, 3:26 a.m. UTC | #1
On 2019/3/18 18:49, Sudeep Holla wrote:
> Add PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP support on arm64.
> We can just make sure of the generic ptrace_syscall_enter hook to
> support PTRACE_SYSEMU. We don't need any special handling for
> PTRACE_SYSEMU_SINGLESTEP.

This looks good to me. But it'd be better to add the same logic to handle
PTRACE_SYSEMU_SINGLESTEP as that of x86 in case we may need enable the single
step trace function in the future.

>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
>  arch/arm64/include/asm/thread_info.h | 5 ++++-
>  arch/arm64/kernel/ptrace.c           | 3 +++
>  2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
> index eb3ef73e07cf..c285d1ce7186 100644
> --- a/arch/arm64/include/asm/thread_info.h
> +++ b/arch/arm64/include/asm/thread_info.h
> @@ -75,6 +75,7 @@ void arch_release_task_struct(struct task_struct *tsk);
>   *  TIF_SYSCALL_TRACE- syscall trace active
>   *  TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace
>   *  TIF_SYSCALL_AUDIT- syscall auditing
> + *  TIF_SYSCALL_EMU     - syscall emulation active
>   *  TIF_SECOMP- syscall secure computing
>   *  TIF_SIGPENDING- signal pending
>   *  TIF_NEED_RESCHED- rescheduling necessary
> @@ -91,6 +92,7 @@ void arch_release_task_struct(struct task_struct *tsk);
>  #define TIF_SYSCALL_AUDIT9
>  #define TIF_SYSCALL_TRACEPOINT10
>  #define TIF_SECCOMP11
> +#define TIF_SYSCALL_EMU12
>  #define TIF_MEMDIE18/* is terminating due to OOM killer */
>  #define TIF_FREEZE19
>  #define TIF_RESTORE_SIGMASK20
> @@ -109,6 +111,7 @@ void arch_release_task_struct(struct task_struct *tsk);
>  #define _TIF_SYSCALL_AUDIT(1 << TIF_SYSCALL_AUDIT)
>  #define _TIF_SYSCALL_TRACEPOINT(1 << TIF_SYSCALL_TRACEPOINT)
>  #define _TIF_SECCOMP(1 << TIF_SECCOMP)
> +#define _TIF_SYSCALL_EMU(1 << TIF_SYSCALL_EMU)
>  #define _TIF_UPROBE(1 << TIF_UPROBE)
>  #define _TIF_FSCHECK(1 << TIF_FSCHECK)
>  #define _TIF_32BIT(1 << TIF_32BIT)
> @@ -120,7 +123,7 @@ void arch_release_task_struct(struct task_struct *tsk);
>
>  #define _TIF_SYSCALL_WORK(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
>   _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
> - _TIF_NOHZ)
> + _TIF_NOHZ | _TIF_SYSCALL_EMU)
>
>  #define INIT_THREAD_INFO(tsk)\
>  {\
> diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
> index b82e0a9b3da3..cf29275cd4d9 100644
> --- a/arch/arm64/kernel/ptrace.c
> +++ b/arch/arm64/kernel/ptrace.c
> @@ -1819,6 +1819,9 @@ static void tracehook_report_syscall(struct pt_regs *regs,
>
>  int syscall_trace_enter(struct pt_regs *regs)
>  {
> +if (unlikely(ptrace_syscall_enter(regs)))
> +return -1;
> +
>  if (test_thread_flag(TIF_SYSCALL_TRACE))
>  tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);
>
>
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
index eb3ef73e07cf..c285d1ce7186 100644
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
@@ -75,6 +75,7 @@  void arch_release_task_struct(struct task_struct *tsk);
  *  TIF_SYSCALL_TRACE	- syscall trace active
  *  TIF_SYSCALL_TRACEPOINT - syscall tracepoint for ftrace
  *  TIF_SYSCALL_AUDIT	- syscall auditing
+ *  TIF_SYSCALL_EMU     - syscall emulation active
  *  TIF_SECOMP		- syscall secure computing
  *  TIF_SIGPENDING	- signal pending
  *  TIF_NEED_RESCHED	- rescheduling necessary
@@ -91,6 +92,7 @@  void arch_release_task_struct(struct task_struct *tsk);
 #define TIF_SYSCALL_AUDIT	9
 #define TIF_SYSCALL_TRACEPOINT	10
 #define TIF_SECCOMP		11
+#define TIF_SYSCALL_EMU		12
 #define TIF_MEMDIE		18	/* is terminating due to OOM killer */
 #define TIF_FREEZE		19
 #define TIF_RESTORE_SIGMASK	20
@@ -109,6 +111,7 @@  void arch_release_task_struct(struct task_struct *tsk);
 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
 #define _TIF_SYSCALL_TRACEPOINT	(1 << TIF_SYSCALL_TRACEPOINT)
 #define _TIF_SECCOMP		(1 << TIF_SECCOMP)
+#define _TIF_SYSCALL_EMU	(1 << TIF_SYSCALL_EMU)
 #define _TIF_UPROBE		(1 << TIF_UPROBE)
 #define _TIF_FSCHECK		(1 << TIF_FSCHECK)
 #define _TIF_32BIT		(1 << TIF_32BIT)
@@ -120,7 +123,7 @@  void arch_release_task_struct(struct task_struct *tsk);
 
 #define _TIF_SYSCALL_WORK	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
 				 _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
-				 _TIF_NOHZ)
+				 _TIF_NOHZ | _TIF_SYSCALL_EMU)
 
 #define INIT_THREAD_INFO(tsk)						\
 {									\
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index b82e0a9b3da3..cf29275cd4d9 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -1819,6 +1819,9 @@  static void tracehook_report_syscall(struct pt_regs *regs,
 
 int syscall_trace_enter(struct pt_regs *regs)
 {
+	if (unlikely(ptrace_syscall_enter(regs)))
+		return -1;
+
 	if (test_thread_flag(TIF_SYSCALL_TRACE))
 		tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);