Received: by 10.213.65.68 with SMTP id h4csp813700imn; Tue, 27 Mar 2018 09:14:01 -0700 (PDT) X-Google-Smtp-Source: AG47ELszihKATvp1lHjZQpZHSukcY4qRe9Rmz3q6HJBw96s0iaHCSaI8qvpt1btAk6i4gDPmp6zN X-Received: by 10.99.62.193 with SMTP id l184mr31114881pga.87.1522167241150; Tue, 27 Mar 2018 09:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522167241; cv=none; d=google.com; s=arc-20160816; b=l7WC+kg8VOG/HJF2Ul9at0m5YBjTOT9CUT+9VQ4wofmU+SU6A+g5jVkbbp4o8V7BEk JjJJozcgn37gWTJQuDShMGKC3S3lW+ofyahklfxF155COdDFH/CJpNPtIOurnejrSJVt qnhCbKF0aMJ+++86DKD2KLpyp77TQSVlLuRLZAIOn54nVKxssi4yCpL+1Tmf2J4slbtJ 23XTPuAP9mVxGCROz4zxNcRs2yV1c5/zGU2URYQYOulq+O05qeR0aHingzRQ3mcx5lpY GqKg5Q4P7sMZ4/XmY/n6pBl2HZkLTIpJutOaf5MrX6NaW6vIKy9PI/K7u1XWk1rGOfTQ oVcw== 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=NQ4xF848AzZhd/BFal7ng4hwwekj7ETAitLEkzVrXNw=; b=IclOJFN95Jn95uxuc3gw+/d5QqdSao4j507vnMXv7gZ9VYVap65ULy4vL2IekeJw+b DbXyYDqtESIGZBDygn2UXxSWTB2WxjyQTVjDtRXC0rbNamHVM22VAc/HvkNmh7Gvgm29 9EGzqBbGIywPUA8zoO4e9auPfjM2nJvTIgqA3z8M5vre3FmsCwx0HkA7hEP++mw/b98B b7yv3gXPG+f/ORSmsW5O2UwsllezC6G9yqxWAgWjIwZiP1suLQo/nmPrWhYpsf5uf9qm rdy71HxfjoKnPp0Pa98pqfnlE9SmNTRsSSTh4KCKEg/2VwOsqgVIqlXwAMzQr8EiyiDZ /nMA== 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 c2si1243749pfj.37.2018.03.27.09.13.46; Tue, 27 Mar 2018 09:14:01 -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 S1753100AbeC0QLh (ORCPT + 99 others); Tue, 27 Mar 2018 12:11:37 -0400 Received: from mail.efficios.com ([167.114.142.138]:51418 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752552AbeC0QGT (ORCPT ); Tue, 27 Mar 2018 12:06:19 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 7C3931A507F; Tue, 27 Mar 2018 12:06:18 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail02.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id p2KYQxfwRviF; Tue, 27 Mar 2018 12:06:18 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 1F4FF1A506B; Tue, 27 Mar 2018 12:06:18 -0400 (EDT) X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail02.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id dyFzknMWw4ZT; Tue, 27 Mar 2018 12:06:18 -0400 (EDT) Received: from thinkos.internal.efficios.com (192-222-157-41.qc.cable.ebox.net [192.222.157.41]) by mail.efficios.com (Postfix) with ESMTPSA id BA5E91A504E; Tue, 27 Mar 2018 12:06:17 -0400 (EDT) From: Mathieu Desnoyers To: Peter Zijlstra , "Paul E . McKenney" , Boqun Feng , Andy Lutomirski , Dave Watson Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Paul Turner , Andrew Morton , Russell King , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andrew Hunter , Andi Kleen , Chris Lameter , Ben Maurer , Steven Rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Mathieu Desnoyers Subject: [RFC PATCH for 4.17 05/21] x86: Add support for restartable sequences Date: Tue, 27 Mar 2018 12:05:26 -0400 Message-Id: <20180327160542.28457-6-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180327160542.28457-1-mathieu.desnoyers@efficios.com> References: <20180327160542.28457-1-mathieu.desnoyers@efficios.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Call the rseq_handle_notify_resume() function on return to userspace if TIF_NOTIFY_RESUME thread flag is set. Increment the event counter and perform fixup on the pre-signal frame when a signal is delivered on top of a restartable sequence critical section. Signed-off-by: Mathieu Desnoyers Reviewed-by: Thomas Gleixner CC: Russell King CC: Catalin Marinas CC: Will Deacon CC: Paul Turner CC: Andrew Hunter CC: Peter Zijlstra CC: Andy Lutomirski CC: Andi Kleen CC: Dave Watson CC: Chris Lameter CC: Ingo Molnar CC: "H. Peter Anvin" CC: Ben Maurer CC: Steven Rostedt CC: "Paul E. McKenney" CC: Josh Triplett CC: Linus Torvalds CC: Andrew Morton CC: Boqun Feng CC: linux-api@vger.kernel.org --- arch/x86/Kconfig | 1 + arch/x86/entry/common.c | 1 + arch/x86/kernel/signal.c | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 0fa71a78ec99..47a2b14fcc7d 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -178,6 +178,7 @@ config X86 select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE if X86_64 && UNWINDER_FRAME_POINTER && STACK_VALIDATION select HAVE_STACK_VALIDATION if X86_64 + select HAVE_RSEQ select HAVE_SYSCALL_TRACEPOINTS select HAVE_UNSTABLE_SCHED_CLOCK select HAVE_USER_RETURN_NOTIFIER diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index 74f6eee15179..ad348b28bcec 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -164,6 +164,7 @@ static void exit_to_usermode_loop(struct pt_regs *regs, u32 cached_flags) if (cached_flags & _TIF_NOTIFY_RESUME) { clear_thread_flag(TIF_NOTIFY_RESUME); tracehook_notify_resume(regs); + rseq_handle_notify_resume(regs); } if (cached_flags & _TIF_USER_RETURN_NOTIFY) diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c index 4cdc0b27ec82..0f549cbd8b46 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c @@ -687,6 +687,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs) sigset_t *set = sigmask_to_save(); compat_sigset_t *cset = (compat_sigset_t *) set; + /* + * Increment event counter and perform fixup for the pre-signal + * frame. + */ + rseq_signal_deliver(regs); + /* Set up the stack frame */ if (is_ia32_frame(ksig)) { if (ksig->ka.sa.sa_flags & SA_SIGINFO) -- 2.11.0