]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.165/x86-mm-kaslr-use-the-_asm_mul-macro-for-multiplication-to-work-around-clang-incompatibility.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.4.165 / x86-mm-kaslr-use-the-_asm_mul-macro-for-multiplication-to-work-around-clang-incompatibility.patch
CommitLineData
22b74881
GKH
1From foo@baz Wed Nov 21 18:50:39 CET 2018
2From: Matthias Kaehlcke <mka@chromium.org>
3Date: Mon, 1 May 2017 15:47:41 -0700
4Subject: x86/mm/kaslr: Use the _ASM_MUL macro for multiplication to work around Clang incompatibility
5
6From: Matthias Kaehlcke <mka@chromium.org>
7
8commit 121843eb02a6e2fa30aefab64bfe183c97230c75 upstream.
9
10The constraint "rm" allows the compiler to put mix_const into memory.
11When the input operand is a memory location then MUL needs an operand
12size suffix, since Clang can't infer the multiplication width from the
13operand.
14
15Add and use the _ASM_MUL macro which determines the operand size and
16resolves to the NUL instruction with the corresponding suffix.
17
18This 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
24Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
25Cc: Grant Grundler <grundler@chromium.org>
26Cc: Greg Hackmann <ghackmann@google.com>
27Cc: Kees Cook <keescook@chromium.org>
28Cc: Linus Torvalds <torvalds@linux-foundation.org>
29Cc: Michael Davidson <md@google.com>
30Cc: Peter Zijlstra <peterz@infradead.org>
31Cc: Thomas Gleixner <tglx@linutronix.de>
32Link: http://lkml.kernel.org/r/20170501224741.133938-1-mka@chromium.org
33Signed-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]
36Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
37Signed-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)