Skip to contentSkip to conversation

arch: define weak abort

PATCH In review Sudip Mukherjee 4 participants 5 messages Dec 12, 2017 – Dec 21, 2017 Synopsys ARC architecture

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 arch: define weak abort

gcc toggle -fisolate-erroneous-paths-dereference (default at -O2 onwards) isolates faulty code paths such as null pointer access, divide by zero etc. If gcc port doesnt implement __builtin_trap, an abort() is generated which causes kernel link error.

In this case, gcc is generating abort due to 'divide by zero' in lib/mpi/mpih-div.c.

Currently 'frv' and 'arc' are failing. Previously other arch was also broken like m32r was fixed by d22e3d69ee1a ("m32r: fix build failure").

Lets define this weak function which is common for all arch and fix the problem permanently. We can even remove the arch specific 'abort' after this is done.

---

Hi Alexey,
I was thinking of sending the m32r revert patch in few days. My m32r builds are having a little problem and should be fixed by this weekend. I can not test m32r before that. We can also send a patch to remove the same code in arm and unicore32.

 kernel/exit.c | 8 ++++++++
 1 file changed, 8 insertions(+)
kernel/exit.c +8 -0
index af6c245..90c6869 100644
@@ -1759,3 +1759,11 @@ long kernel_wait4(pid_t upid, int __user *stat_addr, int options,
 	return -EFAULT;
 }
 #endif
+
+__weak void abort(void)
+{
+	BUG();
+
+	/* if that doesn't kill us, halt */
+	panic("Oops failed to kill thread");
+}
Signature · 1 line
1.9.1
#1 lore raw

Hi Sudip,

Quoted 15 lines · Sudip Mukherjee

gcc toggle -fisolate-erroneous-paths-dereference (default at -O2 onwards) isolates faulty code paths such as null pointer access, divide by zero etc. If gcc port doesnt implement __builtin_trap, an abort() is generated which causes kernel link error.

In this case, gcc is generating abort due to 'divide by zero' in lib/mpi/mpih-div.c.

Currently 'frv' and 'arc' are failing. Previously other arch was also broken like m32r was fixed by d22e3d69ee1a ("m32r: fix build failure").

Lets define this weak function which is common for all arch and fix the problem permanently. We can even remove the arch specific 'abort' after this is done.

Quoted 8 lines
Cc Alexey Brodkin <Alexey.Brodkin at synopsys.com>
Signed-off-by Sudip Mukherjee <sudipm.mukherjee at gmail.com>

---

Hi Alexey,
I was thinking of sending the m32r revert patch in few days. My m32r builds are having a little problem and should be fixed by this weekend. I can not test m32r before that.

Understood, that's fine by me.

Quoted 2 lines

We can also send a patch to remove the
same code in arm and unicore32.

Sure that would be really great!

-Alexey

#2 lore raw
In reply to Sudip Mukherjee
Quoted 34 lines · Sudip Mukherjee

gcc toggle -fisolate-erroneous-paths-dereference (default at -O2 onwards) isolates faulty code paths such as null pointer access, divide by zero etc. If gcc port doesnt implement __builtin_trap, an abort() is generated which causes kernel link error.

In this case, gcc is generating abort due to 'divide by zero' in lib/mpi/mpih-div.c.

Currently 'frv' and 'arc' are failing. Previously other arch was also broken like m32r was fixed by d22e3d69ee1a ("m32r: fix build failure").

Lets define this weak function which is common for all arch and fix the problem permanently. We can even remove the arch specific 'abort' after this is done.

Cc Alexey Brodkin <Alexey.Brodkin at synopsys.com>
Signed-off-by Sudip Mukherjee <sudipm.mukherjee at gmail.com>

---

Hi Alexey,
I was thinking of sending the m32r revert patch in few days. My m32r builds are having a little problem and should be fixed by this weekend. I can not test m32r before that. We can also send a patch to remove the same code in arm and unicore32.

  kernel/exit.c | 8 ++++++++
  1 file changed, 8 insertions(+)
kernel/exit.c +0 -0
index af6c245..90c6869 100644
@@ -1759,3 +1759,11 @@ long kernel_wait4(pid_t upid, int __user *stat_addr, int options,
  	return -EFAULT;

kernel/exit.c long kernel_wait4(pid_t upid, int __user *stat_addr, int options, · line 1769

Quoted 10 lines
kernel/exit.c +8 -0
  }
  #endif
+
+__weak void abort(void)
+{
+	BUG();
+
+	/* if that doesn't kill us, halt */
+	panic("Oops failed to kill thread");
+}

Hmm, I realize there's a small gotcha with this, when testing with a different patch from Arnd. This needs an EXPORT_SYMBOL() as well !

-Vineet

#3 lore raw
Quoted 9 lines · On Tue, 19 Dec 2017 13:39:22 -0800 Vineet Gupta <[email protected]>…
Quoted 9 lines
kernel/exit.c +3 -0
@@ -1759,3 +1759,11 @@ long kernel_wait4(pid_t upid, int __user *stat_addr, int options,
  	return -EFAULT;
  }
  #endif
+
+__weak void abort(void)
+{
Quoted 8 lines

kernel/exit.c long kernel_wait4(pid_t upid, int __user *stat_addr, int options, · line 1769

Quoted 5 lines
kernel/exit.c +5 -0
+	BUG();
+
+	/* if that doesn't kill us, halt */
+	panic("Oops failed to kill thread");
+}

Hmm, I realize there's a small gotcha with this, when testing with a different patch from Arnd. This needs an EXPORT_SYMBOL() as well !

Yup. This?

From: Andrew Morton <[email protected]>
Subject: kernel/exit.c: export abort() to modules

gcc -fisolate-erroneous-paths-dereference can generate calls to abort() from modular code too.

Reported-by Vineet Gupta <Vineet.Gupta1 at synopsys.com>
Cc Sudip Mukherjee <sudipm.mukherjee at gmail.com>
Cc Arnd Bergmann <arnd at arndb.de>
Cc "Alexey Brodkin" <Alexey.Brodkin at synopsys.com>
Signed-off-by Andrew Morton <akpm at linux-foundation.org>

---

 kernel/exit.c |    1 +
 1 file changed, 1 insertion(+)
kernel/exit.c renamed from kernel/exit.c~a +1 -0
diff -puN kernel/exit.c~a kernel/exit.c
@@ -1763,3 +1763,4 @@ __weak void abort(void)
 	/* if that doesn't kill us, halt */
 	panic("Oops failed to kill thread");
 }
+EXPORT_SYMBOL(abort);

_

author Acked-by
#4 lore raw
Quoted 2 lines · Andrew Morton

On Tue, 19 Dec 2017 13:39:22 -0800 Vineet Gupta <[email protected]> wrote:

<snip>

Quoted 4 lines
Quoted 2 lines

Hmm, I realize there's a small gotcha with this, when testing with a different patch from Arnd. This needs an EXPORT_SYMBOL() as well !

Yup. This?

Yes, just faced this when I was testing with the reverted patch on m32r.

Quoted 7 lines

From: Andrew Morton <akpm at linux-foundation.org>
Subject: kernel/exit.c: export abort() to modules

gcc -fisolate-erroneous-paths-dereference can generate calls to abort() from modular code too.

Quoted 6 lines
Reported-by Vineet Gupta <Vineet.Gupta1 at synopsys.com>
Cc Sudip Mukherjee <sudipm.mukherjee at gmail.com>
Cc Arnd Bergmann <arnd at arndb.de>
Cc "Alexey Brodkin" <Alexey.Brodkin at synopsys.com>
Signed-off-by Andrew Morton <akpm at linux-foundation.org>

---

Acked-by Sudip Mukherjee <sudipm.mukherjee at gmail.com>

--
Regards
Sudip