Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1309751imm; Wed, 23 May 2018 13:57:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp/8w3Ls+AH1tW0oc6E8okeDZ7PPFkNX7DlzdrhgLpK+99l80i0VQUZOJRWcB6HBPXJhrrq X-Received: by 2002:a17:902:a586:: with SMTP id az6-v6mr4467088plb.210.1527109062703; Wed, 23 May 2018 13:57:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527109062; cv=none; d=google.com; s=arc-20160816; b=HBgCgiE8wkRv/65J0/2g+HXMbgF6CszLVQnZu9w+D3bl8GS4+scPAAmhRxXTfaiCSq 7a1Ct+JRx7Oziv3m4ujK6J8HcyIEvve0OeteDCJqlQEiDLAGz33PZql9AMFZoWMmHFsq B84dCPr59r++tgCjoad71xKoRvq8sYlS8NgeGDhApTw6xo2dSPkzwtAoxjj1EHhfqD7/ 0qeToipNByvwLmv4WomXniSLgsNa1QrL1gi6oFcPb5/vclF2yvQjqIn1wYDr8kyNLKV7 NJyKCoFq9aNtlC3VbQ226rXAG+2vn2dOTVbVsJWajLle4dUn4LWVgcZGGJyAkneD4rON ccRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=v4vwdmRvqXy7exyPWoAsPxKpKiBCUGtNTAI52OijVyM=; b=i+oJPLmubk5RTGgldeH9HBHySXVlZsOP+oNyLyLkL6T1pRW3SEy9Rc4XaqXCR2Vb5+ 8x4B9PtDcNE+UeXgkXm3ocycyfSxlhn0fy/L6ci9WKoz/TJ0k1Kw1VbUeHQK6MQ2ekp4 JUDFyTjq7yLW2MYWR9Zw4ywitG9HqkuIGfLz88GB08BcdcDijtvQA+3v5lvFlB0v82GY CRhg/xO68o/OfiTi9VVNWSe26ZjAVBZdUV8ZZBJQXgjgPkRZb87UrqqrUhKjvS/JAELR srXKWEbB/Es9QthbZSdhbY3GV6GuTiAQfWAfmXNE/1PQU0nqcV2Lbl4TyfNZS+0wWnKu 5VYw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i73-v6si8854203pgc.634.2018.05.23.13.57.27; Wed, 23 May 2018 13:57:42 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934683AbeEWU5P (ORCPT + 99 others); Wed, 23 May 2018 16:57:15 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33642 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933737AbeEWU5N (ORCPT ); Wed, 23 May 2018 16:57:13 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4NKsn8K064607 for ; Wed, 23 May 2018 16:57:12 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 2j5cxt7bnf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 23 May 2018 16:57:12 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 23 May 2018 14:57:12 -0600 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 23 May 2018 14:57:03 -0600 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4NKihr317301890; Wed, 23 May 2018 20:44:57 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D74D9B2064; Wed, 23 May 2018 17:46:45 -0400 (EDT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A2D26B2065; Wed, 23 May 2018 17:46:45 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.70.82.108]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 23 May 2018 17:46:45 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id DBBA316C5DDF; Wed, 23 May 2018 13:46:35 -0700 (PDT) Date: Wed, 23 May 2018 13:46:35 -0700 From: "Paul E. McKenney" To: Mathieu Desnoyers Cc: Boqun Feng , Will Deacon , Peter Zijlstra , 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 , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linuxppc-dev Subject: Re: [PATCH 07/14] powerpc: Add support for restartable sequences Reply-To: paulmck@linux.vnet.ibm.com References: <20180430224433.17407-1-mathieu.desnoyers@efficios.com> <20180516161837.GI12198@hirez.programming.kicks-ass.net> <112970629.1913.1526501596485.JavaMail.zimbra@efficios.com> <20180517011949.GA1121@tardis> <277374719.2144.1526570889798.JavaMail.zimbra@efficios.com> <1526601043.1338308.1376191416.0444B8C5@webmail.messagingengine.com> <418003803.516.1526667437396.JavaMail.zimbra@efficios.com> <20180520140811.GB1121@tardis> <1928158599.1541.1527106479862.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1928158599.1541.1527106479862.JavaMail.zimbra@efficios.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18052320-0028-0000-0000-000009AD77B0 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009073; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000261; SDB=6.01036651; UDB=6.00530338; IPR=6.00815779; MB=3.00021264; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-23 20:57:10 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052320-0029-0000-0000-00003AF932C8 Message-Id: <20180523204635.GF3803@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-23_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805230204 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 23, 2018 at 04:14:39PM -0400, Mathieu Desnoyers wrote: > ----- On May 20, 2018, at 10:08 AM, Boqun Feng boqun.feng@gmail.com wrote: > > > On Fri, May 18, 2018 at 02:17:17PM -0400, Mathieu Desnoyers wrote: > >> ----- On May 17, 2018, at 7:50 PM, Boqun Feng boqun.feng@gmail.com wrote: > >> [...] > >> >> > 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) > >> >> > > >> > >> By the way, I think this is not the right spot to call rseq_syscall, because > >> interrupts are disabled. I think we should move this hunk right after > >> system_call_exit. > >> > > > > Good point. > > > >> Would you like to implement and test an updated patch adding those calls for ppc > >> 32 and 64 ? > >> > > > > I'd like to help, but I don't have a handy ppc environment for test... > > So I made the below patch which has only been build-tested, hope it > > could be somewhat helpful. > > Hi Boqun, > > I tried your patch in a ppc64 le environment, and it does not survive boot > with CONFIG_DEBUG_RSEQ=y. init gets killed right away. > > Moreover, I'm not sure that the r3 register don't contain something worth > saving before the call on ppc32. Just after there is a "mr" instruction > which AFAIU takes r3 as input register. > > Can you look into it ? Hello, Boqun, You can also request access to a ppc64 environment here: http://osuosl.org/services/powerdev/request_hosting/ Thanx, Paul > Thanks, > > Mathieu > > > > > Regards, > > Boqun > > > > --------------------------------->8 > > Subject: [PATCH] powerpc: Add syscall detection for restartable sequences > > > > Syscalls are not allowed inside restartable sequences, so add a call to > > rseq_syscall() at the very beginning of system call exiting path for > > CONFIG_DEBUG_RSEQ=y kernel. This could help us to detect whether there > > is a syscall issued inside restartable sequences. > > > > Signed-off-by: Boqun Feng > > --- > > arch/powerpc/kernel/entry_32.S | 5 +++++ > > arch/powerpc/kernel/entry_64.S | 5 +++++ > > 2 files changed, 10 insertions(+) > > > > diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S > > index eb8d01bae8c6..2f134eebe7ed 100644 > > --- a/arch/powerpc/kernel/entry_32.S > > +++ b/arch/powerpc/kernel/entry_32.S > > @@ -365,6 +365,11 @@ syscall_dotrace_cont: > > blrl /* Call handler */ > > .globl ret_from_syscall > > ret_from_syscall: > > +#ifdef CONFIG_DEBUG_RSEQ > > + /* Check whether the syscall is issued inside a restartable sequence */ > > + addi r3,r1,STACK_FRAME_OVERHEAD > > + bl rseq_syscall > > +#endif > > mr r6,r3 > > CURRENT_THREAD_INFO(r12, r1) > > /* disable interrupts so current_thread_info()->flags can't change */ > > diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S > > index 2cb5109a7ea3..2e2d59bb45d0 100644 > > --- a/arch/powerpc/kernel/entry_64.S > > +++ b/arch/powerpc/kernel/entry_64.S > > @@ -204,6 +204,11 @@ system_call: /* label this so stack traces look sane */ > > * This is blacklisted from kprobes further below with _ASM_NOKPROBE_SYMBOL(). > > */ > > system_call_exit: > > +#ifdef CONFIG_DEBUG_RSEQ > > + /* Check whether the syscall is issued inside a restartable sequence */ > > + addi r3,r1,STACK_FRAME_OVERHEAD > > + bl rseq_syscall > > +#endif > > /* > > * Disable interrupts so current_thread_info()->flags can't change, > > * and so that we don't get interrupted after loading SRR0/1. > > -- > > 2.16.2 > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com >