android_kernel_oneplus_msm8998/arch
Josh Poimboeuf 69f9dc4b71 x86/asm: Fix inline asm call constraints for GCC 4.4
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 <copy_user_generic_unrolled>

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 <xiaolong.ye@intel.com>
Diagnosed-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: LKP <lkp@01.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matthias Kaehlcke <mka@chromium.org>
Cc: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
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 <mingo@kernel.org>
Cc: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-16 20:09:37 +01:00
..
alpha alpha: fix build failures 2017-12-25 14:22:16 +01:00
arc ARC: uaccess: dont use "l" gcc inline asm constraint modifier 2018-01-10 09:27:11 +01:00
arm ARM: dts: kirkwood: fix pin-muxing of MPP7 on OpenBlocks A7 2018-01-23 19:50:16 +01:00
arm64 bpf: introduce BPF_JIT_ALWAYS_ON config 2018-02-03 17:04:24 +01:00
avr32
blackfin pinctrl: adi2: Fix Kconfig build problem 2017-12-20 10:05:00 +01:00
c6x
cris
frv
h8300
hexagon
ia64
m32r
m68k
metag
microblaze
mips MIPS: AR7: ensure the port type's FCR value is used 2018-01-23 19:50:18 +01:00
mn10300
nios2
openrisc openrisc: fix issue handling 8 byte get_user calls 2017-12-20 10:04:54 +01:00
parisc parisc: Fix alignment of pa_tlb_lock in assembly on 32-bit SMP kernel 2018-01-10 09:27:12 +01:00
powerpc powerpc/64s: Allow control of RFI flush via debugfs 2018-02-16 20:09:36 +01:00
s390 bpf: introduce BPF_JIT_ALWAYS_ON config 2018-02-03 17:04:24 +01:00
score
sh serial: sh-sci: Fix register offsets for the IRDA serial port 2017-11-15 17:13:10 +01:00
sparc sparc64/mm: set fields in deferred pages 2017-12-16 10:33:55 +01:00
tile
um um: link vmlinux with -no-pie 2018-01-31 12:06:12 +01:00
unicore32
x86 x86/asm: Fix inline asm call constraints for GCC 4.4 2018-02-16 20:09:37 +01:00
xtensa
.gitignore
Kconfig