From patchwork Thu Feb 28 18:32:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 159429 Delivered-To: patch@linaro.org Received: by 2002:ac9:18c7:0:0:0:0:0 with SMTP id i7csp987986oce; Thu, 28 Feb 2019 10:32:52 -0800 (PST) X-Google-Smtp-Source: APXvYqxdPLegVMExGTcecMwgQAv18JsWoP3pqIHk6smL9gdq+WViuE9CLQsU3K5pgvzDBxiG28rr X-Received: by 2002:a63:788a:: with SMTP id t132mr576051pgc.0.1551378772328; Thu, 28 Feb 2019 10:32:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551378772; cv=none; d=google.com; s=arc-20160816; b=CTLprYU6+D1kA2WsJeNZmReJ4YzLx939G4zTOHlmJMyZTkfTLDp9dF6efMLGbI/qve DPFczqlg470Cy86831lM6fDFMuEWk+73v3Sem8rD2xrp6tH6PNhgExCQDga0Eb8k+Ez8 XADqPvo/h4jIGxW/4NIlMUKoB3HAXq9qxsCXNlqXnZq05w1MpXlMrZU7hU4XMGfcSh8q kzp3JGozi6tK5FssJnHcGARbrbZTRQarnOsoY5aqdruBlVHh1ci3q54hyURvh7BDzdah 9FI9LBzfcHG0+5uZlqS0MaKW2lKpUNP1prVU0bg/qT1SW03n6EeeHptCKo6RqHEh6QJx mHZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=qJlvM9anl/ArMFL6BDg618T6ZEAhJLwzAgsfwVLXg6c=; b=Td/HnxOQStDuJkHl5spWXaw73JZUUA78XwOCh+Xr7HDPs6Mq47YaZU7JkevhuIq3n4 oF+Xv4Sf1jXQzKzZNgdA9rhRcIysFQ18CPYsWR5celhCkYigjQiDzDiAWAtorFl+kKRH CwCaAYQEXC4zXvbJpx87M51HnUlLG6dejmXQgHl4TZMajRC+4PCNYaY5T00K98H7/ASj 9bibsrU2DyJlfOZtC6e5XVUhzWjaQiaSna4kyPGwvr3SKg11RzdgS6YmJXLn63ScW1A1 w3Qv9Wl4chICaMRz841XoqxrXcNL557y0rbMoxx3CwagNZVsm+dGVgjygi7JuvTAU0c/ 3LBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cm10si19872585plb.295.2019.02.28.10.32.52; Thu, 28 Feb 2019 10:32:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388729AbfB1Scu (ORCPT + 31 others); Thu, 28 Feb 2019 13:32:50 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53006 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388720AbfB1Scr (ORCPT ); Thu, 28 Feb 2019 13:32:47 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5AD121A25; Thu, 28 Feb 2019 10:32:47 -0800 (PST) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8AF0D3F5C1; Thu, 28 Feb 2019 10:32:44 -0800 (PST) From: Sudeep Holla To: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: Sudeep Holla , Catalin Marinas , Will Deacon , Oleg Nesterov , Paul Mackerras , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Richard Weinberger , jdike@addtoit.com, Steve Capper , Haibo Xu , Bin Lu Subject: [PATCH 6/6] arm64: ptrace: add support for syscall emulation Date: Thu, 28 Feb 2019 18:32:20 +0000 Message-Id: <20190228183220.15626-7-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190228183220.15626-1-sudeep.holla@arm.com> References: <20190228183220.15626-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Will Deacon Signed-off-by: Sudeep Holla --- arch/arm64/include/asm/thread_info.h | 5 ++++- arch/arm64/kernel/ptrace.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index bbca68b54732..c86aeb6379d5 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 @@ -92,6 +93,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 @@ -110,6 +112,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) @@ -121,7 +124,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 ddaea0fd2fa4..c377ce597f92 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -1672,6 +1672,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);