186723454070cd605c147992c27a437d315f4024
[openwrt/openwrt.git] / target / linux / generic / backport-4.14 / 080-v4.15-0001-arch-define-weak-abort.patch
1 From 7c2c11b208be09c156573fc0076b7b3646e05219 Mon Sep 17 00:00:00 2001
2 From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
3 Date: Thu, 14 Dec 2017 15:33:19 -0800
4 Subject: [PATCH] arch: define weak abort()
5
6 gcc toggle -fisolate-erroneous-paths-dereference (default at -O2
7 onwards) isolates faulty code paths such as null pointer access, divide
8 by zero etc. If gcc port doesnt implement __builtin_trap, an abort() is
9 generated which causes kernel link error.
10
11 In this case, gcc is generating abort due to 'divide by zero' in
12 lib/mpi/mpih-div.c.
13
14 Currently 'frv' and 'arc' are failing. Previously other arch was also
15 broken like m32r was fixed by commit d22e3d69ee1a ("m32r: fix build
16 failure").
17
18 Let's define this weak function which is common for all arch and fix the
19 problem permanently. We can even remove the arch specific 'abort' after
20 this is done.
21
22 Link: http://lkml.kernel.org/r/1513118956-8718-1-git-send-email-sudipm.mukherjee@gmail.com
23 Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
24 Cc: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
25 Cc: Vineet Gupta <Vineet.Gupta1@synopsys.com>
26 Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
27 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
28 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
29 ---
30 kernel/exit.c | 8 ++++++++
31 1 file changed, 8 insertions(+)
32
33 --- a/kernel/exit.c
34 +++ b/kernel/exit.c
35 @@ -1755,3 +1755,11 @@ Efault:
36 return -EFAULT;
37 }
38 #endif
39 +
40 +__weak void abort(void)
41 +{
42 + BUG();
43 +
44 + /* if that doesn't kill us, halt */
45 + panic("Oops failed to kill thread");
46 +}