linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Matthias Kaehlcke <mka@chromium.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Michael Davidson <md@google.com>,
	Thomas Gleixner <tglx@linutronix.de>, Peter Anvin <hpa@zytor.com>,
	grundler@chromium.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	ghackmann@google.com, Kees Cook <keescook@chromium.org>,
	"linux-tip-commits@vger.kernel.org" 
	<linux-tip-commits@vger.kernel.org>
Subject: Re: [tip:x86/urgent] x86/mm/kaslr: Use the _ASM_MUL macro for multiplication to work around Clang incompatibility
Date: Fri, 5 May 2017 12:30:20 -0700	[thread overview]
Message-ID: <CA+55aFzujof+LjiL_ErR3Js1qdH0X8E3GKMC5HfkOYQYs3PGBA@mail.gmail.com> (raw)
In-Reply-To: <20170505184405.GB128305@google.com>

On Fri, May 5, 2017 at 11:44 AM, Matthias Kaehlcke <mka@chromium.org> wrote:
>
> Indeed, I expect 4.12 (with this patch ...) to build with Clang for a
> x86 defconfig (with tons of warnings). ARM64 is very close.

Does it actually *work*, rather than just build?

clang used to have actual code generation bugs that made for really
subtle kernel issues but didn't matter very often in user space.

The thing that comes to mind is the crazy handling of spilling
'eflags' on x86 (saving and restoring eflags over a function call in
order to save the arithmetic flags, but in the process also undoing
the changes to IF that that function call did.

That was a horrible horrible bug - it generates slow code, but it was
actually *incorrect* code too. It's just that in user space, people
very seldom mess with the non-arithmetic flags (things like IOPL, IF,
AC, etc - they *can* be used in user space but seldom are).

Some of the discussion I saw by the clang people pooh-poohed that bug
and seemed to think it was a kernel problem.

That kind of pure incompetence from compiler people doesn't make me
get the warm and fuzzies.

Generating code that is actively _wrong_ and performs badly too - hey
that happens. But then making excuses for clearly buggy code
generation?

I did have a report saying it was fixed, so hopefully saner people prevailed.

But it left a really bad taste, and it was an example of something
that may have built fine, but generated subtle broken code (where
"subtly" here means "it might work when you don't look too closely and
are lucky, and then cause lockups in odd situations").

I'd love to be able to compile the kernel with clang, but only if the
clang people take it seriously.

            Linus

  reply	other threads:[~2017-05-05 19:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-01 22:47 [PATCH v2] x86/mm/kaslr: Use _ASM_MUL macro for multiplication Matthias Kaehlcke
2017-05-02  2:08 ` Kees Cook
2017-05-05  8:11 ` [tip:x86/urgent] x86/mm/kaslr: Use the _ASM_MUL macro for multiplication to work around Clang incompatibility tip-bot for Matthias Kaehlcke
2017-05-05 10:25   ` Peter Zijlstra
2017-05-05 17:50     ` Ingo Molnar
2017-05-05 18:22       ` Peter Zijlstra
2017-05-05 18:44       ` Matthias Kaehlcke
2017-05-05 19:30         ` Linus Torvalds [this message]
2017-05-05 20:36           ` Michael Davidson
2017-05-06  8:16             ` Peter Zijlstra
2017-05-07 15:42               ` hpa
2017-05-05 20:52           ` Matthias Kaehlcke
2017-05-06  9:57             ` Ingo Molnar
2017-05-05 19:37         ` hpa
2017-05-05 21:24           ` Matthias Kaehlcke

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=CA+55aFzujof+LjiL_ErR3Js1qdH0X8E3GKMC5HfkOYQYs3PGBA@mail.gmail.com \
    --to=torvalds@linux-foundation.org \
    --cc=ghackmann@google.com \
    --cc=grundler@chromium.org \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=md@google.com \
    --cc=mingo@kernel.org \
    --cc=mka@chromium.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).