From: Greg Kroah-Hartman Date: Tue, 6 Feb 2018 22:52:30 +0000 (-0800) Subject: 4.4-stable patches X-Git-Tag: v3.18.94~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c5a7e2abfd093afea69fa035cd304ca18bff82f5;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: x86-asm-fix-inline-asm-call-constraints-for-gcc-4.4.patch --- diff --git a/queue-4.4/series b/queue-4.4/series index a90c1148447..5decb2dbc24 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -23,3 +23,4 @@ asoc-rsnd-don-t-call-free_irq-on-parent-ssi.patch asoc-rsnd-avoid-duplicate-free_irq.patch drm-rcar-du-use-the-vbk-interrupt-for-vblank-events.patch drm-rcar-du-fix-race-condition-when-disabling-planes-at-crtc-stop.patch +x86-asm-fix-inline-asm-call-constraints-for-gcc-4.4.patch diff --git a/queue-4.4/x86-asm-fix-inline-asm-call-constraints-for-gcc-4.4.patch b/queue-4.4/x86-asm-fix-inline-asm-call-constraints-for-gcc-4.4.patch new file mode 100644 index 00000000000..e056a5f66a4 --- /dev/null +++ b/queue-4.4/x86-asm-fix-inline-asm-call-constraints-for-gcc-4.4.patch @@ -0,0 +1,85 @@ +From 520a13c530aeb5f63e011d668c42db1af19ed349 Mon Sep 17 00:00:00 2001 +From: Josh Poimboeuf +Date: Thu, 28 Sep 2017 16:58:26 -0500 +Subject: x86/asm: Fix inline asm call constraints for GCC 4.4 + +From: Josh Poimboeuf + +commit 520a13c530aeb5f63e011d668c42db1af19ed349 upstream. + +The kernel test bot (run by Xiaolong Ye) reported that the following commit: + + f5caf621ee35 ("x86/asm: Fix inline asm call constraints for Clang") + +is causing double faults in a kernel compiled with GCC 4.4. + +Linus subsequently diagnosed the crash pattern and the buggy commit and found that +the issue is with this code: + + register unsigned int __asm_call_sp asm("esp"); + #define ASM_CALL_CONSTRAINT "+r" (__asm_call_sp) + +Even on a 64-bit kernel, it's using ESP instead of RSP. That causes GCC +to produce the following bogus code: + + ffffffff8147461d: 89 e0 mov %esp,%eax + ffffffff8147461f: 4c 89 f7 mov %r14,%rdi + ffffffff81474622: 4c 89 fe mov %r15,%rsi + ffffffff81474625: ba 20 00 00 00 mov $0x20,%edx + ffffffff8147462a: 89 c4 mov %eax,%esp + ffffffff8147462c: e8 bf 52 05 00 callq ffffffff814c98f0 + +Despite the absurdity of it backing up and restoring the stack pointer +for no reason, the bug is actually the fact that it's only backing up +and restoring the lower 32 bits of the stack pointer. The upper 32 bits +are getting cleared out, corrupting the stack pointer. + +So change the '__asm_call_sp' register variable to be associated with +the actual full-size stack pointer. + +This also requires changing the __ASM_SEL() macro to be based on the +actual compiled arch size, rather than the CONFIG value, because +CONFIG_X86_64 compiles some files with '-m32' (e.g., realmode and vdso). +Otherwise Clang fails to build the kernel because it complains about the +use of a 64-bit register (RSP) in a 32-bit file. + +Reported-and-Bisected-and-Tested-by: kernel test robot +Diagnosed-by: Linus Torvalds +Signed-off-by: Josh Poimboeuf +Cc: Alexander Potapenko +Cc: Andrey Ryabinin +Cc: Andy Lutomirski +Cc: Arnd Bergmann +Cc: Dmitriy Vyukov +Cc: LKP +Cc: Linus Torvalds +Cc: Matthias Kaehlcke +Cc: Miguel Bernal Marin +Cc: Peter Zijlstra +Cc: Thomas Gleixner +Fixes: f5caf621ee35 ("x86/asm: Fix inline asm call constraints for Clang") +Link: http://lkml.kernel.org/r/20170928215826.6sdpmwtkiydiytim@treble +Signed-off-by: Ingo Molnar +Cc: Matthias Kaehlcke +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/include/asm/asm.h | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/arch/x86/include/asm/asm.h ++++ b/arch/x86/include/asm/asm.h +@@ -11,10 +11,12 @@ + # define __ASM_FORM_COMMA(x) " " #x "," + #endif + +-#ifdef CONFIG_X86_32 ++#ifndef __x86_64__ ++/* 32 bit */ + # define __ASM_SEL(a,b) __ASM_FORM(a) + # define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(a) + #else ++/* 64 bit */ + # define __ASM_SEL(a,b) __ASM_FORM(b) + # define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(b) + #endif