From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-1758617-1526543065-2-1779634507314435540 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.248, MAILING_LIST_MULTI -1, RCVD_IN_DNSWL_HI -5, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='US', FromHeader='org', MailFrom='org' X-Spam-charsets: plain='us-ascii' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: linux-api-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=fm2; t= 1526543065; b=hWCjhrBuf8+M6ezo9cG4Q+ie2UAFPtMHfjPa1/TGgPI4JtqKIv 57qPHzixE9c4bPBJXEUhoQxwgXxV+/s6LGOIZeVTkHY4yF+bzf4SAFFwKT6F/R/Y x/9t4zTCpM0lLLcrSa3IheQyVXu2LHBLdjHnbTHKE2wHkeIOyN81ZsP83bfYxg53 5TxmDjfMrYaOtVU3ZDrNNhQQn5usHuhzf5whusxKWeRa4esZ7tZ4enlfs60AJR+d fMrAifbklppjPOssa0Zff7ttrfb6mW02AV9rkmeXS0DJZXU3xfmFA4HQOM4EgMcF 801aaEbeGRhFFT90jAIwHw4OLb3NaKf8cXcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to:sender :list-id; s=fm2; t=1526543065; bh=wEys7YglLVlBSnKnzZxOqXs6kneTLg RXhd8ayaPtpDs=; b=PWhkGO91zfO3NwEOVX1ohhpqVKUZpFOpmoPE/uZrQKVXwh LWjBep6Q/3J+OgADgLat1msSiyk2BFXRCkgX4VZIctq0LnPgbh0MmKnge3CPu40E GCDwBDTo1658+DWKKThXqoXWnirTO1zbHNuvdMdU8gRwGcBflsgr5iM8vnr/5XX7 03U1+iiHBBbbildvPA5JjdYdFnYNBA7L6ie3UmVf3Tf7U3kS3rr7zH398XeCDrhZ 240tkcypvd2g547JKwVf/8eqyec5yYY8VE/NMSRqTDyP0xMfhLrtz2s3zWVWiIm/ lUZhQXepN5VSF9FSkIBAWzJQ8GN70LqWvnc7N8/g== ARC-Authentication-Results: i=1; mx6.messagingengine.com; arc=none (no signatures found); dkim=fail (message has been altered, 2048-bit rsa key sha256) header.d=infradead.org header.i=@infradead.org header.b=sQbEs2ug x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=bombadil.20170209; dmarc=none (p=none,has-list-id=yes,d=none) header.from=infradead.org; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=linux-api-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-cm=none score=0; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=infradead.org header.result=pass header_is_org_domain=yes; x-vs=clean score=-100 state=0 Authentication-Results: mx6.messagingengine.com; arc=none (no signatures found); dkim=fail (message has been altered, 2048-bit rsa key sha256) header.d=infradead.org header.i=@infradead.org header.b=sQbEs2ug x-bits=2048 x-keytype=rsa x-algorithm=sha256 x-selector=bombadil.20170209; dmarc=none (p=none,has-list-id=yes,d=none) header.from=infradead.org; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=linux-api-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-cm=none score=0; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=infradead.org header.result=pass header_is_org_domain=yes; x-vs=clean score=-100 state=0 X-ME-VSCategory: clean X-CM-Envelope: MS4wfCWapzrhhgs8T6eLiXtPYSt7JsiSdwMKWuFuVmDONaMFXHonth/vV5zKDrG/mQtgMrh+cywgTkqZQ4JsIm3E0P96YiBrH56ccVHS8lygOP3QygO+mbiO Bm6uSwSJvtdRkDwcT2oM1gkrgvIcPIml/vv3bIyGWYESpr4dyrB5LAC4NkjQXTW7LYyU+YPliIEIw5EcJ+4GGmtx8waLpVKemMHgQR6K2IYfwds9wxLL2wKH X-CM-Analysis: v=2.3 cv=FKU1Odgs c=1 sm=1 tr=0 a=UK1r566ZdBxH71SXbqIOeA==:117 a=UK1r566ZdBxH71SXbqIOeA==:17 a=kj9zAlcOel0A:10 a=VUJBJC2UJ8kA:10 a=VwQbUJbxAAAA:8 a=nuXmDM6KLvHpmz0yDD0A:9 a=CjuIK1q_8ugA:10 a=x8gzFH9gYPwA:10 a=AjGcO6oz07-iQ99wixmX:22 X-ME-CMScore: 0 X-ME-CMCategory: none Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751788AbeEQHoI (ORCPT ); Thu, 17 May 2018 03:44:08 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:46652 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752162AbeEQHoD (ORCPT ); Thu, 17 May 2018 03:44:03 -0400 Date: Thu, 17 May 2018 09:43:14 +0200 From: Peter Zijlstra To: Boqun Feng Cc: Mathieu Desnoyers , "Paul E. McKenney" , 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 , Will Deacon , Michael Kerrisk , Joel Fernandes , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linuxppc-dev Subject: Re: [PATCH 07/14] powerpc: Add support for restartable sequences Message-ID: <20180517074313.GK12217@hirez.programming.kicks-ass.net> References: <20180430224433.17407-1-mathieu.desnoyers@efficios.com> <20180430224433.17407-8-mathieu.desnoyers@efficios.com> <20180516161837.GI12198@hirez.programming.kicks-ass.net> <112970629.1913.1526501596485.JavaMail.zimbra@efficios.com> <20180517011949.GA1121@tardis> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180517011949.GA1121@tardis> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-api-owner@vger.kernel.org X-Mailing-List: linux-api@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Thu, May 17, 2018 at 09:19:49AM +0800, Boqun Feng wrote: > On Wed, May 16, 2018 at 04:13:16PM -0400, Mathieu Desnoyers wrote: > > 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 > > So we actually detect this after the syscall takes effect, right? I > wonder whether this could be problematic, because "disallowing syscall" > in rseq areas may means the syscall won't take effect to some people, I > guess? It doesn't really matter I suspect, the important part is the program getting killed. I agree that doing it on sysenter is slightly nicer, but I'll take sysexit if that's what it takes. > > this on PowerPC ? I was under the impression that PowerPC return to > > userspace fast-path was not calling C code unless work flags were set, > > but I might be wrong. > > > > I think you're right. So we have to introduce callsite to rseq_syscall() > in syscall path, something like: > > diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S > index 51695608c68b..a25734a96640 100644 > --- a/arch/powerpc/kernel/entry_64.S > +++ b/arch/powerpc/kernel/entry_64.S > @@ -222,6 +222,9 @@ system_call_exit: > mtmsrd r11,1 > #endif /* CONFIG_PPC_BOOK3E */ > > + addi r3,r1,STACK_FRAME_OVERHEAD > + bl rseq_syscall > + > ld r9,TI_FLAGS(r12) > li r11,-MAX_ERRNO > andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK) > > But I think it's important for us to first decide where (before or after > the syscall) we do the detection. The important thing is the processed getting very dead. Either sysenter or sysexit gets that done. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [PATCH 07/14] powerpc: Add support for restartable sequences Date: Thu, 17 May 2018 09:43:14 +0200 Message-ID: <20180517074313.GK12217@hirez.programming.kicks-ass.net> References: <20180430224433.17407-1-mathieu.desnoyers@efficios.com> <20180430224433.17407-8-mathieu.desnoyers@efficios.com> <20180516161837.GI12198@hirez.programming.kicks-ass.net> <112970629.1913.1526501596485.JavaMail.zimbra@efficios.com> <20180517011949.GA1121@tardis> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20180517011949.GA1121@tardis> Sender: linux-kernel-owner@vger.kernel.org To: Boqun Feng Cc: Mathieu Desnoyers , "Paul E. McKenney" , 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 List-Id: linux-api@vger.kernel.org On Thu, May 17, 2018 at 09:19:49AM +0800, Boqun Feng wrote: > On Wed, May 16, 2018 at 04:13:16PM -0400, Mathieu Desnoyers wrote: > > 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 > > So we actually detect this after the syscall takes effect, right? I > wonder whether this could be problematic, because "disallowing syscall" > in rseq areas may means the syscall won't take effect to some people, I > guess? It doesn't really matter I suspect, the important part is the program getting killed. I agree that doing it on sysenter is slightly nicer, but I'll take sysexit if that's what it takes. > > this on PowerPC ? I was under the impression that PowerPC return to > > userspace fast-path was not calling C code unless work flags were set, > > but I might be wrong. > > > > I think you're right. So we have to introduce callsite to rseq_syscall() > in syscall path, something like: > > diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S > index 51695608c68b..a25734a96640 100644 > --- a/arch/powerpc/kernel/entry_64.S > +++ b/arch/powerpc/kernel/entry_64.S > @@ -222,6 +222,9 @@ system_call_exit: > mtmsrd r11,1 > #endif /* CONFIG_PPC_BOOK3E */ > > + addi r3,r1,STACK_FRAME_OVERHEAD > + bl rseq_syscall > + > ld r9,TI_FLAGS(r12) > li r11,-MAX_ERRNO > andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK) > > But I think it's important for us to first decide where (before or after > the syscall) we do the detection. The important thing is the processed getting very dead. Either sysenter or sysexit gets that done.