]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
e99799988be7d5e2e6485be3d86a8da6ccbda480
[thirdparty/kernel/stable-queue.git] /
1 From foo@baz Wed Nov 21 18:50:39 CET 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
5
6 From: Matthias Kaehlcke <mka@chromium.org>
7
8 commit 121843eb02a6e2fa30aefab64bfe183c97230c75 upstream.
9
10 The constraint "rm" allows the compiler to put mix_const into memory.
11 When the input operand is a memory location then MUL needs an operand
12 size suffix, since Clang can't infer the multiplication width from the
13 operand.
14
15 Add and use the _ASM_MUL macro which determines the operand size and
16 resolves to the NUL instruction with the corresponding suffix.
17
18 This fixes the following error when building with clang:
19
20 CC arch/x86/lib/kaslr.o
21 /tmp/kaslr-dfe1ad.s: Assembler messages:
22 /tmp/kaslr-dfe1ad.s:182: Error: no instruction mnemonic suffix given and no register operands; can't size instruction
23
24 Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
25 Cc: Grant Grundler <grundler@chromium.org>
26 Cc: Greg Hackmann <ghackmann@google.com>
27 Cc: Kees Cook <keescook@chromium.org>
28 Cc: Linus Torvalds <torvalds@linux-foundation.org>
29 Cc: Michael Davidson <md@google.com>
30 Cc: Peter Zijlstra <peterz@infradead.org>
31 Cc: Thomas Gleixner <tglx@linutronix.de>
32 Link: http://lkml.kernel.org/r/20170501224741.133938-1-mka@chromium.org
33 Signed-off-by: Ingo Molnar <mingo@kernel.org>
34 [nc: Apply to aslr.c in get_random_long as the kaslr shift didn't happen
35 until 4.8 in commit d899a7d146a2]
36 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
37 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
38 ---
39 arch/x86/boot/compressed/aslr.c | 3 ++-
40 arch/x86/include/asm/asm.h | 1 +
41 2 files changed, 3 insertions(+), 1 deletion(-)
42
43 --- a/arch/x86/boot/compressed/aslr.c
44 +++ b/arch/x86/boot/compressed/aslr.c
45 @@ -1,5 +1,6 @@
46 #include "misc.h"
47
48 +#include <asm/asm.h>
49 #include <asm/msr.h>
50 #include <asm/archrandom.h>
51 #include <asm/e820.h>
52 @@ -94,7 +95,7 @@ static unsigned long get_random_long(voi
53 }
54
55 /* Circular multiply for better bit diffusion */
56 - asm("mul %3"
57 + asm(_ASM_MUL "%3"
58 : "=a" (random), "=d" (raw)
59 : "a" (random), "rm" (mix_const));
60 random += raw;
61 --- a/arch/x86/include/asm/asm.h
62 +++ b/arch/x86/include/asm/asm.h
63 @@ -34,6 +34,7 @@
64 #define _ASM_ADD __ASM_SIZE(add)
65 #define _ASM_SUB __ASM_SIZE(sub)
66 #define _ASM_XADD __ASM_SIZE(xadd)
67 +#define _ASM_MUL __ASM_SIZE(mul)
68
69 #define _ASM_AX __ASM_REG(ax)
70 #define _ASM_BX __ASM_REG(bx)