arm64: exception: handle Synchronous External Abort
authorTyler Baicar <tbaicar@codeaurora.org>
Wed, 21 Jun 2017 18:17:08 +0000 (12:17 -0600)
committerWill Deacon <will.deacon@arm.com>
Thu, 22 Jun 2017 17:21:46 +0000 (18:21 +0100)
SEA exceptions are often caused by an uncorrected hardware
error, and are handled when data abort and instruction abort
exception classes have specific values for their Fault Status
Code.
When SEA occurs, before killing the process, report the error
in the kernel logs.
Update fault_info[] with specific SEA faults so that the
new SEA handler is used.

Signed-off-by: Tyler Baicar <tbaicar@codeaurora.org>
CC: Jonathan (Zhixiong) Zhang <zjzhang@codeaurora.org>
Reviewed-by: James Morse <james.morse@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
[will: use NULL instead of 0 when assigning si_addr]
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/include/asm/esr.h
arch/arm64/mm/fault.c

index 85997c0e544312a3d4e60157c4ba30d4d93239bd..28bf02efce76d7adf8ae514ce10d87c0f093d659 100644 (file)
@@ -83,6 +83,7 @@
 #define ESR_ELx_WNR            (UL(1) << 6)
 
 /* Shared ISS field definitions for Data/Instruction aborts */
+#define ESR_ELx_FnV            (UL(1) << 10)
 #define ESR_ELx_EA             (UL(1) << 9)
 #define ESR_ELx_S1PTW          (UL(1) << 7)
 
index 37b95dff0b07f4eb0967c4a9b27318c6d81daa8c..246e64f60610407407b2870da0d77c189f07e7f7 100644 (file)
@@ -522,6 +522,31 @@ static int do_bad(unsigned long addr, unsigned int esr, struct pt_regs *regs)
        return 1;
 }
 
+/*
+ * This abort handler deals with Synchronous External Abort.
+ * It calls notifiers, and then returns "fault".
+ */
+static int do_sea(unsigned long addr, unsigned int esr, struct pt_regs *regs)
+{
+       struct siginfo info;
+       const struct fault_info *inf;
+
+       inf = esr_to_fault_info(esr);
+       pr_err("Synchronous External Abort: %s (0x%08x) at 0x%016lx\n",
+               inf->name, esr, addr);
+
+       info.si_signo = SIGBUS;
+       info.si_errno = 0;
+       info.si_code  = 0;
+       if (esr & ESR_ELx_FnV)
+               info.si_addr = NULL;
+       else
+               info.si_addr  = (void __user *)addr;
+       arm64_notify_die("", regs, &info, esr);
+
+       return 0;
+}
+
 static const struct fault_info fault_info[] = {
        { do_bad,               SIGBUS,  0,             "ttbr address size fault"       },
        { do_bad,               SIGBUS,  0,             "level 1 address size fault"    },
@@ -539,22 +564,22 @@ static const struct fault_info fault_info[] = {
        { do_page_fault,        SIGSEGV, SEGV_ACCERR,   "level 1 permission fault"      },
        { do_page_fault,        SIGSEGV, SEGV_ACCERR,   "level 2 permission fault"      },
        { do_page_fault,        SIGSEGV, SEGV_ACCERR,   "level 3 permission fault"      },
-       { do_bad,               SIGBUS,  0,             "synchronous external abort"    },
+       { do_sea,               SIGBUS,  0,             "synchronous external abort"    },
        { do_bad,               SIGBUS,  0,             "unknown 17"                    },
        { do_bad,               SIGBUS,  0,             "unknown 18"                    },
        { do_bad,               SIGBUS,  0,             "unknown 19"                    },
-       { do_bad,               SIGBUS,  0,             "synchronous external abort (translation table walk)" },
-       { do_bad,               SIGBUS,  0,             "synchronous external abort (translation table walk)" },
-       { do_bad,               SIGBUS,  0,             "synchronous external abort (translation table walk)" },
-       { do_bad,               SIGBUS,  0,             "synchronous external abort (translation table walk)" },
-       { do_bad,               SIGBUS,  0,             "synchronous parity error"      },
+       { do_sea,               SIGBUS,  0,             "level 0 (translation table walk)"      },
+       { do_sea,               SIGBUS,  0,             "level 1 (translation table walk)"      },
+       { do_sea,               SIGBUS,  0,             "level 2 (translation table walk)"      },
+       { do_sea,               SIGBUS,  0,             "level 3 (translation table walk)"      },
+       { do_sea,               SIGBUS,  0,             "synchronous parity or ECC error" },
        { do_bad,               SIGBUS,  0,             "unknown 25"                    },
        { do_bad,               SIGBUS,  0,             "unknown 26"                    },
        { do_bad,               SIGBUS,  0,             "unknown 27"                    },
-       { do_bad,               SIGBUS,  0,             "synchronous parity error (translation table walk)" },
-       { do_bad,               SIGBUS,  0,             "synchronous parity error (translation table walk)" },
-       { do_bad,               SIGBUS,  0,             "synchronous parity error (translation table walk)" },
-       { do_bad,               SIGBUS,  0,             "synchronous parity error (translation table walk)" },
+       { do_sea,               SIGBUS,  0,             "level 0 synchronous parity error (translation table walk)"     },
+       { do_sea,               SIGBUS,  0,             "level 1 synchronous parity error (translation table walk)"     },
+       { do_sea,               SIGBUS,  0,             "level 2 synchronous parity error (translation table walk)"     },
+       { do_sea,               SIGBUS,  0,             "level 3 synchronous parity error (translation table walk)"     },
        { do_bad,               SIGBUS,  0,             "unknown 32"                    },
        { do_alignment_fault,   SIGBUS,  BUS_ADRALN,    "alignment fault"               },
        { do_bad,               SIGBUS,  0,             "unknown 34"                    },