From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753548AbcEPJel (ORCPT ); Mon, 16 May 2016 05:34:41 -0400 Received: from mx2.suse.de ([195.135.220.15]:56587 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753148AbcEPJej (ORCPT ); Mon, 16 May 2016 05:34:39 -0400 Date: Mon, 16 May 2016 11:34:28 +0200 From: Borislav Petkov To: x86-ml Cc: Linus Torvalds , Guenter Roeck , Ingo Molnar , Peter Zijlstra , "linux-next@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] locking/rwsem: Fix comment on register clobbering Message-ID: <20160516093428.GA26108@pd.tnic> References: <57348665.3050301@roeck-us.net> <20160512135131.GA7803@pd.tnic> <20160512144657.GA14245@pd.tnic> <20160512172938.GB14245@pd.tnic> <20160513171915.GG17996@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20160513171915.GG17996@pd.tnic> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 13, 2016 at 07:19:15PM +0200, Borislav Petkov wrote: > The only thing that needs to be corrected then is the misleading comment > above the 32-bit version "... Save the C-clobbered registers (%eax, %edx > and %ecx) .." - the 64-bit version comment is correct AFAICT. --- From: Borislav Petkov Date: Mon, 16 May 2016 11:29:22 +0200 Subject: [PATCH] locking/rwsem: Fix comment on register clobbering Document explicitly that %edx can get clobbered on the slow path, on 32-bit. Something I learned the hard way. :-\ Signed-off-by: Borislav Petkov Cc: Ingo Molnar Cc: Linus Torvalds Cc: Peter Zijlstra --- arch/x86/lib/rwsem.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S index a37462a23546..bb49caa4dd4c 100644 --- a/arch/x86/lib/rwsem.S +++ b/arch/x86/lib/rwsem.S @@ -29,8 +29,10 @@ * there is contention on the semaphore. * * %eax contains the semaphore pointer on entry. Save the C-clobbered - * registers (%eax, %edx and %ecx) except %eax whish is either a return - * value or just clobbered.. + * registers (%eax, %edx and %ecx) except %eax which is either a return + * value or just clobbered. Same is true for %edx so make sure gcc + * reloads it after the slow path, by making it hold a temporary, for + * example; see ____down_write(). */ #define save_common_regs \ -- 2.7.3 SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) --