Skip to content

Commit 32015c2

Browse files
Tyler Baicarwildea01
authored andcommitted
arm64: exception: handle Synchronous External Abort
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 <[email protected]> CC: Jonathan (Zhixiong) Zhang <[email protected]> Reviewed-by: James Morse <[email protected]> Acked-by: Catalin Marinas <[email protected]> [will: use NULL instead of 0 when assigning si_addr] Signed-off-by: Will Deacon <[email protected]>
1 parent 2f74f09 commit 32015c2

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

arch/arm64/include/asm/esr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
#define ESR_ELx_WNR (UL(1) << 6)
8484

8585
/* Shared ISS field definitions for Data/Instruction aborts */
86+
#define ESR_ELx_FnV (UL(1) << 10)
8687
#define ESR_ELx_EA (UL(1) << 9)
8788
#define ESR_ELx_S1PTW (UL(1) << 7)
8889

arch/arm64/mm/fault.c

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,31 @@ static int do_bad(unsigned long addr, unsigned int esr, struct pt_regs *regs)
522522
return 1;
523523
}
524524

525+
/*
526+
* This abort handler deals with Synchronous External Abort.
527+
* It calls notifiers, and then returns "fault".
528+
*/
529+
static int do_sea(unsigned long addr, unsigned int esr, struct pt_regs *regs)
530+
{
531+
struct siginfo info;
532+
const struct fault_info *inf;
533+
534+
inf = esr_to_fault_info(esr);
535+
pr_err("Synchronous External Abort: %s (0x%08x) at 0x%016lx\n",
536+
inf->name, esr, addr);
537+
538+
info.si_signo = SIGBUS;
539+
info.si_errno = 0;
540+
info.si_code = 0;
541+
if (esr & ESR_ELx_FnV)
542+
info.si_addr = NULL;
543+
else
544+
info.si_addr = (void __user *)addr;
545+
arm64_notify_die("", regs, &info, esr);
546+
547+
return 0;
548+
}
549+
525550
static const struct fault_info fault_info[] = {
526551
{ do_bad, SIGBUS, 0, "ttbr address size fault" },
527552
{ do_bad, SIGBUS, 0, "level 1 address size fault" },
@@ -539,22 +564,22 @@ static const struct fault_info fault_info[] = {
539564
{ do_page_fault, SIGSEGV, SEGV_ACCERR, "level 1 permission fault" },
540565
{ do_page_fault, SIGSEGV, SEGV_ACCERR, "level 2 permission fault" },
541566
{ do_page_fault, SIGSEGV, SEGV_ACCERR, "level 3 permission fault" },
542-
{ do_bad, SIGBUS, 0, "synchronous external abort" },
567+
{ do_sea, SIGBUS, 0, "synchronous external abort" },
543568
{ do_bad, SIGBUS, 0, "unknown 17" },
544569
{ do_bad, SIGBUS, 0, "unknown 18" },
545570
{ do_bad, SIGBUS, 0, "unknown 19" },
546-
{ do_bad, SIGBUS, 0, "synchronous external abort (translation table walk)" },
547-
{ do_bad, SIGBUS, 0, "synchronous external abort (translation table walk)" },
548-
{ do_bad, SIGBUS, 0, "synchronous external abort (translation table walk)" },
549-
{ do_bad, SIGBUS, 0, "synchronous external abort (translation table walk)" },
550-
{ do_bad, SIGBUS, 0, "synchronous parity error" },
571+
{ do_sea, SIGBUS, 0, "level 0 (translation table walk)" },
572+
{ do_sea, SIGBUS, 0, "level 1 (translation table walk)" },
573+
{ do_sea, SIGBUS, 0, "level 2 (translation table walk)" },
574+
{ do_sea, SIGBUS, 0, "level 3 (translation table walk)" },
575+
{ do_sea, SIGBUS, 0, "synchronous parity or ECC error" },
551576
{ do_bad, SIGBUS, 0, "unknown 25" },
552577
{ do_bad, SIGBUS, 0, "unknown 26" },
553578
{ do_bad, SIGBUS, 0, "unknown 27" },
554-
{ do_bad, SIGBUS, 0, "synchronous parity error (translation table walk)" },
555-
{ do_bad, SIGBUS, 0, "synchronous parity error (translation table walk)" },
556-
{ do_bad, SIGBUS, 0, "synchronous parity error (translation table walk)" },
557-
{ do_bad, SIGBUS, 0, "synchronous parity error (translation table walk)" },
579+
{ do_sea, SIGBUS, 0, "level 0 synchronous parity error (translation table walk)" },
580+
{ do_sea, SIGBUS, 0, "level 1 synchronous parity error (translation table walk)" },
581+
{ do_sea, SIGBUS, 0, "level 2 synchronous parity error (translation table walk)" },
582+
{ do_sea, SIGBUS, 0, "level 3 synchronous parity error (translation table walk)" },
558583
{ do_bad, SIGBUS, 0, "unknown 32" },
559584
{ do_alignment_fault, SIGBUS, BUS_ADRALN, "alignment fault" },
560585
{ do_bad, SIGBUS, 0, "unknown 34" },

0 commit comments

Comments
 (0)