Skip to contentSkip to conversation

m68k: kernel/traps.c - only force 030 bus error if PC not in exception table

RFC PATCH Superseded Michael Schmitz 3 participants 7 messages Feb 22, 2023 – Feb 28, 2023 m68k architecture

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 m68k: kernel/traps.c - only force 030 bus error if PC not in exception table

__get_kernel_nofault() does copy data in supervisor mode when forcing a task backtrace dump through the sysrq trigger.

Our 030 bus error handler is ill equipped to deal with this:

Whenever ssw indicates a kernel mode access on a data fault, we don't even attempt to handle the fault and instead send a bus error signal (or panic). As a result, the check for exception handling at the fault PC (buried in send_sig_fault() which gets called from do_page_fault() eventually) is never used.

Both 040 and 060 access error handlers do not care whether a fault happened on supervisor mode access, and will call do_page_fault() even on those.

Add a check in bus_error030 to call do_page_fault() in case we do have an entry for the fault PC in our exception table.

Tested on 030 Atari Falcon.

---
 arch/m68k/kernel/traps.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/m68k/kernel/traps.c +2 -1
index 5c8cba0efc63..67576fb0c466 100644
@@ -30,6 +30,7 @@
 #include <linux/init.h>
 #include <linux/ptrace.h>
 #include <linux/kallsyms.h>
+#include <linux/extable.h>
 
 #include <asm/setup.h>
 #include <asm/fpu.h>
@@ -545,7 +546,7 @@ static inline void bus_error030 (struct frame *fp)
 			errorcode |= 2;
 
 		if (mmusr & (MMU_I | MMU_WP)) {
-			if (ssw & 4) {
+			if (ssw & 4 && !search_exception_tables(fp->ptregs.pc)) {
 				pr_err("Data %s fault at %#010lx in %s (pc=%#lx)\n",
 				       ssw & RW ? "read" : "write",
 				       fp->un.fmtb.daddr,
Signature · 1 line
2.17.1
#1 lore raw

Hi Michael,

Quoted 12 lines · Michael Schmitz

__get_kernel_nofault() does copy data in supervisor mode when forcing a task backtrace dump through the sysrq trigger.

Our 030 bus error handler is ill equipped to deal with this:

Whenever ssw indicates a kernel mode access on a data fault, we don't even attempt to handle the fault and instead send a bus error signal (or panic). As a result, the check for exception handling at the fault PC (buried in send_sig_fault() which gets called from do_page_fault() eventually) is never used.

Quoted 8 lines

Both 040 and 060 access error handlers do not care whether a fault happened on supervisor mode access, and will call do_page_fault() even on those.

Add a check in bus_error030 to call do_page_fault() in case we do have an entry for the fault PC in our exception table.

Tested on 030 Atari Falcon.

I've verified that the kernel Oops was there with unpatched kernel, and this fixes it, also when using Hatari emulator 030 / Atari Falcon emulation.

(Verified both with both v6.0 & v6.2 of Linus' kernel sources.)

- Eero

Quoted 31 lines
---
  arch/m68k/kernel/traps.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/m68k/kernel/traps.c +2 -1
index 5c8cba0efc63..67576fb0c466 100644
@@ -30,6 +30,7 @@
  #include <linux/init.h>
  #include <linux/ptrace.h>
  #include <linux/kallsyms.h>
+#include <linux/extable.h>
 
  #include <asm/setup.h>
  #include <asm/fpu.h>
@@ -545,7 +546,7 @@ static inline void bus_error030 (struct frame *fp)
  			errorcode |= 2;
 
  		if (mmusr & (MMU_I | MMU_WP)) {
-			if (ssw & 4) {
+			if (ssw & 4 && !search_exception_tables(fp->ptregs.pc)) {
  				pr_err("Data %s fault at %#010lx in %s (pc=%#lx)\n",
  				       ssw & RW ? "read" : "write",
  				       fp->un.fmtb.daddr,
#2 lore raw

Thanks Eero,

I'll add your Tested-by (and Reported-by; sorry to have forgotten that) in v2.

Cheers,

Michael

Am 24.02.2023 um 13:31 schrieb Eero Tamminen:

Quoted 67 lines

Hi Michael,

Quoted 12 lines · Michael Schmitz

__get_kernel_nofault() does copy data in supervisor mode when forcing a task backtrace dump through the sysrq trigger.

Our 030 bus error handler is ill equipped to deal with this:

Whenever ssw indicates a kernel mode access on a data fault, we don't even attempt to handle the fault and instead send a bus error signal (or panic). As a result, the check for exception handling at the fault PC (buried in send_sig_fault() which gets called from do_page_fault() eventually) is never used.

Quoted 8 lines

Both 040 and 060 access error handlers do not care whether a fault happened on supervisor mode access, and will call do_page_fault() even on those.

Add a check in bus_error030 to call do_page_fault() in case we do have an entry for the fault PC in our exception table.

Tested on 030 Atari Falcon.

I've verified that the kernel Oops was there with unpatched kernel, and this fixes it, also when using Hatari emulator 030 / Atari Falcon emulation.

(Verified both with both v6.0 & v6.2 of Linus' kernel sources.)

- Eero

Quoted 32 lines

the commit message for your changes. Lines starting
CC: Eero Tamminen <[email protected]>
CC: Finn Thain <[email protected]>
CC: Andreas Schwab <[email protected]>
CC: Geert Uytterhoeven <[email protected]> Link:
https://lore.kernel.org/r/[email protected]

---
  arch/m68k/kernel/traps.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/m68k/kernel/traps.c +2 -1
index 5c8cba0efc63..67576fb0c466 100644
@@ -30,6 +30,7 @@
  #include <linux/init.h>
  #include <linux/ptrace.h>
  #include <linux/kallsyms.h>
+#include <linux/extable.h>
    #include <asm/setup.h>
  #include <asm/fpu.h>
@@ -545,7 +546,7 @@ static inline void bus_error030 (struct frame *fp)
              errorcode |= 2;
            if (mmusr & (MMU_I | MMU_WP)) {
-            if (ssw & 4) {
+            if (ssw & 4 && !search_exception_tables(fp->ptregs.pc)) {
                  pr_err("Data %s fault at %#010lx in %s (pc=%#lx)\n",
                         ssw & RW ? "read" : "write",
                         fp->un.fmtb.daddr,
#3 lore raw
In reply to Michael Schmitz

Hi Michael,

Quoted 12 lines · Michael Schmitz

__get_kernel_nofault() does copy data in supervisor mode when forcing a task backtrace dump through the sysrq trigger.

Our 030 bus error handler is ill equipped to deal with this:

Whenever ssw indicates a kernel mode access on a data fault, we don't even attempt to handle the fault and instead send a bus error signal (or panic). As a result, the check for exception handling at the fault PC (buried in send_sig_fault() which gets called from do_page_fault() eventually) is never used.

Quoted 8 lines

Both 040 and 060 access error handlers do not care whether a fault happened on supervisor mode access, and will call do_page_fault() even on those.

Add a check in bus_error030 to call do_page_fault() in case we do have an entry for the fault PC in our exception table.

Tested on 030 Atari Falcon.

Thanks for your patch!

Quoted 1 line

Please remove the comment ;-)

Quoted 5 lines
CC Eero Tamminen <[email protected]>
CC Finn Thain <[email protected]>
CC Andreas Schwab <[email protected]>
CC Geert Uytterhoeven <[email protected]>

404

I assume that a message from debian-68k?
Do you have a https://lists.debian.org/debian-68k/ link?

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#4 lore raw

Hi Geert,

thanks for your feedback!

Quoted 19 lines · Geert Uytterhoeven

Hi Michael,

Quoted 16 lines · Michael Schmitz

__get_kernel_nofault() does copy data in supervisor mode when forcing a task backtrace dump through the sysrq trigger.

Our 030 bus error handler is ill equipped to deal with this:

Whenever ssw indicates a kernel mode access on a data fault, we don't even attempt to handle the fault and instead send a bus error signal (or panic). As a result, the check for exception handling at the fault PC (buried in send_sig_fault() which gets called from do_page_fault() eventually) is never used.

Both 040 and 060 access error handlers do not care whether a fault happened on supervisor mode access, and will call do_page_fault() even on those.

Quoted 8 lines
Quoted 4 lines

Add a check in bus_error030 to call do_page_fault() in case we do have an entry for the fault PC in our exception table.

Tested on 030 Atari Falcon.

Thanks for your patch!

Quoted 1 line

Please remove the comment ;-)

Done that already for v2.

Quoted 9 lines
Quoted 6 lines
CC Eero Tamminen <[email protected]>
CC Finn Thain <[email protected]>
CC Andreas Schwab <[email protected]>
CC Geert Uytterhoeven <[email protected]>

404

I assume that a message from debian-68k?

No, oddly enough that is a message that I have received with CC to linux-m68k (but not from vger!). And mail-archive.com has it:

https://www.mail-archive.com/[email protected]/msg13081.html

And also on marc.info:

https://marc.info/?l=linux-m68k&m=155477039405576&w=2

Later one with an experimental patch of mine:

https://marc.info/?l=linux-m68k&m=155494864731013&w=2

None of these messages show up on a search of lore...

What source do you prefer - marc.info or mail-archive.com?

Cheers,

    Michael

Quoted 6 lines

Do you have a https://lists.debian.org/debian-68k/ link?

Gr{oetje,eeting}s,

Geert

#5 lore raw

Hi Michael,

Quoted 7 lines · Michael Schmitz
Quoted 5 lines · Geert Uytterhoeven
Quoted 1 line · Michael Schmitz

404

I assume that a message from debian-68k?

Quoted 8 lines

No, oddly enough that is a message that I have received with CC to linux-m68k (but not from vger!). And mail-archive.com has it:

https://www.mail-archive.com/[email protected]/msg13081.html

And also on marc.info:

https://marc.info/?l=linux-m68k&m=155477039405576&w=2

That one has a different Message-ID:
[email protected]

Quoted 5 lines

Later one with an experimental patch of mine:

https://marc.info/?l=linux-m68k&m=155494864731013&w=2

None of these messages show up on a search of lore...

Indeed, and I did receive them through vger.

Quoted 1 line

What source do you prefer - marc.info or mail-archive.com?

Let's keep the lore link with the actual Message-ID. Missing emails on lore can be backfilled later...

Upon closer look, this predates lore collecting emails, so perhaps something went wrong while importing my old archives I sent to kernel.org. To be investigated...

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#6 lore raw

Hi Geert,

Quoted 12 lines · Geert Uytterhoeven

Hi Michael,

Quoted 9 lines · Michael Schmitz
Quoted 5 lines · Geert Uytterhoeven
Quoted 1 line · Michael Schmitz

404

I assume that a message from debian-68k?

No, oddly enough that is a message that I have received with CC to linux-m68k (but not from vger!). And mail-archive.com has it:

Quoted 7 lines
Quoted 5 lines

https://www.mail-archive.com/[email protected]/msg13081.html

And also on marc.info:

https://marc.info/?l=linux-m68k&m=155477039405576&w=2

That one has a different Message-ID:
[email protected]

I get [email protected] ...

Quoted 4 lines
Quoted 4 lines

Later one with an experimental patch of mine:

https://marc.info/?l=linux-m68k&m=155494864731013&w=2

[email protected]

Quoted 11 lines
Quoted 2 lines

None of these messages show up on a search of lore...

Indeed, and I did receive them through vger.

Quoted 1 line

What source do you prefer - marc.info or mail-archive.com?

Let's keep the lore link with the actual Message-ID. Missing emails on lore can be backfilled later...

Upon closer look, this predates lore collecting emails, so perhaps something went wrong while importing my old archives I sent to kernel.org. To be investigated...

OK - I'll send around v2 with lore links and comment removed later.

Cheers,

    Michael

Quoted 12 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds