From: Ingo Molnar <mingo@kernel.org>
To: Michael Davidson <md@google.com>
Cc: "H . Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
Alexander Potapenko <glider@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
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
Date: Thu, 16 Mar 2017 08:46:02 +0100 [thread overview]
Message-ID: <20170316074601.GA23914@gmail.com> (raw)
In-Reply-To: <20170315214821.127170-2-md@google.com>
* Michael Davidson <md@google.com> 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 <md@google.com>
> ---
> 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
next prev parent reply other threads:[~2017-03-16 7:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 21:48 [PATCH 1/2] x86, boot: #undef memcpy etc in string.c Michael Davidson
2017-03-15 21:48 ` [PATCH 2/2] x86, boot: Use regparm=0 for memcpy and memset when using clang Michael Davidson
2017-03-16 7:46 ` Ingo Molnar [this message]
2017-03-16 15:21 ` Michael Davidson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170316074601.GA23914@gmail.com \
--to=mingo@kernel.org \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=md@google.com \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox