From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753547AbdIGHEO (ORCPT ); Thu, 7 Sep 2017 03:04:14 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:58109 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751328AbdIGHEN (ORCPT ); Thu, 7 Sep 2017 03:04:13 -0400 Date: Thu, 7 Sep 2017 09:04:04 +0200 From: Peter Zijlstra To: Josh Poimboeuf Cc: Miguel Bernal Marin , Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" , linux-kernel@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH 3/3] locking/rwsem/x86: Add stack frame dependency for __downgrade_write() Message-ID: <20170907070404.5j2wrblttsxd2qyb@hirez.programming.kicks-ass.net> References: <20170906052613.30058-1-miguel.bernal.marin@linux.intel.com> <20170906052613.30058-4-miguel.bernal.marin@linux.intel.com> <20170906213302.s6st6ch32hixhwmg@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170906213302.s6st6ch32hixhwmg@treble> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 06, 2017 at 04:33:02PM -0500, Josh Poimboeuf wrote: > On Wed, Sep 06, 2017 at 12:26:13AM -0500, Miguel Bernal Marin wrote: > > kernel/locking/rwsem.o: warning: objtool: downgrade_write()+0x22: call without frame pointer save/setup > > > > The warning means gcc 7.2.0 placed the __downgrade_write() inline asm (and > > its call instruction) before the frame pointer setup in downgrade_write(), > > which breaks frame pointer convention and can result in incorrect > > stack traces. > > > > Force a stack frame to be created before the call instruction by listing > > the stack pointer as an output operand in the inline asm statement. > > > > Signed-off-by: Miguel Bernal Marin > > --- > > arch/x86/include/asm/rwsem.h | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h > > index d26b6916b935..a749dc6a3103 100644 > > --- a/arch/x86/include/asm/rwsem.h > > +++ b/arch/x86/include/asm/rwsem.h > > @@ -205,8 +205,10 @@ static inline void __up_write(struct rw_semaphore *sem) > > */ > > static inline void __downgrade_write(struct rw_semaphore *sem) > > { > > + register void *__sp asm(_ASM_SP); > > + > > asm volatile("# beginning __downgrade_write\n\t" > > - LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t" > > + LOCK_PREFIX _ASM_ADD "%2,(%2)\n\t" > > The '%2' should be changed to '%3' > > LOCK_PREFIX _ASM_ADD "%3,(%2)\n\t" > > because both inputs' indices are shifted by the new output constraint. Even better would be to used named operands.