Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sh3/sh3 For kernel mode address error, do not overw...



details:   https://anonhg.NetBSD.org/src/rev/013264976f62
branches:  trunk
changeset: 986247:013264976f62
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Sep 15 11:03:24 2021 +0000

description:
For kernel mode address error, do not overwrite tf->tf_spc and tf->tf_r0
*before* checking pcb->pbc_onfault != NULL.

Should fix part of

PR port-sh3/56382
PR port-sh3/56401

i.e., DDB will no longer wrongly indicate NULL as fault PC for kernel mode
address error (and 0xe == EFAULT as r0).

Yes, we have another bugs that cause panics described in the two PRs, but
now we can examine them more easily :).

diffstat:

 sys/arch/sh3/sh3/exception.c |  9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diffs (32 lines):

diff -r 5cc7784e7678 -r 013264976f62 sys/arch/sh3/sh3/exception.c
--- a/sys/arch/sh3/sh3/exception.c      Wed Sep 15 07:49:54 2021 +0000
+++ b/sys/arch/sh3/sh3/exception.c      Wed Sep 15 11:03:24 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exception.c,v 1.73 2019/12/03 12:42:21 ad Exp $        */
+/*     $NetBSD: exception.c,v 1.74 2021/09/15 11:03:24 rin Exp $       */
 
 /*-
  * Copyright (c) 2002, 2019 The NetBSD Foundation, Inc. All rights reserved.
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.73 2019/12/03 12:42:21 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.74 2021/09/15 11:03:24 rin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -196,11 +196,10 @@
        case EXPEVT_ADDR_ERR_LD: /* FALLTHROUGH */
        case EXPEVT_ADDR_ERR_ST:
                pcb = lwp_getpcb(l);
-               KDASSERT(pcb->pcb_onfault != NULL);
+               if (__predict_false(pcb->pcb_onfault == NULL))
+                       goto do_panic;
                tf->tf_spc = (int)pcb->pcb_onfault;
                tf->tf_r0 = EFAULT;
-               if (tf->tf_spc == 0)
-                       goto do_panic;
                break;
 
        case EXPEVT_ADDR_ERR_LD | EXP_USER: /* FALLTHROUGH */



Home | Main Index | Thread Index | Old Index