Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751489AbdCPHqI (ORCPT ); Thu, 16 Mar 2017 03:46:08 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:35979 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751104AbdCPHqH (ORCPT ); Thu, 16 Mar 2017 03:46:07 -0400 Date: Thu, 16 Mar 2017 08:46:02 +0100 From: Ingo Molnar To: Michael Davidson Cc: "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar , Alexander Potapenko , Dmitry Vyukov , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] x86, boot: Use regparm=0 for memcpy and memset when using clang Message-ID: <20170316074601.GA23914@gmail.com> References: <20170315214821.127170-1-md@google.com> <20170315214821.127170-2-md@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170315214821.127170-2-md@google.com> 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 Content-Length: 1602 Lines: 53 * Michael Davidson wrote: > Use the standard regparm=0 calling convention for memcpy and > memset when building with clang. > > This is a work around for a long standing clang bug > (see https://llvm.org/bugs/show_bug.cgi?id=3997) where > clang always uses the standard regparm=0 calling convention > for any implcit calls to memcpy and memset that it generates > (eg for structure assignments and initialization) even if an > alternate calling convention such as regparm=3 has been specified. > > Signed-off-by: Michael Davidson > --- > arch/x86/boot/copy.S | 15 +++++++++++++-- > arch/x86/boot/string.h | 13 +++++++++++++ > 2 files changed, 26 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/boot/copy.S b/arch/x86/boot/copy.S > index 1eb7d298b47d..57142d1ad0d2 100644 > --- a/arch/x86/boot/copy.S > +++ b/arch/x86/boot/copy.S > @@ -18,6 +18,12 @@ > .text > > GLOBAL(memcpy) > +#ifdef __clang__ /* Use normal ABI calling conventions */ > + movw 4(%esp), %ax > + movw 8(%esp), %dx > + movw 12(%esp), %cx > +#endif > +_memcpy: > pushw %si > pushw %di > movw %ax, %di > @@ -34,6 +40,11 @@ GLOBAL(memcpy) > ENDPROC(memcpy) > > GLOBAL(memset) > +#ifdef __clang__ /* Use normal ABI calling conventions */ > + movw 4(%esp), %ax > + movw 8(%esp), %dx > + movw 12(%esp), %cx > +#endif I don't think we want to add such ugly workarounds for clang bugs in a piecemail wise manner. If this was the _only_ workaround required to have a working kernel built with clang then maybe, but there's no way to tell from this submission. Thanks, Ingo