From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755139AbdEESof (ORCPT ); Fri, 5 May 2017 14:44:35 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:33420 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755154AbdEESoR (ORCPT ); Fri, 5 May 2017 14:44:17 -0400 Date: Fri, 5 May 2017 11:44:05 -0700 From: Matthias Kaehlcke To: Ingo Molnar Cc: Peter Zijlstra , md@google.com, tglx@linutronix.de, hpa@zytor.com, torvalds@linux-foundation.org, grundler@chromium.org, linux-kernel@vger.kernel.org, ghackmann@google.com, keescook@chromium.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 Message-ID: <20170505184405.GB128305@google.com> References: <20170501224741.133938-1-mka@chromium.org> <20170505102555.ysjep3foplmhspux@hirez.programming.kicks-ass.net> <20170505175039.hf3jx4ljuyzzgxdn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170505175039.hf3jx4ljuyzzgxdn@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org El Fri, May 05, 2017 at 07:50:39PM +0200 Ingo Molnar ha dit: > > * Peter Zijlstra wrote: > > > On Fri, May 05, 2017 at 01:11:47AM -0700, tip-bot for Matthias Kaehlcke wrote: > > > Commit-ID: 121843eb02a6e2fa30aefab64bfe183c97230c75 > > > Gitweb: http://git.kernel.org/tip/121843eb02a6e2fa30aefab64bfe183c97230c75 > > > Author: Matthias Kaehlcke > > > AuthorDate: Mon, 1 May 2017 15:47:41 -0700 > > > Committer: Ingo Molnar > > > CommitDate: Fri, 5 May 2017 08:31:05 +0200 > > > > > > x86/mm/kaslr: Use the _ASM_MUL macro for multiplication to work around Clang incompatibility > > > > > > The constraint "rm" allows the compiler to put mix_const into memory. > > > When the input operand is a memory location then MUL needs an operand > > > size suffix, since Clang can't infer the multiplication width from the > > > operand. > > > > *sigh*, this is another shining example of how LLVM is a better, faster > > moving compiler? > > Well, I don't like it - but we already have similar patterns to cover some asm > complications so I didn't mind. Apparently Clang is very close to being able to > build a working Linux kernel, right? Indeed, I expect 4.12 (with this patch ...) to build with Clang for a x86 defconfig (with tons of warnings). ARM64 is very close. > In that sense it would be unfair to expect it to not have various legacies, > missing features and quirks - just like the kernel has dozens of GCC related > workarounds. Also my understanding is that this isn't really a clang issue. In the context of this code gcc apparently chooses to use a register for 'mix_const', for memory locations it also needs a suffix. Actually I just tried to build this code from a single C file: void test() { unsigned long raw, random; const unsigned long mix_const = 0x3f39e593UL; asm("MUL %3" : "=a" (random), "=d" (raw) : "a" (random), "rm" (mix_const)); } gcc -c /tmp/test.c /tmp/test.c: Assembler messages: /tmp/test.c:6: Error: no instruction mnemonic suffix given and no register operands; can't size instruction gcc version 4.9.x 20150123 Cheers Matthias