1 From foo@baz Mon Apr 9 17:09:24 CEST 2018
2 From: Matthias Kaehlcke <mka@chromium.org>
3 Date: Mon, 1 May 2017 15:47:41 -0700
4 Subject: x86/mm/kaslr: Use the _ASM_MUL macro for multiplication to work around Clang incompatibility
6 From: Matthias Kaehlcke <mka@chromium.org>
9 [ Upstream commit 121843eb02a6e2fa30aefab64bfe183c97230c75 ]
11 The constraint "rm" allows the compiler to put mix_const into memory.
12 When the input operand is a memory location then MUL needs an operand
13 size suffix, since Clang can't infer the multiplication width from the
16 Add and use the _ASM_MUL macro which determines the operand size and
17 resolves to the NUL instruction with the corresponding suffix.
19 This fixes the following error when building with clang:
21 CC arch/x86/lib/kaslr.o
22 /tmp/kaslr-dfe1ad.s: Assembler messages:
23 /tmp/kaslr-dfe1ad.s:182: Error: no instruction mnemonic suffix given and no register operands; can't size instruction
25 Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
26 Cc: Grant Grundler <grundler@chromium.org>
27 Cc: Greg Hackmann <ghackmann@google.com>
28 Cc: Kees Cook <keescook@chromium.org>
29 Cc: Linus Torvalds <torvalds@linux-foundation.org>
30 Cc: Michael Davidson <md@google.com>
31 Cc: Peter Zijlstra <peterz@infradead.org>
32 Cc: Thomas Gleixner <tglx@linutronix.de>
33 Link: http://lkml.kernel.org/r/20170501224741.133938-1-mka@chromium.org
34 Signed-off-by: Ingo Molnar <mingo@kernel.org>
35 Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
36 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
38 arch/x86/include/asm/asm.h | 1 +
39 arch/x86/lib/kaslr.c | 3 ++-
40 2 files changed, 3 insertions(+), 1 deletion(-)
42 --- a/arch/x86/include/asm/asm.h
43 +++ b/arch/x86/include/asm/asm.h
45 #define _ASM_ADD __ASM_SIZE(add)
46 #define _ASM_SUB __ASM_SIZE(sub)
47 #define _ASM_XADD __ASM_SIZE(xadd)
48 +#define _ASM_MUL __ASM_SIZE(mul)
50 #define _ASM_AX __ASM_REG(ax)
51 #define _ASM_BX __ASM_REG(bx)
52 --- a/arch/x86/lib/kaslr.c
53 +++ b/arch/x86/lib/kaslr.c
55 * kernel starts. This file is included in the compressed kernel and
56 * normally linked in the regular.
59 #include <asm/kaslr.h>
61 #include <asm/archrandom.h>
62 @@ -79,7 +80,7 @@ unsigned long kaslr_get_random_long(cons
65 /* Circular multiply for better bit diffusion */
68 : "=a" (random), "=d" (raw)
69 : "a" (random), "rm" (mix_const));