Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1507091imm; Wed, 23 May 2018 18:06:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoQW4/SZ6JY7Z7EqdnKTXb51w/LU75sHMQr2/frA5gR8qDV1SlQRlE3oWoHfePFjQu1Z0vi X-Received: by 2002:a62:9c93:: with SMTP id u19-v6mr5072295pfk.74.1527123962155; Wed, 23 May 2018 18:06:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527123962; cv=none; d=google.com; s=arc-20160816; b=Byb3RwkSb72Pb3NdMNaKencjdC0mSNm25KlrFsh/UYnaxQM5G4G/iLTuvchd4QX+vq ch1t5SbKr1zFgiQy3zA0Dh4smrAQRfUMBGv+WkoSEL6H5erd9TBGrtc9CjHYqpw5NKQ7 ZKO/oFQiO1En79/I+dA/YWRAiA0I92rrGQhi42x7M0y0H+SWAHM3GcP32lw/2xOnj0E8 CFb7E+vEQNt3vINn61cE9kmMUHy3ov+kc4p/HgLeMnSH6kKrBI3jLClVgdkAwDIUBoJk /EvGDPu+CkQVd7Sdrmd8VeCln9KnLtCKYkys6CfzZ528IwCODbYzvtz8KW4qMYJbkXXQ boRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:arc-authentication-results; bh=pWpzOO4kULh8+bb2EWw7/kcw3G4xxrnZUrI5f4t1lBY=; b=f+9gTWxWMMAKeP6vebVo7PqR6YO6AtyFCsWnj0U+Dnwy4adaa5JbbzFK7yMNTHip5o nM/ci3uKbieUqN40ZC/iujcIa/kVav1Bo4BnzxZsgK+Eqy7+HRGl/9aI6kyLHY7WnJj2 k9eMAtW/w5Uead0XncuEA0WWk4BUoxw5iNqnQEbkvoYEVmecj+s/N8XP0p5/yVYJ/VW1 vWKiFLwIHVwDAjo0w+gLyg5kuZjiM7apTY092Hgn58OuBE5R2icDF//6DeRNID8YKo+f 3Q01MnRGS789obFfNBiXXyJcnN55ntiR3VaEZYcPSGM+acl7MjECUA+LsHEpnHQ8nyAv bBbA== 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 s9-v6si20410925pfk.46.2018.05.23.18.05.47; Wed, 23 May 2018 18:06:02 -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 S935368AbeEXBDk (ORCPT + 99 others); Wed, 23 May 2018 21:03:40 -0400 Received: from ozlabs.org ([203.11.71.1]:40887 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935260AbeEXBDi (ORCPT ); Wed, 23 May 2018 21:03:38 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 40rrjb6ttwz9s02; Thu, 24 May 2018 11:03:30 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au From: Michael Ellerman To: Mathieu Desnoyers , Boqun Feng Cc: Will Deacon , Peter Zijlstra , "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 , Michael Kerrisk , Joel Fernandes , Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev Subject: Re: [PATCH 07/14] powerpc: Add support for restartable sequences In-Reply-To: <37442352.1577.1527110985175.JavaMail.zimbra@efficios.com> References: <20180430224433.17407-1-mathieu.desnoyers@efficios.com> <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> <37442352.1577.1527110985175.JavaMail.zimbra@efficios.com> Date: Thu, 24 May 2018 11:03:29 +1000 Message-ID: <87o9h5sw4e.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mathieu Desnoyers writes: > ----- On May 23, 2018, at 4:14 PM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote: ... >> >> 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. Sorry this code is super gross and hard to deal with. > The following fixup gets ppc64 to work: > > --- a/arch/powerpc/kernel/entry_64.S > +++ b/arch/powerpc/kernel/entry_64.S > @@ -208,6 +208,7 @@ system_call_exit: > /* Check whether the syscall is issued inside a restartable sequence */ > addi r3,r1,STACK_FRAME_OVERHEAD > bl rseq_syscall > + ld r3,RESULT(r1) > #endif > /* > * Disable interrupts so current_thread_info()->flags can't change, I don't think that's safe. If you look above that, we have r3, r8 and r12 all live: .Lsyscall_exit: std r3,RESULT(r1) CURRENT_THREAD_INFO(r12, r1) ld r8,_MSR(r1) #ifdef CONFIG_PPC_BOOK3S /* No MSR:RI on BookE */ andi. r10,r8,MSR_RI beq- .Lunrecov_restore #endif They're all volatile across function calls: http://openpowerfoundation.org/wp-content/uploads/resources/leabi/content/dbdoclet.50655240_68174.html The system_call_exit symbol is actually there for kprobes and cosmetic purposes. The actual syscall return flow starts at .Lsyscall_exit. So I think this would work: diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index db4df061c33a..e19f377a25e0 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S @@ -184,6 +184,14 @@ system_call: /* label this so stack traces look sane */ .Lsyscall_exit: std r3,RESULT(r1) + +#ifdef CONFIG_DEBUG_RSEQ + /* Check whether the syscall is issued inside a restartable sequence */ + addi r3,r1,STACK_FRAME_OVERHEAD + bl rseq_syscall + ld r3,RESULT(r1) +#endif + CURRENT_THREAD_INFO(r12, r1) ld r8,_MSR(r1) I'll try and get this series into my test setup at some point, been a bit busy lately :) cheers