From patchwork Mon Jun 25 17:54:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 139874 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4273787lji; Mon, 25 Jun 2018 10:54:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIn2LQZQmaS8m4jhtzURR4irstM4Hyd4R/3lOovYvtQItjmjkUGm0hepcCQMp/eipikuMPn X-Received: by 2002:a65:5686:: with SMTP id v6-v6mr11586852pgs.141.1529949265056; Mon, 25 Jun 2018 10:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529949265; cv=none; d=google.com; s=arc-20160816; b=fHSYL3Xbn7S9nTj5mz+tr6YbESFdCcHywUZF91VrRmmKW7mKXN89WvXAbwRv2A/oQu 0aA4aNdSHP6WXeo863IsNOQ+sVbCTlF9Nz2JENMzIHieZvFkni/HDApKFhhQfRgasu4v 2+1Q1zwYbo4ZmKsu3zfJ3nBnyJ+64LV6CjHseRkKEsU3fpBnPc/cckng4ORSxhrOJfYq MI3rPJnPAuRBg8CIE2yHDTB28dKvPXDhZZFG10aQsMpv1i7sNh2D2aKLQ6l/XAg2JxQI NWBYkIUc9UuLgvVvBj26omjsQEbhfvAXS91EutOlbf21dJvX1F6g4E8yy0Crd1IJ2sv0 4hSg== 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:arc-authentication-results; bh=bO3y7WlUnX+CKYvq/WzBHByThHZfCN7KpoGZY/pRvBE=; b=ZrZcdGQ/F6BZ7pC6fGXHirynXq8Lg8/oNkGf/9YhDVdS6h4kxXPelDjqW3KpGB4fSv dr96Ec9UprdLTEMYS+8g1ej7DZv0J7dBg2iSOE9q7VJGsATEKkKlBXuTA+7rSrsAt/q8 UUl6LnrRzKlUmP/ctHPM5JBKkf92GWnVAkiXqG2D2p9Rknmioe9ZnVCJNkcmkwl8mUdC t+7NvofgiPw4jUtqZlnq2FW9K4G9SSTfCFmv4l6gRzsrjWHWc0xRHNyOeiuBhVKk3iRQ ZzMiIizod+TrMg2WEoQEzhv3v+ozlKgYNFWjMG3Z711Hllio1dHYDGYaDoH+sIrxELNy se0w== 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 o1-v6si9478984pgb.101.2018.06.25.10.54.24; Mon, 25 Jun 2018 10:54:25 -0700 (PDT) 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 S964888AbeFYRyM (ORCPT + 31 others); Mon, 25 Jun 2018 13:54:12 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:35026 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755521AbeFYRyJ (ORCPT ); Mon, 25 Jun 2018 13:54:09 -0400 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 2CD4AED1; Mon, 25 Jun 2018 10:54:09 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F28173F7CE; Mon, 25 Jun 2018 10:54:08 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 510941AE111F; Mon, 25 Jun 2018 18:54:46 +0100 (BST) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, arnd@arndb.de, mathieu.desnoyers@efficios.com, peterz@infradead.org, paulmck@linux.vnet.ibm.com, boqun.feng@gmail.com, catalin.marinas@arm.com, peter.maydell@linaro.org, mark.rutland@arm.com, Will Deacon Subject: [PATCH 1/3] arm64: rseq: Implement backend rseq calls and select HAVE_RSEQ Date: Mon, 25 Jun 2018 18:54:43 +0100 Message-Id: <1529949285-11013-2-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1529949285-11013-1-git-send-email-will.deacon@arm.com> References: <1529949285-11013-1-git-send-email-will.deacon@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement calls to rseq_signal_deliver, rseq_handle_notify_resume and rseq_syscall so that we can select HAVE_RSEQ on arm64. Signed-off-by: Will Deacon --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/unistd.h | 2 +- arch/arm64/include/asm/unistd32.h | 2 ++ arch/arm64/kernel/entry.S | 2 ++ arch/arm64/kernel/ptrace.c | 2 ++ arch/arm64/kernel/signal.c | 3 +++ 6 files changed, 11 insertions(+), 1 deletion(-) -- 2.1.4 Acked-by: Mark Rutland diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 42c090cf0292..26cb550673b2 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -127,6 +127,7 @@ config ARM64 select HAVE_PERF_USER_STACK_DUMP select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RCU_TABLE_FREE + select HAVE_RSEQ select HAVE_STACKPROTECTOR select HAVE_SYSCALL_TRACEPOINTS select HAVE_KPROBES diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h index a0baa9af5487..e0d0f5b856e7 100644 --- a/arch/arm64/include/asm/unistd.h +++ b/arch/arm64/include/asm/unistd.h @@ -43,7 +43,7 @@ #define __ARM_NR_compat_cacheflush (__ARM_NR_COMPAT_BASE+2) #define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE+5) -#define __NR_compat_syscalls 398 +#define __NR_compat_syscalls 399 #endif #define __ARCH_WANT_SYS_CLONE diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h index ef292160748c..0fdc7ef8a776 100644 --- a/arch/arm64/include/asm/unistd32.h +++ b/arch/arm64/include/asm/unistd32.h @@ -817,6 +817,8 @@ __SYSCALL(__NR_pkey_alloc, sys_pkey_alloc) __SYSCALL(__NR_pkey_free, sys_pkey_free) #define __NR_statx 397 __SYSCALL(__NR_statx, sys_statx) +#define __NR_rseq 398 +__SYSCALL(__NR_rseq, sys_rseq) /* * Please add new compat syscalls above this comment and update diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 28ad8799406f..1eda9e1a1f4a 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -904,6 +904,7 @@ ENDPROC(el0_error) ret_fast_syscall: disable_daif str x0, [sp, #S_X0] // returned x0 +#ifndef CONFIG_DEBUG_RSEQ ldr x1, [tsk, #TSK_TI_FLAGS] // re-check for syscall tracing and x2, x1, #_TIF_SYSCALL_WORK cbnz x2, ret_fast_syscall_trace @@ -911,6 +912,7 @@ ret_fast_syscall: cbnz x2, work_pending enable_step_tsk x1, x2 kernel_exit 0 +#endif ret_fast_syscall_trace: enable_daif b __sys_trace_return_skipped // we already saved x0 diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 5c338ce5a7fa..9f479c111675 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -1656,6 +1656,8 @@ asmlinkage void syscall_trace_exit(struct pt_regs *regs) if (test_thread_flag(TIF_SYSCALL_TRACE)) tracehook_report_syscall(regs, PTRACE_SYSCALL_EXIT); + + rseq_syscall(regs); } /* diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 511af13e8d8f..e3b1d1b0aee8 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -802,6 +802,8 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) int usig = ksig->sig; int ret; + rseq_signal_deliver(ksig, regs); + /* * Set up the stack frame */ @@ -940,6 +942,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, if (thread_flags & _TIF_NOTIFY_RESUME) { clear_thread_flag(TIF_NOTIFY_RESUME); tracehook_notify_resume(regs); + rseq_handle_notify_resume(NULL, regs); } if (thread_flags & _TIF_FOREIGN_FPSTATE)