Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3422836imm; Thu, 17 May 2018 08:31:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo1ycNpSvJ1bxvHx3RH9o/5VSFs/OeZs5kRJkbuSu5V2yUWObkry4CZQxe+D+yv6Y2c+CcK X-Received: by 2002:a65:48c9:: with SMTP id o9-v6mr4552692pgs.106.1526571119201; Thu, 17 May 2018 08:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526571119; cv=none; d=google.com; s=arc-20160816; b=Cr/yZlpqo4FV9uP4kZiLHs0Nz5LyPFFuTGFE1xn1/EFGf1qgdI3TBmtiUusIOX4Vvo vswgFNCuDFz2yvrex4bAN+BXlZ93wR/4gd1/FfYBnIGcFJvskV1RewTcwvGzwrR7DCK4 0XcyDM4JfPHpkGfvRZxPpl6bkZxuNtPJ1KKDwfH52Beum+Oh24MvH1DgtTYQmrFnKMMK jlRWzuFGX8F31QSYez6tOIEKuqzP22nWN7KDFcopvERXK7swNrsAbZGHxNZ6Nk1BCHIb gvNAdUgxiT6n7c9yPgP4+FnMbYHk8Zu55qS23I8eWSclUZYBVTE8rGI3vY8CuyPW18hM uCYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter :arc-authentication-results; bh=4+EeVcADZ8aWf1CCmWv5NijNbF+7gYRDXVsdi4fzHew=; b=vXKMMLKa891fRrXJI5XMntonm5X6o8AKU/8SjzRVNCtXYNQD33WYt6Ca+LcvmXQ9Qm Qgt4upvozaIQ6ujObvAd3LE6P/AyvVHa43gzbtkBA4Xr7yf7vf1mwJFhPCAKf6EEhBeO 4SVnPcvDT+LY0pu6ofgFzyYJ0/bE0LcONpJZp/DXBAWxC/8ytOjoOsQBZVVAD1wNSNEy nvMS7AaXl8y6m7Awe63QS+RxSPJZ7ptLSXXdSB9uZedwOep//FId/IEgewk6z89VsVk0 1FUERUghtGGchwR7cFUxfR7Dt7hxU6V/YIMnnK8ooH69PTNsUfe7gC9DiLyAUMRVcKQX mkog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=cnB0g/0i; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 95-v6si5466925plc.383.2018.05.17.08.31.44; Thu, 17 May 2018 08:31:59 -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; dkim=pass header.i=@efficios.com header.s=default header.b=cnB0g/0i; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752442AbeEQPaF (ORCPT + 99 others); Thu, 17 May 2018 11:30:05 -0400 Received: from mail.efficios.com ([167.114.142.138]:40566 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751494AbeEQPaD (ORCPT ); Thu, 17 May 2018 11:30:03 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id A697D1C01CE; Thu, 17 May 2018 11:30:02 -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 WwLp7pkWzCH0; Thu, 17 May 2018 11:30:01 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id CE25E1C01BA; Thu, 17 May 2018 11:30:01 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com CE25E1C01BA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1526571001; bh=4+EeVcADZ8aWf1CCmWv5NijNbF+7gYRDXVsdi4fzHew=; h=Date:From:To:Message-ID:MIME-Version; b=cnB0g/0i8MdkQhOf2TipX66KcP+MrpYMhS2HOKJPgAk3rfIcZmrnsM3d9Ki5YCEqZ Ne6rnWdXs/dQTp9sS03b3ydHYi96JvPQ+/Po6kqG9wOYqGqMSa86kNYHUdgcKgf/od 4S8dEotq11LiRqq+T+pywvHfGW778tGKqCux8UhYQJWFz4vf0FrQBnnb961UpYuI1O Emb4cMzYrEX8JIxZXcTt4nom0r4ju3nQbVcO5dzBuvMB7LqWNFhxIAuO6vIlnljBK9 FoF/tzYpodE0h+8cjrkE/h8uQ6z6rsK9XOFIkQfd/Ipf2wsQiuGeQbw3uMjEBKxMs4 Iva6LULs1PMQQ== 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 jcc7dTT_i46U; Thu, 17 May 2018 11:30:01 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id ACE401C01B0; Thu, 17 May 2018 11:30:01 -0400 (EDT) Date: Thu, 17 May 2018 11:30:01 -0400 (EDT) From: Mathieu Desnoyers To: Will Deacon Cc: Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Andy Lutomirski , Dave Watson , linux-kernel , linux-api , Paul Turner , Andrew Morton , Russell King , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andrew Hunter , Andi Kleen , Chris Lameter , Ben Maurer , rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Michael Kerrisk , Joel Fernandes Message-ID: <2135166002.2147.1526571001678.JavaMail.zimbra@efficios.com> In-Reply-To: <20180517133230.GA2688@arm.com> References: <20180430224433.17407-1-mathieu.desnoyers@efficios.com> <20180430224433.17407-4-mathieu.desnoyers@efficios.com> <20180516161809.GH12198@hirez.programming.kicks-ass.net> <670368504.1912.1526501593893.JavaMail.zimbra@efficios.com> <20180517133230.GA2688@arm.com> Subject: Re: [PATCH 03/14] arm: Add restartable sequences support MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.138] X-Mailer: Zimbra 8.8.8_GA_2026 (ZimbraWebClient - FF52 (Linux)/8.8.8_GA_2031) Thread-Topic: Add restartable sequences support Thread-Index: hkDF4Yy2rYjeT3UBbYbe4+QoPict4g== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On May 17, 2018, at 9:32 AM, Will Deacon will.deacon@arm.com wrote: > On Wed, May 16, 2018 at 04:13:13PM -0400, Mathieu Desnoyers wrote: >> ----- On May 16, 2018, at 12:18 PM, Peter Zijlstra peterz@infradead.org wrote: >> >> > On Mon, Apr 30, 2018 at 06:44:22PM -0400, Mathieu Desnoyers wrote: >> >> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig >> >> index a7f8e7f4b88f..4f5c386631d4 100644 >> >> --- a/arch/arm/Kconfig >> >> +++ b/arch/arm/Kconfig >> >> @@ -91,6 +91,7 @@ config ARM >> >> select HAVE_PERF_USER_STACK_DUMP >> >> select HAVE_RCU_TABLE_FREE if (SMP && ARM_LPAE) >> >> select HAVE_REGS_AND_STACK_ACCESS_API >> >> + select HAVE_RSEQ >> >> select HAVE_SYSCALL_TRACEPOINTS >> >> select HAVE_UID16 >> >> select HAVE_VIRT_CPU_ACCOUNTING_GEN >> >> diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c >> >> index bd8810d4acb3..5879ab3f53c1 100644 >> >> --- a/arch/arm/kernel/signal.c >> >> +++ b/arch/arm/kernel/signal.c >> >> @@ -541,6 +541,12 @@ static void handle_signal(struct ksignal *ksig, struct >> >> pt_regs *regs) >> >> int ret; >> >> >> >> /* >> >> + * Increment event counter and perform fixup for the pre-signal >> >> + * frame. >> >> + */ >> >> + rseq_signal_deliver(regs); >> >> + >> >> + /* >> >> * Set up the stack frame >> >> */ >> >> if (ksig->ka.sa.sa_flags & SA_SIGINFO) >> >> @@ -660,6 +666,7 @@ do_work_pending(struct pt_regs *regs, unsigned int >> >> thread_flags, int syscall) >> >> } else { >> >> clear_thread_flag(TIF_NOTIFY_RESUME); >> >> tracehook_notify_resume(regs); >> >> + rseq_handle_notify_resume(regs); >> >> } >> >> } >> >> local_irq_disable(); >> > >> > I think you forgot to hook up rseq_syscall() checking. >> >> Considering that rseq_syscall is implemented as follows: >> >> +void rseq_syscall(struct pt_regs *regs) >> +{ >> + unsigned long ip = instruction_pointer(regs); >> + struct task_struct *t = current; >> + struct rseq_cs rseq_cs; >> + >> + if (!t->rseq) >> + return; >> + if (!access_ok(VERIFY_READ, t->rseq, sizeof(*t->rseq)) || >> + rseq_get_rseq_cs(t, &rseq_cs) || in_rseq_cs(ip, &rseq_cs)) >> + force_sig(SIGSEGV, t); >> +} >> >> and that x86 calls it from syscall_return_slowpath() (which AFAIU is >> now used in the fast-path since KPTI), I wonder where we should call >> this on ARM ? I was under the impression that ARM return to userspace >> fast-path was not calling C code unless work flags were set, but I might >> be wrong. >> >> Thoughts ? > > Since this only matters for CONFIG_DEBUG_RSEQ, can we just force the > slowpath for rseq tasks when that option is set? Or as proposed by Boqun, we can simply call rseq_syscall in a CONFIG_DEBUG_RSEQ ifdef. Given that this is a debug option, is it worth it to add the current->rseq test for NULL in assembly before the call, or do we want to favor simplicity ? Thanks, Mathieu > > Will -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com