Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/aarch64/aarch64 avoid double-fault caused by readin...



details:   https://anonhg.NetBSD.org/src/rev/6428e752bed0
branches:  trunk
changeset: 324210:6428e752bed0
user:      ryo <ryo%NetBSD.org@localhost>
date:      Fri Jul 20 07:12:50 2018 +0000

description:
avoid double-fault caused by reading the instruction when panic

diffstat:

 sys/arch/aarch64/aarch64/fault.c |  21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diffs (44 lines):

diff -r df186ebe9aca -r 6428e752bed0 sys/arch/aarch64/aarch64/fault.c
--- a/sys/arch/aarch64/aarch64/fault.c  Fri Jul 20 01:52:07 2018 +0000
+++ b/sys/arch/aarch64/aarch64/fault.c  Fri Jul 20 07:12:50 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fault.c,v 1.4 2018/07/19 18:27:26 christos Exp $       */
+/*     $NetBSD: fault.c,v 1.5 2018/07/20 07:12:50 ryo Exp $    */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.4 2018/07/19 18:27:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.5 2018/07/20 07:12:50 ryo Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvmhist.h"
@@ -327,14 +327,19 @@
        len += snprintf(panicinfo + len, sizeof(panicinfo) - len,
            ": pc %016"PRIxREGISTER, tf->tf_pc);
 
-       len += snprintf(panicinfo + len, sizeof(panicinfo) - len,
-           ": opcode %08x", *(uint32_t *)tf->tf_pc);
-
+       if (tf->tf_pc == tf->tf_far) {  /* XXX? */
+               /* fault address is pc. the causal instruction cannot be read */
+               len += snprintf(panicinfo + len, sizeof(panicinfo) - len,
+                   ": opcode unknown");
+       } else {
+               len += snprintf(panicinfo + len, sizeof(panicinfo) - len,
+                   ": opcode %08x", *(uint32_t *)tf->tf_pc);
 #ifdef DDB
-       /* ...and disassemble the instruction */
-       len += snprintf(panicinfo + len, sizeof(panicinfo) - len,
-           ": %s", strdisasm(tf->tf_pc));
+               /* ...and disassemble the instruction */
+               len += snprintf(panicinfo + len, sizeof(panicinfo) - len,
+                   ": %s", strdisasm(tf->tf_pc));
 #endif
+       }
 
        if (user) {
 #if defined(DEBUG_DDB_ON_USERFAULT) && defined(DDB)



Home | Main Index | Thread Index | Old Index